Наследование: ISerializable, ICloneable
Пример #1
0
        internal MethodResponse(IMethodCallMessage msg, CADMethodReturnMessage retmsg)
        {
            _callMsg = msg;

            _methodBase = msg.MethodBase;
            //_typeName = msg.TypeName;
            _uri        = msg.Uri;
            _methodName = msg.MethodName;

            // Get unmarshalled arguments
            ArrayList args = retmsg.GetArguments();

            _exception   = retmsg.GetException(args);
            _returnValue = retmsg.GetReturnValue(args);
            _args        = retmsg.GetArgs(args);

            _callContext = retmsg.GetLogicalCallContext(args);
            if (_callContext == null)
            {
                _callContext = new LogicalCallContext();
            }

            if (retmsg.PropertiesCount > 0)
            {
                CADMessageBase.UnmarshalProperties(Properties, retmsg.PropertiesCount, args);
            }
        }
Пример #2
0
 public IMessage SyncProcessMessage(IMessage msg)
 {
     try
     {
         LogicalCallContext oldcctx = Message.PropagateCallContextFromMessageToThread(msg);
         if (this._delegate != null)
         {
             this._delegate();
         }
         else
         {
             CallBackHelper       @object = new CallBackHelper(this._eeData, true, this._targetDomainID);
             CrossContextDelegate crossContextDelegate = new CrossContextDelegate(@object.Func);
             crossContextDelegate();
         }
         Message.PropagateCallContextFromThreadToMessage(msg, oldcctx);
     }
     catch (Exception e)
     {
         ReturnMessage returnMessage = new ReturnMessage(e, new ErrorMessage());
         returnMessage.SetLogicalCallContext((LogicalCallContext)msg.Properties[Message.CallContextKey]);
         return(returnMessage);
     }
     return(this);
 }
 public void Read(__BinaryParser input)
 {
     this.messageEnum = (MessageEnum) input.ReadInt32();
     if (IOUtil.FlagTest(this.messageEnum, MessageEnum.NoReturnValue))
     {
         this.returnValue = null;
     }
     else if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueVoid))
     {
         this.returnValue = instanceOfVoid;
     }
     else if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ReturnValueInline))
     {
         this.returnValue = IOUtil.ReadWithCode(input);
     }
     if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInline))
     {
         this.scallContext = (string) IOUtil.ReadWithCode(input);
         LogicalCallContext context = new LogicalCallContext {
             RemotingData = { LogicalCallID = this.scallContext }
         };
         this.callContext = context;
     }
     if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInline))
     {
         this.args = IOUtil.ReadArgs(input);
     }
 }
Пример #4
0
        [System.Security.SecurityCritical]  // auto-generated
        public static Header[] GetHeaders()
        {
            // Header is mutable, so we need to get these from a mutable ExecutionContext
            LogicalCallContext lcc = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;

            return(lcc.InternalGetHeaders());
        } // GetHeaders
Пример #5
0
        internal static LogicalCallContext CreateLogicalCallContext(bool createEmpty)
        {
            LogicalCallContext logicalCallContext = null;

            if (CallContext.datastore != null)
            {
                foreach (object obj in CallContext.datastore)
                {
                    DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                    if (dictionaryEntry.Value is ILogicalThreadAffinative)
                    {
                        if (logicalCallContext == null)
                        {
                            logicalCallContext = new LogicalCallContext();
                        }
                        logicalCallContext.SetData((string)dictionaryEntry.Key, dictionaryEntry.Value);
                    }
                }
            }
            if (logicalCallContext == null && createEmpty)
            {
                return(new LogicalCallContext());
            }
            return(logicalCallContext);
        }
Пример #6
0
 internal MethodCall(object handlerObject, BinaryMethodCallMessage smuggledMsg)
 {
     if (handlerObject != null)
     {
         this.uri = handlerObject as string;
         if (this.uri == null)
         {
             MarshalByRefObject marshalByRefObject = handlerObject as MarshalByRefObject;
             if (marshalByRefObject != null)
             {
                 bool fServer;
                 this.srvID = MarshalByRefObject.GetIdentity(marshalByRefObject, out fServer) as ServerIdentity;
                 this.uri   = this.srvID.URI;
             }
         }
     }
     this.typeName        = smuggledMsg.TypeName;
     this.methodName      = smuggledMsg.MethodName;
     this.methodSignature = (Type[])smuggledMsg.MethodSignature;
     this.args            = smuggledMsg.Args;
     this.instArgs        = smuggledMsg.InstantiationArgs;
     this.callContext     = smuggledMsg.LogicalCallContext;
     this.ResolveMethod();
     if (!smuggledMsg.HasProperties)
     {
         return;
     }
     smuggledMsg.PopulateMessageProperties(this.Properties);
 }
