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

GetPlatforms() protected static method

Common method for handling platform names.
protected static GetPlatforms ( uint celt, string names, uint actual, string platforms ) : int
celt uint Specifies the requested number of platform names. If this number is unknown, celt can be zero.
names string On input, an allocated array to hold the number of platform names specified by celt. This parameter can also be null if the celt parameter is zero. On output, names contains platform names
actual uint A count of the actual number of platform names returned.
platforms string An array of available platform names
return int
        protected static int GetPlatforms(uint celt, string[] names, uint[] actual, string[] platforms)
        {
            Debug.Assert(platforms != null, "The plaforms array should never be null");
            if(names == null)
            {
                if(actual == null || actual.Length == 0)
                {
                    throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "actual");
                }

                actual[0] = (uint)platforms.Length;
                return VSConstants.S_OK;
            }

            //Degenarate case
            if(celt == 0)
            {
                if(actual != null && actual.Length != 0)
                {
                    actual[0] = (uint)platforms.Length;
                }

                return VSConstants.S_OK;
            }

            uint returned = 0;
            for(int i = 0; i < platforms.Length && names.Length > returned; i++)
            {
                names[returned] = platforms[i];
                returned++;
            }

            if(actual != null && actual.Length != 0)
            {
                actual[0] = returned;
            }

            if(celt > returned)
            {
                return VSConstants.S_FALSE;
            }

            return VSConstants.S_OK;
        }