public AssemblyBinaryProperties InferAssemblyBinaryProperties()
        {
            AssemblyBinaryProperties binaryProperties = Utilities.CreateAssemblyInspector((IInputValues)this).GetAssemblyBinaryProperties(this.InputFileName);

            if (this.Cpu == CpuPlatform.None && binaryProperties.BinaryWasScanned)
            {
                this.Cpu = binaryProperties.CpuPlatform;
            }
            return(binaryProperties);
        }
예제 #2
0
        public AssemblyBinaryProperties GetAssemblyBinaryProperties(
            string assemblyFileName)
        {
            AssemblyBinaryProperties binaryProperties;

            if (!File.Exists(assemblyFileName))
            {
                binaryProperties = AssemblyBinaryProperties.GetEmpty();
            }
            else
            {
                AssemblyDefinition assemblyDefinition = this.LoadAssembly(assemblyFileName);
                ModuleDefinition   mainModule         = assemblyDefinition.MainModule;
                string             keyFileName        = (string)null;
                string             keyContainer       = (string)null;
                foreach (CustomAttribute customAttribute in assemblyDefinition.CustomAttributes)
                {
                    switch (customAttribute.Constructor.DeclaringType.FullName)
                    {
                    case "System.Reflection.AssemblyKeyFileAttribute":
                        keyFileName = Convert.ToString((object)customAttribute.ConstructorArguments[0], (IFormatProvider)CultureInfo.InvariantCulture);
                        break;

                    case "System.Reflection.AssemblyKeyNameAttribute":
                        keyContainer = Convert.ToString((object)customAttribute.ConstructorArguments[0], (IFormatProvider)CultureInfo.InvariantCulture);
                        break;
                    }
                    if (!string.IsNullOrEmpty(keyFileName))
                    {
                        if (!string.IsNullOrEmpty(keyContainer))
                        {
                            break;
                        }
                    }
                }
                binaryProperties = new AssemblyBinaryProperties(mainModule.Attributes, mainModule.Architecture, assemblyDefinition.Name.HasPublicKey, keyFileName, keyContainer);
            }
            return(binaryProperties);
        }