示例#1
0
        static object Decode(WADLParam param, string value)
        {
            TemplateConfigurationHandler handler = TemplateConfigurationHandler.GetConfiguration();
            var             encoderCnfg          = handler.Encoders[param.Encoding ?? Encodings.plainText];
            Type            encoder   = Type.GetType(encoderCnfg.Type);
            INetHttpEncoder formatter = Activator.CreateInstance(encoder) as INetHttpEncoder;

            return(formatter.Decode(param, value));
        }
示例#2
0
        //static IFormatter GetEncoder(WADLParam param)
        //{
        //    Type type = Type.GetType(TemplateConfigurationHandler.GetConfiguration().Encoders[param.Encoding].Type);
        //    return (IFormatter)Activator.CreateInstance(type);
        //}

        static void Encode(Stream stream, WADLRepresentation param, object value)
        {
            TemplateConfigurationHandler handler = TemplateConfigurationHandler.GetConfiguration();
            var encoderCnfg = handler.Encoders[param.ContentType];

            if (!String.IsNullOrEmpty(encoderCnfg.Type))
            {
                Type            encoder   = Type.GetType(encoderCnfg.Type);
                INetHttpEncoder formatter = Activator.CreateInstance(encoder) as INetHttpEncoder;
                formatter.Encode(stream, param, value);
            }
        }