public BackwardsCompatibleConfiguration(
                IObjectFactory objectFactory,
                INamingConvention namingConvention,
                bool ignoreUnmatched,
                YamlAttributeOverrides overrides)
            {
                objectFactory    = objectFactory ?? new DefaultObjectFactory();
                namingConvention = namingConvention ?? new NullNamingConvention();

                typeDescriptor.TypeDescriptor =
                    new CachedTypeInspector(
                        new NamingConventionTypeInspector(
                            new YamlAttributesTypeInspector(
                                new YamlAttributeOverridesInspector(
                                    new ReadableAndWritablePropertiesTypeInspector(
                                        new ReadablePropertiesTypeInspector(
                                            new StaticTypeResolver()
                                            )
                                        ),
                                    overrides
                                    )
                                ),
                            namingConvention
                            )
                        );

                converters = new List <IYamlTypeConverter>();
                converters.Add(new GuidConverter(false));

                NodeDeserializers = new List <INodeDeserializer>();
                NodeDeserializers.Add(new YamlConvertibleNodeDeserializer(objectFactory));
                NodeDeserializers.Add(new YamlSerializableNodeDeserializer(objectFactory));
                NodeDeserializers.Add(new TypeConverterNodeDeserializer(converters));
                NodeDeserializers.Add(new NullNodeDeserializer());
                NodeDeserializers.Add(new ScalarNodeDeserializer());
                NodeDeserializers.Add(new ArrayNodeDeserializer());
                NodeDeserializers.Add(new DictionaryNodeDeserializer(objectFactory));
                NodeDeserializers.Add(new CollectionNodeDeserializer(objectFactory));
                NodeDeserializers.Add(new EnumerableNodeDeserializer());
                NodeDeserializers.Add(new ObjectNodeDeserializer(objectFactory, typeDescriptor, ignoreUnmatched));

                tagMappings   = new Dictionary <string, Type>(predefinedTagMappings);
                TypeResolvers = new List <INodeTypeResolver>();
                TypeResolvers.Add(new YamlConvertibleTypeResolver());
                TypeResolvers.Add(new YamlSerializableTypeResolver());
                TypeResolvers.Add(new TagNodeTypeResolver(tagMappings));
                TypeResolvers.Add(new TypeNameInTagNodeTypeResolver());
                TypeResolvers.Add(new DefaultContainersNodeTypeResolver());

                valueDeserializer =
                    new AliasValueDeserializer(
                        new NodeValueDeserializer(
                            NodeDeserializers,
                            TypeResolvers
                            )
                        );
            }
        internal BuilderSkeleton()
        {
            overrides = new YamlAttributeOverrides();

            typeConverterFactories = new LazyComponentRegistrationList <Nothing, IYamlTypeConverter>();
            typeConverterFactories.Add(typeof(GuidConverter), _ => new GuidConverter(false));

            typeInspectorFactories = new LazyComponentRegistrationList <ITypeInspector, ITypeInspector>();
        }
 public Deserializer(
     IObjectFactory objectFactory       = null,
     INamingConvention namingConvention = null,
     bool ignoreUnmatched             = false,
     YamlAttributeOverrides overrides = null)
 {
     backwardsCompatibleConfiguration = new BackwardsCompatibleConfiguration(objectFactory, namingConvention, ignoreUnmatched, overrides);
     valueDeserializer = backwardsCompatibleConfiguration.valueDeserializer;
 }
Esempio n. 4
0
            public BackwardsCompatibleConfiguration(SerializationOptions options, INamingConvention namingConvention, YamlAttributeOverrides overrides)
            {
                this.options          = options;
                this.namingConvention = namingConvention ?? new NullNamingConvention();
                this.overrides        = overrides;

                Converters = new List <IYamlTypeConverter>();
                Converters.Add(new GuidConverter(IsOptionSet(SerializationOptions.JsonCompatible)));

                typeResolver = IsOptionSet(SerializationOptions.DefaultToStaticType)
                    ? (ITypeResolver) new StaticTypeResolver()
                    : (ITypeResolver) new DynamicTypeResolver();
            }
Esempio n. 5
0
        /// <summary>
        /// Creates a copy of this instance.
        /// </summary>
        public YamlAttributeOverrides Clone()
        {
            var clone = new YamlAttributeOverrides();

            foreach (var entry in overrides)
            {
                foreach (var item in entry.Value)
                {
                    clone.Add(item.RegisteredType, entry.Key.PropertyName, item.Attribute);
                }
            }
            return(clone);
        }
Esempio n. 6
0
 public Serializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null, YamlAttributeOverrides overrides = null)
 {
     backwardsCompatibleConfiguration = new BackwardsCompatibleConfiguration(options, namingConvention, overrides);
 }
 public OverridePropertyDescriptor(IPropertyDescriptor baseDescriptor, YamlAttributeOverrides overrides, Type classType)
 {
     this.baseDescriptor = baseDescriptor;
     this.overrides      = overrides;
     this.classType      = classType;
 }
 public YamlAttributeOverridesInspector(ITypeInspector innerTypeDescriptor, YamlAttributeOverrides overrides)
 {
     this.innerTypeDescriptor = innerTypeDescriptor;
     this.overrides           = overrides;
 }