public new static void AddMultiConstructor(string tagPrefix, YamlMultiConstructor ctor) { if (!_yamlMultiConstructors.ContainsKey(tagPrefix)) { _yamlMultiConstructors.Add(tagPrefix, ctor); _yamlMultiRegexps.Add(tagPrefix, new Regex("^" + tagPrefix, RegexOptions.Compiled)); } }
public object ConstructObject(Node node) { if (node == null) { node = GetNullNode(); } if (_recursiveObjects.ContainsKey(node)) { return(new LinkNode(node)); } _recursiveObjects.Add(node, new List <RecursiveFixer>()); YamlConstructor ctor = GetYamlConstructor(node.Tag ?? node.DefaultTag); if (ctor == null) { bool through = true; foreach (string tagPrefix in GetYamlMultiRegexps()) { Regex reg = GetYamlMultiRegexp(tagPrefix); if (reg.IsMatch(node.Tag)) { string tagSuffix = node.Tag.Substring(tagPrefix.Length); ctor = yamlMultiAdapter(GetYamlMultiConstructor(tagPrefix), tagSuffix); through = false; break; } } if (through) { YamlMultiConstructor xctor = GetYamlMultiConstructor(""); if (null != xctor) { ctor = yamlMultiAdapter(xctor, node.Tag); } else { ctor = GetYamlConstructor(""); if (ctor == null) { ctor = (s, n) => s.ConstructPrimitive(n); } } } } object data = ctor(this, node); DoRecursionFix(node, data); return(data); }
public new static void AddMultiConstructor(string tagPrefix, YamlMultiConstructor ctor) { _yamlMultiConstructors.Add(tagPrefix, ctor); _yamlMultiRegexps.Add(tagPrefix, new Regex("^" + tagPrefix, RegexOptions.Compiled)); }
public static void AddMultiConstructor(string tagPrefix, YamlMultiConstructor ctor) { _yamlMultiConstructors.Add(tagPrefix, ctor); _yamlMultiRegexps.Add(tagPrefix, YamlUtils.CompiledRegex("^" + tagPrefix)); }
private YamlConstructor yamlMultiAdapter(YamlMultiConstructor ctor, string prefix) { return(delegate(BaseConstructor self, Node node) { return ctor(self, prefix, node); }); }