Пример #1
0
        private static ProjectConfigurationPlatformsGlobalSection DeserializeProjectConfigurationPlatformsGlobalSection(TextReader reader, ref string currentLine, PreOrPostSolution preOrPostSolution)
        {
            var projectConfigurationPlatformsGlobalSection = new ProjectConfigurationPlatformsGlobalSection
            {
                Name = ProjectConfigurationPlatformsGlobalSection.SolutionFileGlobalSectionName,
                PreOrPostSolution = preOrPostSolution
            };

            currentLine = reader.ReadLine().Trim();

            while (!SolutionFileTextSerializer.GlobalSectionEndRegex.IsMatch(currentLine))
            {
                var assignmentTokens = currentLine.Split("=");

                var targetToken = assignmentTokens[0].Trim();
                var valueToken  = assignmentTokens[1].Trim();

                var projectBuildConfigurationTokens = targetToken.Split(new string[] { Constants.SolutionProjectConfigurationTokenSeparator }, 3, StringSplitOptions.None);

                var projectGuidToken = projectBuildConfigurationTokens[0];
                var solutionBuildConfigurationToken = projectBuildConfigurationTokens[1];
                var indicatorToken = projectBuildConfigurationTokens[2];

                var projectGUID = Guid.Parse(projectGuidToken);
                var solutionBuildConfiguration = SolutionFileTextSerializer.DeserializeSolutionBuildConfiguration(solutionBuildConfigurationToken);
                var indicator = SolutionUtilities.ToProjectConfigurationIndicator(indicatorToken);
                var mappedSolutionBuildConfiguration = SolutionFileTextSerializer.DeserializeSolutionBuildConfiguration(valueToken);

                var projectBuildConfigurationMapping = new ProjectBuildConfigurationMapping
                {
                    ProjectGUID = projectGUID,
                    SolutionBuildConfiguration       = solutionBuildConfiguration,
                    ProjectConfigurationIndicator    = indicator,
                    MappedSolutionBuildConfiguration = mappedSolutionBuildConfiguration,
                };

                projectConfigurationPlatformsGlobalSection.ProjectBuildConfigurationMappings.Add(projectBuildConfigurationMapping);

                currentLine = reader.ReadLine().Trim();
            }

            return(projectConfigurationPlatformsGlobalSection);
        }
Пример #2
0
        private static void DeserializeGlobal(TextReader reader, ref string currentLine, SolutionFile solutionFile)
        {
            if (!SolutionFileTextSerializer.GlobalSectionRegex.IsMatch(currentLine))
            {
                throw new Exception($"Unknown line.\nExpected: \"GlobalSection\".\nFound: {currentLine}");
            }

            var globalSectionMatches = Regex.Matches(currentLine, SolutionFileTextSerializer.GlobalSectionLineValuesRegexPattern);

            var sectionName          = globalSectionMatches[0].Value.TrimStart('(').TrimEnd(')');
            var preOrPostSolutionStr = globalSectionMatches[1].Value;

            var preOrPostSolution = SolutionUtilities.ToPreOrPostSolution(preOrPostSolutionStr);

            ISolutionFileGlobalSection globalSection;

            switch (sectionName)
            {
            case SolutionConfigurationPlatformsGlobalSection.SolutionFileGlobalSectionName:
                globalSection = SolutionFileTextSerializer.DeserializeSolutionConfigurationPlatformsGlobalSection(reader, ref currentLine, preOrPostSolution);
                break;

            case ProjectConfigurationPlatformsGlobalSection.SolutionFileGlobalSectionName:
                globalSection = SolutionFileTextSerializer.DeserializeProjectConfigurationPlatformsGlobalSection(reader, ref currentLine, preOrPostSolution);
                break;

            case NestedProjectsSolutionFileGlobalSection.SolutionFileGlobalSectionName:
                globalSection = SolutionFileTextSerializer.DeserializeNestedProjectsGlobalSection(reader, ref currentLine, preOrPostSolution);
                break;

            default:
                globalSection = SolutionFileTextSerializer.DeserializeGeneralGlobal(reader, ref currentLine, sectionName, preOrPostSolution);
                break;
            }
            solutionFile.GlobalSections.Add(globalSection);
        }
Пример #3
0
        private static void SerializeGlobal(TabinatedWriter writer, ISerializableSolutionFileGlobalSection serializableGlobalSection)
        {
            var globalSectionLine = $"GlobalSection({serializableGlobalSection.Name}) = {SolutionUtilities.ToStringStandard(serializableGlobalSection.PreOrPostSolution)}";

            writer.WriteLine(globalSectionLine);

            writer.IncreaseTabination();
            foreach (var line in serializableGlobalSection.ContentLines)
            {
                writer.WriteLine(line);
            }
            writer.DecreaseTabination();

            writer.WriteLine("EndGlobalSection");
        }