Microsoft.VisualStudio.Project.ConfigProvider.OpenProjectCfg C# (CSharp) Method

OpenProjectCfg() public method

Provides access to the IVsProjectCfg interface implemented on a project's configuration object.
public OpenProjectCfg ( string projectCfgCanonicalName, IVsProjectCfg &projectCfg ) : int
projectCfgCanonicalName string The canonical name of the configuration to access.
projectCfg IVsProjectCfg The IVsProjectCfg interface of the configuration identified by szProjectCfgCanonicalName.
return int
        public virtual int OpenProjectCfg(string projectCfgCanonicalName, out IVsProjectCfg projectCfg)
        {
            if (projectCfgCanonicalName == null)
                throw new ArgumentNullException("projectCfgCanonicalName");
            if (string.IsNullOrEmpty(projectCfgCanonicalName))
                throw new ArgumentException("projectCfgCanonicalName cannot be null or empty");

            projectCfg = null;

            // Be robust in release
            if(projectCfgCanonicalName == null)
            {
                return VSConstants.E_INVALIDARG;
            }

            Debug.Assert(this._project != null && this._project.BuildProject != null);

            string[] configs = GetPropertiesConditionedOn(ProjectFileConstants.Configuration);
            string[] platforms = GetPlatformsFromProject();

            foreach (string config in configs)
            {
                foreach (string platform in platforms)
                {
                    if (string.Equals(string.Format("{0}|{1}", config, platform), projectCfgCanonicalName, StringComparison.OrdinalIgnoreCase))
                    {
                        projectCfg = this.GetProjectConfiguration(config, platform);
                        if (projectCfg != null)
                            return VSConstants.S_OK;
                        else
                            return VSConstants.E_FAIL;
                    }
                }
            }

            return VSConstants.E_INVALIDARG;
        }