Пример #7
0
        internal LogicalCallContext SetLogicalCallContext(LogicalCallContext callCtx)
        {
            LogicalCallContext callContext = this._callContext;

            this._callContext = callCtx;
            return(callContext);
        }
Пример #8
0
        internal static LogicalCallContext CreateLogicalCallContext(bool createEmpty)
        {
            LogicalCallContext ctx = null;

            if (datastore != null)
            {
                foreach (DictionaryEntry entry in datastore)
                {
                    if (entry.Value is ILogicalThreadAffinative)
                    {
                        if (ctx == null)
                        {
                            ctx = new LogicalCallContext();
                        }
                        ctx.SetData((string)entry.Key, entry.Value);
                    }
                }
            }

            if (ctx == null && createEmpty)
            {
                return(new LogicalCallContext());
            }
            else
            {
                return(ctx);
            }
        }
Пример #9
0
        internal MethodResponse(IMethodCallMessage msg,
                                Object handlerObject,
                                BinaryMethodReturnMessage smuggledMrm)
        {
            if (msg != null)
            {
                _methodBase = (MethodBase)msg.MethodBase;
//                _methodCache = InternalRemotingServices.GetReflectionCachedData(MI);

                _methodName = msg.MethodName;
                _uri        = msg.Uri;
//                _typeName = msg.TypeName;

//                if (_methodCache.IsOverloaded())
//                    _methodSignature = (Type[])msg.MethodSignature;

//                argCount = _methodCache.Parameters.Length;
            }

            _returnValue = smuggledMrm.ReturnValue;
            _args        = smuggledMrm.Args;
            _exception   = smuggledMrm.Exception;

            _callContext = smuggledMrm.LogicalCallContext;

            if (smuggledMrm.HasProperties)
            {
                smuggledMrm.PopulateMessageProperties(Properties);
            }
        }
        private SmuggledMethodCallMessage(IMethodCallMessage mcm)
        {
            this._uri        = mcm.Uri;
            this._methodName = mcm.MethodName;
            this._typeName   = mcm.TypeName;
            ArrayList        arrayList       = null;
            IInternalMessage internalMessage = mcm as IInternalMessage;

            if (internalMessage == null || internalMessage.HasProperties())
            {
                this._propertyCount = MessageSmuggler.StoreUserPropertiesForMethodMessage(mcm, ref arrayList);
            }
            if (mcm.MethodBase.IsGenericMethod)
            {
                Type[] genericArguments = mcm.MethodBase.GetGenericArguments();
                if (genericArguments != null && genericArguments.Length != 0)
                {
                    if (arrayList == null)
                    {
                        arrayList = new ArrayList();
                    }
                    this._instantiation = new MessageSmuggler.SerializedArg(arrayList.Count);
                    arrayList.Add(genericArguments);
                }
            }
            if (RemotingServices.IsMethodOverloaded(mcm))
            {
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                }
                this._methodSignature = new MessageSmuggler.SerializedArg(arrayList.Count);
                arrayList.Add(mcm.MethodSignature);
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;

            if (logicalCallContext == null)
            {
                this._callContext = null;
            }
            else if (logicalCallContext.HasInfo)
            {
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                }
                this._callContext = new MessageSmuggler.SerializedArg(arrayList.Count);
                arrayList.Add(logicalCallContext);
            }
            else
            {
                this._callContext = logicalCallContext.RemotingData.LogicalCallID;
            }
            this._args = MessageSmuggler.FixupArgs(mcm.Args, ref arrayList);
            if (arrayList != null)
            {
                MemoryStream memoryStream = CrossAppDomainSerializer.SerializeMessageParts(arrayList);
                this._serializedArgs = memoryStream.GetBuffer();
            }
        }
 internal ADAsyncWorkItem(IMessage reqMsg, IMessageSink nextSink, IMessageSink replySink)
 {
     this._reqMsg = reqMsg;
     this._nextSink = nextSink;
     this._replySink = replySink;
     this._callCtx = CallContext.GetLogicalCallContext();
 }
