public static PropertyDefinitionProxy FromPropertyDefinition(PropertyDefinition propertyDefinition)
 {
     return new PropertyDefinitionProxy
     {
         Name = propertyDefinition.Name.Raw,
         Class = ClassProxy.FromClass(propertyDefinition.Class),
         Attributes = new List<AttributeProxy>(propertyDefinition.Attributes),
         IsLegal = propertyDefinition.IsLegal,
         IsEnabled = propertyDefinition.IsEnabled
     };
 }
        private static void Merge(PropertyDefinition source, PropertyDefinition destination)
        {
            // If the the new property definition is illegal, its match should be illegal.
            // But not the other way around - if the new one is legal, and its match is
            // illegal, *don't* make the match legal. Note that we never want to change
            // IsEnabled - it's set purely by the user.
            if (!source.IsLegal)
            {
                destination.IsLegal = false;
            }

            if (!source.IsEnabled)
            {
                destination.IsEnabled = false;
            }
        }
        private static void InsertPotentialPropertyDefinition(this List<PropertyDefinition> potentialPropertyDefinitions, int index, PropertyDefinition potentialPropertyDefinition)
        {
            var matchingPropertyDefinition = potentialPropertyDefinitions.FirstOrDefault(x => Equals(x.Class, potentialPropertyDefinition.Class));
            if (matchingPropertyDefinition != null)
            {
                Merge(potentialPropertyDefinition, matchingPropertyDefinition);
                return;
            }

            potentialPropertyDefinitions.Insert(index, potentialPropertyDefinition);
        }
 public static void Prepend(this List<PropertyDefinition> potentialPropertyDefinitions, PropertyDefinition potentialPropertyDefinition)
 {
     potentialPropertyDefinitions.InsertPotentialPropertyDefinition(0, potentialPropertyDefinition);
 }
 public static void Append(this List<PropertyDefinition> potentialPropertyDefinitions, PropertyDefinition potentialPropertyDefinition)
 {
     potentialPropertyDefinitions.InsertPotentialPropertyDefinition(potentialPropertyDefinitions.Count, potentialPropertyDefinition);
 }