Exemplo n.º 1
0
        public static RWKinds GetKind(this IReaderWriter rw)
        {
            var type = rw.GetType();

            if (type == typeof(BinaryReaderX))
            {
                return(RWKinds.Binary);
            }
            if (type == typeof(BinaryWriterX))
            {
                return(RWKinds.Binary);
            }
            if (type == typeof(XmlReaderX))
            {
                return(RWKinds.Xml);
            }
            if (type == typeof(XmlWriterX))
            {
                return(RWKinds.Xml);
            }
            if (type == typeof(JsonReader))
            {
                return(RWKinds.Json);
            }
            if (type == typeof(JsonWriter))
            {
                return(RWKinds.Json);
            }

            throw new XException("未识别的读写器类型{0}!", type);
        }