Пример #12
0
 internal MethodResponse(IMethodCallMessage msg, object handlerObject, BinaryMethodReturnMessage smuggledMrm)
 {
     if (msg != null)
     {
         this.MI           = msg.MethodBase;
         this._methodCache = InternalRemotingServices.GetReflectionCachedData(this.MI);
         this.methodName   = msg.MethodName;
         this.uri          = msg.Uri;
         this.typeName     = msg.TypeName;
         if (this._methodCache.IsOverloaded())
         {
             this.methodSignature = (Type[])msg.MethodSignature;
         }
         this.argCount = this._methodCache.Parameters.Length;
     }
     this.retVal      = smuggledMrm.ReturnValue;
     this.outArgs     = smuggledMrm.Args;
     this.fault       = smuggledMrm.Exception;
     this.callContext = smuggledMrm.LogicalCallContext;
     if (smuggledMrm.HasProperties)
     {
         smuggledMrm.PopulateMessageProperties(this.Properties);
     }
     this.fSoap = false;
 }
        // Token: 0x06005A8B RID: 23179 RVA: 0x0013D2C0 File Offset: 0x0013B4C0
        internal LogicalCallContext SetLogicalCallContext(LogicalCallContext ctx)
        {
            LogicalCallContext result = this.callContext;

            this.callContext = ctx;
            return(result);
        }
Пример #14
0
 public IMessage SyncProcessMessage(IMessage msg)
 {
     try
     {
         LogicalCallContext thread = Message.PropagateCallContextFromMessageToThread(msg);
         if (this._delegate != null)
         {
             this._delegate();
         }
         else
         {
             new CrossContextDelegate(new CallBackHelper(this._eeData, true, this._targetDomainID).Func)();
         }
         Message.PropagateCallContextFromThreadToMessage(msg, thread);
     }
     catch (Exception ex)
     {
         ErrorMessage       errorMessage  = new ErrorMessage();
         ReturnMessage      returnMessage = new ReturnMessage(ex, (IMethodCallMessage)errorMessage);
         LogicalCallContext ctx           = (LogicalCallContext)msg.Properties[(object)Message.CallContextKey];
         returnMessage.SetLogicalCallContext(ctx);
         return((IMessage)returnMessage);
     }
     return((IMessage)this);
 }
Пример #15
0
        internal LogicalCallContext SetLogicalCallContext(LogicalCallContext ctx)
        {
            LogicalCallContext logicalCallContext = this.callContext;

            this.callContext = ctx;
            return(logicalCallContext);
        }
Пример #16
0
        internal virtual void InitMethodProperty(string key, object value)
        {
            switch (key)
            {
            case "__TypeName":
                this._typeName = (string)value;
                return;

            case "__MethodName":
                this._methodName = (string)value;
                return;

            case "__MethodSignature":
                this._methodSignature = (Type[])value;
                return;

            case "__Args":
                this._args = (object[])value;
                return;

            case "__CallContext":
                this._callContext = (LogicalCallContext)value;
                return;

            case "__Uri":
                this._uri = (string)value;
                return;

            case "__GenericArguments":
                this._genericArguments = (Type[])value;
                return;
            }
            this.Properties[key] = value;
        }
Пример #17
0
 private void FillHeaders(Header[] h, bool bFromHeaderHandler)
 {
     if (h == null)
     {
         return;
     }
     if (bFromHeaderHandler && this.fSoap)
     {
         for (int index = 0; index < h.Length; ++index)
         {
             Header header = h[index];
             if (header.HeaderNamespace == "http://schemas.microsoft.com/clr/soap/messageProperties")
             {
                 this.FillHeader(header.Name, header.Value);
             }
             else
             {
                 this.FillHeader(LogicalCallContext.GetPropertyKeyForHeader(header), (object)header);
             }
         }
     }
     else
     {
         for (int index = 0; index < h.Length; ++index)
         {
             this.FillHeader(h[index].Name, h[index].Value);
         }
     }
 }
Пример #18
0
        public ExecutionContext CreateCopy()
        {
            if (!this.isNewCapture)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotCopyUsedContext"));
            }
            ExecutionContext context = new ExecutionContext {
                isNewCapture          = true,
                _syncContext          = (this._syncContext == null) ? null : this._syncContext.CreateCopy(),
                _hostExecutionContext = (this._hostExecutionContext == null) ? null : this._hostExecutionContext.CreateCopy()
            };

            if (this._securityContext != null)
            {
                context._securityContext = this._securityContext.CreateCopy();
                context._securityContext.ExecutionContext = context;
            }
            if (this._logicalCallContext != null)
            {
                System.Runtime.Remoting.Messaging.LogicalCallContext logicalCallContext = this.LogicalCallContext;
                context.LogicalCallContext = (System.Runtime.Remoting.Messaging.LogicalCallContext)logicalCallContext.Clone();
            }
            if (this._illogicalCallContext != null)
            {
                System.Runtime.Remoting.Messaging.IllogicalCallContext illogicalCallContext = this.IllogicalCallContext;
                context.IllogicalCallContext = (System.Runtime.Remoting.Messaging.IllogicalCallContext)illogicalCallContext.Clone();
            }
            return(context);
        }
