当前位置: 首页>>代码示例>>C#>>正文


C# ProcessorArchitecture.ToString方法代码示例

本文整理汇总了C#中ProcessorArchitecture.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessorArchitecture.ToString方法的具体用法?C# ProcessorArchitecture.ToString怎么用?C# ProcessorArchitecture.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProcessorArchitecture的用法示例。


在下文中一共展示了ProcessorArchitecture.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFrameworkPath

        private static string GetFrameworkPath(
            string subfolder, ProcessorArchitecture architecture, string windowsFolder, bool is64BitOperatingSystem)
        {
            Guard.AgainstNullArgument("windowsFolder", windowsFolder);
            switch (architecture)
            {
                case ProcessorArchitecture.None:
                case ProcessorArchitecture.MSIL:
                    return is64BitOperatingSystem
                        ? Path.Combine(windowsFolder, "Microsoft.NET", "Framework64", subfolder, "MSBuild.exe")
                        : Path.Combine(windowsFolder, "Microsoft.NET", "Framework", subfolder, "MSBuild.exe");

                case ProcessorArchitecture.X86:
                    return Path.Combine(windowsFolder, "Microsoft.NET", "Framework", subfolder, "MSBuild.exe");

                case ProcessorArchitecture.Amd64:
                    return Path.Combine(windowsFolder, "Microsoft.NET", "Framework64", subfolder, "MSBuild.exe");

                default:
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "MSBuild processor architecture '{0}' is not supported.",
                        architecture.ToString());

                    throw new NotSupportedException(message);
            }
        }
开发者ID:modulexcite,项目名称:bau-msbuild,代码行数:27,代码来源:MSBuild.GetPath.cs

示例2: AppendProccessor

 internal static string AppendProccessor(string fullName, ProcessorArchitecture targetProcessor)
 {
     string processor = targetProcessor == ProcessorArchitecture.None ? "MSIL" : targetProcessor.ToString();
     return AppendProccessor(fullName, processor);
 }
开发者ID:464884492,项目名称:msbuildtasks,代码行数:5,代码来源:FusionWrapper.cs

