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); }
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); }
protected string stEvents(IPM pm) { if (!pm.It(LevelType.Property, "events")) { throw new IncorrectNodeException(pm); } if (pm.It(LevelType.Property, "LastCommand")) { return(stLastCommand(pm)); } throw new IncorrectNodeException(pm); }
protected string StExists(IPM pm) { if (!pm.It(LevelType.Property, "exists")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if (!pm.FinalEmptyIs(LevelType.Method, "directory") && !pm.FinalEmptyIs(LevelType.Method, "file")) { throw new IncorrectNodeException(pm); } if (level.Is(ArgumentType.StringDouble)) { return(StExists(pm.IsData("file"), (string)level.Args[0].data, false)); } if (level.Is(ArgumentType.StringDouble, ArgumentType.Boolean)) { return(StExists(pm.IsData("file"), (string)level.Args[0].data, (bool)level.Args[1].data)); } throw new PMLevelException(level, level.Data + "(string path [, boolean environment])"); }
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)); }
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)); }
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)); }
protected string stData(IPM pm) { if (!pm.It(LevelType.Property, "data")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if (pm.FinalIs(LevelType.Method, "pack")) { return(dataPack(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "free")) { return(dataFree(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "get")) { return(dataGet(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "clone")) { return(dataClone(level, pm)); } throw new IncorrectNodeException(pm); }
protected string stHash(IPM pm) { if (!pm.It(LevelType.Property, "hash")) { throw new IncorrectNodeException(pm); } ILevel lvlHash = pm.FirstLevel; // level of the hash property // hash.MD5("data") if (pm.FinalEmptyIs(LevelType.Method, "MD5")) { lvlHash.Is("hash.MD5(string data)", ArgumentType.StringDouble); return(((string)lvlHash.Args[0].data).MD5Hash()); } // hash.SHA1("data") if (pm.FinalEmptyIs(LevelType.Method, "SHA1")) { lvlHash.Is("hash.SHA1(string data)", ArgumentType.StringDouble); return(((string)lvlHash.Args[0].data).SHA1Hash()); } throw new IncorrectNodeException(pm); }
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)); }
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)); }
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 stLog(IPM pm) { if (pm.It(LevelType.Property, "log")) { if (pm.It(LevelType.Property, "Message")) { return(Value.from(logcopy.Message)); } if (pm.It(LevelType.Property, "Level")) { return(Value.from(logcopy.Level)); } throw new IncorrectNodeException(pm); } throw new IncorrectNodeException(pm); }
protected string StReplace(IPM pm) { SearchType type = SearchType.Null; // old signatures if (pm.FinalEmptyIs(LevelType.Method, "replace")) { // replace(...) type = SearchType.Basic; } else if (pm.It(LevelType.Property, "replace")) { if (pm.FinalEmptyIs(LevelType.Method, "Regex") || pm.FinalEmptyIs(LevelType.Method, "Regexp")) { // replace.Regex(...) & replace.Regexp(...) type = SearchType.Regexp; } else if (pm.FinalEmptyIs(LevelType.Method, "Wildcards")) { // replace.Wildcards(...) type = SearchType.Wildcards; } } if (type == SearchType.Null) { throw new IncorrectNodeException(pm); } // arguments ILevel level = pm.FirstLevel; if (!level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble)) { throw new PMLevelException(level, "(string file, string pattern, string replacement)"); } string file = GetLocation((string)level.Args[0].data); string pattern = (string)level.Args[1].data; string replacement = (string)level.Args[2].data; LSender.Send(this, $"StReplace: found file '{file}', pattern '{pattern}', replacement '{replacement}'", MsgLevel.Trace); Encoding enc = DetectEncodingFromFile(file); string content = ReadToEnd(file, enc); LSender.Send(this, $"StReplace: type '{type}' :: received '{content.Length}', Encoding '{enc}'"); content = StReplaceEngine(type, ref content, pattern, replacement); WriteToFile(file, content, false, enc); return(Value.Empty); }
protected string StProjects(IPM pm) { if (!pm.It(LevelType.Property, "projects")) { throw new IncorrectNodeException(pm); } if (pm.Is(LevelType.Method, "find")) { return(StProjectsFind(pm)); } throw new IncorrectNodeException(pm); }
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); }
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 stOperators(IPM pm) { if (!pm.It(LevelType.Property, "operators")) { throw new IncorrectNodeException(pm); } ILevel lvlOp = pm.FirstLevel; if (pm.FinalEmptyIs(LevelType.Method, "sleep")) { lvlOp.Is("sleep(integer timeout)", ArgumentType.Integer); Thread.Sleep((int)lvlOp.Args[0].data); return(String.Empty); } throw new IncorrectNodeException(pm); }
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); }
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))); }
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); }
protected string StDelete(IPM pm) { if (!pm.It(LevelType.Property, "delete")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if (pm.FinalEmptyIs(LevelType.Method, "files")) { return(DeleteFiles(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "directory")) { return(DeleteDirectory(level, pm)); } throw new IncorrectNodeException(pm); }
protected string StCopy(IPM pm) { if (!pm.It(LevelType.Property, "copy")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if (pm.FinalEmptyIs(LevelType.Method, "file")) { return(CopyFile(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "directory")) { return(CopyDirectory(level, pm)); } throw new IncorrectNodeException(pm); }
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); }
protected string stPack(IPM pm) { if (!pm.It(LevelType.Property, "pack")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; // level of the pack property if (pm.FinalEmptyIs(LevelType.Method, "files")) { return(packFiles(level, pm)); } if (pm.FinalEmptyIs(LevelType.Method, "directory")) { return(packDirectory(level, pm)); } throw new IncorrectNodeException(pm); }
protected string StRemote(IPM pm) { if (!pm.It(LevelType.Property, "remote")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if (pm.FinalEmptyIs(LevelType.Method, "download")) { if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { return(Download((string)level.Args[0].data, (string)level.Args[1].data)); } if (level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble)) { return(Download((string)level.Args[0].data, (string)level.Args[1].data, (string)level.Args[2].data, (string)level.Args[3].data)); } throw new PMLevelException(level, "(string addr, string output [, string user, string pwd])"); } throw new IncorrectNodeException(pm); }
protected string stProjects(IPM pm) { if(!pm.It(LevelType.Property, "projects")) { throw new IncorrectNodeException(pm); } if(pm.Is(LevelType.Method, "find")) { return stProjectsFind(pm); } throw new IncorrectNodeException(pm); }
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 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); }
protected string stExists(IPM pm) { if(!pm.It(LevelType.Property, "exists")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if(!pm.FinalEmptyIs(LevelType.Method, "directory") && !pm.FinalEmptyIs(LevelType.Method, "file")) { throw new IncorrectNodeException(pm); } if(level.Is(ArgumentType.StringDouble)) { return stExists(pm.IsData("file"), (string)level.Args[0].data, false); } if(level.Is(ArgumentType.StringDouble, ArgumentType.Boolean)) { return stExists(pm.IsData("file"), (string)level.Args[0].data, (bool)level.Args[1].data); } throw new ArgumentPMException(level, level.Data + "(string path [, boolean environment])"); }
protected string stRemote(IPM pm) { if(!pm.It(LevelType.Property, "remote")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if(pm.FinalEmptyIs(LevelType.Method, "download")) { if(level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble)) { return download((string)level.Args[0].data, (string)level.Args[1].data); } if(level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble)) { return download((string)level.Args[0].data, (string)level.Args[1].data, (string)level.Args[2].data, (string)level.Args[3].data); } throw new ArgumentPMException(level, "(string addr, string output [, string user, string pwd])"); } throw new IncorrectNodeException(pm); }
/// <summary> /// For work with events of logging. /// `log.Message` /// `log.Level` /// </summary> /// <param name="pm"></param> /// <returns></returns> //[Property("log", "Provides data from events of logging.")] //[Property("Message", "Current message from log.", "log", "stLog", CValueType.String)] //[Property("Level", "The Level of current Message.", "log", "stLog", CValueType.String)] protected string stLog(IPM pm) { if(pm.It(LevelType.Property, "log")) { if(pm.It(LevelType.Property, "Message")) { return Value.from(logcopy.Message); } if(pm.It(LevelType.Property, "Level")) { return Value.from(logcopy.Level); } throw new IncorrectNodeException(pm); } throw new IncorrectNodeException(pm); }
protected string stCopy(IPM pm) { if(!pm.It(LevelType.Property, "copy")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if(pm.FinalEmptyIs(LevelType.Method, "file")) { return copyFile(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "directory")) { return copyDirectory(level, pm); } throw new IncorrectNodeException(pm); }
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; }
protected string stEvents(IPM pm) { if(!pm.It(LevelType.Property, "events")) { throw new IncorrectNodeException(pm); } if(pm.It(LevelType.Property, "LastCommand")) { return stLastCommand(pm); } throw new IncorrectNodeException(pm); }
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); }
protected string stOperators(IPM pm) { if(!pm.It(LevelType.Property, "operators")) { throw new IncorrectNodeException(pm); } ILevel lvlOp = pm.FirstLevel; if(pm.FinalEmptyIs(LevelType.Method, "sleep")) { lvlOp.Is("sleep(integer timeout)", ArgumentType.Integer); Thread.Sleep((int)lvlOp.Args[0].data); return String.Empty; } throw new IncorrectNodeException(pm); }
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); }
protected string stData(IPM pm) { if(!pm.It(LevelType.Property, "data")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if(pm.FinalIs(LevelType.Method, "pack")) { return dataPack(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "free")) { return dataFree(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "get")) { return dataGet(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "clone")) { return dataClone(level, pm); } throw new IncorrectNodeException(pm); }
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 stDelete(IPM pm) { if(!pm.It(LevelType.Property, "delete")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; if(pm.FinalEmptyIs(LevelType.Method, "files")) { return deleteFiles(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "directory")) { return deleteDirectory(level, pm); } throw new IncorrectNodeException(pm); }
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; }
protected string stReplace(IPM pm) { SearchType type = SearchType.Null; // the old signatures if(pm.FinalEmptyIs(LevelType.Method, "replace")) { // replace(...) type = SearchType.Basic; } else if(pm.It(LevelType.Property, "replace")) { if(pm.FinalEmptyIs(LevelType.Method, "Regex") || pm.FinalEmptyIs(LevelType.Method, "Regexp")) { // replace.Regex(...) & replace.Regexp(...) type = SearchType.Regexp; } else if(pm.FinalEmptyIs(LevelType.Method, "Wildcards")) { // replace.Wildcards(...) type = SearchType.Wildcards; } } if(type == SearchType.Null) { throw new IncorrectNodeException(pm); } // arguments ILevel level = pm.FirstLevel; if(!level.Is(ArgumentType.StringDouble, ArgumentType.StringDouble, ArgumentType.StringDouble)) { throw new ArgumentPMException(level, "(string file, string pattern, string replacement)"); } string file = location((string)level.Args[0].data); string pattern = (string)level.Args[1].data; string replacement = (string)level.Args[2].data; Log.Trace("stReplace: found file '{0}', pattern '{1}', replacement '{2}'", file, pattern, replacement); Encoding enc = detectEncodingFromFile(file); string content = readToEnd(file, enc); Log.Debug("stReplace: type '{0}' :: received '{1}', Encoding '{2}'", type, content.Length, enc); content = stReplaceEngine(type, ref content, pattern, replacement); writeToFile(file, content, false, enc); return Value.Empty; }
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); }
protected string stHash(IPM pm) { if(!pm.It(LevelType.Property, "hash")) { throw new IncorrectNodeException(pm); } ILevel lvlHash = pm.FirstLevel; // level of the hash property // hash.MD5("data") if(pm.FinalEmptyIs(LevelType.Method, "MD5")) { lvlHash.Is("hash.MD5(string data)", ArgumentType.StringDouble); return ((string)lvlHash.Args[0].data).MD5Hash(); } // hash.SHA1("data") if(pm.FinalEmptyIs(LevelType.Method, "SHA1")) { lvlHash.Is("hash.SHA1(string data)", ArgumentType.StringDouble); return ((string)lvlHash.Args[0].data).SHA1Hash(); } throw new IncorrectNodeException(pm); }
protected string stPack(IPM pm) { if(!pm.It(LevelType.Property, "pack")) { throw new IncorrectNodeException(pm); } ILevel level = pm.FirstLevel; // level of the pack property if(pm.FinalEmptyIs(LevelType.Method, "files")) { return packFiles(level, pm); } if(pm.FinalEmptyIs(LevelType.Method, "directory")) { return packDirectory(level, pm); } throw new IncorrectNodeException(pm); }