Пример #1
0
		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);
		}
Пример #2
0
		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;
 }