当前位置: 首页>>代码示例>>C#>>正文


C# IMethodCallMessage.GetArg方法代码示例

本文整理汇总了C#中IMethodCallMessage.GetArg方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodCallMessage.GetArg方法的具体用法?C# IMethodCallMessage.GetArg怎么用?C# IMethodCallMessage.GetArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMethodCallMessage的用法示例。


在下文中一共展示了IMethodCallMessage.GetArg方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompositionException

		public CompositionException(IMethodCallMessage Message,string message, System.Exception innerException):this(String.Format("Exception:{0}\r\nAssembly:{1}\r\n{2}:{3}\r\nArgs:\r\n",message,Message.TypeName,Message.MethodBase.MemberType,Message.MethodName),innerException)
		{
			for(int i=0; i<Message.ArgCount; i+=2)
			{
				_message = String.Format("{0}\t{1}={2}\r\n",_message,Message.GetArgName(i),Message.GetArg(i).ToString());
			}
			
		}
开发者ID:dialectsoftware,项目名称:DialectSoftware.Composition,代码行数:8,代码来源:CompositionException.cs

示例2: GetCommand

 public SqlCommand GetCommand(IMethodCallMessage mcm, SqlConnection connection, out SqlParameter returnParameter, out SqlParameter[] outArgs, out ISerializationTypeInfo procedureReturnTypeInfo, out ICallDeserializationInfo procedureInfo, out XmlNameTable xmlNameTable, IList<IDisposable> disposeList)
 {
     SqlCommand result = connection.CreateCommand();
     result.CommandText = ProcedureName;
     result.CommandType = CommandType.StoredProcedure;
     if (timeout > 0) {
         result.CommandTimeout = timeout;
     }
     outArgs = new SqlParameter[outArgCount];
     xmlNameTable = xmlNameTableParameter != null ? (XmlNameTable)mcm.GetArg(xmlNameTableParameter.Position) : null;
     foreach (SqlCallParameterInfo factory in parameters) {
         result.Parameters.Add(factory.GetSqlParameter(result, mcm, outArgs, disposeList));
     }
     if (useReturnValue) {
         returnParameter = result.CreateParameter();
         returnParameter.SqlDbType = SqlDbType.Int;
         returnParameter.Direction = ParameterDirection.ReturnValue;
         result.Parameters.Add(returnParameter);
     } else {
         returnParameter = null;
     }
     procedureReturnTypeInfo = returnTypeInfo;
     procedureInfo = this;
     return result;
 }
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:25,代码来源:SqlCallProcedureInfo.cs

示例3: HandleEventUnsubscription

        /// <summary>
        /// Handles unsubscription.
        /// </summary>
        /// <param name="methodCallMessage"><see cref="IMethodCallMessage"/> to process.</param>
        /// <param name="methodInfo"><see cref="MethodInfo"/> for the method being called.</param>
        /// <returns><see cref="ReturnMessage"/>, if the call is processed successfully, otherwise, false.</returns>
        private ReturnMessage HandleEventUnsubscription(IMethodCallMessage methodCallMessage, MethodInfo methodInfo)
        {
            if (methodInfo.ReturnType.Equals(typeof(void)) &&
                methodCallMessage.MethodName.StartsWith("remove_") &&
                methodCallMessage.InArgCount == 1 &&
                methodCallMessage.ArgCount == 1 &&
                methodCallMessage.Args[0] != null &&
                typeof(Delegate).IsAssignableFrom(methodCallMessage.Args[0].GetType()))
            {
                string propertyName = methodCallMessage.MethodName.Substring(7);
                var inputMessage = methodCallMessage.GetArg(0) as Delegate;
                var eventFilter = default(IEventFilter);

                // Detach event filter, if it is attached
                ExtractEventHandlerDetails(ref inputMessage, ref eventFilter);

                if (_delegateCorrelationSet.Count > 0)
                {
                    // copy delegates
                    IEnumerable<DelegateCorrelationInfo> correlationSet;
                    lock (_delegateCorrelationSet)
                    {
                        correlationSet = _delegateCorrelationSet.ToArray();
                    }

                    var found = (
                        from correlationInfo in correlationSet
                        where correlationInfo.DelegateMemberName.Equals(propertyName) && correlationInfo.ClientDelegateInterceptor.ClientDelegate.Equals(inputMessage)
                        select correlationInfo).FirstOrDefault();

                    if (found != null)
                    {
                        OptionalAsync(ZyanSettings.LegacyBlockingSubscriptions, () =>
                            RemoveRemoteEventHandlers(new List<DelegateCorrelationInfo> { found }));

                        // Remove delegate correlation info
                        lock (_delegateCorrelationSet)
                        {
                            _delegateCorrelationSet.Remove(found);
                            found.Dispose();
                        }
                    }
                }

                return new ReturnMessage(null, null, 0, methodCallMessage.LogicalCallContext, methodCallMessage);
            }

            // This method doesn't represent event unsubscription
            return null;
        }
