Exemple #1
0
        private void GenerateArgumentStringList(CommandLineBuilder builder, BaseProperty property, string value)
        {
            string[] arguments = value.Split(';');

            foreach (string argument in arguments)
            {
                if (argument.Length > 0)
                {
                    StringListProperty casted = (StringListProperty)property;
                    AppendStringValue(builder, property, casted.Subtype, argument);
                }
            }
        }
Exemple #2
0
 //private VdsGameActor _loadGameActor = null;
 public HelloWorld()
 {
     TestInt       = new IntProperty();
     TestInt.Value = 1;
     TestIntList   = new IntListProperty();
     TestIntList.ValueList.Add(1);
     TestIntList.ValueList.Add(2);
     TestDouble       = new DoubleProperty();
     TestDouble.Value = 2.0;
     TestDoubleList   = new DoubleListProperty();
     TestDoubleList.ValueList.Add(3.0);
     TestDoubleList.ValueList.Add(4.0);
     TestString       = new StringProperty();
     TestString.Value = "5";
     TestStringList   = new StringListProperty();
     TestStringList.ValueList.Add("6");
     TestStringList.ValueList.Add("7");
     TestBool       = new BoolProperty();
     TestBool.Value = true;
     //TestBoolList = new BoolListProperty();
     //TestBoolList.ValueList.Add(false);
     //TestBoolList.ValueList.Add(true);
     TestVec2     = new VdsVec2d(8, 9);
     TestVec2List = new VdsVec2dList();
     TestVec2List.ValueList.Add(new VdsVec2d(10, 11));
     TestVec2List.ValueList.Add(new VdsVec2d(12, 13));
     TestVec3     = new VdsVec3d(14, 15, 16);
     TestVec3List = new VdsVec3dList();
     TestVec3List.ValueList.Add(new VdsVec3d(17, 18, 19));
     TestVec3List.ValueList.Add(new VdsVec3d(20, 21, 22));
     TestVec4     = new VdsVec4d(23, 24, 25, 26);
     TestVec4List = new VdsVec4dList();
     TestVec4List.ValueList.Add(new VdsVec4d(27, 28, 29, 30));
     TestVec4List.ValueList.Add(new VdsVec4d(31, 32, 33, 34));
     TestFilePath       = new FilePathProperty();
     TestFilePath.Value = "35";
     TestEnum           = new EnumProperty();
     TestEnum.ValueList.Add("36");
     TestEnum.ValueList.Add("37");
 }
