Exemplo n.º 1
0
        protected string projectCfg(SolutionContext context, IPM pm)
        {
            Debug.Assert(context != null);

            if (pm.It(LevelType.Property, "IsBuildable"))
            {
                if (pm.IsRight(LevelType.RightOperandStd))
                {
                    context.ShouldBuild = Value.toBoolean(pm.FirstLevel.Data);
                    return(Value.Empty);
                }

                if (pm.IsRight(LevelType.RightOperandEmpty))
                {
                    return(Value.from(context.ShouldBuild));
                }
            }

            if (pm.It(LevelType.Property, "IsDeployable"))
            {
                if (pm.IsRight(LevelType.RightOperandStd))
                {
                    context.ShouldDeploy = Value.toBoolean(pm.FirstLevel.Data);
                    return(Value.Empty);
                }

                if (pm.IsRight(LevelType.RightOperandEmpty))
                {
                    return(Value.from(context.ShouldDeploy));
                }
            }

            throw new IncorrectNodeException(pm);
        }
Exemplo n.º 2
0
        protected string ProjectCfg(string projectName, IPM pm)
        {
            ISolutionContext context = env.GetSolutionContext(projectName);

            if (pm.It(LevelType.Property, "IsBuildable"))
            {
                if (pm.IsRight(LevelType.RightOperandStd))
                {
                    context.IsBuildable = Value.ToBoolean(pm.FirstLevel.Data);
                    return(Value.Empty);
                }

                if (pm.IsRight(LevelType.RightOperandEmpty))
                {
                    return(Value.From(context.IsBuildable));
                }
            }

            if (pm.It(LevelType.Property, "IsDeployable"))
            {
                if (pm.IsRight(LevelType.RightOperandStd))
                {
                    context.IsDeployable = Value.ToBoolean(pm.FirstLevel.Data);
                    return(Value.Empty);
                }

                if (pm.IsRight(LevelType.RightOperandEmpty))
                {
                    return(Value.From(context.IsDeployable));
                }
            }

            throw new IncorrectNodeException(pm);
        }
Exemplo n.º 3
0
        protected string StIterate(IPM pm, string expression)
        {
            if (!pm.It(LevelType.Method, "iterate") || !pm.IsRight(LevelType.RightOperandColon))
            {
                throw new IncorrectNodeException(pm);
            }

            var args = new PM().GetArguments(expression, ';');

            if (args == null || args.Count != 3)
            {
                throw new PMArgException(args, $"iterate(; condition; ) `{expression}`");
            }

            string initializer = args[0].data.ToString();
            string condition   = args[1].data.ToString();
            string iterator    = args[2].data.ToString();

            if (!string.IsNullOrWhiteSpace(initializer))
            {
                Evaluate($"$({initializer})");
            }

            iterator = string.IsNullOrWhiteSpace(iterator) ? null : $"$({iterator})";

            return(DoRepeat(condition, pm.FirstLevel.Data, iterator, false));
        }
Exemplo n.º 4
0
        protected string StRepeat(IPM pm, string expression)
        {
            if (!pm.It(LevelType.Method, "repeat") || !pm.IsRight(LevelType.RightOperandColon))
            {
                throw new IncorrectNodeException(pm);
            }

            var args = new PM().GetArguments(expression, ';');

            if (args == null || args.Count > 2 || args.Count < 1)
            {
                throw new PMArgException(args, expression);
            }

            string condition = args[0].data.ToString();
            bool   silent    = false;

            if (args.Count == 2)
            {
                if (args[1].type != ArgumentType.Boolean)
                {
                    throw new PMArgException(args[1], $"bool type for argument `silent`");
                }
                silent = (bool)args[1].data;
            }

            return(DoRepeat(condition, pm.FirstLevel.Data, null, silent));
        }
