Beispiel #1
0
 public ConvertOutputPropertyEventArgs(object value, ConfigurableObject configurableObject, PropertyDefinition property, string propertyInStr)
 {
     this.Value = value;
     this.ConfigurableObject = configurableObject;
     this.Property           = property;
     this.PropertyInStr      = propertyInStr;
 }
        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);
        }
        internal ConfigurableObject GetOriginalObject()
        {
            ConfigurableObject configurableObject = (ConfigurableObject)Activator.CreateInstance(base.GetType());

            configurableObject.propertyBag = this.propertyBag.GetOriginalBag();
            return(configurableObject);
        }
 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);
             }
         }
     }
 }
        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);
        }
        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);
        }
        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);
        }