Ejemplo n.º 1
0
 public ConvertOutputPropertyEventArgs(object value, ConfigurableObject configurableObject, PropertyDefinition property, string propertyInStr)
 {
     this.Value = value;
     this.ConfigurableObject = configurableObject;
     this.Property           = property;
     this.PropertyInStr      = propertyInStr;
 }
Ejemplo n.º 2
0
        internal static IList <ProviderPropertyDefinition> GetPropertiesThatDiffer(ConfigurableObject objA, ConfigurableObject objB, IList <ProviderPropertyDefinition> properties)
        {
            if (objA == null)
            {
                throw new ArgumentNullException("objA");
            }
            if (objB == null)
            {
                throw new ArgumentNullException("objB");
            }
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }
            List <ProviderPropertyDefinition> list = new List <ProviderPropertyDefinition>();

            for (int i = 0; i < properties.Count; i++)
            {
                ProviderPropertyDefinition providerPropertyDefinition = properties[i];
                if (!object.Equals(objA[providerPropertyDefinition], objB[providerPropertyDefinition]))
                {
                    list.Add(providerPropertyDefinition);
                }
            }
            return(list);
        }
Ejemplo n.º 3
0
        internal ConfigurableObject GetOriginalObject()
        {
            ConfigurableObject configurableObject = (ConfigurableObject)Activator.CreateInstance(base.GetType());

            configurableObject.propertyBag = this.propertyBag.GetOriginalBag();
            return(configurableObject);
        }
Ejemplo n.º 4
0
 internal virtual void CopyChangesFrom(ConfigurableObject changedObject)
 {
     if (changedObject == null)
     {
         throw new ArgumentNullException("changedObject");
     }
     this.CheckWritable();
     ProviderPropertyDefinition[] array = new ProviderPropertyDefinition[changedObject.propertyBag.Keys.Count];
     changedObject.propertyBag.Keys.CopyTo(array, 0);
     foreach (ProviderPropertyDefinition providerPropertyDefinition in array)
     {
         if (!providerPropertyDefinition.IsReadOnly && (!providerPropertyDefinition.IsWriteOnce || this.ObjectState == ObjectState.New) && (changedObject.propertyBag.SaveCalculatedValues || !providerPropertyDefinition.IsCalculated) && changedObject.IsModified(providerPropertyDefinition))
         {
             object obj = changedObject[providerPropertyDefinition];
             MultiValuedPropertyBase multiValuedPropertyBase = obj as MultiValuedPropertyBase;
             if (!providerPropertyDefinition.IsMultivalued || multiValuedPropertyBase == null || multiValuedPropertyBase.IsChangesOnlyCopy)
             {
                 this[providerPropertyDefinition] = obj;
             }
             else
             {
                 MultiValuedPropertyBase multiValuedPropertyBase2 = (MultiValuedPropertyBase)this[providerPropertyDefinition];
                 multiValuedPropertyBase2.CopyChangesFrom(multiValuedPropertyBase);
                 this.CleanupInstantiationErrors(providerPropertyDefinition);
             }
         }
     }
 }
Ejemplo n.º 5
0
        public virtual object Clone()
        {
            ConfigurableObject configurableObject = (ConfigurableObject)CloneHelper.SerializeObj(this);

            if (this.DeserializationSchema == null)
            {
                List <PropertyDefinition> list = new List <PropertyDefinition>(this.propertyBag.Keys.Count);
                foreach (object obj in this.propertyBag.Keys)
                {
                    PropertyDefinition item = (PropertyDefinition)obj;
                    list.Add(item);
                }
                configurableObject.propertyBag.SetConfigObjectSchema(list);
            }
            return(configurableObject);
        }
Ejemplo n.º 6
0
        internal static bool TryConvertOutputProperty(object value, ConfigurableObject configurableObject, PropertyDefinition property, string propertyInStr, Delegate[] handlers, out object convertedValue)
        {
            convertedValue = null;
            bool   result = false;
            object value2 = value;

            foreach (ConvertOutputPropertyDelegate convertOutputPropertyDelegate in handlers)
            {
                ConvertOutputPropertyEventArgs args = new ConvertOutputPropertyEventArgs(value2, configurableObject, property, propertyInStr);
                object obj;
                if (convertOutputPropertyDelegate(args, out obj))
                {
                    value2         = obj;
                    convertedValue = obj;
                    result         = true;
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        internal static bool AreEqual(ConfigurableObject objA, ConfigurableObject objB)
        {
            if (objA == null || objB == null)
            {
                return(objA == null && objB == null);
            }
            if (objA.GetType() != objB.GetType())
            {
                return(false);
            }
            ObjectSchema objectSchema = objA.ObjectSchema;

            foreach (PropertyDefinition propertyDefinition in objectSchema.AllProperties)
            {
                if (!object.Equals(objA[propertyDefinition], objB[propertyDefinition]))
                {
                    return(false);
                }
            }
            return(true);
        }