當前位置: 首頁>>代碼示例>>C#>>正文


C# MethodDefinition.GetElementMethod方法代碼示例

本文整理匯總了C#中Mono.Cecil.MethodDefinition.GetElementMethod方法的典型用法代碼示例。如果您正苦於以下問題:C# MethodDefinition.GetElementMethod方法的具體用法?C# MethodDefinition.GetElementMethod怎麽用?C# MethodDefinition.GetElementMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.MethodDefinition的用法示例。


在下文中一共展示了MethodDefinition.GetElementMethod方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsMethodContainsAttribute

 private bool IsMethodContainsAttribute(MethodDefinition method)
 {
     var methodInfo = method.GetElementMethod();
     return method.HasCustomAttributes ||
         methodInfo.MethodReturnType.HasCustomAttributes ||
         methodInfo.MethodReturnType.HasFieldMarshal ||
         methodInfo.MethodReturnType.HasMarshalInfo;
 }
開發者ID:MishaUliutin,項目名稱:RemoveUnusedRef,代碼行數:8,代碼來源:TypesAttributesEntry.cs

示例2: EncryptStringsInAssembly

        /// <summary>
        /// Encrypts the strings within the given assembly.
        /// </summary>
        /// <param name="definition">The assembly definition.</param>
        private void EncryptStringsInAssembly(AssemblyDefinition definition)
        {
            //Add an encryption function
            MethodReference decryptionMethod = null;

            //Generate a new type for decryption
            OutputHelper.WriteLine("Generating global decrypt method");
            foreach (TypeDefinition td in definition.MainModule.GetAllTypes())
                if (td.Name == "<Module>")
                {
                    MethodDefinition md = new MethodDefinition("Decrypt", MethodAttributes.HideBySig | MethodAttributes.Static | MethodAttributes.CompilerControlled, definition.Import(typeof(string)));

                    //Generate the parameters
                    md.Parameters.Add(new ParameterDefinition("v", ParameterAttributes.None, definition.Import(typeof(string))));
                    md.Parameters.Add(new ParameterDefinition("s", ParameterAttributes.None, definition.Import(typeof(int))));

                    //Add it
                    td.Methods.Add(md);
                    //We now need to create a method body
                    md.Body = new MethodBody(md);

                    //Output the encryption method body
                    switch (method)
                    {
                        case StringEncryptionMethod.Xor:
                            GenerateXorDecryptionMethod(definition, md.Body);
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    //Finally get the reference
                    decryptionMethod = md.GetElementMethod();
                }

            //Loop through the modules
            OutputHelper.WriteLine("Processing modules");
            foreach (ModuleDefinition moduleDefinition in definition.Modules)
            {
                //Go through each type
                foreach (TypeDefinition typeDefinition in moduleDefinition.GetAllTypes())
                {
                    //Go through each method
                    foreach (MethodDefinition methodDefinition in typeDefinition.Methods)
                    {
                        if (methodDefinition.HasBody)
                        {
                            OutputHelper.WriteMethod(typeDefinition, methodDefinition);
                            ProcessInstructions(definition, methodDefinition.Body, decryptionMethod);
                        }
                    }
                }
            }
        }
開發者ID:modulexcite,項目名稱:ncloak,代碼行數:58,代碼來源:StringEncryptionTask.cs


注:本文中的Mono.Cecil.MethodDefinition.GetElementMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。