Пример #19
0
        internal static ExecutionContext Capture(ref StackCrawlMark stackMark)
        {
            if (IsFlowSuppressed())
            {
                return(null);
            }
            ExecutionContext executionContextNoCreate = System.Threading.Thread.CurrentThread.GetExecutionContextNoCreate();
            ExecutionContext context2 = new ExecutionContext {
                isNewCapture    = true,
                SecurityContext = System.Security.SecurityContext.Capture(executionContextNoCreate, ref stackMark)
            };

            if (context2.SecurityContext != null)
            {
                context2.SecurityContext.ExecutionContext = context2;
            }
            context2._hostExecutionContext = HostExecutionContextManager.CaptureHostExecutionContext();
            if (executionContextNoCreate != null)
            {
                context2._syncContext = (executionContextNoCreate._syncContext == null) ? null : executionContextNoCreate._syncContext.CreateCopy();
                if (executionContextNoCreate._logicalCallContext != null)
                {
                    System.Runtime.Remoting.Messaging.LogicalCallContext logicalCallContext = executionContextNoCreate.LogicalCallContext;
                    context2.LogicalCallContext = (System.Runtime.Remoting.Messaging.LogicalCallContext)logicalCallContext.Clone();
                }
            }
            return(context2);
        }
 private void FillHeaders(Header[] h, bool bFromHeaderHandler)
 {
     if (h == null)
     {
         return;
     }
     if (bFromHeaderHandler && this.fSoap)
     {
         foreach (Header header in h)
         {
             if (header.HeaderNamespace == "http://schemas.microsoft.com/clr/soap/messageProperties")
             {
                 this.FillHeader(header.Name, header.Value);
             }
             else
             {
                 string propertyKeyForHeader = LogicalCallContext.GetPropertyKeyForHeader(header);
                 this.FillHeader(propertyKeyForHeader, header);
             }
         }
         return;
     }
     for (int j = 0; j < h.Length; j++)
     {
         this.FillHeader(h[j].Name, h[j].Value);
     }
 }
Пример #21
0
        private SmuggledMethodCallMessage(IMethodCallMessage mcm)
        {
            _uri        = mcm.Uri;
            _methodName = mcm.MethodName;
            _typeName   = mcm.TypeName;

            ArrayList argsToSerialize = null;

            IInternalMessage iim = mcm as IInternalMessage;

            // user properties (everything but special entries)
            if ((iim == null) || iim.HasProperties())
            {
                _propertyCount = StoreUserPropertiesForMethodMessage(mcm, ref argsToSerialize);
            }

            // handle method signature
            if (RemotingServices.IsMethodOverloaded(mcm))
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                _methodSignature = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(mcm.MethodSignature);
            }

            // handle call context
            LogicalCallContext lcc = mcm.LogicalCallContext;

            if (lcc == null)
            {
                _callContext = null;
            }
            else
            if (lcc.HasInfo)
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                _callContext = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(lcc);
            }
            else
            {
                // just smuggle the call id string
                _callContext = lcc.RemotingData.LogicalCallID;
            }

            _args = FixupArgs(mcm.Args, ref argsToSerialize);

            if (argsToSerialize != null)
            {
                //MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize, out _serializerSmuggledArgs);
                MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize);
                _serializedArgs = argStm.GetBuffer();
            }
        } // SmuggledMethodCallMessage
Пример #22
0
 internal MethodResponse(object returnValue, object[] outArgs, LogicalCallContext callCtx, IMethodCallMessage msg)
 {
     this._callMsg     = msg;
     this._uri         = msg.Uri;
     this._exception   = null;
     this._returnValue = returnValue;
     this._args        = outArgs;
 }
Пример #23
0
 internal LogicalCallContext GetLogicalCallContext()
 {
     if (this.callContext == null)
     {
         this.callContext = new LogicalCallContext();
     }
     return(this.callContext);
 }
 internal AsyncWorkItem(IMessage reqMsg, IMessageSink replySink, Context oldCtx, ServerIdentity srvID)
 {
     this._reqMsg = reqMsg;
     this._replySink = replySink;
     this._oldCtx = oldCtx;
     this._callCtx = CallContext.GetLogicalCallContext();
     this._srvID = srvID;
 }
 internal LogicalCallContext SetLogicalCallContext(LogicalCallContext ctx)
 {
     if (this._message != null)
     {
         return(this._message.SetLogicalCallContext(ctx));
     }
     throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_InternalState"));
 }
