本文整理汇总了C#中System.Reflection.Module类的典型用法代码示例。如果您正苦于以下问题:C# Module类的具体用法?C# Module怎么用?C# Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Module类属于System.Reflection命名空间,在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomAttributeData
internal CustomAttributeData(Module scope, CustomAttributeRecord caRecord)
{
this.m_scope = scope;
this.m_ctor = (ConstructorInfo) RuntimeType.GetMethodBase(scope, (int) caRecord.tkCtor);
ParameterInfo[] parametersNoCopy = this.m_ctor.GetParametersNoCopy();
this.m_ctorParams = new CustomAttributeCtorParameter[parametersNoCopy.Length];
for (int i = 0; i < parametersNoCopy.Length; i++)
{
this.m_ctorParams[i] = new CustomAttributeCtorParameter(InitCustomAttributeType(parametersNoCopy[i].ParameterType, scope));
}
FieldInfo[] fields = this.m_ctor.DeclaringType.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
PropertyInfo[] properties = this.m_ctor.DeclaringType.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
this.m_namedParams = new CustomAttributeNamedParameter[properties.Length + fields.Length];
for (int j = 0; j < fields.Length; j++)
{
this.m_namedParams[j] = new CustomAttributeNamedParameter(fields[j].Name, CustomAttributeEncoding.Field, InitCustomAttributeType(fields[j].FieldType, scope));
}
for (int k = 0; k < properties.Length; k++)
{
this.m_namedParams[k + fields.Length] = new CustomAttributeNamedParameter(properties[k].Name, CustomAttributeEncoding.Property, InitCustomAttributeType(properties[k].PropertyType, scope));
}
this.m_members = new MemberInfo[fields.Length + properties.Length];
fields.CopyTo(this.m_members, 0);
properties.CopyTo(this.m_members, fields.Length);
CustomAttributeEncodedArgument.ParseAttributeArguments(caRecord.blob, ref this.m_ctorParams, ref this.m_namedParams, this.m_scope);
}
示例2: CodeGenerator
public CodeGenerator(Module targetModule)
: this()
{
Check.Require(targetModule != null, "targetModule could not be null.");
this.serializationModule = targetModule;
}
示例3: getMethod
public MethodBase getMethod(Module module)
{
MethodsModule methodsModule;
if (!moduleToMethods.TryGetValue(module, out methodsModule))
moduleToMethods[module] = methodsModule = new MethodsModule(module);
return methodsModule.getNext();
}
示例4: PropertyBuilder
// Constructs a PropertyBuilder.
//
internal PropertyBuilder(
Module mod, // the module containing this PropertyBuilder
String name, // property name
SignatureHelper sig, // property signature descriptor info
PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc
Type returnType, // return type of the property.
PropertyToken prToken, // the metadata token for this property
TypeBuilder containingType) // the containing type
{
if (name == null)
throw new ArgumentNullException("name");
if (name.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
if (name[0] == '\0')
throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
m_name = name;
m_module = mod;
m_signature = sig;
m_attributes = attr;
m_returnType = returnType;
m_prToken = prToken;
m_tkProperty = prToken.Token;
m_getMethod = null;
m_setMethod = null;
m_containingType = containingType;
}
示例5: DynamicAssemblyManager
static DynamicAssemblyManager()
{
#if !SILVERLIGHT
assemblyName = new AssemblyName("NLiteDynamicAssembly");
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.RunAndSave
);
moduleBuilder = assemblyBuilder.DefineDynamicModule(
assemblyName.Name,
assemblyName.Name + ".dll",
true);
Module = assemblyBuilder.GetModules().FirstOrDefault();
#else
assemblyName = new AssemblyName("EmitMapperAssembly.SL");
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.Run
);
moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, true);
#endif
}
示例6: ScriptAssembly
/// <summary>
/// Creates an instance of <see cref="ScriptAssembly"/>.
/// </summary>
/// <param name="module">The CLR module.</param>
/// <param name="namespacing">Whether namespacing is applied.</param>
public ScriptAssembly(Module/*!*/ module, bool namespacing)
{
Debug.Assert(module != null);
this.module = module;
this.namespacing = namespacing;
}
示例7: ModuleScopeTokenResolver
public ModuleScopeTokenResolver(MethodBase method)
{
m_enclosingMethod = method;
m_module = method.Module;
m_methodContext = (method is ConstructorInfo) ? null : method.GetGenericArguments();
m_typeContext = (method.DeclaringType == null) ? null : method.DeclaringType.GetGenericArguments();
}
示例8: ResolveMember
public static MemberInfo ResolveMember(Module module, int metadataToken)
{
Assumes.NotNull(module);
Assumes.IsTrue(metadataToken != 0);
return module.ResolveMember(metadataToken);
}
示例9: GetLocalVarSigHelper
public static SignatureHelper GetLocalVarSigHelper (Module mod)
{
if (mod != null && !(mod is ModuleBuilder))
throw new ArgumentException ("ModuleBuilder is expected");
return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
}
示例10: DoMutate_Returns_Correct_Sequences
public void DoMutate_Returns_Correct_Sequences()
{
var module = new Module(Assembly.GetExecutingAssembly().Location);
module.LoadDebugInformation();
var method = module.Definition
.Types.Single(t => t.Name == "VariableReadClassUnderTest")
.Methods.Single(t => t.Name == "AddAndDouble");
var mutatedInstruction = method.Body.Instructions.First(i => i.OpCode == OpCodes.Ldarg_1);
string hexPrefix = string.Format("{0:x4}: ", mutatedInstruction.Offset);
var mutator = new VariableReadTurtle();
IList<MutantMetaData> mutations = mutator
.Mutate(method, module, method.Body.Instructions.Select(i => i.Offset).ToArray()).ToList();
// V2 is only read for the return statement; this case is excluded in the code.
Assert.AreEqual(9, mutations.Count);
StringAssert.EndsWith(hexPrefix + "read substitution Int32.a => Int32.b", mutations[0].Description);
StringAssert.EndsWith("read substitution Int32.a => Int32.total", mutations[1].Description);
StringAssert.EndsWith("read substitution Int32.a => Int32.CS$1$0000", mutations[2].Description);
StringAssert.EndsWith("read substitution Int32.b => Int32.a", mutations[3].Description);
StringAssert.EndsWith("read substitution Int32.b => Int32.total", mutations[4].Description);
StringAssert.EndsWith("read substitution Int32.b => Int32.CS$1$0000", mutations[5].Description);
StringAssert.EndsWith("read substitution Int32.total => Int32.a", mutations[6].Description);
StringAssert.EndsWith("read substitution Int32.total => Int32.b", mutations[7].Description);
StringAssert.EndsWith("read substitution Int32.total => Int32.CS$1$0000", mutations[8].Description);
}
示例11: EventOperation
public EventOperation(Delegate assignation)
{
_delegateMethod = assignation.Method;
MethodBody body = _delegateMethod.GetMethodBody();
_stream = new MemoryStream(body.GetILAsByteArray());
_module = _delegateMethod.Module;
}
示例12: GetMethodSigHelper
internal static SignatureHelper GetMethodSigHelper(
Module scope, CallingConventions callingConvention, int cGenericParam,
Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
SignatureHelper sigHelp;
MdSigCallingConvention intCall;
if (returnType == null)
{
returnType = typeof(void);
}
intCall = MdSigCallingConvention.Default;
if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
intCall = MdSigCallingConvention.Vararg;
if (cGenericParam > 0)
{
intCall |= MdSigCallingConvention.Generic;
}
if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
intCall |= MdSigCallingConvention.HasThis;
sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType,
requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
return sigHelp;
}
示例13: TypeValueInfo
public Module Module; // ex RunCode_00002.dll
public TypeValueInfo(Type sourceType, MemberInfo memberInfo)
{
SourceType = sourceType;
Name = memberInfo.Name;
TreeName = memberInfo.Name;
ParentName = null;
Type valueType = memberInfo.zGetValueType();
Type enumerableType = null;
if (valueType != typeof(string))
enumerableType = zReflection.GetEnumerableType(valueType);
if (enumerableType != null)
{
ValueType = enumerableType;
IsEnumerable = true;
}
else
{
ValueType = valueType;
IsEnumerable = false;
}
IsValueType = TypeReflection.IsValueType(ValueType);
DeclaringType = memberInfo.DeclaringType;
ReflectedType = memberInfo.ReflectedType;
MemberTypes = memberInfo.MemberType;
MetadataToken = memberInfo.MetadataToken;
Module = memberInfo.Module;
}
示例14: YetiCsharpConstructor
public YetiCsharpConstructor(Type t, ConstructorInfo cons, ParameterInfo[] par, Module mod)
{
this.ci = cons;
this.parameters = par;
this.type = t;
this.module = mod;
}
示例15: CollectErrorsOnMemberAndDescendents
private static IEnumerable<string> CollectErrorsOnMemberAndDescendents(Module module, IEnumerable<Exemption> exemptions, Func<ICustomAttributeProvider, string, string, IEnumerable<Exemption>, IEnumerable<string>> coreChecker) {
var types = module.GetTypes().Where(type => !IsGeneratedCode(type));
return Enumerable.Concat(
coreChecker(module, module.Name, "module", exemptions),
types.SelectMany(type => CollectErrorsOnMemberAndDescendents(type, exemptions, coreChecker)));
}