Exemplo n.º 5
0
        protected string stRepeat(IPM pm, string expression)
        {
            if (!pm.It(LevelType.Method, "repeat") || !pm.IsRight(LevelType.RightOperandColon))
            {
                throw new IncorrectNodeException(pm);
            }

            Argument[] args = (new PM()).arguments(expression, ';');
            if (args == null || args.Length > 2 || args.Length < 1)
            {
                throw new InvalidArgumentException($"Incorrect arguments: {args?.Length} `{expression}`");
            }

            string condition = args[0].data.ToString();
            bool   silent    = false;

            if (args.Length == 2)
            {
                if (args[1].type != ArgumentType.Boolean)
                {
                    throw new InvalidArgumentException($"Incorrect type of argument `silent`: {args[1].type}");
                }
                silent = (bool)args[1].data;
            }

            return(doRepeat(condition, pm.FirstLevel.Data, null, silent));
        }
Exemplo n.º 6
0
        protected string stIterate(IPM pm, string expression)
        {
            if (!pm.It(LevelType.Method, "iterate") || !pm.IsRight(LevelType.RightOperandColon))
            {
                throw new IncorrectNodeException(pm);
            }

            Argument[] args = (new PM()).arguments(expression, ';');
            if (args == null || args.Length != 3)
            {
                throw new InvalidArgumentException($"Incorrect arguments `iterate(; condition; )`: {args?.Length} `{expression}`");
            }

            string initializer = args[0].data.ToString();
            string condition   = args[1].data.ToString();
            string iterator    = args[2].data.ToString();

            if (!String.IsNullOrWhiteSpace(initializer))
            {
                evaluate($"$({initializer})");
            }

            iterator = String.IsNullOrWhiteSpace(iterator) ? null : $"$({iterator})";

            return(doRepeat(condition, pm.FirstLevel.Data, iterator, false));
        }
Exemplo n.º 7
0
        protected string stItemActivate(string name, IPM pm)
        {
            if (!pm.It(LevelType.Property, "activate") || !pm.IsRight(LevelType.RightOperandStd))
            {
                throw new IncorrectNodeException(pm);
            }

            if (!Value.toBoolean(pm.FirstLevel.Data))
            {
#if DEBUG
                Log.Trace("skip activation of pane '{0}'", name);
#endif
                return(Value.from(false));
            }

            Log.Debug("Activation the item '{0}'", name);
            try {
                OWP.getByName(name, false).Activate();
                return(Value.from(true));
            }
            catch (ArgumentException) {
                Log.Debug("Incorrect name of pane item `{0}`", name);
            }

            return(Value.from(false));
        }
Exemplo n.º 8
0
        protected string StType(IPM pm)
        {
            if (!pm.It(LevelType.Property, "type") || !pm.IsRight(LevelType.RightOperandEmpty))
            {
                throw new IncorrectNodeException(pm);
            }

            return(Value.From(env.BuildType));
        }
        protected string stStartUpProject(IPM pm)
        {
            if (!pm.It(LevelType.Property, "StartUpProject"))
            {
                throw new IncorrectNodeException(pm);
            }

            // get

            if (pm.IsRight(LevelType.RightOperandEmpty))
            {
                return(env.StartupProjectString);
            }

            // set

            if (!pm.IsRight(LevelType.RightOperandStd))
            {
                throw new IncorrectNodeException(pm);
            }

            ILevel level = pm.FirstLevel;
            var    val   = (new PM()).arguments(level.Data);

            if (val == null || val.Length < 1)
            {
                env.updateStartupProject(null);
                return(Value.Empty);
            }

            Argument pname = val[0];

            if (val.Length > 1 ||
                (pname.type != ArgumentType.StringDouble &&
                 pname.type != ArgumentType.EnumOrConst &&
                 pname.type != ArgumentType.Mixed))
            {
                throw new ArgumentPMException(level, "= string name");
            }

            env.updateStartupProject(pname.data.ToString());
            return(Value.Empty);
        }
Exemplo n.º 10
0
        protected string StCancel(IPM pm)
        {
            if (!pm.It(LevelType.Property, "cancel") || !pm.IsRight(LevelType.RightOperandStd))
            {
                throw new IncorrectNodeException(pm);
            }

            if (Value.ToBoolean(pm.FirstLevel.Data))
            {
                LSender.Send(this, "attempt to cancel the build");
                env.CancelBuild();
            }

            return(Value.Empty);
        }