Пример #26
0
 // Sets the given logical call context object on the thread.
 // Returns the previous one.
 internal static LogicalCallContext SetLogicalCallContext(
     LogicalCallContext callCtx)
 {
     ExecutionContext ec = Thread.CurrentThread.GetMutableExecutionContext();
     LogicalCallContext prev = ec.LogicalCallContext;
     ec.LogicalCallContext = callCtx;
     return prev;
 }
Пример #27
0
        // Token: 0x06005B8F RID: 23439 RVA: 0x001404CC File Offset: 0x0013E6CC
        internal static LogicalCallContext SetLogicalCallContext(LogicalCallContext callCtx)
        {
            ExecutionContext   mutableExecutionContext = Thread.CurrentThread.GetMutableExecutionContext();
            LogicalCallContext logicalCallContext      = mutableExecutionContext.LogicalCallContext;

            mutableExecutionContext.LogicalCallContext = callCtx;
            return(logicalCallContext);
        }
 /// <summary>
 /// Extracts and interprets fields from "IMessage"
 /// 
 /// Samle IMassage when the method "ToString" is called:
 ///     msg.Properties["__Uri"]	
 ///         null	
 ///         object
 ///     msg.Properties["__MethodName"]	
 ///         "ToString"	
 ///         object {string}
 ///     msg.Properties["__MethodSignature"]	
 ///         {System.Type[0]}	
 ///         object {System.Type[]}
 ///     msg.Properties["__TypeName"]	
 ///         "System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"	
 ///         object {string}
 ///     msg.Properties["__Args"]	
 ///         {object[0]}	
 ///         object {object[]}
 ///     msg.Properties["__CallContext"]	
 ///         {System.Runtime.Remoting.Messaging.LogicalCallContext}	
 ///         object {System.Runtime.Remoting.Messaging.LogicalCallContext}
 ///     Type.GetType((string)msg.Properties["__TypeName"]) == typeof(object)	
 ///         true	
 ///         bool
 /// </summary>
 /// <param name="msg"></param>
 public MessageMethodInvocation(IMessage msg)
     : base(msg.Properties["__TypeName"] as string,
          msg.Properties["__MethodName"] as string,
          msg.Properties["__MethodSignature"] as Type[],
          msg.Properties["__Args"] as object[])
 {
     _message = msg;
     _callContext = _message.Properties["__CallContext"] as LogicalCallContext;
 }
Пример #29
0
 public ReturnMessage(Object ret, Object[] outArgs, int outArgsCount,
                      LogicalCallContext callCtx, IMethodCallMessage mcm)
 {
     this.ret          = ret;
     this.outArgs      = outArgs;
     this.outArgsCount = outArgsCount;
     this.callCtx      = callCtx;
     this.mcm          = mcm;
 }
Пример #30
0
			public Switcher (ExecutionContext ec)
			{
				this.ec = ec;
				this._lcc = ec._lcc;
				this._suppressFlow = ec._suppressFlow;
				this._capture = ec._capture;
				this.local_data = ec.local_data;
				this.copy_on_write = ec.CopyOnWrite;
			}
        public static void LogicalSetData(String name, Object data)
        {
            IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext();

            ilcc.FreeNamedDataSlot(name);
            LogicalCallContext lcc = Thread.CurrentThread.GetLogicalCallContext();

            lcc.SetData(name, data);
        }
Пример #32
0
        internal static void UpdateCurrentCallContext(LogicalCallContext ctx)
        {
            Hashtable data = ctx.Datastore;

            foreach (DictionaryEntry entry in data)
            {
                SetData((string)entry.Key, entry.Value);
            }
        }
Пример #33
0
	public ReturnMessage(Object ret, Object[] outArgs, int outArgsCount,
						 LogicalCallContext callCtx, IMethodCallMessage mcm)
			{
				this.ret = ret;
				this.outArgs = outArgs;
				this.outArgsCount = outArgsCount;
				this.callCtx = callCtx;
				this.mcm = mcm;
			}
Пример #34
0
        // Sets the given logical call context object on the thread.
        // Returns the previous one.
        internal static LogicalCallContext SetLogicalCallContext(
            LogicalCallContext callCtx)
        {
            ExecutionContext   ec   = Thread.CurrentThread.GetMutableExecutionContext();
            LogicalCallContext prev = ec.LogicalCallContext;

            ec.LogicalCallContext = callCtx;
            return(prev);
        }
Пример #35
0
        internal static LogicalCallContext SetLogicalCallContext(LogicalCallContext callCtx)
        {
            ExecutionContext   executionContext    = Thread.CurrentThread.GetMutableExecutionContext();
            LogicalCallContext logicalCallContext1 = executionContext.LogicalCallContext;
            LogicalCallContext logicalCallContext2 = callCtx;

            executionContext.LogicalCallContext = logicalCallContext2;
            return(logicalCallContext1);
        }
