コード例 #1
0
ファイル: CodeForm.cs プロジェクト: xul8tr/Reflexil
        private MethodDefinition FindMatchingMethod()
        {
            MethodDefinition result = null;

            var asmdef = PluginFactory.GetInstance().LoadAssembly(_compiler.AssemblyLocation, false);

            // Fix for inner types, remove namespace and owner.
            var typename = (_mdefsource.DeclaringType.IsNested)
                                ? _mdefsource.DeclaringType.Name
                                : _mdefsource.DeclaringType.FullName;

            // Generic hierarchy will push all generic parameters to the final type, so fix type name
            var tag = typename.LastIndexOf(BaseLanguageHelper.GenericTypeTag, StringComparison.Ordinal);

            if (tag >= 0)
            {
                typename = string.Concat(typename.Substring(0, tag + 1), _mdefsource.DeclaringType.GenericParameters.Count);
            }

            var tdef = CecilHelper.FindMatchingType(asmdef.MainModule, typename);

            if (tdef != null)
            {
                result = CecilHelper.FindMatchingMethod(tdef, _mdefsource);
            }

            return(result);
        }
コード例 #2
0
        private MethodDefinition FindMatchingMethod()
        {
            MethodDefinition result = null;

            AssemblyDefinition asmdef = AssemblyDefinition.ReadAssembly(_compiler.AssemblyLocation);

            // Fix for inner types, remove namespace and owner.
            string typename = (_mdefsource.DeclaringType.IsNested) ? _mdefsource.DeclaringType.Name : _mdefsource.DeclaringType.FullName;

            TypeDefinition tdef = CecilHelper.FindMatchingType(asmdef.MainModule, typename);

            if (tdef != null)
            {
                result = CecilHelper.FindMatchingMethod(tdef, _mdefsource);
            }

            return(result);
        }