private static void CopyPropertiesFromStorage <T>(T baseConfiguration, FacadeBase storage) where T : PolicyConfigurationBase
        {
            baseConfiguration.Name           = (string)storage.InnerPropertyBag[ADObjectSchema.Name];
            baseConfiguration.Workload       = (Workload)storage.InnerPropertyBag[UnifiedPolicyStorageBaseSchema.WorkloadProp];
            baseConfiguration.WhenCreatedUTC = (DateTime?)storage.InnerPropertyBag[ADObjectSchema.WhenCreatedUTC];
            baseConfiguration.WhenChangedUTC = (DateTime?)storage.InnerPropertyBag[ADObjectSchema.WhenChangedUTC];
            baseConfiguration.ChangeType     = ((storage.InnerConfigurable.ObjectState == ObjectState.Deleted) ? ChangeType.Delete : ChangeType.Update);
            baseConfiguration.Version        = PolicyVersion.Create((Guid)storage.InnerPropertyBag[UnifiedPolicyStorageBaseSchema.PolicyVersion]);
            IEnumerable <PropertyInfo> reflectedProperties = UnifiedPolicyStorageFactory.GetReflectedProperties <T>();

            UnifiedPolicyStorageFactory.InitializeIncrementalAttributes(baseConfiguration, reflectedProperties);
            IEnumerable <PropertyDefinition> propertyDefinitions = DalHelper.GetPropertyDefinitions(storage, false);

            using (IEnumerator <PropertyDefinition> enumerator = propertyDefinitions.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PropertyDefinition property = enumerator.Current;
                    object             propertyValue;
                    if (UnifiedPolicyStorageFactory.TryReadPropertyValue(storage, property, out propertyValue))
                    {
                        PropertyInfo propertyInfo = reflectedProperties.FirstOrDefault((PropertyInfo p) => UnifiedPolicyStorageFactory.PropertiesMatch(property, p));
                        if (!(propertyInfo == null) && !UnifiedPolicyStorageFactory.IsIncrementalCollection(propertyInfo))
                        {
                            UnifiedPolicyStorageFactory.CopyPropertyFromStorage(propertyInfo, propertyValue, baseConfiguration);
                        }
                    }
                }
            }
            using (IEnumerator <PropertyInfo> enumerator2 = (from p in reflectedProperties
                                                             where UnifiedPolicyStorageFactory.IsIncrementalCollection(p)
                                                             select p).GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    UnifiedPolicyStorageFactory.< > c__DisplayClassf <T> CS$ < > 8__locals2 = new UnifiedPolicyStorageFactory.< > c__DisplayClassf <T>();
                    CS$ < > 8__locals2.incrementalCollectionProp = enumerator2.Current;
                    PropertyDefinition addedProperty      = propertyDefinitions.FirstOrDefault((PropertyDefinition p) => UnifiedPolicyStorageFactory.PropertiesMatch(p, CS$ < > 8__locals2.incrementalCollectionProp));
                    PropertyDefinition propertyDefinition = propertyDefinitions.FirstOrDefault((PropertyDefinition p) => p.Name == UnifiedPolicyStorageFactory.GetRemovedCollectionPropertyName(addedProperty));
                    if (addedProperty != null && propertyDefinition != null)
                    {
                        UnifiedPolicyStorageFactory.CopyIncrementalCollection(CS$ < > 8__locals2.incrementalCollectionProp, addedProperty, propertyDefinition, storage, baseConfiguration);
                    }
                }
            }
        }
        private static void CopyPropertyToStorage(PropertyDefinition schemaProperty, PropertyInfo property, IPropertyBag storage, PolicyConfigurationBase baseConfiguration)
        {
            object obj = property.GetGetMethod().Invoke(baseConfiguration, null);

            if (UnifiedPolicyStorageFactory.IsIncrementalAttribute(property) || UnifiedPolicyStorageFactory.IsIncrementalCollection(property))
            {
                IncrementalAttributeBase incrementalAttributeBase = (IncrementalAttributeBase)obj;
                if (incrementalAttributeBase != null && incrementalAttributeBase.Changed)
                {
                    UnifiedPolicyStorageFactory.StoreValue(storage, schemaProperty, incrementalAttributeBase.GetObjectValue());
                    return;
                }
            }
            else
            {
                UnifiedPolicyStorageFactory.StoreValue(storage, schemaProperty, obj);
            }
        }
 private static void InitializeIncrementalAttributes(PolicyConfigurationBase baseConfiguration, IEnumerable <PropertyInfo> allProperties)
 {
     foreach (PropertyInfo propertyInfo in from p in allProperties
              where UnifiedPolicyStorageFactory.IsIncrementalAttribute(p)
              select p)
     {
         IncrementalAttributeBase incrementalAttribute = UnifiedPolicyStorageFactory.GetIncrementalAttribute(propertyInfo, false, null);
         propertyInfo.GetSetMethod().Invoke(baseConfiguration, new IncrementalAttributeBase[]
         {
             incrementalAttribute
         });
     }
     foreach (PropertyInfo propertyInfo2 in from p in allProperties
              where UnifiedPolicyStorageFactory.IsIncrementalCollection(p)
              select p)
     {
         IncrementalAttributeBase incrementalCollection = UnifiedPolicyStorageFactory.GetIncrementalCollection(propertyInfo2, false, null, null);
         propertyInfo2.GetSetMethod().Invoke(baseConfiguration, new IncrementalAttributeBase[]
         {
             incrementalCollection
         });
     }
 }