protected override void Initialize()
 {
     base.Initialize ();
     if(this.Parameter.GetType() != typeof(StringListParameter)) {
         throw new System.ApplicationException("Mismatch Widget and Parameter Type");
     }
     this.listParameter = (StringListParameter) this.Parameter;
     this.InitalizeFromStrings(this.listParameter.Strings);
 }
Example #2
0
 protected override void Initialize()
 {
     base.Initialize();
     if (this.Parameter.GetType() != typeof(StringListParameter))
     {
         throw new System.ApplicationException("Mismatch Widget and Parameter Type");
     }
     this.listParameter = (StringListParameter)this.Parameter;
     this.InitalizeFromStrings(this.listParameter.Strings);
 }
        /// <summary>
        /// This method will update all the variables binded to the Game Parameter "subject"
        /// </summary>
        /// <param name="subject">Game Parameters inherit Subject class</param>
        public void UpdateRoutine(Subject subject)
        {
            // creating a generic variable egVar and instantiating the correct type
            // the eg types are the same implemented as parameters (string, int, bool, double)
            egVar         var;
            GameParameter gp = (GameParameter)subject;

            if (subject.GetType() == typeof(IntParameter))
            {
                IntParameter iP = (IntParameter)subject;
                egInt        i  = iP.Value;
                var = i;
            }
            else if (subject.GetType() == typeof(BoolParameter))
            {
                BoolParameter bP = (BoolParameter)subject;
                egBool        b  = bP.Value;
                var = b;
            }
            else if (subject.GetType() == typeof(StringListParameter))
            {
                StringListParameter sP = (StringListParameter)subject;
                egString            s  = sP.Value;
                var = s;
            }
            else if (subject.GetType() == typeof(StringParameter))
            {
                StringParameter sP = (StringParameter)subject;
                egString        s  = sP.Value;
                Debug.Log((string)s + " variable Handler test");
                var = s;
            }
            else if (subject.GetType() == typeof(RangeParameter))
            {
                RangeParameter fP = (RangeParameter)subject;
                egFloat        s  = fP.Value;
                var = s;
            }
            else
            {
                // if the type is not registered something went wrong
                Debug.Log("ERROR, type: " + subject.GetType() + " not defined as a parameter type. Check parameter types.");
                return;
            }
            //then we will update the variables
            UpdateVariables(var, gp.Name);
        }
Example #4
0
    protected override void Initialize()
    {
        base.Initialize();
        this.listParameter = (StringListParameter)this.Parameter;
        // hard coded part for suki -- we will delete this part when we have a different way to select a suki schema
        if (listParameter.Name == egParameterStrings.SUKI_FILELIST || listParameter.Name == egParameterStrings.SUKI_TYPE)
        {
            sukiParameter     = true;
            AnimatedGifPlayer = GetComponent <AnimatedGifPlayer>();

            if (listParameter.Name == egParameterStrings.SUKI_FILELIST)
            {
                VariableHandler.Instance.Register(egParameterStrings.SUKI_TYPE, selectedFolder);
                oldFolder = selectedFolder;
            }
        }

        if (this.Parameter.GetType() != typeof(StringListParameter))
        {
            throw new System.ApplicationException("Mismatch Widget and Parameter Type");
        }

        this.InitalizeFromStrings(this.listParameter.Strings);
    }
        public IList <AParameter> ConvertParameters(
            IList <ParameterNode> parameters,
            string resourcePrefix = ""
            )
        {
            var resultList = new List <AParameter>();

            if ((parameters == null) || !parameters.Any())
            {
                return(resultList);
            }

            // convert all parameters
            var index = 0;

            foreach (var parameter in parameters)
            {
                ++index;
                var        parameterName     = parameter.Name ?? $"[{index}]";
                AParameter result            = null;
                var        parameterFullName = resourcePrefix + parameter.Name;
                AtLocation(parameterName, () => {
                    if (parameter.Secret != null)
                    {
                        // encrypted value
                        AtLocation("Secret", () => {
                            result = new SecretParameter {
                                Name              = parameter.Name,
                                Description       = parameter.Description,
                                Secret            = parameter.Secret,
                                Export            = parameter.Export,
                                EncryptionContext = parameter.EncryptionContext
                            };
                        });
                    }
                    else if (parameter.Values != null)
                    {
                        // list of values
                        AtLocation("Values", () => {
                            result = new StringListParameter {
                                Name        = parameter.Name,
                                Description = parameter.Description,
                                Values      = parameter.Values,
                                Export      = parameter.Export
                            };
                        });

                        // TODO (2018-08-19, bjorg): this implementation creates unnecessary parameters
                        if (parameter.Resource != null)
                        {
                            AtLocation("Resource", () => {
                                // enumerate individual values with resource definition for each
                                parameter.Parameters = new List <ParameterNode>();
                                for (var i = 1; i <= parameter.Values.Count; ++i)
                                {
                                    parameter.Parameters.Add(new ParameterNode {
                                        Name     = $"Index{i}",
                                        Value    = parameter.Values[i - 1],
                                        Resource = parameter.Resource
                                    });
                                }
                            });
                        }
                    }
                    else if (parameter.Package != null)
                    {
                        // package value
                        result = new PackageParameter {
                            Name        = parameter.Name,
                            Description = parameter.Description,
                            DestinationBucketParameterName = parameter.Package.Bucket,
                            DestinationKeyPrefix           = parameter.Package.Prefix ?? "",
                            PackagePath = parameter.Package.PackagePath
                        };
                    }
                    else if (parameter.Value != null)
                    {
                        if (parameter.Resource != null)
                        {
                            AtLocation("Resource", () => {
                                // existing resource
                                var resource = ConvertResource((string)parameter.Value, parameter.Resource);
                                result       = new ReferencedResourceParameter {
                                    Name        = parameter.Name,
                                    Description = parameter.Description,
                                    Resource    = resource
                                };
                            });
                        }
                        else if (parameter.Value is string text)
                        {
                            // plaintext value
                            result = new StringParameter {
                                Name        = parameter.Name,
                                Description = parameter.Description,
                                Value       = text
                            };
                        }
                        else
                        {
                            // plaintext value
                            result = new ExpressionParameter {
                                Name        = parameter.Name,
                                Description = parameter.Description,
                                Expression  = parameter.Value
                            };
                        }
                    }
                    else if (parameter.Resource != null)
                    {
                        // managed resource
                        AtLocation("Resource", () => {
                            result = new CloudFormationResourceParameter {
                                Name        = parameter.Name,
                                Description = parameter.Description,
                                Resource    = ConvertResource(null, parameter.Resource)
                            };
                        });
                    }
                });

                // check if there are nested parameters
                if (parameter.Parameters != null)
                {
                    AtLocation("Parameters", () => {
                        var nestedParameters = ConvertParameters(
                            parameter.Parameters,
                            parameterFullName
                            );

                        // keep nested parameters only if they have values
                        if (nestedParameters.Any())
                        {
                            // create empty string parameter if collection has no value
                            result = result ?? new StringParameter {
                                Name        = parameter.Name,
                                Value       = "",
                                Description = parameter.Description,
                                Export      = parameter.Export
                            };
                            result.Parameters = nestedParameters;
                        }
                    });
                }

                // add parameter
                if (result != null)
                {
                    result.FullName = parameterFullName;
                    result.Export   = parameter.Export;
                    resultList.Add(result);
                }
            }
            return(resultList);
        }