Ejemplo n.º 1
0
        private MethodDefinition GetBodySource(TypeDefinition targetType, MethodDefinition yourMethod,
                                               DuplicatesBodyAttribute insertAttribute)
        {
            //Note that the source type is resolved using yourMethod's module, which uses a different IMetadataResolver,
            //and thus will resolve the method from the target, unmodified assembly.

            var importSourceType = insertAttribute.SourceType != null
                                ? yourMethod.Module.Import((TypeReference)insertAttribute.SourceType)
                                : yourMethod.Module.Import(targetType);

            var importMethod = importSourceType.Resolve().GetMethodLike(yourMethod, insertAttribute.MethodName);

            var others =
                importSourceType.Resolve().Methods.Where(x => x.Name == insertAttribute.MethodName).ToArray();

            if (importMethod == null)
            {
                throw Errors.Missing_member_in_attribute("method", yourMethod, insertAttribute.MethodName);
            }
            return(importMethod);
        }
Ejemplo n.º 2
0
        private MethodDefinition GetBodySource(TypeDefinition targetType, MethodDefinition yourMethod,
			DuplicatesBodyAttribute insertAttribute)
        {
            //Note that the source type is resolved using yourMethod's module, which uses a different IMetadataResolver,
            //and thus will resolve the method from the target, unmodified assembly.

            var importSourceType = insertAttribute.SourceType != null
                ? yourMethod.Module.Import((TypeReference) insertAttribute.SourceType)
                : yourMethod.Module.Import(targetType);

            var importMethod = importSourceType.Resolve().GetMethodLike(yourMethod, insertAttribute.MethodName);

            var others =
                importSourceType.Resolve().Methods.Where(x => x.Name == insertAttribute.MethodName).ToArray();

            if (importMethod == null) {
                throw Errors.Missing_member_in_attribute("method", yourMethod, insertAttribute.MethodName);
            }
            return importMethod;
        }