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


C# ClassEmitter.GetField方法代码示例

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


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

示例1: GetMethodGenerator

		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class,
		                                                      ProxyGenerationOptions options,
		                                                      OverrideMethodDelegate overrideMethod)
		{
			if (!method.Proxyable)
			{
				return new ForwardingMethodGenerator(method,
				                                     overrideMethod,
				                                     (c, m) => c.GetField("__target"));
			}

			var targetMethod = options.ProxyEffectiveType == null ? method.Method : InvocationHelper.GetMethodOnType(proxyTargetType, method.Method);

			if (targetMethod == null)
			{
				return new MinimialisticMethodGenerator(method, overrideMethod);
			}

			var invocation = GetInvocationType(method, targetMethod, @class, options);

			return new MethodWithInvocationGenerator(method,
			                                         @class.GetField("__interceptors"),
			                                         invocation,
			                                         (c, m) => c.GetField("__target").ToExpression(),
			                                         overrideMethod,
			                                         null);
		}
开发者ID:evoxmusic,项目名称:Castle.Core,代码行数:27,代码来源:InterfaceProxyTargetContributor.cs

示例2: GetMethodGenerator

		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class,
		                                                      ProxyGenerationOptions options,
		                                                      OverrideMethodDelegate overrideMethod)
		{
			if (methodsToSkip.Contains(method.Method))
				return null;

			if (!method.Proxyable)
			{
				return new MinimialisticMethodGenerator(method,
				                                        overrideMethod);
			}

			if (ExplicitlyImplementedInterfaceMethod(method))
			{
#if SILVERLIGHT
				return null;
#else
				return ExplicitlyImplementedInterfaceMethodGenerator(method, @class, options, overrideMethod);
#endif
			}

			var invocation = GetInvocationType(method, @class, options);

			return new MethodWithInvocationGenerator(method,
			                                         @class.GetField("__interceptors"),
			                                         invocation,
			                                         (c, m) => new TypeTokenExpression(targetType),
			                                         overrideMethod,
			                                         null);
		}
开发者ID:n2cms,项目名称:Castle.Core,代码行数:31,代码来源:ClassProxyTargetContributor.cs

示例3: GetMethodGenerator

		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class,
		                                                      ProxyGenerationOptions options,
		                                                      OverrideMethodDelegate overrideMethod)
		{
			if (methodsToSkip.Contains(method.Method))
			{
				return null;
			}

			if (!method.Proxyable)
			{
				return new MinimialisticMethodGenerator(method,
				                                        overrideMethod);
			}

			if (IsDirectlyAccessible(method) == false)
			{
				return IndirectlyCalledMethodGenerator(method, @class, options, overrideMethod);
			}

			var invocation = GetInvocationType(method, @class, options);

			return new MethodWithInvocationGenerator(method,
			                                         @class.GetField("__interceptors"),
			                                         invocation,
			                                         (c, m) => c.GetField("__target").ToExpression(),
			                                         overrideMethod,
			                                         null);
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:29,代码来源:ClassProxyWithTargetTargetContributor.cs

示例4: GetMethodGenerator

		// 重载 InterfaceProxyWithTargetInterfaceContributor 中的方法,以指定使用扩展的 InvocationType 生成方法执行类
		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod)
		{
			if (!method.Proxyable)
			{
				return new MinimialisticMethodGenerator(method, overrideMethod);
			}
			return new MethodWithInvocationGenerator(method, @class.GetField("__interceptors"), this.GetInvocationType(method, @class, options), this.getTargetExpression, overrideMethod, null);
		}
开发者ID:Kjubo,项目名称:xms.core,代码行数:9,代码来源:WCFInterfaceProxyWithTargetInterfaceTargetContributor.cs

示例5: Generate

 /// <summary>
 /// Generates the class defined by the provided class emitter.
 /// </summary>
 /// <param name="class">
 /// The <see cref="Castle.DynamicProxy.Generators.Emitters.ClassEmitter"/>
 /// being used to build the target type.
 /// </param>
 /// <param name="options">The options to use during proxy generation.</param>
 /// <exception cref="System.ArgumentNullException">
 /// Thrown if <paramref name="class" /> is <see langword="null" />.
 /// </exception>
 /// <remarks>
 /// <para>
 /// This overridden version of the method does everything that the base
 /// <see cref="Castle.DynamicProxy.Contributors.ProxyInstanceContributor.Generate"/>
 /// method does but it skips the part where it checks for non-inherited
 /// attributes and copies them over from the proxy target.
 /// </para>
 /// </remarks>
 public override void Generate(ClassEmitter @class, ProxyGenerationOptions options)
 {
     if (@class == null)
     {
         throw new ArgumentNullException("class");
     }
     FieldReference field = @class.GetField("__interceptors");
     this.ImplementGetObjectData(@class);
     this.ImplementProxyTargetAccessor(@class, field);
 }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:29,代码来源:IgnoreAttributeInterfaceProxyInstanceContributor.cs

示例6: Generate

		public virtual void Generate(ClassEmitter @class, ProxyGenerationOptions options)
		{
			var interceptors = @class.GetField("__interceptors");
#if FEATURE_SERIALIZATION
			ImplementGetObjectData(@class);
#endif
			ImplementProxyTargetAccessor(@class, interceptors);
			foreach (var attribute in targetType.GetTypeInfo().GetNonInheritableAttributes())
			{
				@class.DefineCustomAttribute(attribute.Builder);
			}
		}
开发者ID:textmetal,项目名称:main,代码行数:12,代码来源:ProxyInstanceContributor.cs

