Пример #1
0
        private static Option <bool> CreateNewLineForBracesOption(NewLineOption newLineOption, string name)
        {
            var option = CreateOption(
                CSharpFormattingOptionGroups.NewLine, name,
                defaultValue: true,
                storageLocations: new OptionStorageLocation[] {
                new EditorConfigStorageLocation <bool>(
                    "csharp_new_line_before_open_brace",
                    value => DetermineIfNewLineOptionIsSet(value, newLineOption),
                    GetNewLineOptionEditorConfigString),
                new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{name}")
            });

            Debug.Assert(s_newLineOptionsEditorConfigMap.ContainsValue(newLineOption));
            s_newLineOptionsMapBuilder.Add(option, newLineOption);

            return(option);
        }
        internal static bool DetermineIfNewLineOptionIsSet(string value, NewLineOption optionName)
        {
            var values = value.Split(',').Select(v => v.Trim());

            if (values.Any(s => s == "all"))
            {
                return(true);
            }

            if (values.Any(s => s == "none"))
            {
                return(false);
            }

            return((from v in values
                    let option = ConvertToNewLineOption(v)
                                 where option.HasValue && option.Value == optionName
                                 select option)
                   .Any());
        }
 static void TestParseNewLineOptionTrue(string value, NewLineOption option)
 {
     Assert.True(DetermineIfNewLineOptionIsSet(value, option),
                 $"Expected option {value} to be set");
 }
 static void TestParseNewLineOptionTrue(string value, NewLineOption option)
 {
     Assert.True(DetermineIfNewLineOptionIsSet(value, option),
                 $"Expected option {value} to be set");
 }