public void Ctor_Type(Type valueSerializerType) { var attribute = new ValueSerializerAttribute(valueSerializerType); Assert.Equal(valueSerializerType?.AssemblyQualifiedName, attribute.ValueSerializerTypeName); Assert.Equal(valueSerializerType, attribute.ValueSerializerType); }
public void Ctor_String(string valueSerializerTypeName, Type expectedValueSerializerType) { var attribute = new ValueSerializerAttribute(valueSerializerTypeName); Assert.Equal(valueSerializerTypeName, attribute.ValueSerializerTypeName); Assert.Equal(expectedValueSerializerType, attribute.ValueSerializerType); }
public void ConstructedWithTypeName() { var vsa = new ValueSerializerAttribute(TestTypeTypeName); Assert.AreEqual(typeof(TestType).AssemblyQualifiedName, vsa.ValueSerializerTypeName, "#1"); Assert.AreEqual(typeof(TestType), vsa.ValueSerializerType, "#1"); }
static ValueSerializer GetValueSerializerByCache(Type t) { ValueSerializer vs; if (XAMLValueSerializerContainer.VSCache.TryGetValue(t, out vs)) { return(vs); } var c = t.GetCustomAttributes(typeof(ValueSerializerAttribute), true); ValueSerializerAttribute att = c[0] as ValueSerializerAttribute; vs = System.Activator.CreateInstance(att.ValueSerializerType) as ValueSerializer; XAMLValueSerializerContainer.VSCache.Add(t, vs); return(vs); }