Exemplo n.º 11
0
        protected string stCancel(IPM pm)
        {
            if (!pm.It(LevelType.Property, "cancel") || !pm.IsRight(LevelType.RightOperandStd))
            {
                throw new IncorrectNodeException(pm);
            }

            if (Value.toBoolean(pm.FirstLevel.Data))
            {
                Log.Debug("attempt to cancel the build");
                DTEO.exec("Build.Cancel");
            }

            return(Value.Empty);
        }
        protected string stExec(IPM pm)
        {
            if (!pm.It(LevelType.Property, "exec") || !pm.IsRight(LevelType.RightOperandColon))
            {
                throw new IncorrectNodeException(pm);
            }

            string cmd = pm.FirstLevel.Data.Trim();

            if (String.IsNullOrWhiteSpace(cmd))
            {
                throw new InvalidArgumentException("The command cannot be empty.");
            }
            Log.Debug("Execute command `{0}`", cmd);

            dteo.exec(new string[] { cmd }, false);
            return(Value.Empty);
        }
Exemplo n.º 13
0
        protected string StItemActivate(string name, IPM pm)
        {
            if (!pm.It(LevelType.Property, "activate") || !pm.IsRight(LevelType.RightOperandStd))
            {
                throw new IncorrectNodeException(pm);
            }

            if (!Value.ToBoolean(pm.FirstLevel.Data))
            {
#if DEBUG
                LSender.Send(this, $"skip activation of pane '{name}'", MsgLevel.Trace);
#endif
                return(Value.From(false));
            }

            LSender.Send(this, $"Activation the item '{name}'");
            return(Value.From(env.Activate(name)));
        }
Exemplo n.º 14
0
        protected string StExec(IPM pm)
        {
            if (!pm.It(LevelType.Property, "exec") || !pm.IsRight(LevelType.RightOperandColon))
            {
                throw new IncorrectNodeException(pm);
            }

            string cmd = pm.FirstLevel.Data.Trim();

            if (string.IsNullOrWhiteSpace(cmd))
            {
                throw new ArgumentException("The command cannot be empty.");
            }

            LSender.Send(this, $"Execute command `{cmd}`");

            env.Execute(cmd);
            return(Value.Empty);
        }
Exemplo n.º 15
0
        protected string projectCfg(SolutionContext context, IPM pm)
        {
            Debug.Assert(context != null);

            if(pm.It(LevelType.Property, "IsBuildable"))
            {
                if(pm.IsRight(LevelType.RightOperandStd)) {
                    context.ShouldBuild = Value.toBoolean(pm.FirstLevel.Data);
                    return Value.Empty;
                }

                if(pm.IsRight(LevelType.RightOperandEmpty)) {
                    return Value.from(context.ShouldBuild);
                }
            }

            if(pm.It(LevelType.Property, "IsDeployable"))
            {
                if(pm.IsRight(LevelType.RightOperandStd)) {
                    context.ShouldDeploy = Value.toBoolean(pm.FirstLevel.Data);
                    return Value.Empty;
                }

                if(pm.IsRight(LevelType.RightOperandEmpty)) {
                    return Value.from(context.ShouldDeploy);
                }
            }

            throw new IncorrectNodeException(pm);
        }
Exemplo n.º 16
0
        protected string stRepeat(IPM pm, string expression)
        {
            if(!pm.It(LevelType.Method, "repeat") || !pm.IsRight(LevelType.RightOperandColon)) {
                throw new IncorrectNodeException(pm);
            }

            Argument[] args = (new PM()).arguments(expression, ';');
            if(args == null || args.Length > 2 || args.Length < 1) {
                throw new InvalidArgumentException($"Incorrect arguments: {args?.Length} `{expression}`");
            }

            string condition    = args[0].data.ToString();
            bool silent         = false;

            if(args.Length == 2) {
                if(args[1].type != ArgumentType.Boolean) {
                    throw new InvalidArgumentException($"Incorrect type of argument `silent`: {args[1].type}");
                }
                silent = (bool)args[1].data;
            }

            return doRepeat(condition, pm.FirstLevel.Data, null, silent);
        }
