protected override void ContextParse(TextMold mold, Type type, LogicErrorList errors) { var cat = TypeResolver.GetResolver(type).Category; if (mold.Value == null) return; if (cat == Categories.Field) return; var p = mold.Value; switch (cat) { case Categories.Dictionary: case Categories.Node: if (!fieldRegex.Match(mold.Value).Success) { errors.Add(LogicErrorLevel.Error, string.Format("Неправильное присвоение {0}. Строка: {1}", cat.ToString(), p)); return; } p.Split(' ').ToList().ForEach( a => { if (a.Length == 0) return; var pairs = a.Split(':').Select(b => b.Trim()); if (pairs.Count() < 2) errors.Add(LogicErrorLevel.Error, string.Format("Неверный формат описания.\nОбрабатываемая строка: {1}\nОшибка: {2}", mold.Address.GetDottedString(), p, a)); else { var newAddr = new FieldAddress(pairs.First()); newAddr = mold.Address.Child(newAddr); GetMold(newAddr).Value = pairs.Last(); } } ); return; case Categories.Tensor: case Categories.List: var parts = p.Split('|'); for (int i = 0; i < parts.Length; ++i) GetMold(mold.Address.Child(i.ToString())).Value = parts[i]; return; } }
public TextMoldRoot() { RootMold = new TextMold(FieldAddress.Root, this); }
public TextMold CreateMold(string key) { var mold = new TextMold(this.Address.Child(key), Root); Nodes[key] = mold; return mold; }