//Serialize------------------------------------------------ public XElement Serialize(object value) { SwitchToInvariantCulture(); try { if (value != null) { if (SerializerMapper.CanMap <ISerializer>(value.GetType())) { return(SerializerMapper.Map <ISerializer>(value.GetType()).Serialize(value, this)); } //if (SerializerMapper.CanMap(value.GetType(), typeof(ISerializer<>))) //{ // ret = ((ISerializer<object>)SerializerMapper.Map(value.GetType(), typeof(ISerializer<>))).Serialize(value, this); //} //Type st = typeof(ISerializer<>).MakeGenericType(value.GetType()); //if (SerializerMapper.CanMap(value.GetType(), st)) //{ // ret = ((ISerializer<object>)SerializerMapper.Map(value.GetType(), st)).Serialize(value, this); //} } return(ToXml(value)); } finally { SwitchCultureBack(); } }
//default public object Deserialize(XElement data, Type type) { SwitchToInvariantCulture(); try { if (SerializerMapper.CanMap <ISerializer>(type)) { return(SerializerMapper.Map <ISerializer>(type).Deserialize(data, type, this)); } else { //if (SerializerMapper.CanMap(type, typeof(ISerializer<>))) //{ // ret = ((ISerializer<object>)SerializerMapper.Map(type, typeof(ISerializer<>))).Deserialize(data, type, this); //} //else //{ //Type st = typeof(ISerializer<>).MakeGenericType(type); //if (SerializerMapper.CanMap(type, st)) //{ // ret = ((ISerializer<object>)SerializerMapper.Map(type, st)).Deserialize(data, type, this); //} //else return(FromXml(data, type)); //} } } finally { SwitchCultureBack(); } }