Exemple #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void GenerateArgumentStringList(CommandLineBuilder builder, BaseProperty property, string value)
        {
            string [] arguments = value.Split(new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (arguments.Length > 0)
            {
                StringListProperty casted = (StringListProperty)property;

                if (casted.CommandLineValueSeparator != null)
                {
                    List <string> sanitised = new List <string> ();

                    foreach (string argument in arguments)
                    {
                        if (argument.Length > 0)
                        {
                            sanitised.Add(argument.Trim(new char [] { ' ', '\"' }));
                        }
                    }

                    if (sanitised.Count > 0)
                    {
                        AppendStringListValue(builder, property, casted.Subtype, sanitised.ToArray(), casted.CommandLineValueSeparator);
                    }
                }
                else
                {
                    foreach (string argument in arguments)
                    {
                        if (argument.Length > 0)
                        {
                            AppendStringValue(builder, property, casted.Subtype, argument.Trim(new char [] { ' ', '\"' }));
                        }
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Validates the properties of this object. This method should be called
        /// after initialization is complete.
        /// </summary>
        internal void Validate(this BaseProperty type)
        {
            string namePropertyId = GetPropertyId("Name", type);

            VerifyThrowPropertyNotSetOrEmptyString(type.Name, namePropertyId);

            string categoryPropertyId = GetPropertyId("Category", type.Name, type);

            VerifyThrowPropertyEmptyString(typeCategory, categoryPropertyId);

            // Validate children.
            if (null != type.DataSource)
            {
                type.DataSource.Validate();
            }

            foreach (Argument argument in type.Arguments)
            {
                argument.Validate();
            }

            foreach (ValueEditor editor in type.ValueEditors)
            {
                editor.Validate();
            }

            // Validate any known derivations.
            BoolProperty boolProp = type as BoolProperty;

            if (null != boolProp)
            {
                return;
            }

            DynamicEnumProperty dynamicEnumProp = type as DynamicEnumProperty;

            if (dynamicEnumProp != null)
            {
                dynamicEnumProp.Validate();
                return;
            }

            EnumProperty enumProp = type as EnumProperty;

            if (enumProp != null)
            {
                enumProp.Validate();
                return;
            }

            IntProperty intProp = type as IntProperty;

            if (intProp != null)
            {
                intProp.Validate();
                return;
            }

            StringListProperty stringListProp = type as StringListProperty;

            if (stringListProp != null)
            {
                return;
            }

            StringProperty stringProp = type as StringProperty;

            if (stringProp != null)
            {
                return;
            }

            // Unknown derivation, but that's ok.
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void AppendStringListValue(ref CommandLineBuilder builder, Rule rule, StringListProperty property, object value)
        {
            if (value == null)
            {
                return;
            }

            string switchPrefix = !string.IsNullOrWhiteSpace(property.SwitchPrefix) ? property.SwitchPrefix : rule.SwitchPrefix;

            string evaluatedSwitch = $"{switchPrefix ?? string.Empty}{property.Switch ?? string.Empty}{property.Separator ?? string.Empty}";

            var delimiter = !string.IsNullOrWhiteSpace(property.CommandLineValueSeparator) ? property.CommandLineValueSeparator : $" {evaluatedSwitch}";

            if (value.GetType() == typeof(ITaskItem[]))
            {
                builder.AppendSwitchIfNotNull(evaluatedSwitch, value as ITaskItem[], delimiter);
            }
            else if (value.GetType() == typeof(string[]))
            {
                builder.AppendSwitchIfNotNull($"{evaluatedSwitch}", value as string[], delimiter);
            }
            else
            {
                throw new NotImplementedException($"{property.Name} {value.GetType()}");
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void GenerateArgumentStringList(ref CommandLineBuilder builder, Rule rule, StringListProperty property, object value)
        {
            AppendStringListValue(ref builder, rule, property, value);
        }
        private Property ObtainAttributes(BaseProperty baseProperty, Property parameterGroup)
        {
            Property property;

            if (parameterGroup != null)
            {
                property = parameterGroup.Clone();
            }
            else
            {
                property = new Property();
            }
            BoolProperty        property2 = baseProperty as BoolProperty;
            DynamicEnumProperty property3 = baseProperty as DynamicEnumProperty;
            EnumProperty        property4 = baseProperty as EnumProperty;
            IntProperty         property5 = baseProperty as IntProperty;
            StringProperty      property6 = baseProperty as StringProperty;
            StringListProperty  property7 = baseProperty as StringListProperty;

            if (baseProperty.Name != null)
            {
                property.Name = baseProperty.Name;
            }
            if ((property2 != null) && !string.IsNullOrEmpty(property2.ReverseSwitch))
            {
                property.Reversible = "true";
            }
            if (property2 != null)
            {
                property.Type = PropertyType.Boolean;
            }
            else if (property4 != null)
            {
                property.Type = PropertyType.String;
            }
            else if (property3 != null)
            {
                property.Type = PropertyType.String;
            }
            else if (property5 != null)
            {
                property.Type = PropertyType.Integer;
            }
            else if (property6 != null)
            {
                property.Type = PropertyType.String;
            }
            else if (property7 != null)
            {
                property.Type = PropertyType.StringArray;
            }
            if (((baseProperty.DataSource != null) && !string.IsNullOrEmpty(baseProperty.DataSource.SourceType)) && baseProperty.DataSource.SourceType.Equals("Item", StringComparison.OrdinalIgnoreCase))
            {
                property.Type = PropertyType.ItemArray;
            }
            if (property5 != null)
            {
                property.Max = property5.MaxValue.HasValue ? property5.MaxValue.ToString() : null;
                property.Min = property5.MinValue.HasValue ? property5.MinValue.ToString() : null;
            }
            if (property2 != null)
            {
                property.ReverseSwitchName = property2.ReverseSwitch;
            }
            if (baseProperty.Switch != null)
            {
                property.SwitchName = baseProperty.Switch;
            }
            if (property7 != null)
            {
                property.Separator = property7.Separator;
            }
            if (baseProperty.Default != null)
            {
                property.DefaultValue = baseProperty.Default;
            }
            property.Required = baseProperty.IsRequired.ToString().ToLower(CultureInfo.InvariantCulture);
            if (baseProperty.Category != null)
            {
                property.Category = baseProperty.Category;
            }
            if (baseProperty.DisplayName != null)
            {
                property.DisplayName = baseProperty.DisplayName;
            }
            if (baseProperty.Description != null)
            {
                property.Description = baseProperty.Description;
            }
            if (baseProperty.SwitchPrefix != null)
            {
                property.Prefix = baseProperty.SwitchPrefix;
            }
            return(property);
        }