本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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())));
}
示例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);
}
示例14: GetTargetReferenceExpression
protected override Expression GetTargetReferenceExpression(ClassEmitter emitter)
{
Reference target = emitter.GetField("__target");
return (target ?? SelfReference.Self).ToExpression();
}
示例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);
}