1 // Copyright (c) Microsoft. All rights reserved. 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 //----------------------------------------------------------------------- 4 // </copyright> 5 // <summary>Represents a solution configuration (e.g. "Debug|x86")</summary> 6 //----------------------------------------------------------------------- 7 8 using System; 9 using System.Globalization; 10 11 namespace Microsoft.Build.Construction 12 { 13 /// <summary> 14 /// This represents an entry for a solution configuration 15 /// </summary> 16 public sealed class SolutionConfigurationInSolution 17 { 18 /// <summary> 19 /// Default separator between configuration and platform in configuration 20 /// full names 21 /// </summary> 22 internal const char ConfigurationPlatformSeparator = '|'; 23 24 /// <summary> 25 /// The configuration part of this configuration - e.g. "Debug", "Release" 26 /// </summary> 27 private string _configurationName; 28 29 /// <summary> 30 /// The platform part of this configuration - e.g. "Any CPU", "Win32" 31 /// </summary> 32 private string _platformName; 33 34 /// <summary> 35 /// The full name of this configuration - e.g. "Debug|Any CPU" 36 /// </summary> 37 private string _fullName; 38 39 /// <summary> 40 /// Constructor 41 /// </summary> SolutionConfigurationInSolution(string configurationName, string platformName)42 internal SolutionConfigurationInSolution(string configurationName, string platformName) 43 { 44 _configurationName = configurationName; 45 _platformName = platformName; 46 _fullName = ComputeFullName(configurationName, platformName); 47 } 48 49 /// <summary> 50 /// The configuration part of this configuration - e.g. "Debug", "Release" 51 /// </summary> 52 public string ConfigurationName 53 { 54 get { return _configurationName; } 55 } 56 57 /// <summary> 58 /// The platform part of this configuration - e.g. "Any CPU", "Win32" 59 /// </summary> 60 public string PlatformName 61 { 62 get { return _platformName; } 63 } 64 65 /// <summary> 66 /// The full name of this configuration - e.g. "Debug|Any CPU" 67 /// </summary> 68 public string FullName 69 { 70 get { return _fullName; } 71 } 72 73 /// <summary> 74 /// Given a configuration name and a platform name, compute the full name 75 /// of this configuration 76 /// </summary> ComputeFullName(string configurationName, string platformName)77 internal static string ComputeFullName(string configurationName, string platformName) 78 { 79 // Some configurations don't have the platform part 80 if ((platformName != null) && (platformName.Length > 0)) 81 { 82 return String.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", configurationName, ConfigurationPlatformSeparator, platformName); 83 } 84 else 85 { 86 return configurationName; 87 } 88 } 89 } 90 } 91