Пример #36
0
		public ReturnMessage (Exception e, IMethodCallMessage mcm)
		{
			_exception = e;
			
			if (mcm != null) {
				_methodBase = mcm.MethodBase;
				_callCtx = mcm.LogicalCallContext;
			}
			_args = new object[0];	// .NET does this
		}
Пример #37
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Remoting.Messaging.ReturnMessage" /> class.</summary>
 /// <param name="e">The exception that was thrown during execution of the remotely called method. </param>
 /// <param name="mcm">An <see cref="T:System.Runtime.Remoting.Messaging.IMethodCallMessage" /> with which to create an instance of the <see cref="T:System.Runtime.Remoting.Messaging.ReturnMessage" /> class. </param>
 public ReturnMessage(Exception e, IMethodCallMessage mcm)
 {
     this._exception = e;
     if (mcm != null)
     {
         this._methodBase = mcm.MethodBase;
         this._callCtx    = mcm.LogicalCallContext;
     }
     this._args = new object[0];
 }
Пример #38
0
        internal static void UpdateCurrentCallContext(LogicalCallContext ctx)
        {
            Hashtable hashtable = ctx.Datastore;

            foreach (object obj in hashtable)
            {
                DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                CallContext.SetData((string)dictionaryEntry.Key, dictionaryEntry.Value);
            }
        }
Пример #39
0
		private ExecutionContext (ExecutionContext ec)
		{
#if !MOBILE
			if (ec._sc != null)
				_sc = new SecurityContext (ec._sc);
#endif
			if (ec._lcc != null)
				_lcc = (LogicalCallContext) ec._lcc.Clone ();

			_suppressFlow = ec._suppressFlow;
			_capture = true;
		}
 private ExecutionContext(SerializationInfo info, StreamingContext context)
 {
     SerializationInfoEnumerator enumerator = info.GetEnumerator();
     while (enumerator.MoveNext())
     {
         if (enumerator.Name.Equals("LogicalCallContext"))
         {
             this._logicalCallContext = (System.Runtime.Remoting.Messaging.LogicalCallContext) enumerator.Value;
         }
     }
     this.Thread = System.Threading.Thread.CurrentThread;
 }
	internal MethodResponse(IMethodReturnMessage mrm)
			{
				outArgs = mrm.OutArgs;
				methodName = mrm.MethodName;
				typeName = mrm.TypeName;
				uri = mrm.Uri;
				hasVarArgs = mrm.HasVarArgs;
				context = mrm.LogicalCallContext;
				method = mrm.MethodBase;
				exception = mrm.Exception;
				returnValue = mrm.ReturnValue;
			}
 internal MethodMessage(Type interfaceType, string methodName, object[] args, string identity, bool responseRequired)
 {
     this.interfaceType = interfaceType;
     this.methodName = methodName;
     this.args = args;
     this.callContext = GetLogicalCallContext();
     if (responseRequired)
     {
         this.returnValueSignalEvent = new ManualResetEvent(false);
     }
     this.PopulateIdentity(this.callContext, identity);
     this.Clone();
 }
Пример #43
0
		public ReturnMessage (object ret, object [] outArgs,
			       int outArgsCount, LogicalCallContext callCtx,
			       IMethodCallMessage mcm)
		{
			// outArgCount tells how many values of outArgs are valid

			_returnValue = ret;
			_args = outArgs;
			_callCtx = callCtx;
			if (mcm != null) {
				_uri = mcm.Uri;
				_methodBase = mcm.MethodBase;
			}
			if (_args == null) _args = new object [outArgsCount];
		}
 internal void Read(__BinaryParser input)
 {
     this.messageEnum = (MessageEnum) input.ReadInt32();
     this.methodName = (string) IOUtil.ReadWithCode(input);
     this.typeName = (string) IOUtil.ReadWithCode(input);
     if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ContextInline))
     {
         this.scallContext = (string) IOUtil.ReadWithCode(input);
         LogicalCallContext context = new LogicalCallContext {
             RemotingData = { LogicalCallID = this.scallContext }
         };
         this.callContext = context;
     }
     if (IOUtil.FlagTest(this.messageEnum, MessageEnum.ArgsInline))
     {
         this.args = IOUtil.ReadArgs(input);
     }
 }
