示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializerSettings" /> class.
        /// </summary>
        public SerializerSettings(IYamlSchema schema)
        {
            PreferredIndent            = 2;
            IndentLess                 = false;
            EmitAlias                  = true;
            EmitTags                   = true;
            AllowErrors                = false;
            ResetAlias                 = true;
            SortKeyForMapping          = true;
            EmitJsonComptible          = false;
            EmitCapacityForList        = false;
            SpecialCollectionMember    = "~Items";
            LimitPrimitiveFlowSequence = 0;
            DefaultStyle               = YamlStyle.Block;
            this.schema                = schema ?? new CoreSchema();
            AssemblyRegistry           = new AssemblyRegistry(Schema);
            attributeRegistry          = new AttributeRegistry();
            ObjectFactory              = new DefaultObjectFactory();
            ObjectSerializerBackend    = new DefaultObjectSerializerBackend();
            ComparerForKeySorting      = new DefaultKeyComparer();
            NamingConvention           = new DefaultNamingConvention();

            // Register default mapping for map and seq
            AssemblyRegistry.RegisterTagMapping("!!map", typeof(IDictionary <object, object>), false);
            AssemblyRegistry.RegisterTagMapping("!!seq", typeof(IList <object>), false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializerSettings" /> class.
        /// </summary>
        public SerializerSettings(IYamlSchema schema)
        {
            PreferredIndent = 2;
            IndentLess = false;
            EmitAlias = true;
            EmitTags = true;
            SortKeyForMapping = true;
            EmitJsonComptible = false;
            EmitCapacityForList = false;
            SpecialCollectionMember = "~Items";
            LimitPrimitiveFlowSequence = 0;
            DefaultStyle = YamlStyle.Block;
            this.schema = schema ?? new CoreSchema();
            AssemblyRegistry = new AssemblyRegistry(Schema);
            attributeRegistry = new AttributeRegistry();
            ObjectFactory = new DefaultObjectFactory();
            ObjectSerializerBackend = new DefaultObjectSerializerBackend();
            ComparerForKeySorting = new DefaultKeyComparer();
            NamingConvention = new DefaultNamingConvention();

            // Register default mapping for map and seq
            AssemblyRegistry.RegisterTagMapping("!!map", typeof(IDictionary<object, object>));
            AssemblyRegistry.RegisterTagMapping("!!seq", typeof(IList<object>));
        }
示例#3
0
 /// <summary>
 /// Register a mapping between a tag and a type.
 /// </summary>
 /// <param name="tagName">Name of the tag.</param>
 /// <param name="tagType">Type of the tag.</param>
 /// <param name="isAlias">if set to <c>true</c> the new tag name is an alias to a type that has already a tag name associated to it.</param>
 public void RegisterTagMapping(string tagName, Type tagType, bool isAlias = false)
 {
     AssemblyRegistry.RegisterTagMapping(tagName, tagType, isAlias);
 }
示例#4
0
 /// <summary>
 /// Register a mapping between a tag and a type.
 /// </summary>
 /// <param name="tagName">Name of the tag.</param>
 /// <param name="tagType">Type of the tag.</param>
 public void RegisterTagMapping(string tagName, Type tagType)
 {
     AssemblyRegistry.RegisterTagMapping(tagName, tagType);
 }