Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameSystem" /> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public YamlManager(Game game) : base(game)
 {
     Services.AddService(this);
     yamlSettings = new SerializerSettings();
     attributeRegistry = yamlSettings.Attributes;
     serializer = new Serializer(yamlSettings);
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Serializer"/> class.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public Serializer(SerializerSettings settings)
        {
            this.settings         = settings ?? new SerializerSettings();
            TypeDescriptorFactory = CreateTypeDescriptorFactory();
            RoutingSerializer routingSerializer;

            ObjectSerializer  = CreateProcessor(out routingSerializer);
            RoutingSerializer = routingSerializer;
        }
		public void NotSpecifyingObjectFactoryUsesDefault()
		{
			var settings = new SerializerSettings();
			settings.RegisterTagMapping("!foo", typeof(FooBase));
			var serializer = new Serializer(settings);
			var result = serializer.Deserialize(new StringReader("!foo {}"));

			Assert.IsInstanceOf<FooBase>(result);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="SerializerContext"/> class.
 /// </summary>
 /// <param name="serializer">The serializer.</param>
 internal SerializerContext(Serializer serializer)
 {
     Serializer = serializer;
     settings = serializer.Settings;
     tagTypeRegistry = settings.tagTypeRegistry;
     ObjectFactory = settings.ObjectFactory;
     ObjectSerializerBackend = settings.ObjectSerializerBackend;
     Schema = Settings.Schema;
     typeDescriptorFactory = new TypeDescriptorFactory(Settings.Attributes, Settings.EmitDefaultValues);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SerializerContext"/> class.
 /// </summary>
 /// <param name="serializer">The serializer.</param>
 internal SerializerContext(Serializer serializer)
 {
     Serializer = serializer;
     settings = serializer.Settings;
     tagTypeRegistry = settings.AssemblyRegistry;
     ObjectFactory = settings.ObjectFactory;
     ObjectSerializerBackend = settings.ObjectSerializerBackend;
     Schema = Settings.Schema;
     ObjectSerializer = serializer.ObjectSerializer;
     typeDescriptorFactory = serializer.TypeDescriptorFactory;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SerializerContext"/> class.
 /// </summary>
 /// <param name="serializer">The serializer.</param>
 internal SerializerContext(Serializer serializer)
 {
     Serializer              = serializer;
     settings                = serializer.Settings;
     tagTypeRegistry         = settings.AssemblyRegistry;
     ObjectFactory           = settings.ObjectFactory;
     ObjectSerializerBackend = settings.ObjectSerializerBackend;
     Schema                = Settings.Schema;
     ObjectSerializer      = serializer.ObjectSerializer;
     typeDescriptorFactory = serializer.TypeDescriptorFactory;
 }
		public void ObjectFactoryIsInvoked()
		{
			var settings = new SerializerSettings()
				{
					ObjectFactory = new LambdaObjectFactory(t => new FooDerived(), new DefaultObjectFactory())
				};
			settings.RegisterTagMapping("!foo", typeof(FooBase));

			var serializer = new Serializer(settings);

			var result = serializer.Deserialize(new StringReader("!foo {}"));

            Assert.IsInstanceOf<FooDerived>(result);
		}
 public AssetObjectSerializerBackend(SerializerSettings settings, IContentManager contentManager)
 {
     settings.RegisterTagMapping("!asset", typeof(AssetName));
     settings.RegisterSerializerFactory(new AssetNameFactory());
     this.contentManager = contentManager;
 }