Пример #45
0
		internal MethodCall (CADMethodCallMessage msg) 
		{
			_uri = string.Copy (msg.Uri);
			
			// Get unmarshalled arguments
			ArrayList args = msg.GetArguments ();

			_args = msg.GetArgs (args);
			_callContext = msg.GetLogicalCallContext (args);
			if (_callContext == null)
				_callContext = new LogicalCallContext ();
	
			_methodBase = msg.GetMethod ();
			
			Init();

			if (msg.PropertiesCount > 0)
				CADMessageBase.UnmarshalProperties (Properties, msg.PropertiesCount, args);
		}
 private void SerializeContextElements(CdrOutputStream targetStream,
                                       LogicalCallContext callContext,
                                       Serializer contextElementSer) {
     // if no context elements specified, don't serialise a context sequence.
     if (m_contextElementKeys.Length > 0) {
         string[] contextSeq = new string[m_contextElementKeys.Length * 2];
         for (int i = 0; i < m_contextElementKeys.Length; i++) {
             string contextKey =
                 m_contextElementKeys[i];
             contextSeq[i * 2] = contextKey;
             if (callContext.GetData(contextKey) != null) {
                 contextSeq[i * 2 + 1] = callContext.GetData(contextKey).ToString();
             } else {
                 contextSeq[i * 2 + 1] = "";
             }
         }
         contextElementSer.Serialize(contextSeq, targetStream);
     }
 }
Пример #47
0
        internal BinaryMethodCallMessage(String uri, String methodName, String typeName, Object[] args, Object methodSignature, LogicalCallContext callContext, Object[] properties)
        {
            _methodName = methodName;
            _typeName = typeName;
            //_uri = uri;
            if (args == null)
                args = new Object[0];

            _inargs = args;
            _args = args;
            _methodSignature = methodSignature;
            if (callContext == null)
                _logicalCallContext = new LogicalCallContext();
            else
                _logicalCallContext = callContext;

            _properties = properties;

        }
 internal BinaryMethodReturnMessage(object returnValue, object[] args, System.Exception e, System.Runtime.Remoting.Messaging.LogicalCallContext callContext, object[] properties)
 {
     this._returnValue = returnValue;
     if (args == null)
     {
         args = new object[0];
     }
     this._outargs = args;
     this._args = args;
     this._exception = e;
     if (callContext == null)
     {
         this._logicalCallContext = new System.Runtime.Remoting.Messaging.LogicalCallContext();
     }
     else
     {
         this._logicalCallContext = callContext;
     }
     this._properties = properties;
 }
 public object Clone()
 {
     LogicalCallContext context = new LogicalCallContext();
     if (this.m_RemotingData != null)
     {
         context.m_RemotingData = (CallContextRemotingData) this.m_RemotingData.Clone();
     }
     if (this.m_SecurityData != null)
     {
         context.m_SecurityData = (CallContextSecurityData) this.m_SecurityData.Clone();
     }
     if (this.m_HostContext != null)
     {
         context.m_HostContext = this.m_HostContext;
     }
     if (this.HasUserData)
     {
         IDictionaryEnumerator enumerator = this.m_Datastore.GetEnumerator();
         if (this.m_IsCorrelationMgr)
         {
             while (enumerator.MoveNext())
             {
                 string key = (string) enumerator.Key;
                 if (key.Equals("System.Diagnostics.Trace.CorrelationManagerSlot"))
                 {
                     context.Datastore[key] = ((ICloneable) enumerator.Value).Clone();
                 }
                 else
                 {
                     context.Datastore[key] = enumerator.Value;
                 }
             }
             return context;
         }
         while (enumerator.MoveNext())
         {
             context.Datastore[(string) enumerator.Key] = enumerator.Value;
         }
     }
     return context;
 }
 internal BinaryMethodCallMessage(string uri, string methodName, string typeName, Type[] instArgs, object[] args, object methodSignature, System.Runtime.Remoting.Messaging.LogicalCallContext callContext, object[] properties)
 {
     this._methodName = methodName;
     this._typeName = typeName;
     if (args == null)
     {
         args = new object[0];
     }
     this._inargs = args;
     this._args = args;
     this._instArgs = instArgs;
     this._methodSignature = methodSignature;
     if (callContext == null)
     {
         this._logicalCallContext = new System.Runtime.Remoting.Messaging.LogicalCallContext();
     }
     else
     {
         this._logicalCallContext = callContext;
     }
     this._properties = properties;
 }
Пример #51
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void Merge(LogicalCallContext lc)
        {
            // we ignore the RemotingData & SecurityData 
            // and only merge the user sections of the two call contexts
            // the idea being that if the original call had any 
            // identity/remoting callID that should remain unchanged

            // If we have a non-null callContext and it is not the same
            // as the one on the current thread (can happen in x-context async)
            // and there is any userData in the callContext, do the merge
            if ((lc != null) && (this != lc) && lc.HasUserData)
            {
                IDictionaryEnumerator de = lc.Datastore.GetEnumerator();
                
                while (de.MoveNext())
                {
                    Datastore[(String)de.Key] = de.Value;  
                }                
            }
        }
