private void UpdateControls()
        {
            stack_Options.Children.Clear();
            if (RegisteredVariables == null)
            {
                return;
            }

            foreach (var variablename in RegisteredVariables.GetRegisteredVariableKeys())
            {
                Control_VariableRegistryItem varItem = new Control_VariableRegistryItem {
                    VariableName = variablename,
                    VarRegistry  = VarRegistrySource,
                    //HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    //VerticalContentAlignment = VerticalAlignment.Stretch
                };


                stack_Options.Children.Add(varItem);
                stack_Options.Children.Add(new Separator()
                {
                    Height = 5, Opacity = 0
                });
            }
        }
예제 #2
0
        /// <summary>
        /// Gets all the registered names
        /// </summary>
        public string[] GetVariableNames()
        {
            var result = RegisteredVariables?.Select(r => r.RegisteredName);

            if (result != null)
            {
                return(result.ToArray());
            }

            return(emptyStringArray);
        }
예제 #3
0
 /// <summary>
 /// Registers a direct variable reference
 /// </summary>
 public void RegisterValue <T>(Ref <T> value, string name)
 {
     RegisteredVariables.Add(
         new RegisteredVariableItem
     {
         Name = name,
         IsDirectReference = true,
         Reference         = value,
         RegisteredName    = name
     });
 }
예제 #4
0
        /// <summary>
        /// Registers a property
        /// </summary>
        public void RegisterProperties(object value, string parentName, params string[] properties)
        {
            foreach (var property in properties)
            {
                var registeredName = $"{parentName}.{property}";

                RegisteredVariables.Add(
                    new RegisteredVariableItem
                {
                    Name = property,
                    IsDirectReference = false,
                    Reference         = value,
                    RegisteredName    = registeredName
                });
            }
        }
예제 #5
0
        /// <summary>
        /// Sets the specific property value
        /// </summary>
        public bool SetVariableValue(string variableName, string json)
        {
            var result = string.Empty;

            if (RegisteredVariables.Any(r => string.Compare(r.RegisteredName, variableName) == 0))
            {
                var variable = RegisteredVariables.First(r => string.Compare(r.RegisteredName, variableName) == 0);
                if (variable.IsDirectReference)
                {
                    return(false); //not done this part yet
                }
                else
                {
                    return(SetPropertyValue(variable, json));
                }
            }

            return(false);
        }
예제 #6
0
        /// <summary>
        /// Converts the registered variable to a string
        /// </summary>
        public string GetVariableValue(string variableName)
        {
            var result = string.Empty;

            if (RegisteredVariables.Any(r => string.Compare(r.RegisteredName, variableName) == 0))
            {
                var variable = RegisteredVariables.First(r => string.Compare(r.RegisteredName, variableName) == 0);
                if (variable.IsDirectReference)
                {
                    result = InstanceAsString(((Ref)variable.Reference).RawValue);
                }
                else
                {
                    result = InstanceAsString(GetPropertyValue(variable));
                }
            }

            return(result);
        }
예제 #7
0
        public static void RegisterMethod(MethodInfo method)
        {
            var attr = method.GetCustomAttribute <Registered>();

            if (attr == null)
            {
                return;
            }
            if (RegisteredFunctions.ContainsKey(attr.Name))
            {
                throw new Exception("Key Duplicated");
            }
            if (RegisteredVariables.ContainsKey(attr.Name))
            {
                throw new Exception("Key Duplicated");
            }
            Func <object[], object> func = objs => method.Invoke(null, new object[] { objs });

            RegisteredFunctions.Add(attr.Name, func);
            RegisteredVariables.Add(attr.Name, func);
        }
예제 #8
0
 public static void RegisterMethod(string name, Func <object[], object> method)
 {
     RegisteredFunctions.Add(name, method);
     RegisteredVariables.Add(name, method);
 }