/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="name">The name of the tag.</param> /// <param name="type">The data type of the tag.</param> /// <param name="value">The value of the tag.</param> public Tag(string name, TagType type, object value) { this.Name = name; this.Type = type; this.Value = value; }
public TagList(string name) : base(name, TagType.TagList, null) { this.ListType = TagType.GetTagTypeByDataType(typeof(T)); _tags = new List <Tag>(); }
/// <summary> /// Adds a tag to the structure. /// </summary> /// <typeparam name="T">The data type of the tag.</typeparam> /// <param name="name">The name of the tag.</param> /// <param name="value">The value of the tag.</param> public void AddTag <T>(string name, T value) { this.AddTag(name, TagType.GetTagTypeByDataType(typeof(T)), value); }
/// <summary> /// Sets the value of the specified tag. /// </summary> /// <typeparam name="T">The data type of the tag.</typeparam> /// <param name="path">The path to the binary tag.</param> /// <param name="value">The new value of the binary tag.</param> /// <param name="create">Set to true if the tag should be created if it doesn't exist.</param> public void SetTag <T>(string path, T value, bool create) { this.SetTag(path, value, TagType.GetTagTypeByDataType(typeof(T)), create); }
/// <summary> /// Converts a value to the data type of the specified tag type. /// </summary> /// <param name="value">The value to convert.</param> /// <param name="type">The target tag type.</param> /// <returns>Returns a value in the form of the target tag type.</returns> public static object ConvertTo(object value, TagType type) { return(Convert.ChangeType(value, type.DataType, CultureInfo.InvariantCulture)); }