public void SetCaps(Capitalization caps) { foreach (var ch in GetVisibleChannels()) { ch.Capitalization = caps; } }
public OutputChainBuffer(Sandbox sb, OutputChainBuffer prev, OutputChainBuffer targetOrigin) { _prevItem = prev; if (prev != null) { prev._nextItem = this; _caps = prev is OutputChainArticleBuffer && prev.Caps == Capitalization.First ? Capitalization.None : prev._caps; } _buffer = targetOrigin._buffer; sandbox = sb; }
public OutputChainBuffer(Sandbox sb, OutputChainBuffer prev) { _prevItem = prev; if (prev != null) { prev._nextItem = this; _caps = prev is OutputChainArticleBuffer && prev.Caps == Capitalization.First ? Capitalization.None : prev._caps; _numberFormatter.BinaryFormat = prev.NumberFormatter.BinaryFormat; _numberFormatter.BinaryFormatDigits = prev.NumberFormatter.BinaryFormatDigits; _numberFormatter.Endianness = prev.NumberFormatter.Endianness; _numberFormatter.NumberFormat = prev.NumberFormatter.NumberFormat; } _isTarget = true; _buffer = new StringBuilder(InitialCapacity); sandbox = sb; }
public static string Capitalize(string input, ref Capitalization caps, ref char lastChar) { if (String.IsNullOrEmpty(input)) return input; switch (caps) { case Capitalization.Lower: input = input.ToLower(); break; case Capitalization.Upper: input = input.ToUpper(); break; case Capitalization.First: input = RegCapsFirst.Replace(input, m => m.Value.ToUpper()); caps = Capitalization.None; break; case Capitalization.Word: char _lastChar = lastChar; input = RegCapsProper.Replace(input, m => (m.Index > 0 || Char.IsSeparator(_lastChar) || Char.IsWhiteSpace(_lastChar)) ? m.Value.ToUpper() : m.Value); break; } lastChar = input[input.Length - 1]; return input; }
public void Capitalize(Capitalization caps) => Do(chain => chain.Last.Caps = caps);
public CapitalizationDisplay(Capitalization capitalization, string name) { this.Capitalization = capitalization; this.Name = name; }
protected void Format(ref string value) { if (Util.IsNullOrWhiteSpace(value)) return; switch (_caps) { case Capitalization.Upper: value = value.ToUpperInvariant(); break; case Capitalization.Lower: value = value.ToLowerInvariant(); break; case Capitalization.Word: { char lastChar = _buffer.Length > 0 ? _buffer[_buffer.Length - 1] : _prevItem?.LastChar ?? '\0'; if (Char.IsWhiteSpace(lastChar) || wordSepChars.Contains(lastChar) || lastChar == '\0') { CapitalizeFirstLetter(ref value); } } break; case Capitalization.Sentence: { var b = _buffer; // Capitalize sentences in input value CapitalizeSentences(ref value); // If the buffer's empty, check previous buffer if (_buffer.Length == 0) { // Check if we're at the start if (_prevItem == null || (_prevItem.Prev == null && _prevItem.Length == 0)) { CapitalizeFirstLetter(ref value); break; } // If there is a previous buffer, scan the end. b = _prevItem._buffer; } // Scan buffer end to determine if capitalization is needed for (int i = b.Length - 1; i >= 0; i--) { if (Char.IsLetterOrDigit(b[i])) break; if (!sentenceTerminators.Contains(b[i])) continue; CapitalizeFirstLetter(ref value); break; } } break; case Capitalization.Title: { char lastChar = _buffer.Length > 0 ? _buffer[_buffer.Length - 1] : _prevItem?.LastChar ?? '\0'; bool boundary = Char.IsWhiteSpace(lastChar) || Char.IsSeparator(lastChar) || lastChar == '\0'; // This ensures that the first title word is always capitalized if (!_printedSinceCapsChange) { CapitalizeFirstLetter(ref value); return; } // If it's not capitalizable in a title, skip it. if (sandbox.Format.Excludes(value) && boundary) return; CapitalizeFirstLetter(ref value); } break; case Capitalization.First: if (CapitalizeFirstLetter(ref value) && !(this is OutputChainArticleBuffer)) _caps = Capitalization.None; break; } }
public static string ToCase(this string instance, Capitalization capitalization) { if (instance.IsNullOrDefault()) { return(String.Empty); } switch (capitalization) { case Capitalization.Lowercase: return(instance.ToLowerInvariant()); case Capitalization.Uppercase: return(instance.ToUpperInvariant()); case Capitalization.TitleCase: return(instance.ToTitleCase()); case Capitalization.TitleCaseExceptConjunctions: return(instance.ToTitleCase(true)); case Capitalization.SentenceCase: return(instance.ToSentenceCase()); default: return(instance); } }
private static bool TryParseCapitalizationScheme( string namingStyleCapitalization, out Capitalization capitalization ) { switch (namingStyleCapitalization) { case "pascal_case": capitalization = Capitalization.PascalCase; return(true); case "camel_case": capitalization = Capitalization.CamelCase; return(true); case "first_word_upper": capitalization = Capitalization.FirstUpper; return(true); case "all_upper": capitalization = Capitalization.AllUpper; return(true); case "all_lower": capitalization = Capitalization.AllLower; return(true); default: capitalization = default; return(false); } }
public void SetCaps(Capitalization caps) { foreach (var ch in GetActive()) { ch.Capitalization = caps; } }
public Text(string _text, GameFont _font, int _fontSize = 28, Capitalization capitalization = Capitalization.Regularcase) { Font = _font; fontSize = _fontSize; textCapitalzation = capitalization; UpdateText(_text); }
public static string Capitalize(string input, ref Capitalization caps, ref char lastChar) { if (String.IsNullOrEmpty(input)) { return(input); } switch (caps) { case Capitalization.Lower: input = input.ToLower(); break; case Capitalization.Upper: input = input.ToUpper(); break; case Capitalization.First: input = RegCapsFirst.Replace(input, m => m.Value.ToUpper()); caps = Capitalization.None; break; case Capitalization.Word: char _lastChar = lastChar; input = RegCapsProper.Replace(input, m => (m.Index > 0 || Char.IsSeparator(_lastChar) || Char.IsWhiteSpace(_lastChar)) ? m.Value.ToUpper() : m.Value); break; } lastChar = input[input.Length - 1]; return(input); }
/// <summary> /// Builds a randomized chain using weighted values. /// </summary> /// <param name="cap"></param> /// <param name="spaces"></param> /// <param name="c"></param> /// <param name="preferStopAfter">How long until we ask to stop ASAP?</param> /// <param name="demandStopAfter">How long until we call an immediate halt to generation?</param> /// <returns></returns> public Chain WriteChain(Capitalization cap, bool spaces, int preferStopAfter, int demandStopAfter, CultureInfo c = null) { var chain = new Chain(cap, spaces, c); var cur = BeginEndToken; bool runon = false; // did we get cut off? do { if (!cur.Links.Any()) { throw new InvalidOperationException($"Token \"{cur}\" has no outgoing links."); } cur = cur.Links.PickWeighted(Rng); if (chain.Tokens.Count() >= demandStopAfter) { cur = BeginEndToken; runon = true; } if (chain.Tokens.Count() >= preferStopAfter && cur.Links.ContainsKey(BeginEndToken)) { cur = BeginEndToken; runon = true; } chain.Append(cur); } while (cur != BeginEndToken); chain.IsRunon = runon; return(chain); }
public NamingStyle( Guid id, string name = null, string prefix = null, string suffix = null, string wordSeparator = null, Capitalization capitalizationScheme = Capitalization.PascalCase) : this() { ID = id; Name = name; Prefix = prefix ?? ""; Suffix = suffix ?? ""; WordSeparator = wordSeparator ?? ""; CapitalizationScheme = capitalizationScheme; }
public OutputChainBuffer(Sandbox sb, OutputChainBuffer prev, OutputChainBuffer targetOrigin) { NumberFormatter = new NumberFormatter(sb); Prev = prev; if (prev != null) { prev.Next = this; _caps = prev is OutputChainArticleBuffer && prev.Caps == Capitalization.First ? Capitalization.None : prev._caps; } _buffer = targetOrigin._buffer; _sandbox = sb; }
private static bool TryGetNamingCapitalization( string namingStyleName, IReadOnlyDictionary <string, string> conventionsDictionary, out Capitalization capitalization ) { var result = GetStringFromConventionsDictionary( namingStyleName, "capitalization", conventionsDictionary ); return(TryParseCapitalizationScheme(result, out capitalization)); }
private UiListItem NewRow(UCultureInfo modified, Capitalization capitalization) { #pragma warning disable 612, 618 UCultureInfo minimized = UCultureInfo.MinimizeSubtags(modified, UCultureInfo.Minimize.FavorScript); #pragma warning restore 612, 618 string tempName = modified.GetDisplayName(locale); bool titlecase = capitalization == Capitalization.UIListOrMenu; string nameInDisplayLocale = titlecase ? ToTitleWholeStringNoLowercase(locale, tempName) : tempName; tempName = modified.GetDisplayName(modified); string nameInSelf = capitalization == Capitalization.UIListOrMenu ? ToTitleWholeStringNoLowercase(modified, tempName) : tempName; return(new UiListItem(minimized, modified, nameInDisplayLocale, nameInSelf)); }
public static string ToCase(this string value, Capitalization capitalization) { if (string.IsNullOrEmpty(value)) { return(string.Empty); } return(capitalization switch { Capitalization.Lowercase => value.ToLowerInvariant(), Capitalization.Uppercase => value.ToUpperInvariant(), Capitalization.TitleCase => value.ToTitleCase(), Capitalization.TitleCaseExceptConjunctions => value.ToTitleCase(true), Capitalization.SentenceCase => value.ToSentenceCase(), _ => value, });
//функция для инициирования валидации private void validate() { int x1 = 0; flag = false; Initial_investment_amount += " "; flag = true; x1 = Initial_investment_amount.Length - 1; Initial_investment_amount = Initial_investment_amount.Substring(0, x1); flag = false; Yield += " "; flag = true; x1 = Yield.Length - 1; Yield = Yield.Substring(0, x1); flag = false; Capitalization += " "; flag = true; x1 = Capitalization.Length - 1; Capitalization = Capitalization.Substring(0, x1); flag = false; Addon_amount += " "; flag = true; x1 = Addon_amount.Length - 1; Addon_amount = Addon_amount.Substring(0, x1); flag = false; Number_of_additions += " "; flag = true; x1 = Number_of_additions.Length - 1; Number_of_additions = Number_of_additions.Substring(0, x1); flag = false; Total_investment_term += " "; flag = true; x1 = Total_investment_term.Length - 1; Total_investment_term = Total_investment_term.Substring(0, x1); flag = false; }
public OutputChainBuffer(Sandbox sb, OutputChainBuffer prev) { NumberFormatter = new NumberFormatter(sb); Prev = prev; if (prev != null) { if (prev.Next != null) { prev.Next.Prev = this; } prev.Next = this; _caps = prev is OutputChainArticleBuffer && prev.Caps == Capitalization.First ? Capitalization.None : prev._caps; NumberFormatter.BinaryFormat = prev.NumberFormatter.BinaryFormat; NumberFormatter.BinaryFormatDigits = prev.NumberFormatter.BinaryFormatDigits; NumberFormatter.Endianness = prev.NumberFormatter.Endianness; NumberFormatter.NumberFormat = prev.NumberFormatter.NumberFormat; } IsTarget = true; _buffer = new StringBuilder(InitialCapacity); _sandbox = sb; }
/// <summary> /// Get a string composed of random lorem ipsum words. Will not end with punctuation. /// </summary> /// <param name="wordCount">Number of words.</param> /// <param name="capitalize">How to capitalize the words.</param> /// <returns></returns> public static string GetWords(int wordCount, Capitalization capitalization) { EnsureWords(); _builder.Length = 0; while (wordCount-- > 0) { int position = _builder.Length; _builder.Append(_rnd.Next(_words)); if (capitalization == Capitalization.AllWords || (position == 0 && capitalization == Capitalization.FirstWord)) { _builder[position] = char.ToUpper(_builder[position]); } if (wordCount > 0) { _builder.Append(' '); } } return(_builder.ToString()); }
public static string ToEditorConfigString(this Capitalization capitalization) { switch (capitalization) { case Capitalization.PascalCase: return("pascal_case"); case Capitalization.CamelCase: return("camel_case"); case Capitalization.FirstUpper: return("first_word_upper"); case Capitalization.AllUpper: return("all_upper"); case Capitalization.AllLower: return("all_lower"); default: throw ExceptionUtilities.UnexpectedValue(capitalization); } }
protected void Format(ref string value) { if (Util.IsNullOrWhiteSpace(value)) { return; } switch (_caps) { case Capitalization.Upper: value = value.ToUpperInvariant(); break; case Capitalization.Lower: value = value.ToLowerInvariant(); break; case Capitalization.Word: { char lastChar = _buffer.Length > 0 ? _buffer[_buffer.Length - 1] : _prevItem?.LastChar ?? '\0'; if (Char.IsWhiteSpace(lastChar) || wordSepChars.Contains(lastChar) || lastChar == '\0') { CapitalizeFirstLetter(ref value); } } break; case Capitalization.Sentence: { var b = _buffer; // Capitalize sentences in input value CapitalizeSentences(ref value); // If the buffer's empty, check previous buffer if (_buffer.Length == 0) { // Check if we're at the start if (_prevItem == null || (_prevItem.Prev == null && _prevItem.Length == 0)) { CapitalizeFirstLetter(ref value); break; } // If there is a previous buffer, scan the end. b = _prevItem._buffer; } // Scan buffer end to determine if capitalization is needed for (int i = b.Length - 1; i >= 0; i--) { if (Char.IsLetterOrDigit(b[i])) { break; } if (!sentenceTerminators.Contains(b[i])) { continue; } CapitalizeFirstLetter(ref value); break; } } break; case Capitalization.Title: { char lastChar = _buffer.Length > 0 ? _buffer[_buffer.Length - 1] : _prevItem?.LastChar ?? '\0'; bool boundary = Char.IsWhiteSpace(lastChar) || Char.IsSeparator(lastChar) || lastChar == '\0'; // This ensures that the first title word is always capitalized if (!_printedSinceCapsChange) { CapitalizeFirstLetter(ref value); return; } // If it's not capitalizable in a title, skip it. if (sandbox.Format.Excludes(value) && boundary) { return; } CapitalizeFirstLetter(ref value); } break; case Capitalization.First: if (CapitalizeFirstLetter(ref value) && !(this is OutputChainArticleBuffer)) { _caps = Capitalization.None; } break; } }
public Chain(Capitalization cap, bool spaces, CultureInfo c = null) { Capitalization = cap; UseSpaces = spaces; Culture = c; }
protected void Format(ref string value) { if (Util.IsNullOrWhiteSpace(value)) { return; } switch (_charType) { case CharConversion.Fullwidth: value = new string(value.Select(c => CharConverter.ToFullwidth(c)).ToArray()); break; case CharConversion.Cursive: { var sb = new StringBuilder(); foreach (char c in value) { sb.Append(CharConverter.ToScript(c)); } value = sb.ToString(); break; } case CharConversion.BoldCursive: { var sb = new StringBuilder(); foreach (char c in value) { sb.Append(CharConverter.ToBoldScript(c)); } value = sb.ToString(); break; } } switch (_caps) { case Capitalization.Upper: value = value.ToUpperInvariant(); break; case Capitalization.Lower: value = value.ToLowerInvariant(); break; case Capitalization.Word: { char lastChar = _buffer.Length > 0 ? _buffer[_buffer.Length - 1] : Prev?.LastChar ?? '\0'; if (char.IsWhiteSpace(lastChar) || _wordSepChars.Contains(lastChar) || lastChar == '\0') { CapitalizeFirstLetter(ref value); } } break; case Capitalization.Sentence: { var b = _buffer; // Capitalize sentences in input value CapitalizeSentences(ref value); // If the buffer's empty, check previous buffer if (_buffer.Length == 0) { // Check if we're at the start if (Prev == null || Prev.Prev == null && Prev.Length == 0) { CapitalizeFirstLetter(ref value); break; } // If there is a previous buffer, scan the end. b = Prev._buffer; } else if (Prev == null || Prev.Length == 0) { for (int i = b.Length - 1; i >= 0; i--) { if (char.IsLetterOrDigit(b[i])) { break; } if (_sentenceTerminators.Contains(b[i])) { break; } if (i == 0) { CapitalizeFirstLetter(ref value); } } } // Scan buffer end to determine if capitalization is needed for (int i = b.Length - 1; i >= 0; i--) { if (char.IsLetterOrDigit(b[i])) { break; } if (!_sentenceTerminators.Contains(b[i])) { continue; } CapitalizeFirstLetter(ref value); break; } } break; case Capitalization.Title: { CapitalizeTitleString(ref value, _sandbox.Format, !PrintedSinceCapsChange); } break; case Capitalization.First: if (CapitalizeFirstLetter(ref value) && !(this is OutputChainArticleBuffer)) { _caps = Capitalization.None; } break; } }
private static void Case(Sandbox sb, [RantDescription("The capitalization mode to use.")] Capitalization textCase) { sb.Output.Capitalize(textCase); }
public CapitalizationDisplay(Capitalization capitalization, string name) { Capitalization = capitalization; Name = name; }
public static string GetDualTerm(this DateTimeInterval instance, Capitalization capitalization = Capitalization.Lowercase) { return(instance.GetAttribute <QuantifierAttribute, DateTimeInterval>().Dual.ToCase(capitalization)); }
/// <summary> /// Format the current date giving the user the same options as the legacy eScribe merge fields wizard /// </summary> protected override void DoWork(CodeActivityContext context) { string result = DateTime.Now.ToShortDateString(); switch (DateFormat.Get(context)) { case 1: result = DateTime.Now.ToShortDateString(); break; case 2: result = DateTime.Now.ToLongDateString(); break; case 3: result = DateTime.Now.ToString("M/dd/yy"); break; case 4: result = DateTime.Now.ToString("MM/dd/yy"); break; case 5: result = DateTime.Now.ToString("MM/dd/yyyy"); break; case 6: result = DateTime.Now.ToString("MMM dd, yyyy"); break; case 7: result = DateTime.Now.ToString("MMMM dd, yyyy"); break; case 8: result = DateTime.Now.ToString("dd/MM/yy"); break; case 9: result = DateTime.Now.ToString("dd/MM/yyyy"); break; case 10: result = DateTime.Now.ToString("dd MMM yy"); break; case 11: result = DateTime.Now.ToString("dd MMM yyyy"); break; case 12: result = DateTime.Now.ToString("yy/MM/dd"); break; case 13: result = DateTime.Now.ToString("yyyy/MM/dd"); break; case 14: result = DateTime.Now.ToString("yyMMdd"); break; case 15: result = DateTime.Now.ToString("yyyyMMdd"); break; case 16: result = DateTime.Now.ToString("MM/yy"); break; case 17: result = DateTime.Now.ToString("MM/yyyy"); break; case 18: result = DateTime.Now.ToString("yy/MM"); break; case 19: result = DateTime.Now.ToString("yyyy/MM"); break; } switch (AlternateSeparators.Get(context)) { case 1: // do nothing break; case 2: // do nothing break; case 3: result = result.Replace('/', '.'); break; case 4: result = result.Replace('/', '-'); break; case 5: result = result.Replace('/', ' '); break; case 6: result = result.Replace('/', ' '); break; } string shortDayOfWeek = DateTime.Now.ToString("ddd"); string longDayOfWeek = DateTime.Now.ToString("dddd"); switch (Capitalization.Get(context)) { case 1: // do nothing break; case 2: result = result.ToUpper(); shortDayOfWeek = shortDayOfWeek.ToUpper(); longDayOfWeek = longDayOfWeek.ToUpper(); break; case 3: result = result.ToLower(); shortDayOfWeek = shortDayOfWeek.ToLower(); longDayOfWeek = longDayOfWeek.ToLower(); break; case 4: // capitalize first letter break; } // It looks like the .Net 'control panel long format' includes the day of the week, while Clarion's // function does not. For that reason we need to remove it first and then add it as necessary int pos = result.IndexOf(longDayOfWeek); if (pos >= 0) result = result.Remove(pos, longDayOfWeek.Length + 1).Trim(); pos = result.IndexOf(shortDayOfWeek); if (pos >= 0) result = result.Remove(pos, shortDayOfWeek.Length + 1).Trim(); switch (PrependDayOfWeek.Get(context)) { case 1: break; case 2: result = String.Format("{0}, {1}", longDayOfWeek, result); break; case 3: result = String.Format("{0}, {1}", shortDayOfWeek, result); break; } PlainText.Set(context, result); Html.Set(context, null); }
public override IList <UiListItem> GetUiListCompareWholeItems(ICollection <UCultureInfo> cultures, IComparer <UiListItem> comparer) { Capitalization capContext = displayContextOptions.Capitalization; List <UiListItem> result = new List <UiListItem>(); IDictionary <UCultureInfo, ISet <UCultureInfo> > baseToLocales = new Dictionary <UCultureInfo, ISet <UCultureInfo> >(); UCultureInfoBuilder builder = new UCultureInfoBuilder(); foreach (var locOriginal in cultures) { builder.SetCulture(locOriginal); // verify well-formed. We do this here so that we consistently throw exception UCultureInfo loc = UCultureInfo.AddLikelySubtags(locOriginal); UCultureInfo @base = new UCultureInfo(loc.Language); if (!baseToLocales.TryGetValue(@base, out ISet <UCultureInfo> locales) || locales == null) { baseToLocales[@base] = locales = new JCG.HashSet <UCultureInfo>(1); } locales.Add(loc); } foreach (var entry in baseToLocales) { UCultureInfo @base = entry.Key; ISet <UCultureInfo> values = entry.Value; if (values.Count == 1) { UCultureInfo locale = values.First(); #pragma warning disable 612, 618 result.Add(NewRow(UCultureInfo.MinimizeSubtags(locale, UCultureInfo.Minimize.FavorScript), capContext)); #pragma warning restore 612, 618 } else { ISet <string> scripts = new JCG.HashSet <string>(values.Count + 1); ISet <string> regions = new JCG.HashSet <string>(values.Count + 1); // need the follow two steps to make sure that unusual scripts or regions are displayed UCultureInfo maxBase = UCultureInfo.AddLikelySubtags(@base); scripts.Add(maxBase.Script); regions.Add(maxBase.Country); foreach (UCultureInfo locale in values) { scripts.Add(locale.Script); regions.Add(locale.Country); } bool hasScripts = scripts.Count > 1; bool hasRegions = regions.Count > 1; foreach (UCultureInfo locale in values) { UCultureInfoBuilder modified = builder.SetCulture(locale); if (!hasScripts) { modified.SetScript(""); } if (!hasRegions) { modified.SetRegion(""); } result.Add(NewRow(modified.Build(), capContext)); } } } result.Sort(comparer); return(result); }