Skip to content

Instantly share code, notes, and snippets.

@adilakhter
Last active December 14, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adilakhter/5057168 to your computer and use it in GitHub Desktop.
Save adilakhter/5057168 to your computer and use it in GitHub Desktop.
/// <summary>
/// Represents Element to set the ProtectionLevel to different Endpoint using configuration
/// </summary>
public class MessageSecurityBehaviorElement : BehaviorExtensionElement
{
private const string PROTECTION_LEVEL_ELEMENT_NAME = "messageProtection";
public override Type BehaviorType
{
get
{
return typeof(MessageSecurityBehavior);
}
}
protected override object CreateBehavior()
{
return new MessageSecurityBehavior { ProtectionLevel = this.ProtectionLevel };
}
[ConfigurationProperty(PROTECTION_LEVEL_ELEMENT_NAME)]
public ProtectionLevel ProtectionLevel
{
get
{
return (ProtectionLevel)base[PROTECTION_LEVEL_ELEMENT_NAME];
}
set
{
base[PROTECTION_LEVEL_ELEMENT_NAME] = value;
}
}
private ConfigurationPropertyCollection properties = null;
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection propertys = new ConfigurationPropertyCollection();
propertys.Add(new ConfigurationProperty(PROTECTION_LEVEL_ELEMENT_NAME, typeof(ProtectionLevel), null, ConfigurationPropertyOptions.IsRequired));
properties = propertys;
}
return properties;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment