本文整理汇总了C#中IKVM.Reflection.Type.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Type.CopyTo方法的具体用法?C# Type.CopyTo怎么用?C# Type.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM.Reflection.Type
的用法示例。
在下文中一共展示了Type.CopyTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishProperties
private void PublishProperties(TypeBuilder typeBuilder, IKVM.Internal.MapXml.Class clazz)
{
foreach(IKVM.Internal.MapXml.Property prop in clazz.Properties)
{
TypeWrapper typeWrapper = GetClassLoader().RetTypeWrapperFromSigNoThrow(prop.Sig);
TypeWrapper[] propargs = GetClassLoader().ArgTypeWrapperListFromSigNoThrow(prop.Sig);
Type[] indexer = new Type[propargs.Length];
for(int i = 0; i < propargs.Length; i++)
{
indexer[i] = propargs[i].TypeAsSignatureType;
}
PropertyBuilder propbuilder = typeBuilder.DefineProperty(prop.Name, PropertyAttributes.None, typeWrapper.TypeAsSignatureType, indexer);
AttributeHelper.HideFromJava(propbuilder);
if(prop.Attributes != null)
{
foreach(IKVM.Internal.MapXml.Attribute attr in prop.Attributes)
{
AttributeHelper.SetCustomAttribute(classLoader, propbuilder, attr);
}
}
MethodWrapper getter = null;
MethodWrapper setter = null;
if(prop.getter != null)
{
getter = GetMethodWrapper(prop.getter.Name, prop.getter.Sig, true);
if(getter == null)
{
Console.Error.WriteLine("Warning: getter not found for {0}::{1}", clazz.Name, prop.Name);
}
}
if(prop.setter != null)
{
setter = GetMethodWrapper(prop.setter.Name, prop.setter.Sig, true);
if(setter == null)
{
Console.Error.WriteLine("Warning: setter not found for {0}::{1}", clazz.Name, prop.Name);
}
}
bool final = (getter != null && getter.IsFinal) || (setter != null && setter.IsFinal);
if(getter != null)
{
MethodWrapper mw = getter;
if(!CheckPropertyArgs(mw.GetParametersForDefineMethod(), indexer) || mw.ReturnType != typeWrapper)
{
Console.Error.WriteLine("Warning: ignoring invalid property getter for {0}::{1}", clazz.Name, prop.Name);
}
else
{
MethodBuilder mb = mw.GetMethod() as MethodBuilder;
if(mb == null || mb.DeclaringType != typeBuilder || (!mb.IsFinal && final))
{
mb = typeBuilder.DefineMethod("get_" + prop.Name, GetPropertyMethodAttributes(mw, final), typeWrapper.TypeAsSignatureType, indexer);
AttributeHelper.HideFromJava(mb);
CodeEmitter ilgen = CodeEmitter.Create(mb);
if(mw.IsStatic)
{
for(int i = 0; i < indexer.Length; i++)
{
ilgen.EmitLdarg(i);
}
mw.EmitCall(ilgen);
}
else
{
ilgen.Emit(OpCodes.Ldarg_0);
for(int i = 0; i < indexer.Length; i++)
{
ilgen.EmitLdarg(i + 1);
}
mw.EmitCallvirt(ilgen);
}
ilgen.Emit(OpCodes.Ret);
ilgen.DoEmit();
}
propbuilder.SetGetMethod(mb);
}
}
if(setter != null)
{
MethodWrapper mw = setter;
Type[] args = new Type[indexer.Length + 1];
indexer.CopyTo(args, 0);
args[args.Length - 1] = typeWrapper.TypeAsSignatureType;
if(!CheckPropertyArgs(args, mw.GetParametersForDefineMethod()))
{
Console.Error.WriteLine("Warning: ignoring invalid property setter for {0}::{1}", clazz.Name, prop.Name);
}
else
{
MethodBuilder mb = mw.GetMethod() as MethodBuilder;
if(mb == null || mb.DeclaringType != typeBuilder || (!mb.IsFinal && final))
{
mb = typeBuilder.DefineMethod("set_" + prop.Name, GetPropertyMethodAttributes(mw, final), mw.ReturnTypeForDefineMethod, args);
AttributeHelper.HideFromJava(mb);
CodeEmitter ilgen = CodeEmitter.Create(mb);
if(mw.IsStatic)
{
for(int i = 0; i <= indexer.Length; i++)
{
ilgen.EmitLdarg(i);
//.........这里部分代码省略.........