Пример #1
0
 public MemberResolver(TypeReference target, ModuleDefinition targetModule = null)
 {
     if (target == null) throw new ArgumentNullException("target");
       Target = target;
       Module = targetModule ?? Target.Module;
       Source = Target.Resolve();
       TargetWithArguments = Target as GenericInstanceType;
       _map = new GenericParametersMap(Source, TargetWithArguments);
 }
Пример #2
0
        public MethodDefinition ResolveMethodDefinition(MethodDefinition sourceMethod, string name, MethodAttributes methodAttributes)
        {
            if (sourceMethod == null) throw new ArgumentNullException("sourceMethod");

              bool createdMap = false;
              if (sourceMethod.HasGenericParameters) {
            createdMap = true;
            _map = new GenericParametersMap(sourceMethod) { Next = _map };
              }

              var returnType = ResolveConstituentType(sourceMethod.ReturnType);
              var targetMethod = new MethodDefinition(
            name,
            methodAttributes,
            returnType);
              targetMethod.SemanticsAttributes = sourceMethod.SemanticsAttributes;

              ResolveGenericParameters(sourceMethod, targetMethod);
              ResolveParameters(sourceMethod, targetMethod);

              if (createdMap) {
            _map = _map.Next;
              }

              return targetMethod;
        }