Microsoft.VisualStudio.Project.ProjectConfig.TrySplitConfigurationCanonicalName C# (CSharp) Method

TrySplitConfigurationCanonicalName() static private method

Splits the canonical configuration name into platform and configuration name.
static private TrySplitConfigurationCanonicalName ( string canonicalName, string &configName, string &platformName ) : bool
canonicalName string The canonicalName name.
configName string The name of the configuration.
platformName string The name of the platform.
return bool
        internal static bool TrySplitConfigurationCanonicalName(string canonicalName, out string configName, out string platformName)
        {
            configName = String.Empty;
            platformName = String.Empty;

            if (String.IsNullOrEmpty(canonicalName))
                return false;

            string[] splittedCanonicalName = canonicalName.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            if (splittedCanonicalName == null || (splittedCanonicalName.Length != 1 && splittedCanonicalName.Length != 2))
                return false;

            configName = splittedCanonicalName[0];

            if (splittedCanonicalName.Length == 2)
                platformName = ToMSBuildPlatform(splittedCanonicalName[1]);

            return true;
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Retrives the configuration and the platform using the IVsSolutionBuildManager2 interface.
        /// </summary>
        /// <param name="serviceProvider">A service provider.</param>
        /// <param name="hierarchy">The hierrachy whose configuration is requested.</param>
        /// <param name="configuration">The name of the active configuration.</param>
        /// <param name="platform">The name of the platform.</param>
        /// <returns>true if successfull.</returns>
        internal static bool TryGetActiveConfigurationAndPlatform(System.IServiceProvider serviceProvider, IVsHierarchy hierarchy, out string configuration, out string platform)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            if (hierarchy == null)
            {
                throw new ArgumentNullException("hierarchy");
            }

            configuration = String.Empty;
            platform      = String.Empty;

            IVsSolutionBuildManager2 solutionBuildManager = serviceProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;

            if (solutionBuildManager == null)
            {
                return(false);
            }

            IVsProjectCfg[] activeConfigs = new IVsProjectCfg[1];
            var             res           = solutionBuildManager.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy, activeConfigs);

            if (ErrorHandler.Failed(res))
            {
                return(false);
            }

            IVsProjectCfg activeCfg = activeConfigs[0];

            // Can it be that the activeCfg is null?
            System.Diagnostics.Debug.Assert(activeCfg != null, "Cannot find the active configuration");

            string canonicalName;

            ErrorHandler.ThrowOnFailure(activeCfg.get_CanonicalName(out canonicalName));

            return(ProjectConfig.TrySplitConfigurationCanonicalName(canonicalName, out configuration, out platform));
        }
All Usage Examples Of Microsoft.VisualStudio.Project.ProjectConfig::TrySplitConfigurationCanonicalName