コード例 #1
0
        public ActionsDescription Clone(string oldValue, string newValue)
        {
            var actionDescription = new ActionsDescription()
            {
                Actions     = new Action[Actions.Length],
                Description = "// GENERATED",
            };

            for (int i = 0; i < Actions.Length; i++)
            {
                actionDescription.Actions[i] = Actions[i].Clone(oldValue, newValue);
            }

            return(actionDescription);
        }
コード例 #2
0
ファイル: ActionsDescription.cs プロジェクト: five-x/siprevo
		public ActionsDescription Clone(string oldValue, string newValue)
		{
			var actionDescription = new ActionsDescription()
			{
				Actions = new Action[Actions.Length],
				Description = "// GENERATED",
			};

			for (int i = 0; i < Actions.Length; i++)
				actionDescription.Actions[i] = Actions[i].Clone(oldValue, newValue);

			return actionDescription;
		}
コード例 #3
0
        public static ActionsDescription TryParse(string description, string path)
        {
            if (description != "" && description.TrimEnd().EndsWith(";") == false)
            {
                description += ";";
            }

            var reservArgs = path.Split('.');
            var actions    = new List <Action>();

            var match = _regex.Match(description);

            while (match.Success)
            {
                Action action = null;
                try
                {
                    switch (match.Groups["func"].Value)
                    {
                    case "Custom":
                        action = new Action(Marks.Custom, 4);
                        SetArg(action, 0, match, reservArgs, 1);
                        TestArg(1, match, "Begin", "End", "Each", "AfterBegin");
                        action.Args[1] = match.Groups["arg2"].Value;
                        action.Args[2] = match.Groups["arg3"].Value.Trim('"');
                        action.Args[3] = match.Groups["arg4"].Value;
                        break;

                    case "Const":
                        action = new Action(Marks.Const, 3);
                        SetArg(action, 0, match, reservArgs, 2);
                        SetArg(action, 1, match, reservArgs, 2);
                        SetArg(action, 2, match, 10);
                        break;

                    case "Range":
                        action = new Action(Marks.Range, 3);
                        SetArg(action, 0, match, reservArgs, 1);
                        SetArg(action, 1, match, 0);
                        SetArg(action, 2, match, 0);
                        break;

                    case "LookupRange":
                        action = new Action(Marks.Range, 3);
                        SetArg(action, 0, match, reservArgs, 1);
                        SetArg(action, 1, match, 1);
                        SetArg(action, 2, match, -1);
                        break;

                    case "BeginRange":
                        action = new Action(Marks.BeginRange, 3);
                        SetArg(action, 0, match, reservArgs, 1);
                        TestArg(1, match, "", "AtBegin", "AtEnd");
                        SetArg(action, 1, match, "AtBegin");
                        SetArg(action, 2, match, 0);
                        break;

                    case "EndRange":
                        action = new Action(Marks.EndRange, 3);
                        SetArg(action, 0, match, reservArgs, 1);
                        TestArg(1, match, "", "AtBegin", "AtEnd");
                        SetArg(action, 1, match, "AtEnd");
                        SetArg(action, 2, match, 0);
                        break;

                    case "EndRangeIfInvalid":
                        action = new Action(Marks.EndRangeIfInvalid, 3);
                        SetArg(action, 0, match, reservArgs, 1);
                        TestArg(1, match, "", "AtBegin", "AtEnd");
                        SetArg(action, 1, match, "AtEnd");
                        SetArg(action, 2, match, 0);
                        break;

                    case "ContinueRange":
                        action = new Action(Marks.ContinueRange, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "Reset":
                        action = new Action(Marks.ResetRange, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "ResetIfInvalid":
                        action = new Action(Marks.ResetRangeIfInvalid, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "Count":
                        action = new Action(Marks.Count, 3);
                        SetArg(action, 0, match, reservArgs, 1);
                        SetArg(action, 1, match, 10);
                        SetArg(action, 2, match, 0);
                        break;

                    case "Decimal":
                        action = new Action(Marks.Decimal, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "Hex":
                        action = new Action(Marks.Hex, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "Bool":
                        action = new Action(Marks.Bool, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "BoolEx":
                        action = new Action(Marks.BoolEx, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "BoolExNot":
                        action = new Action(Marks.BoolExNot, 1);
                        SetArg(action, 0, match, reservArgs, 1);
                        break;

                    case "Group":
                        action = new Action(Marks.Group, 2);
                        SetArg(action, 0, match, "");
                        SetArg(action, 1, match, "NoneStruct");
                        break;

                    default:
                        throw new Exception();
                    }
                }
                catch
                {
                    return(null);
                }

                actions.Add(action);

                match = match.NextMatch();
            }

            var result = new ActionsDescription()
            {
                Description = description,
            };

            if (actions != null && actions.Count > 0)
            {
                result.Actions = actions.ToArray();
            }

            if (result.IsEmpty == false && result.Actions == null)
            {
                return(null);
            }

            return(result);
        }
コード例 #4
0
ファイル: ActionsDescription.cs プロジェクト: five-x/siprevo
		public static ActionsDescription TryParse(string description, string path)
		{
			if (description != "" && description.TrimEnd().EndsWith(";") == false)
				description += ";";

			var reservArgs = path.Split('.');
			var actions = new List<Action>();

			var match = _regex.Match(description);
			while (match.Success)
			{
				Action action = null;
				try
				{
					switch (match.Groups["func"].Value)
					{
						case "Custom":
							action = new Action(Marks.Custom, 4);
							SetArg(action, 0, match, reservArgs, 1);
							TestArg(1, match, "Begin", "End", "Each", "AfterBegin");
							action.Args[1] = match.Groups["arg2"].Value;
							action.Args[2] = match.Groups["arg3"].Value.Trim('"');
							action.Args[3] = match.Groups["arg4"].Value;
							break;
						case "Const":
							action = new Action(Marks.Const, 3);
							SetArg(action, 0, match, reservArgs, 2);
							SetArg(action, 1, match, reservArgs, 2);
							SetArg(action, 2, match, 10);
							break;
						case "Range":
							action = new Action(Marks.Range, 3);
							SetArg(action, 0, match, reservArgs, 1);
							SetArg(action, 1, match, 0);
							SetArg(action, 2, match, 0);
							break;
						case "LookupRange":
							action = new Action(Marks.Range, 3);
							SetArg(action, 0, match, reservArgs, 1);
							SetArg(action, 1, match, 1);
							SetArg(action, 2, match, -1);
							break;
						case "BeginRange":
							action = new Action(Marks.BeginRange, 3);
							SetArg(action, 0, match, reservArgs, 1);
							TestArg(1, match, "", "AtBegin", "AtEnd");
							SetArg(action, 1, match, "AtBegin");
							SetArg(action, 2, match, 0);
							break;
						case "EndRange":
							action = new Action(Marks.EndRange, 3);
							SetArg(action, 0, match, reservArgs, 1);
							TestArg(1, match, "", "AtBegin", "AtEnd");
							SetArg(action, 1, match, "AtEnd");
							SetArg(action, 2, match, 0);
							break;
						case "EndRangeIfInvalid":
							action = new Action(Marks.EndRangeIfInvalid, 3);
							SetArg(action, 0, match, reservArgs, 1);
							TestArg(1, match, "", "AtBegin", "AtEnd");
							SetArg(action, 1, match, "AtEnd");
							SetArg(action, 2, match, 0);
							break;
						case "ContinueRange":
							action = new Action(Marks.ContinueRange, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "Reset":
							action = new Action(Marks.ResetRange, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "ResetIfInvalid":
							action = new Action(Marks.ResetRangeIfInvalid, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "Count":
							action = new Action(Marks.Count, 3);
							SetArg(action, 0, match, reservArgs, 1);
							SetArg(action, 1, match, 10);
							SetArg(action, 2, match, 0);
							break;
						case "Decimal":
							action = new Action(Marks.Decimal, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "Hex":
							action = new Action(Marks.Hex, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "Bool":
							action = new Action(Marks.Bool, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "BoolEx":
							action = new Action(Marks.BoolEx, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "BoolExNot":
							action = new Action(Marks.BoolExNot, 1);
							SetArg(action, 0, match, reservArgs, 1);
							break;
						case "Group":
							action = new Action(Marks.Group, 2);
							SetArg(action, 0, match, "");
							SetArg(action, 1, match, "NoneStruct");
							break;
						default:
							throw new Exception();
					}
				}
				catch
				{
					return null;
				}

				actions.Add(action);

				match = match.NextMatch();
			}

			var result = new ActionsDescription() { Description = description, };

			if (actions != null && actions.Count > 0)
				result.Actions = actions.ToArray();

			if (result.IsEmpty == false && result.Actions == null)
				return null;

			return result;
		}