protected override void WriteSectionEnd(Action<string> Flusher, FieldAddress address, Type actualType, Type customType) { string name = ""; if (address.IsRoot) name = actualType.Name.Replace('`','_'); else name = address.LastElement; Flusher("</" + Tag(name) + ">"); }
protected override void WriteSectionStact(Action<string> Flusher, FieldAddress address, Type actualType, Type customType) { string name=""; if (address.IsRoot) name = actualType.Name.Replace('`','_'); else name = address.LastElement; string Type = ""; if (customType!=null) Type=" Type=\""+customType.FullName+"\""; Flusher("<"+Tag(name)+Type+">"); }
/// <summary> /// Создает ошибку /// </summary> /// <param name="type">Тип</param> /// <param name="level">Уровень</param> /// <param name="source">Источник</param> /// <param name="context">Контекст</param> /// <param name="message">Сообщение об ошибке</param> /// <param name="address">Адрес ошибки в дереве данных</param> public LogicError(LogicErrorType type, LogicErrorLevel level, LogicErrorSource source, string context, string message, FieldAddress address) { this.Type = type; this.Level = level; this.Source = source; this.Context = context; this.Message = message; this.Address = address; }
public static object GetElement(object obj, FieldAddress addr) { foreach (var e in addr.Elements) { if (obj == null) throw new NullReferenceException(); obj=TypeResolver.GetResolver(obj.GetType()).GetElement(obj,e); } return obj; }
public override void Wykonaj() { //pobieram obiekt ze stosu var obj = PopObject(); //szukam pola var field = (System.Reflection.FieldInfo)Instruction.Operand; var fieldAddress = new FieldAddress(); fieldAddress.Field = field; fieldAddress.Object = obj; //kładę na stos wartość pola Push(fieldAddress); WykonajNastepnaInstrukcje(); }
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; } }
protected override void WriteNullField(Action<string> Flusher, FieldAddress address, string sub) { Flusher("<" + Tag(sub) + " Null=\"\"/>"); }
protected override void WriteField(Action<string> Flusher, FieldAddress address, string sub, string value) { Flusher("<"+Tag(sub)+">"+value.Replace("&","&").Replace("<","<").Replace(">",">")+"</"+Tag(sub)+">"); }
protected override void WriteSectionStact(Action<string> Flusher, FieldAddress address, Type actualType, Type customType) { }
protected override void WriteNullField(Action<string> Flusher, FieldAddress address, string sub) { Flusher(string.Format("{0}@Null", address.Child(sub).GetDottedString())); }
protected override void WriteField(Action<string> Flusher, FieldAddress address, string sub, string value) { Flusher(string.Format("{0}={1}", address.Child(sub).GetDottedString(), value)); }
internal TextMold(FieldAddress address, TextMoldRoot root) { this.Address = address; this.Root = root; }
protected override void WriteSectionStact(Action<string> Flusher, FieldAddress address, Type actualType, Type customType) { Flusher("[" + address + "]"+Environment.NewLine); if (customType != null) Flusher("@Type=" + customType.FullName+Environment.NewLine); }
protected override void WriteNullField(Action<string> Flusher, FieldAddress address, string sub) { Flusher(sub + "@Null" + Environment.NewLine); }
protected override void WriteField(Action<string> Flusher, FieldAddress address, string sub, string value) { Flusher(sub + "=" + value.Replace("\\","\\\\").Replace("\n","\\n")+Environment.NewLine); }
static void TreeRunDown(FieldAddress address, object obj, Action<FieldAddress, object> rootFirstAction, Action<FieldAddress, object> leafFirstAction) { if (obj==null) return; if (rootFirstAction != null) rootFirstAction(address, obj); var res = TypeResolver.GetResolver(obj.GetType()); foreach (var e in res.GetSubaddresses(obj)) TreeRunDown(address.Child(e),res.GetElement(obj, e), rootFirstAction, leafFirstAction); if (leafFirstAction != null) leafFirstAction(address, obj); }