示例3: CheckForFullFusionNameInGac

        /// <summary>
        /// Given a strong name, find its path in the GAC.
        /// </summary>
        /// <param name="strongName">The strong name.</param>
        /// <param name="targetProcessorArchitecture">Like x86 or IA64\AMD64.</param>
        /// <param name="getRuntimeVersion">Delegate to get the runtime version from a file path</param>
        /// <param name="targetedRuntimeVersion">What version of the runtime are we targeting</param>
        /// <param name="fullFusionName">Are we guranteed to have a full fusion name. This really can only happen if we have already resolved the assembly</param>
        /// <returns>The path to the assembly. Empty if none exists.</returns>
        internal static string GetLocation
        (
            IBuildEngine4 buildEngine,
            AssemblyNameExtension strongName,
            ProcessorArchitecture targetProcessorArchitecture,
            GetAssemblyRuntimeVersion getRuntimeVersion,
            Version targetedRuntimeVersion,
            bool fullFusionName,
            FileExists fileExists,
            GetPathFromFusionName getPathFromFusionName,
            GetGacEnumerator getGacEnumerator,
            bool specificVersion
        )
        {
            ConcurrentDictionary<AssemblyNameExtension, string> fusionNameToResolvedPath = null;
            bool useGacRarCache = Environment.GetEnvironmentVariable("MSBUILDDISABLEGACRARCACHE") == null;
            if (buildEngine != null && useGacRarCache)
            {
                string key = "44d78b60-3bbe-48fe-9493-04119ebf515f" + "|" + targetProcessorArchitecture.ToString() + "|" + targetedRuntimeVersion.ToString() + "|" + fullFusionName.ToString() + "|" + specificVersion.ToString();
                fusionNameToResolvedPath = buildEngine.GetRegisteredTaskObject(key, RegisteredTaskObjectLifetime.Build) as ConcurrentDictionary<AssemblyNameExtension, string>;
                if (fusionNameToResolvedPath == null)
                {
                    fusionNameToResolvedPath = new ConcurrentDictionary<AssemblyNameExtension, string>(AssemblyNameComparer.GenericComparer);
                    buildEngine.RegisterTaskObject(key, fusionNameToResolvedPath, RegisteredTaskObjectLifetime.Build, true /* dispose early ok*/);
                }
                else
                {
                    if (fusionNameToResolvedPath.ContainsKey(strongName))
                    {
                        string fusionName = null;
                        fusionNameToResolvedPath.TryGetValue(strongName, out fusionName);
                        return fusionName;
                    }
                }
            }

            // Optimize out the case where the public key token is null, if it is null it is not a strongly named assembly and CANNOT be in the gac.
            // also passing it would cause the gac enumeration method to throw an exception indicating the assembly is not a strongnamed assembly.

            string location = null;

            // If the publickeyToken is null and the publickeytoken is in the fusion name then this means we are passing in a null or empty PublicKeyToken and then this cannot possibly be in the gac.
            if ((strongName.GetPublicKeyToken() == null || strongName.GetPublicKeyToken().Length == 0) && strongName.FullName.IndexOf("PublicKeyToken", StringComparison.OrdinalIgnoreCase) != -1)
            {
                if (fusionNameToResolvedPath != null)
                {
                    fusionNameToResolvedPath.TryAdd(strongName, location);
                }

                return location;
            }

            // A delegate was not passed in to use the default one
            getPathFromFusionName = getPathFromFusionName ?? pathFromFusionName;

            // A delegate was not passed in to use the default one
            getGacEnumerator = getGacEnumerator ?? gacEnumerator;

            // If we have no processor architecture set then we can tryout a number of processor architectures.
            if (!strongName.HasProcessorArchitectureInFusionName)
            {
                if (targetProcessorArchitecture != ProcessorArchitecture.MSIL && targetProcessorArchitecture != ProcessorArchitecture.None)
                {
                    string processorArchitecture = ResolveAssemblyReference.ProcessorArchitectureToString(targetProcessorArchitecture);
                    // Try processor specific first.
                    if (fullFusionName)
                    {
                        location = CheckForFullFusionNameInGac(strongName, processorArchitecture, getPathFromFusionName);
                    }
                    else
                    {
                        location = GetLocationImpl(strongName, processorArchitecture, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion);
                    }

                    if (location != null && location.Length > 0)
                    {
                        if (fusionNameToResolvedPath != null)
                        {
                            fusionNameToResolvedPath.TryAdd(strongName, location);
                        }
                        return location;
                    }
                }

                // Next, try MSIL
                if (fullFusionName)
                {
                    location = CheckForFullFusionNameInGac(strongName, "MSIL", getPathFromFusionName);
                }
                else
                {
//.........这里部分代码省略.........
开发者ID:ChronosWS,项目名称:msbuild,代码行数:101,代码来源:GlobalAssemblyCache.cs

示例4: GetVisualStudioPath

        private static string GetVisualStudioPath(
            string subfolder, ProcessorArchitecture architecture, string programFilesFolder, bool is64BitOperatingSystem)
        {
            Guard.AgainstNullArgument("programFilesFolder", programFilesFolder);

            switch (architecture)
            {
                case ProcessorArchitecture.None:
                case ProcessorArchitecture.MSIL:
                    return is64BitOperatingSystem
                        ? Path.Combine(programFilesFolder, "MSBuild", subfolder, "bin", "amd64", "MSBuild.exe")
                        : Path.Combine(programFilesFolder, "MSBuild", subfolder, "bin", "MSBuild.exe");

                case ProcessorArchitecture.X86:
                    return Path.Combine(programFilesFolder, "MSBuild", subfolder, "bin", "MSBuild.exe");

                case ProcessorArchitecture.Amd64:
                    return Path.Combine(programFilesFolder, "MSBuild", subfolder, "bin", "amd64", "MSBuild.exe");

                default:
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "MSBuild processor architecture '{0}' is not supported.",
                        architecture.ToString());

                    throw new NotSupportedException(message);
            }
        }
开发者ID:modulexcite,项目名称:bau-msbuild,代码行数:28,代码来源:MSBuild.GetPath.cs

示例5: SetMsiTargetPlatform

        public static void SetMsiTargetPlatform(string msiPath, ProcessorArchitecture architecture)
        {
            const string x86 = "Intel;1033";
            const string x64 = "x64;1033";
            string platform;

            switch (architecture)
            {
                case ProcessorArchitecture.X64:
                    platform = x64;
                    break;

                case ProcessorArchitecture.X86:
                    platform = x86;
                    break;

                default:
                    throw new InvalidOperationException("Platform must be X86 or X64 (" + architecture.ToString() + ")");
            }

            UIntPtr hDatabase = UIntPtr.Zero;
            UIntPtr hSummary = UIntPtr.Zero;

            try
            {
                uint retVal = NativeConstants.ERROR_SUCCESS;

                retVal = NativeMethods.MsiOpenDatabaseW(
                    msiPath,
                    (UIntPtr)NativeConstants.MSIDBOPEN_DIRECT,
                    out hDatabase);

                ThrowIfFailed(retVal, "MsiOpenDatabaseW");

                retVal = NativeMethods.MsiGetSummaryInformationW(
                    hDatabase,
                    null,
                    1,
                    out hSummary);

                ThrowIfFailed(retVal, "MsiGetSummaryInformationW");

                retVal = NativeMethods.MsiSummaryInfoSetPropertyW(
                    hSummary,
                    NativeConstants.PID_TEMPLATE,
                    NativeConstants.VT_LPSTR,
                    0,
                    UIntPtr.Zero,
                    platform);

                ThrowIfFailed(retVal, "MsiSummaryInfoSetPropertyW");

                retVal = NativeMethods.MsiSummaryInfoPersist(hSummary);
                ThrowIfFailed(retVal, "MsiSummaryInfoPersist");
            }

            finally
            {
                if (hSummary != UIntPtr.Zero)
                {
                    NativeMethods.MsiCloseHandle(hSummary);
                    hSummary = UIntPtr.Zero;
                }

                if (hDatabase != UIntPtr.Zero)
                {
                    NativeMethods.MsiCloseHandle(hDatabase);
                    hDatabase = UIntPtr.Zero;
                }
            }

            // Add a launch condition for x86 to prevent its installation on 64-bit Windows
            if (architecture == ProcessorArchitecture.X86)
            {
                string launchError = PdnResources.GetString("SetupWizard.x86Msi.LaunchCondition.NotAllowedOn64bitOS");

                SetMsiProperties(
                    msiPath,
                    LaunchConditionTable,
                    new string[] { "NOT VersionNT64" },
                    new string[] { launchError });
            }

            // Permute the ProductCode on non-x86 so that each platform has its own ProductCode
            string[] properties = new string[] { ProductCodeProperty };
            string[] values;
            GetMsiProperties(msiPath, PropertyTable, properties, out values);
            Guid productCode = new Guid(values[0]);
            byte[] productCodeBytes = productCode.ToByteArray();

            if (architecture == ProcessorArchitecture.X64)
            {
                unchecked
                {
                    productCodeBytes[productCodeBytes.Length - 1] += 1;
                }
            }

            Guid newProductCode = new Guid(productCodeBytes);

//.........这里部分代码省略.........
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:101,代码来源:Msi.cs


注:本文中的ProcessorArchitecture.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。