Example #1
0
 public string Serialize() {
     return (Serializer ?? (Serializer = new XmlSerializer())).Serialize(this);
 }
Example #2
0
        void SetDefaultSerializer(string cfg, Source source, ISourceDetector sourceDetector) {

            if (Serializer != null)
                return;

            switch (source) {
                case Source.Json:
                    Serializer = new JsonSerializer();
                    break;
                case Source.Xml:
                    Serializer = new XmlSerializer();
                    break;
                case Source.File:
                case Source.Url:
                    if (sourceDetector.Detect(cfg, new NullLogger()) == Source.Json) {
                        Serializer = new JsonSerializer();
                    } else {
                        Serializer = new XmlSerializer();
                    }
                    break;
                default:
                    Serializer = new XmlSerializer();
                    break;
            }
        }