コード例 #1
0
        private static void ParseFrameworkName(string frameworkName, out string identifier, out int version, out string profile)
        {
            if (frameworkName == null)
            {
                throw new ArgumentNullException("frameworkName");
            }
            if (frameworkName.Length == 0)
            {
                throw new ArgumentException(ResourceHelper
                                            .GetResourceString("Argument_StringZeroLength"), "frameworkName");
            }
            string[] array = frameworkName.Split(new char[]
            {
                ','
            });
            version = 0;
            if (array.Length < 2 || array.Length > 3)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("Argument_FrameworkNameTooShort"), "frameworkName");
            }
            identifier = array[0].Trim();
            if (identifier.Length == 0)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("Argument_FrameworkNameInvalid"), "frameworkName");
            }
            bool flag = false;

            profile = null;
            for (int i = 1; i < array.Length; i++)
            {
                string[] array2 = array[i].Split(new char[]
                {
                    '='
                });
                if (array2.Length != 2)
                {
                    throw new ArgumentException(ResourceHelper.GetResourceString("SR.Argument_FrameworkNameInvalid"), "frameworkName");
                }
                string text  = array2[0].Trim();
                string text2 = array2[1].Trim();
                if (text.Equals("Version", StringComparison.OrdinalIgnoreCase))
                {
                    flag = true;
                    if (text2.Length > 0 && (text2[0] == 'v' || text2[0] == 'V'))
                    {
                        text2 = text2.Substring(1);
                    }
                    Version version2 = new Version(text2);
                    version = version2.Major * 10000;
                    if (version2.Minor > 0)
                    {
                        version += version2.Minor * 100;
                    }
                    if (version2.Build > 0)
                    {
                        version += version2.Build;
                    }
                }
                else
                {
                    if (!text.Equals("Profile", StringComparison.OrdinalIgnoreCase))
                    {
                        throw new ArgumentException(ResourceHelper.GetResourceString("Argument_FrameworkNameInvalid"), "frameworkName");
                    }
                    if (!string.IsNullOrEmpty(text2))
                    {
                        profile = text2;
                    }
                }
            }
            if (!flag)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("Argument_FrameworkNameMissingVersion"), "frameworkName");
            }
        }