예제 #1
0
        /// <summary>
        /// Fills in the property data structure
        /// </summary>
        private bool ParseParameter(XamlTypes.BaseProperty baseProperty, LinkedList<Property> propertyList, Property property, Dictionary<string, Property> argumentDependencyLookup)
        {
            Property propertyToAdd = ObtainAttributes(baseProperty, property);

            if (String.IsNullOrEmpty(propertyToAdd.Name))
            {
                propertyToAdd.Name = "AlwaysAppend";
            }

            // generate the list of parameters in order
            if (!_switchesAdded.Contains(propertyToAdd.Name))
            {
                _switchOrderList.Add(propertyToAdd.Name);
                _switchesAdded.Add(propertyToAdd.Name);
            }

            // Inherit the Prefix from the Tool
            if (String.IsNullOrEmpty(propertyToAdd.Prefix))
            {
                propertyToAdd.Prefix = DefaultPrefix;
            }

            // If the property is an enum type, parse that.
            XamlTypes.EnumProperty enumProperty = baseProperty as XamlTypes.EnumProperty;
            if (enumProperty != null)
            {
                foreach (XamlTypes.EnumValue enumValue in enumProperty.AdmissibleValues)
                {
                    Value value = new Value();

                    value.Name = enumValue.Name;
                    value.SwitchName = enumValue.Switch;
                    if (value.SwitchName == null)
                    {
                        value.SwitchName = String.Empty;
                    }

                    value.DisplayName = enumValue.DisplayName;
                    value.Description = enumValue.Description;
                    value.Prefix = enumValue.SwitchPrefix;
                    if (String.IsNullOrEmpty(value.Prefix))
                    {
                        value.Prefix = enumProperty.SwitchPrefix;
                    }

                    if (String.IsNullOrEmpty(value.Prefix))
                    {
                        value.Prefix = DefaultPrefix;
                    }

                    if (enumValue.Arguments.Count > 0)
                    {
                        value.Arguments = new List<Argument>();
                        foreach (XamlTypes.Argument argument in enumValue.Arguments)
                        {
                            Argument arg = new Argument();
                            arg.Parameter = argument.Property;
                            arg.Separator = argument.Separator;
                            arg.Required = argument.IsRequired;
                            value.Arguments.Add(arg);
                        }
                    }

                    if (value.Prefix == null)
                    {
                        value.Prefix = propertyToAdd.Prefix;
                    }

                    propertyToAdd.Values.Add(value);
                }
            }

            // build the dependencies and the values for a parameter
            foreach (XamlTypes.Argument argument in baseProperty.Arguments)
            {
                // To refactor into a separate func
                if (propertyToAdd.Arguments == null)
                {
                    propertyToAdd.Arguments = new List<Argument>();
                }

                Argument arg = new Argument();
                arg.Parameter = argument.Property;
                arg.Separator = argument.Separator;
                arg.Required = argument.IsRequired;
                propertyToAdd.Arguments.Add(arg);
            }

            if (argumentDependencyLookup != null && !argumentDependencyLookup.ContainsKey(propertyToAdd.Name))
            {
                argumentDependencyLookup.Add(propertyToAdd.Name, propertyToAdd);
            }

            // We've read any enumerated values and any dependencies, so we just 
            // have to add the property
            propertyList.AddLast(propertyToAdd);
            return true;
        }
 private bool ParseParameter(BaseProperty baseProperty, LinkedList<Property> propertyList, Property property)
 {
     Property property2 = this.ObtainAttributes(baseProperty, property);
     if (string.IsNullOrEmpty(property2.Name))
     {
         property2.Name = "AlwaysAppend";
     }
     if (!this.switchesAdded.Contains(property2.Name))
     {
         this.switchOrderList.Add(property2.Name);
     }
     if (string.IsNullOrEmpty(property2.Prefix))
     {
         property2.Prefix = this.DefaultPrefix;
     }
     EnumProperty property3 = baseProperty as EnumProperty;
     if (property3 != null)
     {
         foreach (EnumValue value2 in property3.AdmissibleValues)
         {
             Value value3 = new Value {
                 Name = value2.Name,
                 SwitchName = value2.Switch
             };
             if (value3.SwitchName == null)
             {
                 value3.SwitchName = string.Empty;
             }
             value3.DisplayName = value2.DisplayName;
             value3.Description = value2.Description;
             value3.Prefix = value2.SwitchPrefix;
             if (string.IsNullOrEmpty(value3.Prefix))
             {
                 value3.Prefix = property3.SwitchPrefix;
             }
             if (string.IsNullOrEmpty(value3.Prefix))
             {
                 value3.Prefix = this.DefaultPrefix;
             }
             if (value2.Arguments.Count > 0)
             {
                 value3.Arguments = new ArrayList();
                 foreach (Microsoft.Build.Framework.XamlTypes.Argument argument in value2.Arguments)
                 {
                     Microsoft.Build.Tasks.Xaml.Argument argument2 = new Microsoft.Build.Tasks.Xaml.Argument {
                         Parameter = argument.Property,
                         Separator = argument.Separator,
                         Required = argument.IsRequired
                     };
                     value3.Arguments.Add(argument2);
                 }
             }
             if (value3.Prefix == null)
             {
                 value3.Prefix = property2.Prefix;
             }
             property2.Values.Add(value3);
         }
     }
     foreach (Microsoft.Build.Framework.XamlTypes.Argument argument3 in baseProperty.Arguments)
     {
         if (property2.Arguments == null)
         {
             property2.Arguments = new ArrayList();
         }
         Microsoft.Build.Tasks.Xaml.Argument argument4 = new Microsoft.Build.Tasks.Xaml.Argument {
             Parameter = argument3.Property,
             Separator = argument3.Separator,
             Required = argument3.IsRequired
         };
         property2.Arguments.Add(argument4);
     }
     propertyList.AddLast(property2);
     return true;
 }