Inheritance: IXmlCompressor, IParameterizedType
Esempio n. 1
0
        public static void GetXlobSettings(IDictionary<string, string> parameters, out IXmlCompressor compression, out int length)
        {
            length = ParseLength(parameters);

            string compr = parameters == null ? null : parameters["compression"];
            if (string.IsNullOrEmpty(compr))
                compression = null;
            else if (compr.Equals("gzip", StringComparison.OrdinalIgnoreCase))
                compression = new XmlTextCompressor(GZipCompressor.Instance);
            else
            {
                System.Type compressor = System.Type.GetType(compr);
                if (typeof (IXmlCompressor).IsAssignableFrom(compressor))
                    compression = (IXmlCompressor) Activator.CreateInstance(compressor);
                else if (typeof (IStreamCompressor).IsAssignableFrom(compressor))
                    compression = new XmlTextCompressor((IStreamCompressor) Activator.CreateInstance(compressor));
                else
                    throw new Exception("Unknown compression type.");
            }
            var parameterized = compression as IParameterizedType;

            if (parameterized != null) parameterized.SetParameterValues(parameters);
        }
Esempio n. 2
0
 public override void SetParameterValues(IDictionary<string, string> parameters)
 {
     base.SetParameterValues(parameters);
     if (Compression == null) Compression = new XmlTextCompressor(new GZipCompressor());
 }