Пример #1
0
        protected static string Serialize(object val, SerializerType serializerType)
        {
            if (val == null)
            {
                return(null);
            }

            var serialized = val as string;

            if (serialized != null)
            {
                return(serialized);
            }

            switch (serializerType)
            {
            case SerializerType.DataContractSerializer:
                return(SerializationFactory.DataContractSerialize(val));

            case SerializerType.DataContractJsonSerializer:
                return(SerializationFactory.DataContractJsonSerialize(val));

            case SerializerType.JsonNetSerializer:
                return(SerializationFactory.JsonNetSerialize(val));

            case SerializerType.XmlSerializer:
            default:
                return(SerializationFactory.XmlSerialize(val));
            }

            #endregion
        }