Ejemplo n.º 1
0
 public new static void AddConstructor(string tag, YamlConstructor ctor)
 {
     if (!_yamlConstructors.ContainsKey(tag))
     {
         _yamlConstructors.Add(tag, ctor);
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public new static void AddConstructor(string tag, YamlConstructor ctor) {
     _yamlConstructors.Add(tag, ctor);
 }
Ejemplo n.º 4
0
 public static void AddConstructor(string tag, YamlConstructor ctor)
 {
     _yamlConstructors.Add(tag, ctor);
 }
Ejemplo n.º 5
0
 public new static void AddConstructor(string tag, YamlConstructor ctor) {
     if (!_yamlConstructors.ContainsKey(tag)) {
         _yamlConstructors.Add(tag, ctor);
     }
 }