本文整理汇总了C#中ProxyGenerationOptions类的典型用法代码示例。如果您正苦于以下问题:C# ProxyGenerationOptions类的具体用法?C# ProxyGenerationOptions怎么用?C# ProxyGenerationOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxyGenerationOptions类属于命名空间,在下文中一共展示了ProxyGenerationOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetCtorArgumentsAndBaseCtorToCall
protected override ArgumentReference[] GetCtorArgumentsAndBaseCtorToCall(Type targetFieldType, ProxyGenerationOptions proxyGenerationOptions,out ConstructorInfo baseConstructor)
{
if (proxyGenerationOptions.Selector == null)
{
baseConstructor = InvocationMethods.CompositionInvocationConstructorNoSelector;
return new[]
{
new ArgumentReference(targetFieldType),
new ArgumentReference(typeof(object)),
new ArgumentReference(typeof(IInterceptor[])),
new ArgumentReference(typeof(MethodInfo)),
new ArgumentReference(typeof(object[])),
};
}
baseConstructor = InvocationMethods.CompositionInvocationConstructorWithSelector;
return new[]
{
new ArgumentReference(targetFieldType),
new ArgumentReference(typeof(object)),
new ArgumentReference(typeof(IInterceptor[])),
new ArgumentReference(typeof(MethodInfo)),
new ArgumentReference(typeof(object[])),
new ArgumentReference(typeof(IInterceptorSelector)),
new ArgumentReference(typeof(IInterceptor[]).MakeByRefType())
};
}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:27,代码来源:InterfaceInvocationTypeGenerator.cs
示例2: 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
示例3: CacheKey
/// <summary>
/// Initializes a new instance of the <see cref = "CacheKey" /> class.
/// </summary>
/// <param name = "target">Target element. This is either target type or target method for invocation types.</param>
/// <param name = "type">The type of the proxy. This is base type for invocation types.</param>
/// <param name = "interfaces">The interfaces.</param>
/// <param name = "options">The options.</param>
private CacheKey(MemberWrapper target, Type type, Type[] interfaces, ProxyGenerationOptions options)
{
this.target = target;
this.type = type;
this.interfaces = interfaces ?? TypeExtender.EmptyTypes;
this.options = options;
}
开发者ID:rajgit31,项目名称:MetroUnitTestsDemoApp,代码行数:14,代码来源:CacheKey.cs
示例4: 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
示例5: GetFieldInterceptionProxy
/// <summary>
/// Returns a proxy capable of field interception.
/// </summary>
/// <returns></returns>
public override object GetFieldInterceptionProxy()
{
var proxyGenerationOptions = new ProxyGenerationOptions();
var interceptor = new LazyFieldInterceptor();
proxyGenerationOptions.AddMixinInstance(interceptor);
return ProxyGenerator.CreateClassProxy(PersistentClass, proxyGenerationOptions, interceptor);
}
开发者ID:oillio,项目名称:Castle.ActiveRecord,代码行数:11,代码来源:ProxyFactory.cs
示例6: GetInvocationType
private Type GetInvocationType(MetaMethod method, ClassEmitter @class, ProxyGenerationOptions options)
{
var scope = @class.ModuleScope;
Type[] invocationInterfaces;
if (canChangeTarget)
{
invocationInterfaces = new[] { typeof(IInvocation), typeof(IChangeProxyTarget) };
}
else
{
invocationInterfaces = new[] { typeof(IInvocation) };
}
var key = new CacheKey(method.Method, CompositionInvocationTypeGenerator.BaseType, invocationInterfaces, null);
// no locking required as we're already within a lock
var invocation = scope.GetFromCache(key);
if (invocation != null)
{
return invocation;
}
invocation = new CompositionInvocationTypeGenerator(method.Method.DeclaringType,
method,
method.Method,
canChangeTarget,
null)
.Generate(@class, options, namingScope).BuildType();
scope.RegisterInCache(key, invocation);
return invocation;
}
开发者ID:ArthurYiL,项目名称:JustMockLite,代码行数:35,代码来源:InterfaceProxyTargetContributor.cs
示例7: Generate
public virtual void Generate(ClassEmitter @class, ProxyGenerationOptions options)
{
foreach (var method in methods)
{
if (!method.Standalone)
{
continue;
}
ImplementMethod(method,
@class,
options,
@class.CreateMethod);
}
foreach (var property in properties)
{
ImplementProperty(@class, property, options);
}
foreach (var @event in events)
{
ImplementEvent(@class, @event, options);
}
}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:25,代码来源:CompositeTypeContributor.cs
示例8: CacheKey
/// <summary>
/// Initializes a new instance of the <see cref = "CacheKey" /> class.
/// </summary>
/// <param name = "target">Target element. This is either target type or target method for invocation types.</param>
/// <param name = "type">The type of the proxy. This is base type for invocation types.</param>
/// <param name = "interfaces">The interfaces.</param>
/// <param name = "options">The options.</param>
public CacheKey(MemberInfo target, Type type, Type[] interfaces, ProxyGenerationOptions options)
{
this.target = target;
this.type = type;
this.interfaces = interfaces ?? Type.EmptyTypes;
this.options = options;
}
开发者ID:AndreKraemer,项目名称:Castle.Core,代码行数:14,代码来源:CacheKey.cs
示例9: 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
示例10: SetGenerationOptions
protected void SetGenerationOptions (ProxyGenerationOptions options)
{
if (proxyGenerationOptions != null)
{
throw new InvalidOperationException ("ProxyGenerationOptions can only be set once.");
}
proxyGenerationOptions = options;
}
开发者ID:ray2006,项目名称:WCell,代码行数:8,代码来源:BaseProxyGenerator.cs
示例11: On_interfaces
public void On_interfaces()
{
ProxyGenerationOptions options = new ProxyGenerationOptions();
options.AttributesToAddToGeneratedTypes.Add(new __Protect());
object proxy = new ProxyGenerator().CreateInterfaceProxyWithoutTarget(typeof(IDisposable), new Type[0], options);
Assert.IsTrue(proxy.GetType().IsDefined(typeof(__Protect), false));
}
开发者ID:ralescano,项目名称:castle,代码行数:9,代码来源:CanDefineAdditionalCustomAttributes.cs
示例12: On_class
public void On_class()
{
var options = new ProxyGenerationOptions();
options.AdditionalAttributes.Add(AttributeUtil.CreateInfo<__Protect>());
var proxy = generator.CreateClassProxy(typeof(CanDefineAdditionalCustomAttributes), options);
Assert.IsTrue(proxy.GetType().GetTypeInfo().IsDefined(typeof(__Protect), false));
}
开发者ID:castleproject,项目名称:Core,代码行数:9,代码来源:CanDefineAdditionalCustomAttributes.cs
示例13: On_interfaces
public void On_interfaces()
{
var options = new ProxyGenerationOptions();
options.AdditionalAttributes.Add(AttributeUtil.CreateInfo<__Protect>());
var proxy = generator.CreateInterfaceProxyWithoutTarget(typeof(IDisposable), new Type[0], options);
Assert.IsTrue(proxy.GetType().GetTypeInfo().IsDefined(typeof(__Protect), false));
}
开发者ID:castleproject,项目名称:Core,代码行数:9,代码来源:CanDefineAdditionalCustomAttributes.cs
示例14: SetGenerationOptions
protected void SetGenerationOptions (ProxyGenerationOptions options, ClassEmitter emitter)
{
if (proxyGenerationOptions != null)
{
throw new InvalidOperationException ("ProxyGenerationOptions can only be set once.");
}
proxyGenerationOptions = options;
proxyGenerationOptionsField = emitter.CreateStaticField ("proxyGenerationOptions", typeof (ProxyGenerationOptions));
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:9,代码来源:BaseProxyGenerator.cs
示例15: Generate
public virtual void Generate(ClassEmitter @class, ProxyGenerationOptions options)
{
var interceptors = @class.GetField("__interceptors");
ImplementProxyTargetAccessor(@class, interceptors);
foreach (var attribute in targetType.GetNonInheritableAttributes())
{
@class.DefineCustomAttribute(attribute);
}
}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:9,代码来源:ProxyInstanceContributor.cs
示例16: On_class
public void On_class()
{
ProxyGenerationOptions options = new ProxyGenerationOptions();
options.AttributesToAddToGeneratedTypes.Add(new __Protect());
object proxy = new ProxyGenerator().CreateClassProxy(typeof(CanDefineAdditionalCustomAttributes), options);
Assert.IsTrue(proxy.GetType().IsDefined(typeof(__Protect), false));
}
开发者ID:ralescano,项目名称:castle,代码行数:9,代码来源:CanDefineAdditionalCustomAttributes.cs
示例17: BuildProxiedMethodBody
protected override MethodEmitter BuildProxiedMethodBody(MethodEmitter emitter, ClassEmitter @class,
ProxyGenerationOptions options, INamingScope namingScope)
{
var targetReference = getTargetReference(@class, MethodToOverride);
emitter.CodeBuilder.AddStatement(
new ExpressionStatement(
new IfNullExpression(targetReference, IfNull(emitter.ReturnType), IfNotNull(targetReference))));
return emitter;
}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:10,代码来源:OptionallyForwardingMethodGenerator.cs
示例18: Mixin_methods_should_be_forwarded_to_target_if_implements_mixin_interface
public void Mixin_methods_should_be_forwarded_to_target_if_implements_mixin_interface()
{
var options = new ProxyGenerationOptions();
options.AddMixinInstance(new Two());
var proxy = generator.CreateInterfaceProxyWithTargetInterface(typeof(IOne),
new OneTwo(),
options);
var result = (proxy as ITwo).TwoMethod();
Assert.AreEqual(2, result);
}
开发者ID:gitter-badger,项目名称:Core-8,代码行数:10,代码来源:InterfaceProxyWithTargetInterfaceTestCase.cs
示例19: GetMethodGenerator
protected override MethodGenerator GetMethodGenerator(MetaMethod method, ClassEmitter @class,
ProxyGenerationOptions options,
OverrideMethodDelegate overrideMethod)
{
if (!method.Proxyable)
{
return new OptionallyForwardingMethodGenerator(method, overrideMethod, getTargetReference);
}
return base.GetMethodGenerator(method, @class, options, overrideMethod);
}
开发者ID:Biswo,项目名称:n2cms,代码行数:11,代码来源:InterfaceProxyWithOptionalTargetContributor.cs
示例20: GenerateCode
public Type GenerateCode(Type[] interfaces, ProxyGenerationOptions options)
{
// make sure ProxyGenerationOptions is initialized
options.Initialize();
interfaces = TypeUtil.GetAllInterfaces(interfaces);
CheckNotGenericTypeDefinitions(interfaces, "interfaces");
ProxyGenerationOptions = options;
var cacheKey = new CacheKey(targetType, interfaces, options);
return ObtainProxyType(cacheKey, (n, s) => GenerateType(n, interfaces, s));
}
开发者ID:elevine,项目名称:Core,代码行数:11,代码来源:ClassProxyGenerator.cs
注:本文中的ProxyGenerationOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论