Files
Dec2017-Script-Dump/mscorlib/System/Runtime/Remoting/Contexts/ContextAttribute.cs
T
2026-06-04 11:42:34 +02:00

145 lines
6.6 KiB
C#

using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Activation;
namespace System.Runtime.Remoting.Contexts
{
/// <summary>Provides the default implementations of the <see cref="T:System.Runtime.Remoting.Contexts.IContextAttribute" /> and <see cref="T:System.Runtime.Remoting.Contexts.IContextProperty" /> interfaces.</summary>
// Token: 0x020003BC RID: 956
[ComVisible(true)]
[AttributeUsage(AttributeTargets.Class)]
[Serializable]
public class ContextAttribute : Attribute, IContextAttribute, IContextProperty
{
/// <summary>Creates an instance of the <see cref="T:System.Runtime.Remoting.Contexts.ContextAttribute" /> class with the specified name.</summary>
/// <param name="name">The name of the context attribute. </param>
// Token: 0x06002612 RID: 9746 RVA: 0x0007DC80 File Offset: 0x0007BE80
public ContextAttribute(string name)
{
this.AttributeName = name;
}
/// <summary>Gets the name of the context attribute.</summary>
/// <returns>The name of the context attribute.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x1700071E RID: 1822
// (get) Token: 0x06002613 RID: 9747 RVA: 0x0007DC90 File Offset: 0x0007BE90
public virtual string Name
{
get
{
return this.AttributeName;
}
}
/// <summary>Returns a Boolean value indicating whether this instance is equal to the specified object.</summary>
/// <returns>true if <paramref name="o" /> is not null and if the object names are equivalent; otherwise, false.</returns>
/// <param name="o">The object to compare with this instance. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x06002614 RID: 9748 RVA: 0x0007DC98 File Offset: 0x0007BE98
public override bool Equals(object o)
{
if (o == null)
{
return false;
}
if (!(o is ContextAttribute))
{
return false;
}
ContextAttribute contextAttribute = (ContextAttribute)o;
return !(contextAttribute.AttributeName != this.AttributeName);
}
/// <summary>Called when the context is frozen.</summary>
/// <param name="newContext">The context to freeze. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x06002615 RID: 9749 RVA: 0x0007DCDC File Offset: 0x0007BEDC
public virtual void Freeze(Context newContext)
{
}
/// <summary>Returns the hashcode for this instance of <see cref="T:System.Runtime.Remoting.Contexts.ContextAttribute" />.</summary>
/// <returns>The hashcode for this instance of <see cref="T:System.Runtime.Remoting.Contexts.ContextAttribute" />.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x06002616 RID: 9750 RVA: 0x0007DCE0 File Offset: 0x0007BEE0
public override int GetHashCode()
{
if (this.AttributeName == null)
{
return 0;
}
return this.AttributeName.GetHashCode();
}
/// <summary>Adds the current context property to the given message.</summary>
/// <param name="ctorMsg">The <see cref="T:System.Runtime.Remoting.Activation.IConstructionCallMessage" /> to which to add the context property. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="ctorMsg" /> parameter is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x06002617 RID: 9751 RVA: 0x0007DCFC File Offset: 0x0007BEFC
public virtual void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
{
if (ctorMsg == null)
{
throw new ArgumentNullException("ctorMsg");
}
IList contextProperties = ctorMsg.ContextProperties;
contextProperties.Add(this);
}
/// <summary>Returns a Boolean value indicating whether the context parameter meets the context attribute's requirements.</summary>
/// <returns>true if the passed in context is okay; otherwise, false.</returns>
/// <param name="ctx">The context in which to check. </param>
/// <param name="ctorMsg">The <see cref="T:System.Runtime.Remoting.Activation.IConstructionCallMessage" /> to which to add the context property.</param>
/// <exception cref="T:System.ArgumentNullException">Either <paramref name="ctx" /> or <paramref name="ctorMsg" /> is null. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x06002618 RID: 9752 RVA: 0x0007DD2C File Offset: 0x0007BF2C
public virtual bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg)
{
if (ctorMsg == null)
{
throw new ArgumentNullException("ctorMsg");
}
if (ctx == null)
{
throw new ArgumentNullException("ctx");
}
if (!ctorMsg.ActivationType.IsContextful)
{
return true;
}
IContextProperty property = ctx.GetProperty(this.AttributeName);
return property != null && this == property;
}
/// <summary>Returns a Boolean value indicating whether the context property is compatible with the new context.</summary>
/// <returns>true if the context property is okay with the new context; otherwise, false.</returns>
/// <param name="newCtx">The new context in which the property has been created. </param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x06002619 RID: 9753 RVA: 0x0007DD8C File Offset: 0x0007BF8C
public virtual bool IsNewContextOK(Context newCtx)
{
return true;
}
/// <summary>Indicates the name of the context attribute.</summary>
// Token: 0x04000EDC RID: 3804
protected string AttributeName;
}
}