Пример #1
0
        public static TransformCommand Parse(string input)
        {
            var regex = @"(.+?)\((.+?)\)";

            var matches            = Regex.Matches(input, regex);
            TransformCommand first = null;
            TransformCommand last  = null;

            foreach (Match match in matches)
            {
                var key   = match.Groups[1].Value.Trim();
                var value = match.Groups[2].Value.Trim();
                TransformCommandType type;
                if (!Enum.TryParse <TransformCommandType>(key, true, out type))
                {
                    throw new FormatException("Input string was not in correct format: " + input);
                }
                var command = new TransformCommand(type, value.Split(new[] { " ", "," }, StringSplitOptions.RemoveEmptyEntries).Select(n => double.Parse(n)).ToArray());
                if (first == null)
                {
                    first = command;
                }
                else
                {
                    last.SetNext(command);
                }
                last = command;
            }
            return(first);
        }
Пример #2
0
 public object GetRealObject(StreamingContext context)
 {
     return(TransformCommand.Parse(Input));
 }
Пример #3
0
 public TransformCommand Append(TransformCommand command)
 {
     return(Last.SetNext(command));
 }
Пример #4
0
 public virtual TransformCommand SetNext(TransformCommand command)
 {
     command.Next = Next;
     Next         = command;
     return(command);
 }