mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
114 lines
3.7 KiB
C#
114 lines
3.7 KiB
C#
//------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//------------------------------------------------------------
|
|
namespace System.ServiceModel.Channels
|
|
{
|
|
using System.ServiceModel.Configuration;
|
|
using System.ServiceModel.Description;
|
|
using System.Xml;
|
|
|
|
|
|
public sealed class PrivacyNoticeBindingElement : BindingElement, IPolicyExportExtension
|
|
{
|
|
Uri url;
|
|
int version;
|
|
|
|
public PrivacyNoticeBindingElement()
|
|
{
|
|
this.url = null;
|
|
}
|
|
|
|
public PrivacyNoticeBindingElement(PrivacyNoticeBindingElement elementToBeCloned)
|
|
: base(elementToBeCloned)
|
|
{
|
|
this.url = elementToBeCloned.url;
|
|
this.version = elementToBeCloned.version;
|
|
}
|
|
|
|
public Uri Url
|
|
{
|
|
get
|
|
{
|
|
return this.url;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
|
}
|
|
|
|
this.url = value;
|
|
}
|
|
}
|
|
|
|
public int Version
|
|
{
|
|
get
|
|
{
|
|
return this.version;
|
|
}
|
|
set
|
|
{
|
|
if (value < 0)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
|
|
SR.GetString(SR.ValueMustBePositive)));
|
|
}
|
|
this.version = value;
|
|
}
|
|
}
|
|
|
|
public override BindingElement Clone()
|
|
{
|
|
return new PrivacyNoticeBindingElement(this);
|
|
}
|
|
|
|
public override T GetProperty<T>(BindingContext context)
|
|
{
|
|
if (context == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
|
|
}
|
|
return context.GetInnerProperty<T>();
|
|
}
|
|
|
|
void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
|
|
{
|
|
if (context == null)
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
|
|
|
|
if (context.BindingElements != null)
|
|
{
|
|
PrivacyNoticeBindingElement settings =
|
|
context.BindingElements.Find<PrivacyNoticeBindingElement>();
|
|
|
|
if (settings != null)
|
|
{
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
// PrivacyNotice assertion
|
|
XmlElement assertion = doc.CreateElement(PrivacyNoticePolicyStrings.PrivacyNoticePrefix,
|
|
PrivacyNoticePolicyStrings.PrivacyNoticeName,
|
|
PrivacyNoticePolicyStrings.PrivacyNoticeNamespace);
|
|
|
|
assertion.InnerText = settings.Url.ToString();
|
|
assertion.SetAttribute(PrivacyNoticePolicyStrings.PrivacyNoticeVersionAttributeName, PrivacyNoticePolicyStrings.PrivacyNoticeNamespace, XmlConvert.ToString(settings.Version));
|
|
|
|
context.GetBindingAssertions().Add(assertion);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal override bool IsMatch(BindingElement b)
|
|
{
|
|
if (b == null)
|
|
return false;
|
|
PrivacyNoticeBindingElement privacy = b as PrivacyNoticeBindingElement;
|
|
if (privacy == null)
|
|
return false;
|
|
return (this.url == privacy.url && this.version == privacy.version);
|
|
}
|
|
}
|
|
}
|