Exemple #1
0
        protected override object InnerRun(List <Variable> variables)
        {
            Type[] types = new Type[parameters.Length];
            var    p     = (object[])parameters.Run(variables);

            for (int i = 0; i < types.Length; i++)
            {
                types[i] = p[i].GetType();
            }
            return(ReturnType.GetConstructor(types).Invoke(p));
        }
        protected override object InnerRun(List <Variable> variables)
        {
            var obj            = variables.FirstOrDefault(v => v.Name == variable);
            var method         = obj.Value.GetType().GetMethods().Where(m => m.Name.ToLower() == methodName.ToLower()).First();
            var compParameters = (object[])parameters.Run(variables);
            var result         = method.Invoke(obj.Value, compParameters);

            if (methodName == "add")
            {
                return(compParameters[0]);
            }
            return(result);
        }
        protected override object InnerRun(List <Variable> variables)
        {
            Element element = null;

            object[] parameterValues = (object[])parameters.Run(variables);
            switch (name)
            {
            case "center":
                StaticFunctions.Center(parameterValues);
                return(null);

            case "margin":
                StaticFunctions.Margin(parameterValues);
                return(null);

            case "padding":
                StaticFunctions.Padding(parameterValues);
                return(null);

            case "leftHalf":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("0px", "50%", "0px", "0px");
                return(null);

            case "topLeftQuarter":
            case "leftTopQuarter":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("0px", "50%", "50%", "0px");
                return(null);

            case "bottomLeftQuarter":
            case "leftBottomQuarter":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("50%", "50%", "0px", "0px");
                return(null);

            case "rightHalf":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("0px", "0px", "0px", "50%");
                return(null);

            case "topRightQuarter":
            case "rightTopQuarter":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("0px", "0px", "50%", "50%");
                return(null);

            case "bottomRightQuarter":
            case "rightBottomQuarter":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("50%", "0px", "0px", "50%");
                return(null);

            case "topHalf":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("0px", "0px", "50%", "0px");
                return(null);

            case "bottomHalf":
                element         = (Element)parameterValues[0];
                element.Margin += new Thickness("50%", "0px", "0px", "0px");
                return(null);

            case "resetMargin":
                StaticFunctions.ResetMargin(parameterValues);
                return(null);

            case "image":
                return(StaticFunctions.LoadImage(parameterValues));

            case "youtube":
                return(StaticFunctions.LoadYoutubeVideo(parameterValues));

            case "pattern":
                return(Patterns.Pattern.GetByName(((VariableCommand)parameters.Parameters[0]).Name));

            case "noPattern":
                return(null);

            default:
                throw new ArgumentException("No static function named " + name + ".");
            }
        }