xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="RemotingCompress" type="Xrinehart.Framework.CommSupport.Section.RemotingCompressSection, ConfigManagement"
allowDefinition="Everywhere" allowExeDefinition="MachineToApplication" restartOnExternalChanges="true"/>
configSections>
<RemotingCompress CompressLevel="DEFAULT_COMPRESSION" CompressCacheSize="1024" UnCompressCacheSize="1024" MinCompressSize="0">
configuration>
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
namespace Xrinehart.Framework.CommSupport.Section

{
/**////
/// 压缩率级别的枚举
///
public enum Deflater 
{
/**////
/// 最佳压缩效果, 速度慢
///
BEST_COMPRESSION = 9, 
/**////
/// 默认压缩率, 压缩速度比最高(推荐)
///
DEFAULT_COMPRESSION = -1,
/**////
/// 强化压缩率,速度较慢
///
DEFLATED = 8,
/**////
/// 最佳速度压缩率,速度最快(宽带推荐)
///
BEST_SPEED = 1, 
/**////
/// 不压缩
///
NO_COMPRESSION =0
};

/**////
/// RemotingCompress配置节类
///
public sealed class RemotingCompressSection : System.Configuration.ConfigurationSection
{
// 该配置文件只读
private static bool _ReadOnly = true;
public RemotingCompressSection()
{
}
private new bool IsReadOnly
{
get
{
return _ReadOnly;
}
}
private void ThrowIfReadOnly(string propertyName)
{
if (IsReadOnly)
throw new ConfigurationErrorsException(
"The property " + propertyName + " is read only.");
}
protected override object GetRuntimeObject()
{
// To enable property setting just assign true to
// the following flag.
_ReadOnly = true;
return base.GetRuntimeObject();
}

所有配置属性#region 所有配置属性

/**////
/// 配置节属性:压缩率级别(可选)
///
[ConfigurationProperty("CompressLevel", DefaultValue = "DEFAULT_COMPRESSION", Options = ConfigurationPropertyOptions.None)]
public Deflater CompressLevel
{
get
{
return (Deflater)this["CompressLevel"];
}
set
{
ThrowIfReadOnly("CompressLevel");
this["compressLevel"] = value;
}
}

/**////
/// 配置节属性:压缩时缓冲区大小(可选)
///
[ConfigurationProperty("CompressCacheSize", DefaultValue = (Int32)40960, Options = ConfigurationPropertyOptions.None)]
[IntegerValidator(MinValue = 1024, MaxValue = 1024 * 1024, ExcludeRange = false)]
public int CompressCacheSize
{
get
{
return (Int32)this["CompressCacheSize"];
}
set
{
ThrowIfReadOnly("CompressCacheSize");
this["CompressCacheSize"] = value;
}
}

/**////
/// 配置节属性:解压时缓冲区大小(可选)
///
[ConfigurationProperty("UnCompressCacheSize", DefaultValue = (Int32)40960, Options = ConfigurationPropertyOptions.None)]
[IntegerValidator(MinValue = 1024, MaxValue = 1024 * 1024, ExcludeRange = false)]
public int UnCompressCacheSize
{
get
{
return (Int32)this["UnCompressCacheSize"];
}
set
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-343353/ ,如需转载,请注明出处,否则将追究法律责任。