コード例 #1
0
        private bool parseParameters(XamlTypes.Rule rule)
        {
            Dictionary <string, string> strOptions = new Dictionary <string, string>();

            string[] paras = Parameters.Split('|');
            foreach (string p in paras)
            {
                int    pos   = p.IndexOf('=');
                string name  = p.Substring(0, pos);
                string value = p.Substring(pos + 1);
                strOptions[name] = value;
                switchOrderList.Add(name);
            }

            foreach (XamlTypes.BaseProperty property in rule.Properties)
            {
                string val;
                if (strOptions.TryGetValue(property.Name, out val))
                {
                    XamlTypes.BoolProperty        boolProperty        = property as XamlTypes.BoolProperty;
                    XamlTypes.DynamicEnumProperty dynamicEnumProperty = property as XamlTypes.DynamicEnumProperty;
                    XamlTypes.EnumProperty        enumProperty        = property as XamlTypes.EnumProperty;
                    XamlTypes.IntProperty         intProperty         = property as XamlTypes.IntProperty;
                    XamlTypes.StringProperty      stringProperty      = property as XamlTypes.StringProperty;
                    XamlTypes.StringListProperty  stringListProperty  = property as XamlTypes.StringListProperty;

                    if (stringListProperty != null)
                    {
                        string[] values = val.Split(';');
                        parameterValues[property.Name] = values;
                    }
                    else if (boolProperty != null)
                    {
                        parameterValues[property.Name] = string.Compare(val, "true", StringComparison.OrdinalIgnoreCase) == 0;
                    }
                    else if (intProperty != null)
                    {
                        parameterValues[property.Name] = Int64.Parse(val);
                    }
                    else
                    {
                        parameterValues[property.Name] = val;
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// The list of switches in the order they should appear, if set.
        /// </summary>
        private Dictionary <String, Object> parseParameters(XamlTypes.Rule rule)
        {
            Dictionary <String, Object> parameterValues = new Dictionary <string, object>();

            Dictionary <string, string> strOptions = parseParamValues(Parameters);

            foreach (XamlTypes.BaseProperty property in rule.Properties)
            {
                string val;
                if (strOptions.TryGetValue(property.Name, out val))
                {
                    XamlTypes.BoolProperty        boolProperty        = property as XamlTypes.BoolProperty;
                    XamlTypes.DynamicEnumProperty dynamicEnumProperty = property as XamlTypes.DynamicEnumProperty;
                    XamlTypes.EnumProperty        enumProperty        = property as XamlTypes.EnumProperty;
                    XamlTypes.IntProperty         intProperty         = property as XamlTypes.IntProperty;
                    XamlTypes.StringProperty      stringProperty      = property as XamlTypes.StringProperty;
                    XamlTypes.StringListProperty  stringListProperty  = property as XamlTypes.StringListProperty;

                    if (stringListProperty != null)
                    {
                        string[] values = val.Split(';');
                        parameterValues[property.Name] = values;
                    }
                    else if (boolProperty != null)
                    {
                        parameterValues[property.Name] = string.Compare(val, "true", StringComparison.OrdinalIgnoreCase) == 0;
                    }
                    else if (intProperty != null)
                    {
                        parameterValues[property.Name] = Int64.Parse(val);
                    }
                    else
                    {
                        parameterValues[property.Name] = val;
                    }
                }
            }
            return(parameterValues);
        }
コード例 #3
0
        /// <summary>
        /// Gets all the attributes assigned in the xml file for this parameter or all of the nested switches for
        /// this parameter group
        /// </summary>
        private static Property ObtainAttributes(XamlTypes.BaseProperty baseProperty, Property parameterGroup)
        {
            Property parameter;

            if (parameterGroup != null)
            {
                parameter = parameterGroup.Clone();
            }
            else
            {
                parameter = new Property();
            }

            XamlTypes.BoolProperty        boolProperty        = baseProperty as XamlTypes.BoolProperty;
            XamlTypes.DynamicEnumProperty dynamicEnumProperty = baseProperty as XamlTypes.DynamicEnumProperty;
            XamlTypes.EnumProperty        enumProperty        = baseProperty as XamlTypes.EnumProperty;
            XamlTypes.IntProperty         intProperty         = baseProperty as XamlTypes.IntProperty;
            XamlTypes.StringProperty      stringProperty      = baseProperty as XamlTypes.StringProperty;
            XamlTypes.StringListProperty  stringListProperty  = baseProperty as XamlTypes.StringListProperty;

            parameter.IncludeInCommandLine = baseProperty.IncludeInCommandLine;

            if (baseProperty.Name != null)
            {
                parameter.Name = baseProperty.Name;
            }

            if (boolProperty != null && !String.IsNullOrEmpty(boolProperty.ReverseSwitch))
            {
                parameter.Reversible = "true";
            }

            // Determine the type for this property.
            if (boolProperty != null)
            {
                parameter.Type = PropertyType.Boolean;
            }
            else if (enumProperty != null)
            {
                parameter.Type = PropertyType.String;
            }
            else if (dynamicEnumProperty != null)
            {
                parameter.Type = PropertyType.String;
            }
            else if (intProperty != null)
            {
                parameter.Type = PropertyType.Integer;
            }
            else if (stringProperty != null)
            {
                parameter.Type = PropertyType.String;
            }
            else if (stringListProperty != null)
            {
                parameter.Type = PropertyType.StringArray;
            }

            // We might need to override this type based on the data source, if it specifies a source type of 'Item'.
            if (baseProperty.DataSource != null)
            {
                if (!String.IsNullOrEmpty(baseProperty.DataSource.SourceType))
                {
                    if (baseProperty.DataSource.SourceType.Equals("Item", StringComparison.OrdinalIgnoreCase))
                    {
                        parameter.Type = PropertyType.ItemArray;
                    }
                }
            }

            if (intProperty != null)
            {
                parameter.Max = intProperty.MaxValue != null?intProperty.MaxValue.ToString() : null;

                parameter.Min = intProperty.MinValue != null?intProperty.MinValue.ToString() : null;
            }

            if (boolProperty != null)
            {
                parameter.ReverseSwitchName = boolProperty.ReverseSwitch;
            }

            if (baseProperty.Switch != null)
            {
                parameter.SwitchName = baseProperty.Switch;
            }

            if (stringListProperty != null)
            {
                parameter.Separator = stringListProperty.Separator;
            }

            if (baseProperty.Default != null)
            {
                parameter.DefaultValue = baseProperty.Default;
            }

            parameter.Required = baseProperty.IsRequired.ToString().ToLower(CultureInfo.InvariantCulture);

            if (baseProperty.Category != null)
            {
                parameter.Category = baseProperty.Category;
            }

            if (baseProperty.DisplayName != null)
            {
                parameter.DisplayName = baseProperty.DisplayName;
            }

            if (baseProperty.Description != null)
            {
                parameter.Description = baseProperty.Description;
            }

            if (baseProperty.SwitchPrefix != null)
            {
                parameter.Prefix = baseProperty.SwitchPrefix;
            }

            return(parameter);
        }