Exemplo n.º 17
0
        protected string stIterate(IPM pm, string expression)
        {
            if(!pm.It(LevelType.Method, "iterate") || !pm.IsRight(LevelType.RightOperandColon)) {
                throw new IncorrectNodeException(pm);
            }

            Argument[] args = (new PM()).arguments(expression, ';');
            if(args == null || args.Length != 3) {
                throw new InvalidArgumentException($"Incorrect arguments `iterate(; condition; )`: {args?.Length} `{expression}`");
            }

            string initializer  = args[0].data.ToString();
            string condition    = args[1].data.ToString();
            string iterator     = args[2].data.ToString();

            if(!String.IsNullOrWhiteSpace(initializer)) {
                evaluate($"$({initializer})");
            }

            iterator = String.IsNullOrWhiteSpace(iterator) ? null : $"$({iterator})";

            return doRepeat(condition, pm.FirstLevel.Data, iterator, false);
        }
Exemplo n.º 18
0
        protected string stItemDelete(string name, IPM pm)
        {
            if(!pm.It(LevelType.Property, "delete") || !pm.IsRight(LevelType.RightOperandStd)) {
                throw new IncorrectNodeException(pm);
            }

            if(!Value.toBoolean(pm.FirstLevel.Data)) {
            #if DEBUG
                Log.Trace("skip removing '{0}'", name);
            #endif
                return Value.from(false);
            }

            Log.Debug("removing the item '{0}'", name);
            try {
                OWP.deleteByName(name);
                return Value.from(true);
            }
            catch(ArgumentException) {
                Log.Debug("Incorrect name of pane item `{0}`", name);
            }

            return Value.from(false);
        }
Exemplo n.º 19
0
        protected string stExec(IPM pm)
        {
            if(!pm.It(LevelType.Property, "exec") || !pm.IsRight(LevelType.RightOperandColon)) {
                throw new IncorrectNodeException(pm);
            }

            string cmd = pm.FirstLevel.Data.Trim();
            if(String.IsNullOrWhiteSpace(cmd)) {
                throw new InvalidArgumentException("The command cannot be empty.");
            }
            Log.Debug("Execute command `{0}`", cmd);

            dteo.exec(new string[] { cmd }, false);
            return Value.Empty;
        }
Exemplo n.º 20
0
        protected string stCancel(IPM pm)
        {
            if(!pm.It(LevelType.Property, "cancel") || !pm.IsRight(LevelType.RightOperandStd)) {
                throw new IncorrectNodeException(pm);
            }

            if(Value.toBoolean(pm.FirstLevel.Data)) {
                Log.Debug("attempt to cancel the build");
                DTEO.exec("Build.Cancel");
            }

            return Value.Empty;
        }
Exemplo n.º 21
0
        protected string stType(IPM pm)
        {
            if(!pm.It(LevelType.Property, "type") || !pm.IsRight(LevelType.RightOperandEmpty)) {
                throw new IncorrectNodeException(pm);
            }

            return Value.from(env.BuildType);
        }
Exemplo n.º 22
0
        protected string stStartUpProject(IPM pm)
        {
            if(!pm.It(LevelType.Property, "StartUpProject")) {
                throw new IncorrectNodeException(pm);
            }

            // get

            if(pm.IsRight(LevelType.RightOperandEmpty)) {
                return env.StartupProjectString;
            }

            // set

            if(!pm.IsRight(LevelType.RightOperandStd)) {
                throw new IncorrectNodeException(pm);
            }

            ILevel level    = pm.FirstLevel;
            var val         = (new PM()).arguments(level.Data);

            if(val == null || val.Length < 1) {
                env.updateStartupProject(null);
                return Value.Empty;
            }

            Argument pname = val[0];
            if(val.Length > 1 ||
                (pname.type != ArgumentType.StringDouble
                    && pname.type != ArgumentType.EnumOrConst
                    && pname.type != ArgumentType.Mixed))
            {
                throw new ArgumentPMException(level, "= string name");
            }

            env.updateStartupProject(pname.data.ToString());
            return Value.Empty;
        }