开发者ID:yallie,项目名称:zyan,代码行数:56,代码来源:ZyanProxy.cs

示例4: HandleEventSubscription

        /// <summary>
        /// Handles subscription to events.
        /// </summary>
        /// <param name="methodCallMessage"><see cref="IMethodCallMessage"/> to process.</param>
        /// <param name="methodInfo"><see cref="MethodInfo"/> for the method being called.</param>
        /// <returns><see cref="ReturnMessage"/>, if the call is processed successfully, otherwise, false.</returns>
        private ReturnMessage HandleEventSubscription(IMethodCallMessage methodCallMessage, MethodInfo methodInfo)
        {
            // Check for delegate parameters in properties and events
            if (methodInfo.ReturnType.Equals(typeof(void)) &&
                (methodCallMessage.MethodName.StartsWith("set_") || methodCallMessage.MethodName.StartsWith("add_")) &&
                methodCallMessage.InArgCount == 1 &&
                methodCallMessage.ArgCount == 1 &&
                methodCallMessage.Args[0] != null &&
                typeof(Delegate).IsAssignableFrom(methodCallMessage.Args[0].GetType()))
            {
                // Get client delegate
                var receiveMethodDelegate = methodCallMessage.GetArg(0) as Delegate;
                var eventFilter = default(IEventFilter);

                // Get event filter, if it is attached
                ExtractEventHandlerDetails(ref receiveMethodDelegate, ref eventFilter);

                // Trim "set_" or "add_" prefix
                string propertyName = methodCallMessage.MethodName.Substring(4);

                // Create delegate interceptor and correlation info
                var wiring = new DelegateInterceptor()
                {
                    ClientDelegate = receiveMethodDelegate,
                    SynchronizationContext = _synchronizationContext
                };

                var correlationInfo = new DelegateCorrelationInfo()
                {
                    IsEvent = methodCallMessage.MethodName.StartsWith("add_"),
                    DelegateMemberName = propertyName,
                    ClientDelegateInterceptor = wiring,
                    EventFilter = eventFilter
                };

                OptionalAsync(ZyanSettings.LegacyBlockingSubscriptions, () =>
                    AddRemoteEventHandlers(new List<DelegateCorrelationInfo> { correlationInfo }));

                // Save delegate correlation info
                lock (_delegateCorrelationSet)
                {
                    _delegateCorrelationSet.Add(correlationInfo);
                }

                return new ReturnMessage(null, null, 0, methodCallMessage.LogicalCallContext, methodCallMessage);
            }

            // This method doesn't represent event subscription
            return null;
        }
开发者ID:yallie,项目名称:zyan,代码行数:56,代码来源:ZyanProxy.cs

