| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- namespace Novacode
- {
- public class CustomProperty
- {
- private string name;
- private object value;
- private string type;
-
- /// <summary>
- /// The name of this CustomProperty.
- /// </summary>
- public string Name { get { return name;} }
-
- /// <summary>
- /// The value of this CustomProperty.
- /// </summary>
- public object Value { get { return value; } }
-
- internal string Type { get { return type; } }
-
- internal CustomProperty(string name, string type, string value)
- {
- object realValue;
- switch (type)
- {
- case "lpwstr":
- {
- realValue = value;
- break;
- }
-
- case "i4":
- {
- realValue = int.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
- break;
- }
-
- case "r8":
- {
- realValue = Double.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
- break;
- }
-
- case "filetime":
- {
- realValue = DateTime.Parse(value, System.Globalization.CultureInfo.InvariantCulture);
- break;
- }
-
- case "bool":
- {
- realValue = bool.Parse(value);
- break;
- }
-
- default: throw new Exception();
- }
-
- this.name = name;
- this.type = type;
- this.value = realValue;
- }
-
- private CustomProperty(string name, string type, object value)
- {
- this.name = name;
- this.type = type;
- this.value = value;
- }
-
- /// <summary>
- /// Create a new CustomProperty to hold a string.
- /// </summary>
- /// <param name="name">The name of this CustomProperty.</param>
- /// <param name="value">The value of this CustomProperty.</param>
- public CustomProperty(string name, string value) : this(name, "lpwstr", value as object) { }
-
-
- /// <summary>
- /// Create a new CustomProperty to hold an int.
- /// </summary>
- /// <param name="name">The name of this CustomProperty.</param>
- /// <param name="value">The value of this CustomProperty.</param>
- public CustomProperty(string name, int value) : this(name, "i4", value as object) { }
-
-
- /// <summary>
- /// Create a new CustomProperty to hold a double.
- /// </summary>
- /// <param name="name">The name of this CustomProperty.</param>
- /// <param name="value">The value of this CustomProperty.</param>
- public CustomProperty(string name, double value) : this(name, "r8", value as object) { }
-
-
- /// <summary>
- /// Create a new CustomProperty to hold a DateTime.
- /// </summary>
- /// <param name="name">The name of this CustomProperty.</param>
- /// <param name="value">The value of this CustomProperty.</param>
- public CustomProperty(string name, DateTime value) : this(name, "filetime", value.ToUniversalTime() as object) { }
-
- /// <summary>
- /// Create a new CustomProperty to hold a bool.
- /// </summary>
- /// <param name="name">The name of this CustomProperty.</param>
- /// <param name="value">The value of this CustomProperty.</param>
- public CustomProperty(string name, bool value) : this(name, "bool", value as object) { }
- }
- }
|