Пример #52
0
        [System.Security.SecuritySafeCritical] // overrides public transparent member
        public Object Clone()
        {
            LogicalCallContext lc = new LogicalCallContext();
            if (m_RemotingData != null)
                lc.m_RemotingData = (CallContextRemotingData)m_RemotingData.Clone();
            if (m_SecurityData != null)
                lc.m_SecurityData = (CallContextSecurityData)m_SecurityData.Clone();
            if (m_HostContext != null)
                lc.m_HostContext = m_HostContext;
            lc.m_IsCorrelationMgr = m_IsCorrelationMgr;
            if (HasUserData)
            {
                IDictionaryEnumerator de = m_Datastore.GetEnumerator();
                
                if (!m_IsCorrelationMgr) 
                {
                    while (de.MoveNext())
                    {
                        lc.Datastore[(String)de.Key] = de.Value;  
                    }
                }
                else 
                {
                    while (de.MoveNext())
                    {
                        String key = (String)de.Key;

                        // Deep clone "System.Diagnostics.Trace.CorrelationManagerSlot" 
                        if (key.Equals(s_CorrelationMgrSlotName))
                        {
                            lc.Datastore[key] = ((ICloneable)de.Value).Clone();   
                        }
                        else
                            lc.Datastore[key] = de.Value;    
                    }
                }
            }      
            return lc;
        }
Пример #53
0
 public Reader(LogicalCallContext ctx) { m_ctx = ctx; }
 [System.Security.SecurityCritical]  // auto-generated
 internal WorkItem(IMessage reqMsg, IMessageSink nextSink, IMessageSink replySink)
 {
     _reqMsg = reqMsg;
     _replyMsg = null;
     _nextSink = nextSink;
     _replySink = replySink;
     _ctx = Thread.CurrentContext;
     _callCtx = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
     //DBGDBG 
     //_thread = Thread.CurrentThread.GetHashCode();
 }
 internal void SerializeRequestArgs(string idlMethodName, object[] arguments,
                                    CdrOutputStream targetStream, LogicalCallContext context) {
     ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName);
     mapping.SerializeRequestArgs(arguments, targetStream, context, m_contextElementSer);
 }
 internal void SerializeRequestArgs(object[] arguments, CdrOutputStream targetStream,
                                    LogicalCallContext context, Serializer contextElementSer) {
     for (int actualParamNr = 0; actualParamNr < arguments.Length; actualParamNr++) {
         ArgumentMapping paramInfo = m_arguments[actualParamNr];
         // iterate through the parameters, nonOut and nonRetval params are serialised for a request
         if (paramInfo.IsInArg() || paramInfo.IsRefArg()) {
             paramInfo.Serialize(targetStream, arguments[actualParamNr]);
         }
         // move to next parameter
         // out-args are also part of the arguments array -> move to next for those whithout doing something
     }
     SerializeContextElements(targetStream, context, contextElementSer);
 }
 internal void Merge(LogicalCallContext lc)
 {
     if (((lc != null) && (this != lc)) && lc.HasUserData)
     {
         IDictionaryEnumerator enumerator = lc.Datastore.GetEnumerator();
         while (enumerator.MoveNext())
         {
             this.Datastore[(string) enumerator.Key] = enumerator.Value;
         }
     }
 }
	internal virtual void SetSpecialProperty(String name, Object value)
			{
				switch(name)
				{
					case "__Uri":		Uri = (String)value; break;
					case "__CallContext":
						context = (LogicalCallContext)value; break;
				}
			}
 private ExecutionContext(SerializationInfo info, StreamingContext context) 
 {
     SerializationInfoEnumerator e = info.GetEnumerator();
     while (e.MoveNext())
     {
         if (e.Name.Equals("LogicalCallContext"))
         {
             _logicalCallContext = (LogicalCallContext) e.Value;
         }
     }
     this.Thread = Thread.CurrentThread;
 } // ObjRef .ctor
Пример #60
0
        [System.Security.SecurityCritical]  // auto-generated 
        internal static void PreserveThreadPrincipalIfNecessary(
            LogicalCallContext messageCallContext, 
            LogicalCallContext threadCallContext)
        {
            BCLDebug.Assert(messageCallContext != null, "message should always have a call context");
 
            if (threadCallContext != null)
            { 
                if (messageCallContext.Principal == null) 
                {
                    IPrincipal currentPrincipal = threadCallContext.Principal; 
                    if (currentPrincipal != null)
                    {
                        messageCallContext.Principal = currentPrincipal;
                    } 
                }
            } 
        } // PreserveThreadPrincipalIfNecessary