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


C# MethodBase.Equals方法代码示例

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


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

示例1: Invoke

		/// <summary>
		/// Invokes the method if this is something that the LazyInitializer can handle
		/// without the underlying proxied object being instantiated.
		/// </summary>
		/// <param name="method">The name of the method/property to Invoke.</param>
		/// <param name="args">The arguments to pass the method/property.</param>
		/// <param name="proxy">The proxy object that the method is being invoked on.</param>
		/// <returns>
		/// The result of the Invoke if the underlying proxied object is not needed.  If the 
		/// underlying proxied object is needed then it returns the result <see cref="InvokeImplementation"/>
		/// which indicates that the Proxy will need to forward to the real implementation.
		/// </returns>
		public virtual object Invoke(MethodBase method, object[] args, object proxy)
		{
			string methodName = method.Name;
			int paramCount = method.GetParameters().Length;

			if (paramCount == 0)
			{
				if (!_overridesEquals && methodName == "GetHashCode")
				{
					return IdentityHashCodeProvider.GetHashCode(proxy);
				}
				else if (method.Equals(_getIdentifierMethod))
				{
					return _id;
				}
				else if (methodName == "Finalize")
				{
					return null;
				}
			}
			else if (paramCount == 1)
			{
				if (!_overridesEquals && methodName == "Equals")
				{
					return args[0] == proxy;
				}
				else if (method.Equals(_setIdentifierMethod))
				{
					Initialize();
					_id = args[0];
					return InvokeImplementation;
				}
			}
			else if (paramCount == 2)
			{
				// if the Proxy Engine delegates the call of GetObjectData to the Initializer
				// then we need to handle it.  Castle.DynamicProxy takes care of serializing
				// proxies for us, but other providers might not.
				if (methodName == "GetObjectData")
				{
					SerializationInfo info = (SerializationInfo) args[0];
					StreamingContext context = (StreamingContext) args[1]; // not used !?!

					if (_target == null & _session != null)
					{
						EntityKey key = new EntityKey(_id, _session.Factory.GetEntityPersister(_persistentClass));
						_target = _session.GetEntity(key);
					}

					// let the specific LazyInitializer write its requirements for deserialization 
					// into the stream.
					AddSerializationInfo(info, context);

					// don't need a return value for proxy.
					return null;
				}
			}

			return InvokeImplementation;
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:72,代码来源:LazyInitializer.cs

示例2: Invoke

		/// <summary>
		/// Invokes the method if this is something that the LazyInitializer can handle
		/// without the underlying proxied object being instantiated.
		/// </summary>
		/// <param name="method">The name of the method/property to Invoke.</param>
		/// <param name="args">The arguments to pass the method/property.</param>
		/// <param name="proxy">The proxy object that the method is being invoked on.</param>
		/// <returns>
		/// The result of the Invoke if the underlying proxied object is not needed.  If the 
		/// underlying proxied object is needed then it returns the result <see cref="AbstractLazyInitializer.InvokeImplementation"/>
		/// which indicates that the Proxy will need to forward to the real implementation.
		/// </returns>
		public virtual object Invoke(MethodBase method, object[] args, object proxy)
		{
			string methodName = method.Name;
			int paramCount = method.GetParameters().Length;

			if (paramCount == 0)
			{
				if (!overridesEquals && methodName == "GetHashCode")
				{
					return IdentityEqualityComparer.GetHashCode(proxy);
				}
				else if (IsUninitialized && method.Equals(getIdentifierMethod))
				{
					return Identifier;
				}
				else if (methodName == "Finalize")
				{
					return null;
				}
				else if ("get_HibernateLazyInitializer".Equals(methodName))
				{
					return this;
				}
			}
			else if (paramCount == 1)
			{
				if (!overridesEquals && methodName == "Equals")
				{
					return IdentityEqualityComparer.Equals(args[0], proxy);
				}
				else if (method.Equals(setIdentifierMethod))
				{
					Initialize();
					Identifier = args[0];
					return InvokeImplementation;
				}
			}
			else if (paramCount == 2)
			{
				// if the Proxy Engine delegates the call of GetObjectData to the Initializer
				// then we need to handle it.  Castle.DynamicProxy takes care of serializing
				// proxies for us, but other providers might not.
				if (methodName == "GetObjectData")
				{
					SerializationInfo info = (SerializationInfo)args[0];
					StreamingContext context = (StreamingContext)args[1]; // not used !?!

					if (Target == null & Session != null)
					{
						EntityKey key = new EntityKey(Identifier, Session.Factory.GetEntityPersister(EntityName), Session.EntityMode);
						object entity = Session.PersistenceContext.GetEntity(key);
						if (entity != null)
							SetImplementation(entity);
					}

					// let the specific ILazyInitializer write its requirements for deserialization 
					// into the stream.
					AddSerializationInfo(info, context);

					// don't need a return value for proxy.
					return null;
				}
			}

			//if it is a property of an embedded component, invoke on the "identifier"
			if (componentIdType != null && componentIdType.IsMethodOf(method))
			{
				return method.Invoke(Identifier, args);
			}

			return InvokeImplementation;
		}
开发者ID:pallmall,项目名称:WCell,代码行数:84,代码来源:BasicLazyInitializer.cs


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