コード例 #1
0
        public SerializerBuilder()
        {
            typeInspectorFactories.Add(typeof(CachedTypeInspector), inner => new CachedTypeInspector(inner));
            typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), inner => namingConvention != null ? new NamingConventionTypeInspector(inner, namingConvention) : inner);
            typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), inner => new YamlAttributesTypeInspector(inner));
            typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), inner => overrides != null ? new YamlAttributeOverridesInspector(inner, overrides.Clone()) : inner);

            preProcessingPhaseObjectGraphVisitorFactories = new LazyComponentRegistrationList <IEnumerable <IYamlTypeConverter>, IObjectGraphVisitor <Nothing> >();
            preProcessingPhaseObjectGraphVisitorFactories.Add(typeof(AnchorAssigner), typeConverters => new AnchorAssigner(typeConverters));

            emissionPhaseObjectGraphVisitorFactories = new LazyComponentRegistrationList <EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor <IEmitter> >();
            emissionPhaseObjectGraphVisitorFactories.Add(typeof(CustomSerializationObjectGraphVisitor),
                                                         args => new CustomSerializationObjectGraphVisitor(args.InnerVisitor, args.TypeConverters, args.NestedObjectSerializer));

            emissionPhaseObjectGraphVisitorFactories.Add(typeof(AnchorAssigningObjectGraphVisitor),
                                                         args => new AnchorAssigningObjectGraphVisitor(args.InnerVisitor, args.EventEmitter, args.GetPreProcessingPhaseObjectGraphVisitor <AnchorAssigner>()));

            emissionPhaseObjectGraphVisitorFactories.Add(typeof(DefaultExclusiveObjectGraphVisitor),
                                                         args => new DefaultExclusiveObjectGraphVisitor(args.InnerVisitor));

            eventEmitterFactories = new LazyComponentRegistrationList <IEventEmitter, IEventEmitter>();
            eventEmitterFactories.Add(typeof(TypeAssigningEventEmitter), inner => new TypeAssigningEventEmitter(inner, false));

            objectGraphTraversalStrategyFactory = (typeInspector, typeResolver, typeConverters) => new FullObjectGraphTraversalStrategy(typeInspector, typeResolver, 50, namingConvention ?? new NullNamingConvention());

            WithTypeResolver(new DynamicTypeResolver());
            WithEventEmitter(inner => new CustomTagEventEmitter(inner, tagMappings));
        }
コード例 #2
0
        internal BuilderSkeleton()
        {
            overrides = new YamlAttributeOverrides();

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

            typeInspectorFactories = new LazyComponentRegistrationList <ITypeInspector, ITypeInspector>();
        }