public virtual void SetProperty(IContextProperty prop) { if (prop == null || prop.Name == null) { throw new ArgumentNullException(prop == null ? "prop" : "property name"); } if ((this._ctxFlags & 2) != 0) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AddContextFrozen")); } lock (this) { Context.CheckPropertyNameClash(prop.Name, this._ctxProps, this._numCtxProps); if (this._ctxProps == null || this._numCtxProps == this._ctxProps.Length) { this._ctxProps = Context.GrowPropertiesArray(this._ctxProps); } IContextProperty[] temp_28 = this._ctxProps; int local_2 = this._numCtxProps; this._numCtxProps = local_2 + 1; int temp_35 = local_2; IContextProperty temp_36 = prop; temp_28[temp_35] = temp_36; } }
// <summary> // True whether the context arguments satisfies the requirements // of the current context. // </summary> 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 p = ctx.GetProperty(AttributeName); if (p == null) { return(false); } if (this != p) { return(false); } return(true); }
internal static IContextProperty[] GrowPropertiesArray(IContextProperty[] props) { IContextProperty[] contextPropertyArray = new IContextProperty[(props != null ? props.Length : 0) + 8]; if (props != null) { Array.Copy((Array)props, (Array)contextPropertyArray, props.Length); } return(contextPropertyArray); }
public override bool Equals(object o) { IContextProperty contextProperty = o as IContextProperty; if (contextProperty != null) { return(this.AttributeName.Equals(contextProperty.Name)); } return(false); }
/// <summary>Freezes the context, making it impossible to add or remove context properties from the current context.</summary> /// <exception cref="T:System.InvalidOperationException">The context is already frozen. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public virtual void Freeze() { if (this.context_properties != null) { foreach (object obj in this.context_properties) { IContextProperty contextProperty = (IContextProperty)obj; contextProperty.Freeze(this); } } }
// Token: 0x06005778 RID: 22392 RVA: 0x00133B00 File Offset: 0x00131D00 internal static IContextProperty[] GrowPropertiesArray(IContextProperty[] props) { int num = ((props != null) ? props.Length : 0) + 8; IContextProperty[] array = new IContextProperty[num]; if (props != null) { Array.Copy(props, array, props.Length); } return(array); }
public IIndexer <int, string> GetValue(object targetObject, IContextProperty <IIndexer <int, string> > targetProperty) { if (targetProperty != KeyTable.KeyProperty) { throw new ArgumentException("Property does not match.", nameof(targetProperty)); } if (_key.HasValue) { return(new HarmonyDispatcher((KeyTable)targetObject, !_key.Value.Signs.RecommendSharp())); } return((KeyTable)targetObject); }
internal static IContextProperty[] GrowPropertiesArray(IContextProperty[] props) { // grow the array of IContextProperty objects int newSize = (props != null ? props.Length : 0) + GROW_BY; IContextProperty[] newProps = new IContextProperty[newSize]; if (props != null) { // Copy existing properties over. Array.Copy(props, newProps, props.Length); } return(newProps); }
//判断一个context是否已经有LogProperty,如果有就用这个context,如果没有则新建一个 public bool IsNewContextOK(Context newCtx) { IContextProperty property = newCtx.GetProperty(this.Name) as LogProperty; if (property == null) { return(false); } else { return(true); } }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context context = null; if (isContextful) { context = new Context(); ArrayList arrayList = (ArrayList)reqMsg.ContextProperties; for (int i = 0; i < arrayList.Count; i++) { IContextProperty contextProperty = arrayList[i] as IContextProperty; if (contextProperty == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } RuntimeAssembly asm = (RuntimeAssembly)contextProperty.GetType().Assembly; ActivationServices.CheckForInfrastructurePermission(asm); if (context.GetProperty(contextProperty.Name) == null) { context.SetProperty(contextProperty); } } context.Freeze(); for (int j = 0; j < arrayList.Count; j++) { if (!((IContextProperty)arrayList[j]).IsNewContextOK(context)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate internalCrossContextDelegate = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[] { reqMsg }; IConstructionReturnMessage result; if (isContextful) { result = (Thread.CurrentThread.InternalCrossContextCallback(context, internalCrossContextDelegate, args) as IConstructionReturnMessage); } else { result = (internalCrossContextDelegate(args) as IConstructionReturnMessage); } return(result); }
// Set a property on this context. public virtual void SetProperty(IContextProperty prop) { if (prop == null) { throw new ArgumentNullException("prop"); } if (prop.Name == null) { throw new ArgumentNullException("prop.Name"); } lock (this) { // The context must not be currently frozen. if (freeze) { throw new InvalidOperationException (_("Invalid_ContextFrozen")); } // Bail out if there is already a property with this name. if (properties != null) { foreach (IContextProperty prop2 in properties) { if (prop.Name == prop2.Name) { throw new InvalidOperationException (_("Invalid_PropertyClash")); } } } // Expand the property array and add the new element. if (properties == null) { properties = new IContextProperty [1]; properties[0] = prop; } else { IContextProperty[] newProperties; newProperties = new IContextProperty [properties.Length + 1]; Array.Copy(properties, 0, newProperties, 0, properties.Length); properties[properties.Length] = prop; newProperties = properties; } } }
/// <summary>Returns a specific context property, specified by name.</summary> /// <returns>The specified context property.</returns> /// <param name="name">The name of the property. </param> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public virtual IContextProperty GetProperty(string name) { if (this.context_properties == null) { return(null); } foreach (object obj in this.context_properties) { IContextProperty contextProperty = (IContextProperty)obj; if (contextProperty.Name == name) { return(contextProperty); } } return(null); }
public virtual IContextProperty GetProperty(String name) { if (_ctxProps == null || name == null) { return(null); } IContextProperty prop = null; for (int i = 0; i < _numCtxProps; i++) { if (_ctxProps[i].Name.Equals(name)) { prop = _ctxProps[i]; break; } } return(prop); }
public virtual IContextProperty GetProperty(string name) { if (this._ctxProps == null || name == null) { return(null); } IContextProperty result = null; for (int i = 0; i < this._numCtxProps; i++) { if (this._ctxProps[i].Name.Equals(name)) { result = this._ctxProps[i]; break; } } return(result); }
/// <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> 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); }
public virtual IContextProperty GetProperty(string name) { if (this._ctxProps == null || name == null) { return((IContextProperty)null); } IContextProperty contextProperty = (IContextProperty)null; for (int index = 0; index < this._numCtxProps; ++index) { if (this._ctxProps[index].Name.Equals(name)) { contextProperty = this._ctxProps[index]; break; } } return(contextProperty); }
internal IMessageSink CreateEnvoySink(MarshalByRefObject serverObject) { IMessageSink messageSink = EnvoyTerminatorSink.Instance; if (this.context_properties != null) { foreach (object obj in this.context_properties) { IContextProperty contextProperty = (IContextProperty)obj; IContributeEnvoySink contributeEnvoySink = contextProperty as IContributeEnvoySink; if (contributeEnvoySink != null) { messageSink = contributeEnvoySink.GetEnvoySink(serverObject, messageSink); } } } return(messageSink); }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context newCtx = null; if (isContextful) { newCtx = new Context(); ArrayList contextProperties = (ArrayList)reqMsg.ContextProperties; RuntimeAssembly asm = null; for (int i = 0; i < contextProperties.Count; i++) { IContextProperty prop = contextProperties[i] as IContextProperty; if (prop == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } asm = (RuntimeAssembly)prop.GetType().Assembly; CheckForInfrastructurePermission(asm); if (newCtx.GetProperty(prop.Name) == null) { newCtx.SetProperty(prop); } } newCtx.Freeze(); for (int j = 0; j < contextProperties.Count; j++) { if (!((IContextProperty)contextProperties[j]).IsNewContextOK(newCtx)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[] { reqMsg }; if (isContextful) { return(Thread.CurrentThread.InternalCrossContextCallback(newCtx, ftnToCall, args) as IConstructionReturnMessage); } return(ftnToCall(args) as IConstructionReturnMessage); }
/// <summary>Sets a specific context property by name.</summary> /// <param name="prop">The actual context property. </param> /// <exception cref="T:System.InvalidOperationException">There is an attempt to add properties to the default context. </exception> /// <exception cref="T:System.InvalidOperationException">The context is frozen. </exception> /// <exception cref="T:System.ArgumentNullException">The property or the property name 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> public virtual void SetProperty(IContextProperty prop) { if (prop == null) { throw new ArgumentNullException("IContextProperty"); } if (this == Context.DefaultContext) { throw new InvalidOperationException("Can not add properties to default context"); } if (this.frozen) { throw new InvalidOperationException("Context is Frozen"); } if (this.context_properties == null) { this.context_properties = new ArrayList(); } this.context_properties.Add(prop); }
public virtual void SetProperty(IContextProperty prop) { if ((prop == null) || (prop.Name == null)) { throw new ArgumentNullException((prop == null) ? "prop" : "property name"); } if ((this._ctxFlags & 2) != 0) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AddContextFrozen")); } lock (this) { CheckPropertyNameClash(prop.Name, this._ctxProps, this._numCtxProps); if ((this._ctxProps == null) || (this._numCtxProps == this._ctxProps.Length)) { this._ctxProps = GrowPropertiesArray(this._ctxProps); } this._ctxProps[this._numCtxProps++] = prop; } }
internal IMessageSink CreateServerObjectSinkChain(MarshalByRefObject obj, bool forceInternalExecute) { IMessageSink messageSink = new StackBuilderSink(obj, forceInternalExecute); messageSink = new ServerObjectTerminatorSink(messageSink); messageSink = new LeaseSink(messageSink); if (this.context_properties != null) { for (int i = this.context_properties.Count - 1; i >= 0; i--) { IContextProperty contextProperty = (IContextProperty)this.context_properties[i]; IContributeObjectSink contributeObjectSink = contextProperty as IContributeObjectSink; if (contributeObjectSink != null) { messageSink = contributeObjectSink.GetObjectSink(obj, messageSink); } } } return(messageSink); }
internal IMessageSink GetClientContextSinkChain() { if (this.client_context_sink_chain == null) { this.client_context_sink_chain = new ClientContextTerminatorSink(this); if (this.context_properties != null) { foreach (object obj in this.context_properties) { IContextProperty contextProperty = (IContextProperty)obj; IContributeClientContextSink contributeClientContextSink = contextProperty as IContributeClientContextSink; if (contributeClientContextSink != null) { this.client_context_sink_chain = contributeClientContextSink.GetClientContextSink(this.client_context_sink_chain); } } } } return(this.client_context_sink_chain); }
public virtual void SetProperty(IContextProperty prop) { if (prop == null) { throw new ArgumentNullException("IContextProperty"); } if (this == DefaultContext) { throw new InvalidOperationException("Can not add properties to " + "default context"); } // if (frozen) // throw new InvalidOperationException ("Context is Frozen"); if (context_properties == null) { context_properties = new List <IContextProperty> (); } context_properties.Add(prop); }
internal IMessageSink CreateServerObjectSinkChain(MarshalByRefObject obj, bool forceInternalExecute) { IMessageSink objectSink = new StackBuilderSink(obj, forceInternalExecute); objectSink = new ServerObjectTerminatorSink(objectSink); objectSink = new Lifetime.LeaseSink(objectSink); if (context_properties != null) { // Contribute object sinks in reverse order for (int n = context_properties.Count - 1; n >= 0; n--) { IContextProperty prop = (IContextProperty)context_properties[n]; IContributeObjectSink contributor = prop as IContributeObjectSink; if (contributor != null) { objectSink = contributor.GetObjectSink(obj, objectSink); } } } return(objectSink); }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context context = (Context)null; if (isContextful) { context = new Context(); ArrayList arrayList = (ArrayList)reqMsg.ContextProperties; for (int index = 0; index < arrayList.Count; ++index) { IContextProperty prop = arrayList[index] as IContextProperty; if (prop == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } ActivationServices.CheckForInfrastructurePermission((RuntimeAssembly)prop.GetType().Assembly); if (context.GetProperty(prop.Name) == null) { context.SetProperty(prop); } } context.Freeze(); for (int index = 0; index < arrayList.Count; ++index) { if (!((IContextProperty)arrayList[index]).IsNewContextOK(context)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[1] { (object)reqMsg }; return(!isContextful?ftnToCall(args) as IConstructionReturnMessage : Thread.CurrentThread.InternalCrossContextCallback(context, ftnToCall, args) as IConstructionReturnMessage); }
internal static Context CreateNewContext(IConstructionCallMessage msg) { Context context = new Context(); foreach (object obj in msg.ContextProperties) { IContextProperty contextProperty = (IContextProperty)obj; if (context.GetProperty(contextProperty.Name) == null) { context.SetProperty(contextProperty); } } context.Freeze(); foreach (object obj2 in msg.ContextProperties) { IContextProperty contextProperty2 = (IContextProperty)obj2; if (!contextProperty2.IsNewContextOK(context)) { throw new RemotingException("A context property did not approve the candidate context for activating the object"); } } return(context); }
[System.Security.SecurityCritical] // auto-generated_required public virtual void SetProperty(IContextProperty prop) { // We do not let people add properties to the default context. /* We allow appdomain level properties to be added to the default context * if ((_ctxFlags & CTX_DEFAULT_CONTEXT) != 0) * { * throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AddContextFrozen")); * } */ if (prop == null || prop.Name == null) { throw new ArgumentNullException((prop == null) ? "prop" : "property name"); } Contract.EndContractBlock(); if ((_ctxFlags & CTX_FROZEN) != 0) { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_AddContextFrozen")); } lock (this) { // Check if we have a property by this name CheckPropertyNameClash(prop.Name, _ctxProps, _numCtxProps); // check if we need to grow the array. if (_ctxProps == null || _numCtxProps == _ctxProps.Length) { _ctxProps = GrowPropertiesArray(_ctxProps); } // now add the property _ctxProps[_numCtxProps++] = prop; } }
internal static IContextProperty[] GrowPropertiesArray(IContextProperty[] props) { // grow the array of IContextProperty objects int newSize = (props != null ? props.Length : 0) + GROW_BY; IContextProperty[] newProps = new IContextProperty[newSize]; if (props != null) { // Copy existing properties over. Array.Copy(props, newProps, props.Length); } return newProps; }
[System.Security.SecurityCritical] // auto-generated internal static void CheckPropertyNameClash(String name, IContextProperty[] props, int count) { for (int i=0; i<count; i++) { if (props[i].Name.Equals(name)) { throw new InvalidOperationException( Environment.GetResourceString( "InvalidOperation_DuplicatePropertyName")); } } }
[System.Security.SecurityCritical] // auto-generated_required public virtual void SetProperty(IContextProperty prop) { // We do not let people add properties to the default context. /* We allow appdomain level properties to be added to the default context if ((_ctxFlags & CTX_DEFAULT_CONTEXT) != 0) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AddContextFrozen")); } */ if (prop == null || prop.Name == null) { throw new ArgumentNullException((prop==null) ? "prop" : "property name"); } Contract.EndContractBlock(); if ((_ctxFlags & CTX_FROZEN) != 0) { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_AddContextFrozen")); } lock (this) { // Check if we have a property by this name CheckPropertyNameClash(prop.Name, _ctxProps, _numCtxProps); // check if we need to grow the array. if (_ctxProps == null || _numCtxProps == _ctxProps.Length) { _ctxProps = GrowPropertiesArray(_ctxProps); } // now add the property _ctxProps[_numCtxProps++] = prop; } }
public void SetProperty (IContextProperty prop) { Contract.Requires(prop != null); }
public void SetProperty(IContextProperty prop) { Contract.Requires(prop != null); }
public virtual void SetProperty(IContextProperty prop) {}
bool IContextProvider <IContextProperty <T>, T> .OverridesValue(object targetObject, IContextProperty <T> targetProperty) { return(Provider.OverridesValue(targetObject, targetProperty)); }
T IContextProvider <IContextProperty <T>, T> .GetValue(object targetObject, IContextProperty <T> targetProperty) { return(Provider.GetValue(targetObject, targetProperty)); }
internal static IContextProperty[] GrowPropertiesArray(IContextProperty[] props) { int num = ((props != null) ? props.Length : 0) + 8; IContextProperty[] destinationArray = new IContextProperty[num]; if (props != null) { Array.Copy(props, destinationArray, props.Length); } return destinationArray; }
// Set a property on this context. public virtual void SetProperty(IContextProperty prop) { if(prop == null) { throw new ArgumentNullException("prop"); } if(prop.Name == null) { throw new ArgumentNullException("prop.Name"); } lock(this) { // The context must not be currently frozen. if(freeze) { throw new InvalidOperationException (_("Invalid_ContextFrozen")); } // Bail out if there is already a property with this name. if(properties != null) { foreach(IContextProperty prop2 in properties) { if(prop.Name == prop2.Name) { throw new InvalidOperationException (_("Invalid_PropertyClash")); } } } // Expand the property array and add the new element. if(properties == null) { properties = new IContextProperty [1]; properties[0] = prop; } else { IContextProperty[] newProperties; newProperties = new IContextProperty [properties.Length + 1]; Array.Copy(properties, 0, newProperties, 0, properties.Length); properties[properties.Length] = prop; newProperties = properties; } } }
public virtual void SetProperty (IContextProperty prop) { if (prop == null) throw new ArgumentNullException ("IContextProperty"); if (this == DefaultContext) throw new InvalidOperationException ("Can not add properties to " + "default context"); // if (frozen) // throw new InvalidOperationException ("Context is Frozen"); if (context_properties == null) context_properties = new List<IContextProperty> (); context_properties.Add (prop); }
/// <summary> /// 속성개체를 추가합니다. /// 같은 이름을 가지는 속성개체가 존재하는 경우 덮어쓰기가 됩니다. /// </summary> /// <param name="property"></param> public virtual void SetProperty(IContextProperty property) { if (property == null) { throw new ArgumentNullException("property"); } _propDict[property.Name] = property; property.Owner = this; }