示例7: CreateFields

        protected override void CreateFields(ClassEmitter emitter)
        {
            base.CreateFields(emitter);

            var interceptorsField = emitter.GetField(InterceptorsFieldName);
            if (interceptorsField != null)
            {
                emitter.DefineCustomAttributeFor<IgnoreDataMemberAttribute>(interceptorsField);

                CreateMetadataProperty(emitter, interceptorsField);
            }
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:12,代码来源:DocumentProxyGenerator.cs

示例8: Generate

		public virtual void Generate(ClassEmitter @class, ProxyGenerationOptions options)
		{
			var interceptors = @class.GetField("__interceptors");
#if !SILVERLIGHT
			ImplementGetObjectData(@class);
#endif
			ImplementProxyTargetAccessor(@class, interceptors);
			foreach (var attribute in targetType.GetNonInheritableAttributes())
			{
				@class.DefineCustomAttribute(attribute);
			}
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:12,代码来源:ProxyInstanceContributor.cs

示例9: GetMethodGenerator

		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class,
		                                                      ProxyGenerationOptions options,
		                                                      OverrideMethodDelegate overrideMethod)
		{
			var invocation = GetInvocationType(method, @class, options);
			return new MethodWithInvocationGenerator(method,
			                                         @class.GetField("__interceptors"),
			                                         invocation,
			                                         (c, m) => c.GetField("__target").ToExpression(),
			                                         overrideMethod,
			                                         null);
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:12,代码来源:DelegateProxyTargetContributor.cs

示例10: GetMethodGenerator

		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class, ProxyGenerationOptions options, CreateMethodDelegate createMethod)
		{
			if (!method.Proxyable)
			{
				return new MinimialisticMethodGenerator(method,
														createMethod);
			}

			var invocation = GetInvocationType(method, @class, options);
			return new MethodWithInvocationGenerator(method,
													 @class.GetField("__interceptors"),
													 invocation,
													 getTargetExpression,
													 createMethod);
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:15,代码来源:InterfaceProxyWithoutTargetContributor.cs

示例11: Generate

		public override void Generate(ClassEmitter @class, ProxyGenerationOptions options)
		{
			var interceptors = @class.GetField("__interceptors");
#if FEATURE_SERIALIZATION
			if (implementISerializable)
			{
				ImplementGetObjectData(@class);
				Constructor(@class);
			}
#endif
			ImplementProxyTargetAccessor(@class, interceptors);
			foreach (var attribute in targetType.GetNonInheritableAttributes())
			{
				@class.DefineCustomAttribute(attribute);
			}
		}
开发者ID:elevine,项目名称:Core,代码行数:16,代码来源:ClassProxyInstanceContributor.cs

示例12: CustomizeGetObjectData

		protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference serializationInfo, ArgumentReference streamingContext, ClassEmitter emitter)
		{
			var targetField = emitter.GetField("__target");

			codebuilder.AddStatement(new ExpressionStatement(
			                         	new MethodInvocationExpression(serializationInfo, SerializationInfoMethods.AddValue_Object,
			                         	                               new ConstReference("__targetFieldType").ToExpression(),
			                         	                               new ConstReference(
			                         	                               	targetField.Reference.FieldType.AssemblyQualifiedName).
			                         	                               	ToExpression())));

			codebuilder.AddStatement(new ExpressionStatement(
			                         	new MethodInvocationExpression(serializationInfo, SerializationInfoMethods.AddValue_Object,
			                         	                               new ConstReference("__theInterface").ToExpression(),
			                         	                               new ConstReference(targetType.AssemblyQualifiedName).
			                         	                               	ToExpression())));
		}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:17,代码来源:InterfaceProxyInstanceContributor.cs

示例13: GetMethodGenerator

		protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class, ProxyGenerationOptions options, CreateMethodDelegate createMethod)
		{
			if (methodsToSkip.Contains(method.Method)) return null;

			if (!method.Proxyable)
			{
				return new MinimialisticMethodGenerator(method,
				                                        createMethod);
			}

			var invocation = GetInvocationType(method, @class, options);

			return new MethodWithInvocationGenerator(method,
			                                         @class.GetField("__interceptors"),
			                                         invocation,
			                                         (c, m) => new TypeTokenExpression(targetType),
			                                         createMethod);
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:18,代码来源:ClassProxyTargetContributor.cs

示例14: GetTargetReferenceExpression

		protected override Expression GetTargetReferenceExpression(ClassEmitter emitter)
		{
			Reference target = emitter.GetField("__target");
			return (target ?? SelfReference.Self).ToExpression();
		}
开发者ID:evoxmusic,项目名称:Castle.Core,代码行数:5,代码来源:ClassProxyInstanceContributor.cs

示例15: ExplicitlyImplementedInterfaceMethodGenerator

		private MethodGenerator ExplicitlyImplementedInterfaceMethodGenerator(MetaMethod method, ClassEmitter @class,
		                                                                      ProxyGenerationOptions options,
		                                                                      OverrideMethodDelegate overrideMethod)
		{
			var @delegate = GetDelegateType(method, @class, options);
			var contributor = GetContributor(@delegate, method);
			var invocation = new InheritanceInvocationTypeGenerator(targetType, method, null, contributor)
				.Generate(@class, options, namingScope)
				.BuildType();
			return new MethodWithInvocationGenerator(method,
			                                             @class.GetField("__interceptors"),
			                                             invocation,
			                                             (c, m) => new TypeTokenExpression(targetType),
			                                             overrideMethod,
			                                             contributor);
		}
开发者ID:n2cms,项目名称:Castle.Core,代码行数:16,代码来源:ClassProxyTargetContributor.cs


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