Пример #1
0
 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) + ">");
 }
Пример #2
0
 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+">");
 }
Пример #3
0
 /// <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;
 }
Пример #4
0
 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;
 }
Пример #5
0
        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();
        }
Пример #6
0
 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;
     }
 }
Пример #7
0
 protected override void WriteNullField(Action<string> Flusher, FieldAddress address, string sub)
 {
     Flusher("<" + Tag(sub) + " Null=\"\"/>");
 }
Пример #8
0
 protected override void WriteField(Action<string> Flusher, FieldAddress address, string sub, string value)
 {
     Flusher("<"+Tag(sub)+">"+value.Replace("&","&amp;").Replace("<","&lt;").Replace(">","&gt;")+"</"+Tag(sub)+">");
 }
Пример #9
0
 protected override void WriteSectionStact(Action<string> Flusher, FieldAddress address, Type actualType, Type customType)
 {
 }
Пример #10
0
 protected override void WriteNullField(Action<string> Flusher, FieldAddress address, string sub)
 {
     Flusher(string.Format("{0}@Null", address.Child(sub).GetDottedString()));
 }
Пример #11
0
 protected override void WriteField(Action<string> Flusher, FieldAddress address, string sub, string value)
 {
     Flusher(string.Format("{0}={1}", address.Child(sub).GetDottedString(), value));
 }
Пример #12
0
 internal TextMold(FieldAddress address, TextMoldRoot root)
 {
     this.Address = address;
     this.Root = root;
 }
Пример #13
0
 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);
 }
Пример #14
0
 protected override void WriteNullField(Action<string> Flusher, FieldAddress address, string sub)
 {
     Flusher(sub + "@Null" + Environment.NewLine);
 }
Пример #15
0
 protected override void WriteField(Action<string> Flusher, FieldAddress address, string sub, string value)
 {
     Flusher(sub + "=" + value.Replace("\\","\\\\").Replace("\n","\\n")+Environment.NewLine);
 }
Пример #16
0
 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);
 }