Ejemplo n.º 1
0
        /// <summary>
        /// 获取格式化器
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        //public async static Task<FormatterBase> GetFormatterAsync(String data)
        public static FormatterBase GetFormatter(string data)
        {
            // var protocal = await GetDataProtocalTypeAsync(data);
            //var protocal = GetDataProtocalType(data);
            const DataProtocalType protocal = DataProtocalType.Json;

            //switch (protocal)
            //{
            //    case DataProtocalType.Json:
            //        formatter = new JsonFormatter();
            //        break;
            //    case DataProtocalType.Xml:
            //        formatter = new XmlFormatter();
            //        break;
            //    default:
            //        formatter = new NotSupportFormatter();
            //        break;
            //}
            var formatter = Container.Resolve <FormatterBase>(protocal.ToString());

            return(formatter);
        }
Ejemplo n.º 2
0
 public SocketTransport(DataProtocalType protocalType = DataProtocalType.Json)
 {
     ProtocalType = protocalType;
 }
Ejemplo n.º 3
0
 public HttpTransport(DataProtocalType protocalType = DataProtocalType.Json)
 {
     ProtocalType = protocalType;
 }
Ejemplo n.º 4
0
 public FormatterBase(DataProtocalType protocalType)
 {
     this.ProtocalType = protocalType;
 }