Beispiel #1
0
 /// <summary>
 /// De-serialise the stored data so that it can be used
 /// </summary>
 public void OnAfterDeserialize()
 {
     DataType = Type.GetType(typeString, false);
     IsValid  = GenericSerialisation.CanProcess(DataType);
     Value    = (IsValid ?
                 GenericSerialisation.Parse(data, DataType) :
                 null
                 );
 }
Beispiel #2
0
        /// <summary>
        /// Assign a new value to this generic data collection
        /// </summary>
        /// <param name="value">The value data that is to be kept in this object</param>
        /// <param name="type">The type of the object that is to be stored</param>
        /// <returns>Returns true if the value will be serialised for storage/display</returns>
        public bool SetValue(object value, Type type)
        {
            // Set the valid flag based on the received values
            if (!GenericSerialisation.CanProcess(type))
            {
                IsValid = false;
            }
            else if (object.Equals(value, null))
            {
                IsValid = !type.IsValueType;
            }
            else
            {
                IsValid = type.IsAssignableFrom(value.GetType());
            }

            // Save the values for use
            DataType = type;
            Value    = value;

            return(IsValid);
        }