Information associated to a key from an INI file. Includes both the value and the comments associated to the key.
Inheritance: ICloneable
Ejemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="KeyData"/> class
 ///     from a previous instance of <see cref="KeyData"/>.
 /// </summary>
 /// <remarks>
 ///     Data is deeply copied
 /// </remarks>
 /// <param name="ori">
 ///     The instance of the <see cref="KeyData"/> class
 ///     used to create the new instance.
 /// </param>
 public KeyData(KeyData ori)
 {
     _value    = ori._value;
     _keyName  = ori._keyName;
     _comments = new List <string>(ori._comments);
 }
Ejemplo n.º 2
0
		/// <summary>
		/// Gets configuration as collection of KeyData.
		/// Derived classes can replace this to customize what to save into configuration. 
		/// </summary>
		/// <returns>Collection of KeyData</returns>
		public virtual IEnumerable<KeyData> GetConfiguration ()
		{
			var sectionData		=	new List<KeyData>();
			var configObject	=	this;

			if (configObject==null) {
				return sectionData;
			}

			foreach ( var prop in GetConfigurationProperties() ) {

				var name	=	prop.Name;
				var value	=	prop.GetValue( configObject );
				var conv	=	TypeDescriptor.GetConverter( prop.PropertyType );
				var keyData	=	new KeyData(name);

				keyData.Value	=	conv.ConvertToInvariantString( value );

				sectionData.Add( keyData );
			}

			return sectionData;
		}
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="KeyData"/> class
 ///     from a previous instance of <see cref="KeyData"/>.
 /// </summary>
 /// <remarks>
 ///     Data is deeply copied
 /// </remarks>
 /// <param name="ori">
 ///     The instance of the <see cref="KeyData"/> class 
 ///     used to create the new instance.
 /// </param>
 public KeyData(KeyData ori)
 {
     _value = ori._value;
     _keyName = ori._keyName;
     _comments = new List<string>(ori._comments);
 }