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
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));
        }
Esempio n. 2
0
        /// <summary>
        /// Proved access to an IDispatchable object being a list of configuration properties
        /// </summary>
        /// <param name="configurationName">Combined Name and Platform for the configuration requested</param>
        /// <param name="configurationProperties">The IDispatchcable object</param>
        /// <returns>S_OK if successful</returns>
        public virtual int GetAutomationObject(string configurationName, out object configurationProperties)
        {
            //Init out param
            configurationProperties = null;

            string name, platform;

            if (!ProjectConfig.TrySplitConfigurationCanonicalName(configurationName, out name, out platform))
            {
                return(VSConstants.E_INVALIDARG);
            }

            // Get the configuration
            IVsCfg cfg;

            ErrorHandler.ThrowOnFailure(this.GetCfgOfName(name, platform, out cfg));

            // Get the properties of the configuration
            configurationProperties = ((ProjectConfig)cfg).ConfigurationProperties;

            return(VSConstants.S_OK);
        }