public Deserializer( IObjectFactory objectFactory = null, INamingConvention namingConvention = null, bool ignoreUnmatched = false, YamlAttributeOverrides overrides = null) { objectFactory = objectFactory ?? new DefaultObjectFactory(); namingConvention = namingConvention ?? new NullNamingConvention(); typeDescriptor.TypeDescriptor = new CachedTypeInspector( new YamlAttributesTypeInspector( new YamlAttributeOverridesInspector( new NamingConventionTypeInspector( new ReadableAndWritablePropertiesTypeInspector( new ReadablePropertiesTypeInspector( new StaticTypeResolver() ) ), namingConvention ), overrides ) ) ); converters = new List <IYamlTypeConverter>(); foreach (IYamlTypeConverter yamlTypeConverter in YamlTypeConverters.GetBuiltInConverters(false)) { converters.Add(yamlTypeConverter); } 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), (Nothing _) => new GuidConverter(false)); typeConverterFactories.Add(typeof(SystemTypeConverter), (Nothing _) => new SystemTypeConverter()); 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; }
internal BuilderSkeleton(ITypeResolver typeResolver) { overrides = new YamlAttributeOverrides(); typeConverterFactories = new LazyComponentRegistrationList <Nothing, IYamlTypeConverter> { { typeof(GuidConverter), _ => new GuidConverter(false) }, { typeof(SystemTypeConverter), _ => new SystemTypeConverter() } }; typeInspectorFactories = new LazyComponentRegistrationList <ITypeInspector, ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); }
/// <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); }
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(); }
public YamlAttributeOverrides Clone() { YamlAttributeOverrides yamlAttributeOverrides = new YamlAttributeOverrides(); foreach (KeyValuePair <AttributeKey, List <AttributeMapping> > @override in overrides) { foreach (AttributeMapping item in @override.Value) { YamlAttributeOverrides yamlAttributeOverrides2 = yamlAttributeOverrides; Type registeredType = item.RegisteredType; AttributeKey key = @override.Key; yamlAttributeOverrides2.Add(registeredType, key.PropertyName, item.Attribute); } } return(yamlAttributeOverrides); }
/// <summary> /// /// </summary> /// <param name="options">Options that control how the serialization is to be performed.</param> /// <param name="namingConvention">Naming strategy to use for serialized property names</param> /// <param name="overrides">Yaml attribute overrides</param> public Serializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null, YamlAttributeOverrides overrides = null) { this.options = options; this.namingConvention = namingConvention ?? new NullNamingConvention(); this.overrides = overrides; Converters = new List <IYamlTypeConverter>(); foreach (IYamlTypeConverter yamlTypeConverter in Utilities.YamlTypeConverters.GetBuiltInConverters(IsOptionSet(SerializationOptions.JsonCompatible))) { Converters.Add(yamlTypeConverter); } typeResolver = IsOptionSet(SerializationOptions.DefaultToStaticType) ? (ITypeResolver) new StaticTypeResolver() : (ITypeResolver) new DynamicTypeResolver(); }
public Serializer(SerializationOptions options = 0, INamingConvention namingConvention = null, YamlAttributeOverrides overrides = null) { this.options = options; INamingConvention convention1 = namingConvention; if (namingConvention == null) { INamingConvention local1 = namingConvention; convention1 = new NullNamingConvention(); } this.namingConvention = convention1; this.overrides = overrides; this.Converters = new List <IYamlTypeConverter>(); foreach (IYamlTypeConverter converter in YamlTypeConverters.GetBuiltInConverters(this.IsOptionSet(SerializationOptions.JsonCompatible))) { this.Converters.Add(converter); } this.typeResolver = !this.IsOptionSet(SerializationOptions.DefaultToStaticType) ? ((ITypeResolver) new DynamicTypeResolver()) : ((ITypeResolver) new StaticTypeResolver()); }
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; }