本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.SimpleAST.ArgumentReference类的典型用法代码示例。如果您正苦于以下问题:C# ArgumentReference类的具体用法?C# ArgumentReference怎么用?C# ArgumentReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArgumentReference类属于Castle.DynamicProxy.Generators.Emitters.SimpleAST命名空间,在下文中一共展示了ArgumentReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InitializeArgumentsByPosition
public static void InitializeArgumentsByPosition(ArgumentReference[] args, bool isStatic)
{
int offset = isStatic ? 0 : 1;
for(int i = 0; i < args.Length; ++i)
{
args[i].Position = i + offset;
}
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:8,代码来源:ArgumentsUtil.cs
示例2: CreateConstructor
public ConstructorEmitter CreateConstructor(ArgumentReference[] baseCtorArguments, AbstractTypeEmitter invocation)
{
var arguments = GetArguments(baseCtorArguments);
var constructor = invocation.CreateConstructor(arguments);
var delegateField = invocation.CreateField("delegate", delegateType);
constructor.CodeBuilder.AddStatement(new AssignStatement(delegateField, new ReferenceExpression(arguments[0])));
return constructor;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:9,代码来源:InvocationWithDelegateContributor.cs
示例3: ConvertToArgumentReference
public static ArgumentReference[] ConvertToArgumentReference(Type[] args)
{
ArgumentReference[] arguments = new ArgumentReference[args.Length];
for(int i = 0; i < args.Length; ++i)
{
arguments[i] = new ArgumentReference(args[i]);
}
return arguments;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:11,代码来源:ArgumentsUtil.cs
示例4: ConvertArgumentReferenceToExpression
public static Expression[] ConvertArgumentReferenceToExpression(ArgumentReference[] args)
{
var expressions = new Expression[args.Length];
for (var i = 0; i < args.Length; ++i)
{
expressions[i] = args[i].ToExpression();
}
return expressions;
}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:11,代码来源:ArgumentsUtil.cs
示例5: ConvertToArgumentReference
public static ArgumentReference[] ConvertToArgumentReference(ParameterInfo[] args)
{
var arguments = new ArgumentReference[args.Length];
for (var i = 0; i < args.Length; ++i)
{
arguments[i] = new ArgumentReference(args[i].ParameterType);
}
return arguments;
}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:11,代码来源:ArgumentsUtil.cs
示例6: InitializeAndConvert
public static Type[] InitializeAndConvert(ArgumentReference[] args)
{
Type[] types = new Type[args.Length];
for(int i = 0; i < args.Length; ++i)
{
args[i].Position = i + 1;
types[i] = args[i].Type;
}
return types;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:ArgumentsUtil.cs
示例7: 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
示例8: CustomizeGetObjectData
protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference serializationInfo,
ArgumentReference streamingContext, ClassEmitter emitter)
{
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(
serializationInfo,
SerializationInfoMethods.AddValue_Bool,
new ConstReference("__delegateToBase").ToExpression(),
new ConstReference(delegateToBaseGetObjectData).
ToExpression())));
if (delegateToBaseGetObjectData == false)
{
EmitCustomGetObjectData(codebuilder, serializationInfo);
return;
}
EmitCallToBaseGetObjectData(codebuilder, serializationInfo, streamingContext);
}
开发者ID:dbroudy,项目名称:Castle.Core,代码行数:19,代码来源:ClassProxyInstanceContributor.cs
示例9: CustomizeGetObjectData
protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference serializationInfo, ArgumentReference streamingContext, ClassEmitter emitter)
{
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(serializationInfo, SerializationInfoMethods.AddValue_Bool,
new ConstReference("__delegateToBase").ToExpression(),
new ConstReference(delegateToBaseGetObjectData ? 1 : 0).
ToExpression())));
if (delegateToBaseGetObjectData)
{
MethodInfo baseGetObjectData = targetType.GetMethod("GetObjectData",
new[] {typeof (SerializationInfo), typeof (StreamingContext)});
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(baseGetObjectData,
serializationInfo.ToExpression(),
streamingContext.ToExpression())));
}
else
{
LocalReference members_ref = codebuilder.DeclareLocal(typeof (MemberInfo[]));
LocalReference data_ref = codebuilder.DeclareLocal(typeof (object[]));
codebuilder.AddStatement(new AssignStatement(members_ref,
new MethodInvocationExpression(null,
FormatterServicesMethods.
GetSerializableMembers,
new TypeTokenExpression(targetType))));
codebuilder.AddStatement(new AssignStatement(data_ref,
new MethodInvocationExpression(null,
FormatterServicesMethods.GetObjectData,
SelfReference.Self.ToExpression(),
members_ref.ToExpression())));
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(serializationInfo, SerializationInfoMethods.AddValue_Object,
new ConstReference("__data").ToExpression(),
data_ref.ToExpression())));
}
}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:41,代码来源:ClassProxyInstanceContributor.cs
示例10: ImplementGetObjectData
protected virtual void ImplementGetObjectData(ClassEmitter emitter, FieldReference interceptorsField,
Type[] interfaces)
{
if (interfaces == null)
{
interfaces = new Type[0];
}
Type[] get_type_args = new Type[] {typeof(String), typeof(bool), typeof(bool)};
Type[] key_and_object = new Type[] {typeof(String), typeof(Object)};
MethodInfo addValueMethod = typeof(SerializationInfo).GetMethod("AddValue", key_and_object);
ArgumentReference arg1 = new ArgumentReference(typeof(SerializationInfo));
ArgumentReference arg2 = new ArgumentReference(typeof(StreamingContext));
MethodEmitter getObjectData = emitter.CreateMethod("GetObjectData",
typeof(void), arg1, arg2);
LocalReference typeLocal = getObjectData.CodeBuilder.DeclareLocal(typeof(Type));
getObjectData.CodeBuilder.AddStatement(new AssignStatement(
typeLocal,
new MethodInvocationExpression(null,
typeof(Type).GetMethod("GetType",
get_type_args),
new ConstReference(
typeof(ProxyObjectReference).
AssemblyQualifiedName).ToExpression(),
new ConstReference(1).ToExpression(),
new ConstReference(0).ToExpression())));
getObjectData.CodeBuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(
arg1, typeof(SerializationInfo).GetMethod("SetType"),
typeLocal.ToExpression())));
getObjectData.CodeBuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(arg1, addValueMethod,
new ConstReference("__interceptors").
ToExpression(),
interceptorsField.ToExpression())));
LocalReference interfacesLocal =
getObjectData.CodeBuilder.DeclareLocal(typeof(String[]));
getObjectData.CodeBuilder.AddStatement(
new AssignStatement(interfacesLocal,
new NewArrayExpression(interfaces.Length, typeof(String))));
for(int i = 0; i < interfaces.Length; i++)
{
getObjectData.CodeBuilder.AddStatement(new AssignArrayStatement(
interfacesLocal, i,
new ConstReference(interfaces[i].AssemblyQualifiedName).ToExpression()));
}
getObjectData.CodeBuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(arg1, addValueMethod,
new ConstReference("__interfaces").
ToExpression(),
interfacesLocal.ToExpression())));
getObjectData.CodeBuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(arg1, addValueMethod,
new ConstReference("__baseType").
ToExpression(),
new ConstReference (emitter.BaseType.AssemblyQualifiedName).ToExpression())));
getObjectData.CodeBuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(arg1, addValueMethod,
new ConstReference("__proxyGenerationOptions").
ToExpression(),
proxyGenerationOptionsField.ToExpression())));
CustomizeGetObjectData(getObjectData.CodeBuilder, arg1, arg2);
getObjectData.CodeBuilder.AddStatement(new ReturnStatement());
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:77,代码来源:BaseProxyGenerator.cs
示例11: GetArguments
private ArgumentReference[] GetArguments(ArgumentReference[] baseCtorArguments)
{
var arguments = new ArgumentReference[baseCtorArguments.Length + 1];
arguments[0] = new ArgumentReference(delegateType);
baseCtorArguments.CopyTo(arguments, 1);
return arguments;
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:7,代码来源:InvocationWithDelegateContributor.cs
示例12: AssignArgumentStatement
public AssignArgumentStatement(ArgumentReference argument, Expression expression)
{
this.argument = argument;
this.expression = expression;
}
开发者ID:brianmatic,项目名称:n2cms,代码行数:5,代码来源:AssignArgumentStatement.cs
示例13: GenerateConstructor
protected void GenerateConstructor(ClassEmitter emitter, ConstructorInfo baseConstructor,
params FieldReference[] fields)
{
ArgumentReference[] args;
ParameterInfo[] baseConstructorParams = null;
if (baseConstructor != null)
{
baseConstructorParams = baseConstructor.GetParameters();
}
if (baseConstructorParams != null && baseConstructorParams.Length != 0)
{
args = new ArgumentReference[fields.Length + baseConstructorParams.Length];
var offset = fields.Length;
for (var i = offset; i < offset + baseConstructorParams.Length; i++)
{
var paramInfo = baseConstructorParams[i - offset];
args[i] = new ArgumentReference(paramInfo.ParameterType);
}
}
else
{
args = new ArgumentReference[fields.Length];
}
for (var i = 0; i < fields.Length; i++)
{
args[i] = new ArgumentReference(fields[i].Reference.FieldType);
}
var constructor = emitter.CreateConstructor(args);
if (baseConstructorParams != null && baseConstructorParams.Length != 0)
{
var last = baseConstructorParams.Last();
#if !NETFX_CORE
if (last.ParameterType.IsArray && last.HasAttribute<ParamArrayAttribute>())
#else
if (last.ParameterType.IsArray && ParameterInfoExtender.HasAttribute<ParamArrayAttribute>(last))
#endif
{
var parameter = constructor.ConstructorBuilder.DefineParameter(args.Length, ParameterAttributes.None, last.Name);
var builder = AttributeUtil.CreateBuilder<ParamArrayAttribute>();
parameter.SetCustomAttribute(builder);
}
}
for (var i = 0; i < fields.Length; i++)
{
constructor.CodeBuilder.AddStatement(new AssignStatement(fields[i], args[i].ToExpression()));
}
// Invoke base constructor
if (baseConstructor != null)
{
Debug.Assert(baseConstructorParams != null);
var slice = new ArgumentReference[baseConstructorParams.Length];
Array.Copy(args, fields.Length, slice, 0, baseConstructorParams.Length);
constructor.CodeBuilder.InvokeBaseConstructor(baseConstructor, slice);
}
else
{
constructor.CodeBuilder.InvokeBaseConstructor();
}
constructor.CodeBuilder.AddStatement(new ReturnStatement());
}
开发者ID:mbrit,项目名称:MoqForWinRT,代码行数:72,代码来源:BaseProxyGenerator.cs
示例14: CustomizeGetObjectData
protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder,
ArgumentReference arg1, ArgumentReference arg2)
{
Type[] key_and_object = new Type[] {typeof(String), typeof(Object)};
Type[] key_and_bool = new Type[] {typeof(String), typeof(bool)};
MethodInfo addValueMethod = typeof(SerializationInfo).GetMethod("AddValue", key_and_object);
MethodInfo addValueBoolMethod = typeof(SerializationInfo).GetMethod("AddValue", key_and_bool);
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(arg1, addValueBoolMethod,
new ConstReference("__delegateToBase").ToExpression(),
new ConstReference(delegateToBaseGetObjectData ? 1 : 0).
ToExpression())));
if (delegateToBaseGetObjectData)
{
MethodInfo baseGetObjectData = targetType.GetMethod("GetObjectData",
new Type[] {typeof(SerializationInfo), typeof(StreamingContext)});
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(baseGetObjectData,
arg1.ToExpression(), arg2.ToExpression())));
}
else
{
LocalReference members_ref = codebuilder.DeclareLocal(typeof(MemberInfo[]));
LocalReference data_ref = codebuilder.DeclareLocal(typeof(object[]));
MethodInfo getSerMembers = typeof(FormatterServices).GetMethod("GetSerializableMembers",
new Type[] {typeof(Type)});
MethodInfo getObjData = typeof(FormatterServices).GetMethod("GetObjectData",
new Type[] {typeof(object), typeof(MemberInfo[])});
codebuilder.AddStatement(new AssignStatement(members_ref,
new MethodInvocationExpression(null, getSerMembers,
new TypeTokenExpression(targetType))));
codebuilder.AddStatement(new AssignStatement(data_ref,
new MethodInvocationExpression(null, getObjData,
SelfReference.Self.ToExpression(),
members_ref.ToExpression())));
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(arg1, addValueMethod,
new ConstReference("__data").ToExpression(),
data_ref.ToExpression())));
}
}
开发者ID:havard,项目名称:strongbind,代码行数:48,代码来源:ClassProxyGenerator.cs
示例15: AddAddValueInvocation
protected virtual void AddAddValueInvocation(ArgumentReference serializationInfo, MethodEmitter getObjectData,
FieldReference field)
{
getObjectData.CodeBuilder.AddStatement(
new ExpressionStatement(
new MethodInvocationExpression(
serializationInfo,
SerializationInfoMethods.AddValue_Object,
new ConstReference(field.Reference.Name).ToExpression(),
field.ToExpression())));
return;
}
开发者ID:textmetal,项目名称:main,代码行数:12,代码来源:ProxyInstanceContributor.cs
示例16: CustomizeGetObjectData
protected virtual void CustomizeGetObjectData(
AbstractCodeBuilder codebuilder, ArgumentReference arg1,
ArgumentReference arg2)
{
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:5,代码来源:BaseProxyGenerator.cs
示例17: GenerateSerializationConstructor
protected void GenerateSerializationConstructor(ClassEmitter emitter, FieldReference interceptorField,
bool delegateToBaseGetObjectData)
{
ArgumentReference arg1 = new ArgumentReference(typeof(SerializationInfo));
ArgumentReference arg2 = new ArgumentReference(typeof(StreamingContext));
ConstructorEmitter constr = emitter.CreateConstructor(arg1, arg2);
constr.CodeBuilder.AddStatement(
new ConstructorInvocationStatement(serializationConstructor,
arg1.ToExpression(), arg2.ToExpression()));
Type[] object_arg = new Type[] {typeof(String), typeof(Type)};
MethodInfo getValueMethod = typeof(SerializationInfo).GetMethod("GetValue", object_arg);
MethodInvocationExpression getInterceptorInvocation =
new MethodInvocationExpression(arg1, getValueMethod,
new ConstReference("__interceptors").ToExpression(),
new TypeTokenExpression(typeof(IInterceptor[])));
constr.CodeBuilder.AddStatement(new AssignStatement(
interceptorField,
new ConvertExpression(typeof(IInterceptor[]), typeof(object),
getInterceptorInvocation)));
constr.CodeBuilder.AddStatement(new ReturnStatement());
}
开发者ID:havard,项目名称:strongbind,代码行数:27,代码来源:ClassProxyGenerator.cs
示例18: GenerateSerializationConstructor
private void GenerateSerializationConstructor(ClassEmitter emitter)
{
var serializationInfo = new ArgumentReference(typeof(SerializationInfo));
var streamingContext = new ArgumentReference(typeof(StreamingContext));
var ctor = emitter.CreateConstructor(serializationInfo, streamingContext);
ctor.CodeBuilder.AddStatement(
new ConstructorInvocationStatement(serializationConstructor,
serializationInfo.ToExpression(),
streamingContext.ToExpression()));
foreach (var field in serializedFields)
{
var getValue = new MethodInvocationExpression(serializationInfo,
SerializationInfoMethods.GetValue,
new ConstReference(field.Reference.Name).ToExpression(),
new TypeTokenExpression(field.Reference.FieldType));
ctor.CodeBuilder.AddStatement(new AssignStatement(
field,
new ConvertExpression(field.Reference.FieldType,
typeof(object),
getValue)));
}
ctor.CodeBuilder.AddStatement(new ReturnStatement());
}
开发者ID:dbroudy,项目名称:Castle.Core,代码行数:26,代码来源:ClassProxyInstanceContributor.cs
示例19: BuildInvocationNestedType
/// <summary>
/// If callbackMethod is null the InvokeOnTarget implementation
/// is just the code to throw an exception
/// </summary>
/// <param name="emitter"></param>
/// <param name="targetType"></param>
/// <param name="targetForInvocation"></param>
/// <param name="methodInfo"></param>
/// <param name="callbackMethod"></param>
/// <param name="version"></param>
/// <param name="allowChangeTarget">If true the invocation will implement the IChangeProxyTarget interface</param>
/// <returns></returns>
protected NestedClassEmitter BuildInvocationNestedType(
ClassEmitter emitter,
Type targetType,
Type targetForInvocation,
MethodInfo methodInfo,
MethodInfo callbackMethod,
ConstructorVersion version,
bool allowChangeTarget)
{
CheckNotGenericTypeDefinition(targetType, "targetType");
CheckNotGenericTypeDefinition(targetForInvocation, "targetForInvocation");
nestedCounter++;
Type[] interfaces = new Type[0];
if (allowChangeTarget)
{
interfaces = new Type[] {typeof(IChangeProxyTarget)};
}
NestedClassEmitter nested =
new NestedClassEmitter(emitter,
"Invocation" + methodInfo.Name + "_" + nestedCounter.ToString(),
typeof(AbstractInvocation),
interfaces);
// invocation only needs to mirror the generic parameters of the MethodInfo
// targetType cannot be a generic type definition
nested.CreateGenericParameters(methodInfo.GetGenericArguments());
// Create the invocation fields
FieldReference targetRef = nested.CreateField("target", targetForInvocation);
// Create constructor
CreateIInvocationConstructor(targetForInvocation, nested, targetRef, version);
if (allowChangeTarget)
{
ArgumentReference argument1 = new ArgumentReference(typeof(object));
MethodEmitter methodEmitter =
nested.CreateMethod("ChangeInvocationTarget", MethodAttributes.Public | MethodAttributes.Virtual,
typeof(void), argument1);
methodEmitter.CodeBuilder.AddStatement(
new AssignStatement(targetRef,
new ConvertExpression(targetType, argument1.ToExpression())
)
);
methodEmitter.CodeBuilder.AddStatement(new ReturnStatement());
}
// InvokeMethodOnTarget implementation
if (callbackMethod != null)
{
ParameterInfo[] parameters = methodInfo.GetParameters();
CreateIInvocationInvokeOnTarget(emitter, nested, parameters, targetRef, callbackMethod);
}
else
{
CreateEmptyIInvocationInvokeOnTarget(nested);
}
nested.DefineCustomAttribute(new SerializableAttribute());
return nested;
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:82,代码来源:BaseProxyGenerator.cs
示例20: EmitCallToBaseGetObjectData
private void EmitCallToBaseGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference serializationInfo,
ArgumentReference streamingContext)
{
var baseGetObjectData = targetType.GetMethod("GetObjectData",
new[] { typeof(SerializationInfo), typeof(StreamingContext) });
codebuilder.AddStatement(new ExpressionStatement(
new MethodInvocationExpression(baseGetObjectData,
serializationInfo.ToExpression(),
streamingContext.ToExpression())));
}
开发者ID:dbroudy,项目名称:Castle.Core,代码行数:11,代码来源:ClassProxyInstanceContributor.cs
注:本文中的Castle.DynamicProxy.Generators.Emitters.SimpleAST.ArgumentReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论