示例5: InternalExecuteMessage

		internal static IMethodReturnMessage InternalExecuteMessage (
		        MarshalByRefObject target, IMethodCallMessage reqMsg)
		{
			ReturnMessage result;
			
			Type tt = target.GetType ();
			MethodBase method;
			if (reqMsg.MethodBase.DeclaringType == tt ||
			    reqMsg.MethodBase == FieldSetterMethod || 
			    reqMsg.MethodBase == FieldGetterMethod) {
				method = reqMsg.MethodBase;
			} else {
				method = GetVirtualMethod (tt, reqMsg.MethodBase);

				if (method == null)
					throw new RemotingException (
						String.Format ("Cannot resolve method {0}:{1}", tt, reqMsg.MethodName));
			}

			if (reqMsg.MethodBase.IsGenericMethod) {
				Type[] genericArguments = reqMsg.MethodBase.GetGenericArguments ();
				MethodInfo gmd = ((MethodInfo)method).GetGenericMethodDefinition ();
				method = gmd.MakeGenericMethod (genericArguments);
			}

			object oldContext = CallContext.SetCurrentCallContext (reqMsg.LogicalCallContext);
			
			try 
			{
				object [] out_args;
				object rval = InternalExecute (method, target, reqMsg.Args, out out_args);
			
				// Collect parameters with Out flag from the request message
				// FIXME: This can be done in the unmanaged side and will be
				// more efficient
				
				ParameterInfo[] parameters = method.GetParameters();
				object[] returnArgs = new object [parameters.Length];
				
				int n = 0;
				int noa = 0;
				foreach (ParameterInfo par in parameters)
				{
					if (par.IsOut && !par.ParameterType.IsByRef) 
						returnArgs [n++] = reqMsg.GetArg (par.Position);
					else if (par.ParameterType.IsByRef)
						returnArgs [n++] = out_args [noa++]; 
					else
						returnArgs [n++] = null; 
				}
				
				result = new ReturnMessage (rval, returnArgs, n, CallContext.CreateLogicalCallContext (true), reqMsg);
			} 
			catch (Exception e) 
			{
				result = new ReturnMessage (e, reqMsg);
			}
			
			CallContext.RestoreCallContext (oldContext);
			return result;
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:61,代码来源:RemotingServices.cs

示例6: GetSqlParameter

 public SqlParameter GetSqlParameter(SqlCommand command, IMethodCallMessage mcm, SqlParameter[] outArgs, IList<IDisposable> disposeList)
 {
     SqlParameter parameter = command.CreateParameter();
     parameter.ParameterName = parameterName;
     parameter.IsNullable = nullable;
     if (size > 0) {
         parameter.Size = size;
     }
     parameter.Direction = direction;
     object value = mcm.GetArg(position);
     switch (sqlType) {
     case SqlDbType.SmallInt:
         IIdentifiable<short> identifiableShort = value as IIdentifiable<short>;
         if (identifiableShort != null) {
             value = identifiableShort.Id;
         }
         break;
     case SqlDbType.Int:
         IIdentifiable<int> identifiableInt = value as IIdentifiable<int>;
         if (identifiableInt != null) {
             value = identifiableInt.Id;
         }
         break;
     case SqlDbType.BigInt:
         IIdentifiable<long> identifiableLong = value as IIdentifiable<long>;
         if (identifiableLong != null) {
             value = identifiableLong.Id;
         }
         break;
     case SqlDbType.UniqueIdentifier:
         IIdentifiable<Guid> identifiableGuid = value as IIdentifiable<Guid>;
         if (identifiableGuid != null) {
             value = identifiableGuid.Id;
         }
         break;
     case SqlDbType.Xml:
         value = GetXmlValue(value, disposeList);
         break;
     case SqlDbType.Udt:
         parameter.UdtTypeName = userDefinedTypeName;
         break;
     case SqlDbType.Structured:
         value = GetDataTableValue(value, disposeList);
         break;
     }
     ISerializationTypeInfo typeInfo = typeInfoProvider.GetSerializationTypeInfo(parameterType);
     if (typeInfo.SimpleConverter != null) {
         value = typeInfo.SimpleConverter.ProcessToDb(value);
     }
     parameter.Value = value ?? DBNull.Value;
     parameter.SqlDbType = sqlType;
     if (direction != ParameterDirection.Input) {
         outArgs[outArgPosition] = parameter;
     }
     return parameter;
 }
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:56,代码来源:SqlCallParameterInfo.cs

示例7: SetParameterValue

 protected override object SetParameterValue(IMethodCallMessage mcm, IList<IDisposable> disposeList)
 {
     object value = mcm.GetArg(parameterInfo.Position);
     if (value != null) {
         switch (SqlType) {
         case SqlDbType.Xml:
             XmlReader reader = value as XmlReader;
             if (reader == null) {
                 XPathNavigator navigator = value as XPathNavigator;
                 if (navigator == null) {
                     IXPathNavigable navigable = value as IXPathNavigable;
                     if (navigable != null) {
                         navigator = navigable.CreateNavigator();
                     } else {
                         XNode node = value as XNode;
                         if (node != null) {
                             navigator = node.CreateNavigator();
                         }
                     }
                     if (navigator == null) {
                         throw new NotSupportedException(String.Format("XML could not be retrieved from value of type {0}.", value.GetType()));
                     }
                 }
                 reader = navigator.ReadSubtree();
                 disposeList.Add(reader);
             }
             value = new SqlXml(reader);
             break;
         case SqlDbType.SmallInt:
             IIdentifiable<short> identifiableShort = value as IIdentifiable<short>;
             if (identifiableShort != null) {
                 value = identifiableShort.Id;
             }
             break;
         case SqlDbType.Int:
             IIdentifiable<int> identifiableInt = value as IIdentifiable<int>;
             if (identifiableInt != null) {
                 value = identifiableInt.Id;
             }
             break;
         case SqlDbType.BigInt:
             IIdentifiable<long> identifiableLong = value as IIdentifiable<long>;
             if (identifiableLong != null) {
                 value = identifiableLong.Id;
             }
             break;
         case SqlDbType.UniqueIdentifier:
             IIdentifiable<Guid> identifiableGuid = value as IIdentifiable<Guid>;
             if (identifiableGuid != null) {
                 value = identifiableGuid.Id;
             }
             break;
             //				case SqlDbType.Udt:
             //					parameter.UdtTypeName = userDefinedTypeName;
             //					break;
         }
     }
     if (SqlType == SqlDbType.Structured) {
         IDataReader dataReader = new StructuredParameterReader(structuredSchema, (IEnumerable)value);
         disposeList.Add(dataReader);
         value = dataReader;
     }
     return value;
 }
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:64,代码来源:SqlCallParameterInfo.cs

示例8: HandleEventUnsubscription

        /// <summary>
        /// Handles unsubscription.
        /// </summary>
        /// <param name="methodCallMessage"><see cref="IMethodCallMessage"/> to process.</param>
        /// <param name="methodInfo"><see cref="MethodInfo"/> for the method being called.</param>
        /// <returns><see cref="ReturnMessage"/>, if the call is processed successfully, otherwise, false.</returns>
        private ReturnMessage HandleEventUnsubscription(IMethodCallMessage methodCallMessage, MethodInfo methodInfo)
        {
            if (methodInfo.ReturnType.Equals(typeof(void)) &&
                methodCallMessage.MethodName.StartsWith("remove_") &&
                methodCallMessage.InArgCount == 1 &&
                methodCallMessage.ArgCount == 1 &&
                methodCallMessage.Args[0] != null &&
                typeof(Delegate).IsAssignableFrom(methodCallMessage.Args[0].GetType()))
            {
                string propertyName = methodCallMessage.MethodName.Substring(7);
                var inputMessage = methodCallMessage.GetArg(0) as Delegate;
                var eventFilter = default(IEventFilter);

                // Detach event filter, if it is attached
                ExtractEventHandlerDetails(ref inputMessage, ref eventFilter);

                if (_delegateCorrelationSet.Count > 0)
                {
                    var found = (
                        from correlationInfo in _delegateCorrelationSet.ToArray()
                        where correlationInfo.DelegateMemberName.Equals(propertyName) && correlationInfo.ClientDelegateInterceptor.ClientDelegate.Equals(inputMessage)
                        select correlationInfo).FirstOrDefault();

                    if (found != null)
                    {
                        RemoveRemoteEventHandler(found);

                        // Remove delegate correlation info
                        _delegateCorrelationSet.Remove(found);
                    }
                }

                return new ReturnMessage(null, null, 0, methodCallMessage.LogicalCallContext, methodCallMessage);
            }

            // This method doesn't represent event subscription
            return null;
        }
开发者ID:yallie,项目名称:zyan,代码行数:44,代码来源:ZyanProxy.cs


注:本文中的IMethodCallMessage.GetArg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。