public AbstractBareJsonParser(JsonTypeFactory jsonTypeFactory, ParserPolicy parserPolicy) : this(jsonTypeFactory, parserPolicy, false) // true or false ?? { }
public AbstractJsonTokenizerAnonymousInnerClass(AbstractLayeredJsonParser outerInstance, TextReader reader, ParserPolicy parserPolicy) : base(reader, parserPolicy) { this.outerInstance = outerInstance; }
public SimpleLayeredJsonParser(JsonTypeFactory jsonTypeFactory, ParserPolicy parserPolicy) : base(jsonTypeFactory, parserPolicy) { }
public SimpleLayeredJsonParser(JsonTypeFactory jsonTypeFactory, ParserPolicy parserPolicy, bool threadSafe) : base(jsonTypeFactory, parserPolicy, threadSafe) { }
public string ParseString(string strSource, ParserPolicy flagsPolicy = ParserPolicy.AllowDefines | ParserPolicy.AllowIncludes) // TODO: Порезать на методы, а то читается сложно { var sbResult = new StringBuilder(""); policy = flagsPolicy; if (strSource == null) { throw new ArgumentNullException("strSource"); } if (strSource.Length > 0) { var strStrings = Regex.Split(strSource, @"\r?\n|\r"); foreach (var strString in strStrings) { if (strString.Contains("{%")) { string strProceed = strString; string strFull = null; string strDirective = null; string strParams = null; Match mt; // Сначала проверим, нет ли в обрабатываемой строке ранее определёных DEFINES, вида {%ItemName%} do { strFull = null; strDirective = null; mt = Regex.Match(strProceed, @"\{\%\s*(?<Key>\w+)\s*\%\}"); // TODO поддержка дефолтных значений с форматом вида {%ItemName|"Value if ItemName not exists"%} if (mt.Success) { strFull = mt.Groups[0].Value; strDirective = mt.Groups["Key"].Value; if (LDefines.Count > 0 && !String.IsNullOrWhiteSpace(strDirective) && !String.IsNullOrWhiteSpace(strFull)) { strProceed = Strings.ReplaceByStrong(strProceed, strFull, GetFirstParent().LDefines.Get(strDirective)); } else { strProceed = Strings.ReplaceByStrong(strProceed, strFull, ""); } } } while (mt.Success); // Теперь смотрим на конструкции типа {% DEFINE a = "b" %} или {% INCLUDE "zzzz.tpl" %} do { strFull = null; strDirective = null; strParams = null; mt = Regex.Match(strProceed, @"\{\%\s*(?<Directive>\w+?)[\s\=\s]+(?<Params>.*?)\s*?\%\}"); if (mt.Success) { strFull = mt.Groups[0].Value; strDirective = mt.Groups["Directive"].Value; strParams = mt.Groups["Params"].Value; if (String.Equals(strDirective, "DEFINE") && !flagsPolicy.HasFlag(ParserPolicy.AllowDefines)) { strDirective = null; } if (String.Equals(strDirective, "INCLUDE") && !flagsPolicy.HasFlag(ParserPolicy.AllowIncludes)) { strDirective = null; } if (!String.IsNullOrWhiteSpace(strDirective) && strParams != null && !String.IsNullOrWhiteSpace(strFull)) { strProceed = Strings.ReplaceByStrong(strProceed, strFull, GetFirstParent()[strDirective](ref strParams)); } else { strProceed = Strings.ReplaceByStrong(strProceed, strFull, ""); } } } while (mt.Success); if (!String.IsNullOrWhiteSpace(strProceed)) { sbResult.AppendLine(strProceed); } } else { if (!String.IsNullOrWhiteSpace(strString)) { sbResult.AppendLine(strString); } } } } return(sbResult.ToString()); }
public CustomJsonTokenizer(TextReader reader, ParserPolicy parserPolicy) : base(reader, parserPolicy) { }
public SimpleJsonTokenizer(TextReader reader, ParserPolicy parserPolicy) : base(reader, parserPolicy) { }
public AbstractJsonTokenizer(TextReader reader, ParserPolicy parserPolicy) : this(reader, parserPolicy, CHARQUEUE_SIZE) { }
public CustomJsonParser(JsonTypeFactory jsonTypeFactory, ParserPolicy parserPolicy) : base(jsonTypeFactory, parserPolicy) { }