public static string GetStyle <T>(NamingStyles style) { switch (style) { case NamingStyles.Windows: return(Styles[typeof(T)].Windows); break; case NamingStyles.Fixed: return(Styles[typeof(T)].Fixed); break; case NamingStyles.CSharp: return(Styles[typeof(T)].CSharp); break; case NamingStyles.CSharpKeyword: return(Styles[typeof(T)].CSharpKeyword); break; default: throw new ArgumentOutOfRangeException(nameof(style), style, null); } }
internal void UpdateStyleList(ManageNamingStylesDialogViewModel viewModel) { var namingStyles = viewModel.Items .Cast <NamingStyleViewModel>() .Select( n => new MutableNamingStyle( new NamingStyle( id: n.ID, name: n.ItemName, prefix: n.RequiredPrefix, suffix: n.RequiredSuffix, wordSeparator: n.WordSeparator, capitalizationScheme: n.CapitalizationSchemes[ n.CapitalizationSchemeIndex ].Capitalization ) ) ); NamingStyles.Clear(); foreach (var style in namingStyles) { NamingStyles.Add(style); } // The existing rules have had their Styles pulled out from underneath them, so // this goes through and resets them. foreach (var rule in CodeStyleItems) { var selectedStyle = rule.SelectedStyle; rule.NamingStyles.Clear(); foreach (var style in namingStyles) { rule.NamingStyles.Add(style); } // Set the SelectedStyle to null and then back to the actual selected // style to trigger the INotifyPropertyChanged event. rule.SelectedStyle = null; if (selectedStyle != null) { rule.SelectedStyle = rule.NamingStyles.Single(n => n.ID == selectedStyle.ID); } } }
internal nameHandler(NamingStyles style) { switch (style) { case NamingStyles.LowerCase: _handle = (s) => s.ToLower(); break; case NamingStyles.CamelCase: _handle = (s) => { var chars = s.ToCharArray(); var isAllUpper = true; for (var ci = 0; ci < chars.Length; ci++) { if (!Char.IsUpper(chars[ci])) { isAllUpper = false; break; } } if (isAllUpper) { return(s.ToLower()); } chars[0] = Char.ToLower(chars[0]); return(new string(chars)); }; break; case NamingStyles.Normal: default: _handle = (s) => s; break; } }