Skip to content

Instantly share code, notes, and snippets.

@adilakhter
Last active Dec 14, 2015
Embed
What would you like to do?
/// <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