Ejemplo n.º 1
0
        private static List<ItemPath> ParseXmlArguments(Context context, string[] itemsPath)
        {
            var paths = new List<ItemPath>(itemsPath.Length);
            var chars = new char[] { ':', ';', };
            foreach (var spec in itemsPath)
            {
                var path = new ItemPath();

                if (spec.Count(c => c.Equals(':')) >= 3)
                {
                    var parts = spec.Split(new char[] { ':', }, 4);

                    ItemStyle style;
                    if (Enum.TryParse<ItemStyle>(parts[0], out style))
                    {
                        path.Style = style;
                    }
                    else
                    {
                        context.AddError("Invalid style in '" + spec + "'.");
                    }

                    path.Path = parts[1];
                    path.Attribute = string.IsNullOrWhiteSpace(parts[2]) ? null : parts[2];
                    path.Text = string.IsNullOrEmpty(parts[3]) ? null : parts[3];
                }
                else
                {
                    context.AddError("Not enough parameters in '" + spec + "'.");
                    continue;
                }

                paths.Add(path);
            }
            return paths;
        }