/// <summary> /// Converts or manipulates the <see cref="string" /> value based on the specified <see cref="StringConverterMethod" /> parameter. /// </summary> /// <param name="value">The <see cref="string" /> value to convert.</param> /// <param name="parameter">A parameter <see cref="object" /> that specifies the parameter used in some of the <see cref="StringConverterMethod" /> methods.</param> /// <returns> /// An <see cref="object" /> with the result of the conversion. /// </returns> public override object Convert(string value, object parameter) { return(Method switch { StringConverterMethod.Concat => value + parameter, StringConverterMethod.Trim => value?.Trim(), StringConverterMethod.TrimStart => value?.TrimStart(), StringConverterMethod.TrimStartString => value?.TrimStartString(parameter?.ToString()), StringConverterMethod.TrimStartStringIgnoreCase => value?.TrimStartString(parameter?.ToString(), true), StringConverterMethod.TrimEnd => value?.TrimEnd(), StringConverterMethod.TrimEndString => value?.TrimEndString(parameter?.ToString()), StringConverterMethod.TrimEndStringIgnoreCase => value?.TrimEndString(parameter?.ToString(), true), StringConverterMethod.ToLower => value?.ToLower(), StringConverterMethod.ToUpper => value?.ToUpper(), StringConverterMethod.ToCamelCase => value?.ChangeCasing(StringCasing.CamelCase), StringConverterMethod.ToLowerSnakeCase => value?.ChangeCasing(StringCasing.LowerSnakeCase), StringConverterMethod.ToUpperSnakeCase => value?.ChangeCasing(StringCasing.UpperSnakeCase), StringConverterMethod.ToLowerKebabCase => value?.ChangeCasing(StringCasing.LowerKebabCase), StringConverterMethod.ToUpperKebabCase => value?.ChangeCasing(StringCasing.UpperKebabCase), StringConverterMethod.Substring => value?.Substring((int)parameter), StringConverterMethod.Left => value?.Left((int)parameter), StringConverterMethod.Right => value?.Right((int)parameter), StringConverterMethod.StartsWith => value?.StartsWith(parameter?.ToString()) == true, StringConverterMethod.StartsWithIgnoreCase => value?.StartsWith(parameter?.ToString(), StringComparison.OrdinalIgnoreCase) == true, StringConverterMethod.EndsWith => value?.EndsWith(parameter?.ToString()) == true, StringConverterMethod.EndsWithIgnoreCase => value?.EndsWith(parameter?.ToString(), StringComparison.OrdinalIgnoreCase) == true, StringConverterMethod.Contains => value?.Contains(parameter?.ToString()) == true, StringConverterMethod.ContainsIgnoreCase => value?.Contains(parameter?.ToString(), SpecialStringComparisons.IgnoreCase) == true, StringConverterMethod.ReplaceLineBreaks => value?.ReplaceLineBreaks(parameter?.ToString()), StringConverterMethod.TrimText => value == null ? null : Wording.TrimText(value, (int)parameter), StringConverterMethod.StringDistanceLevenshtein => value != null && parameter is string?StringDistance.Levenshtein(value, (string)parameter) : (int?)null, StringConverterMethod.StringDistanceDamerauLevenshtein => value != null && parameter is string?StringDistance.DamerauLevenshtein(value, (string)parameter) : (int?)null, _ => throw Throw.InvalidEnumArgument(nameof(Method), Method) });
static void Main(string[] args) { //A string is considered to be in title case if each word in the string is //either (a)capitalised(that is, only the first letter of the word is in upper case) //or(b) considered to be an exception and put entirely into lower case unless it is the //first word, which is always capitalised. Write a function that will convert a string //into title case, given an optional list of exceptions(minor words). //Вызов StringConversion sc = new StringConversion(); string title1 = sc.ToTitleWords("a clash of KINGS"); Console.WriteLine(title1); string title2 = sc.ToTitleWords("THE WIND IN THE WILLOWS"); Console.WriteLine(title2); //You need to write a function AddOrChangeUrlParameter(url, keyValueParameter) that //can manipulate URL parameters. It should be able to add a parameter to an existing URL, but //also to change a parameter if it already exists. //Вызов ModifyUrl.AddOrChangeUrlParameter("www.example.com", "key=value"); ModifyUrl.AddOrChangeUrlParameter("www.example.com?key=value", "key2=value2"); ModifyUrl.AddOrChangeUrlParameter("www.example.com?key=oldValue", "key=newValue"); //Implement the function UniqueInOrder which takes as argument a sequence and returns a list of //items without any elements with the same value next to each other and preserving //the original order of elements. //Вызов UniqueOrder <string, char> list1 = new UniqueOrder <string, char>(); string s1 = list1.UniqueInOrder("AAAABBBCCDAABBB").ToString(); string s2 = list1.UniqueInOrder("ABBCcAD").ToString(); string s3 = list1.UniqueInOrder("12233").ToString(); UniqueOrder <List <double>, double> list2 = new UniqueOrder <List <double>, double>(); List <double> num = list2.UniqueInOrder(new List <double> { 1.1, 2.2, 2.2, 3.3 }); //Complete the solution so that it reverses all of the words within the string passed in //Вызов Wording words = new Wording(); string text = words.ReverseWords("The greatest victory is that which requires no battle"); Console.WriteLine(text); //Write a function that returns the sum of two big numbers. The input numbers are strings and the function must return a string. Summing sum = new Summing(); string sumTotal = sum.findSum("4567902", "245666"); Console.WriteLine(sumTotal); }
private void SaveRecord() { Wording current = (Wording)bs.Current; if (current.WordID == 0) // new wording created by this form { // insert into table DBAction.InsertWording(current); Dirty = false; } else if (Dirty) // existing study edited { DBAction.UpdateWording(current); Dirty = false; } }
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = true; string stackTrace = e.Exception.GetFullStackTrace(); if (MainWindowViewModel.Singleton?.IsInitialized == true) { // If the main window is initialized, display the exception in the log view. MainWindowViewModel.Singleton.Log(new LogMessage ( LogMessageType.Error, new LogTextItem(stackTrace) )); } else { // If the exception occurred before the main window is initialized, display a MessageBox and exit. MessageBoxes.Error(Wording.TrimText(stackTrace, 1000)); Current.Shutdown(); } }
public SceneGame(Wording w, string prefix) : base(w, prefix) { }
public SceneTitle(Wording w, string prefix) : base(w, prefix) { }
public TerrainImage(Wording w, string prefix) : base(w, prefix) { }
public static string GetWordingPath(Wording wording) { return(GetRootPath() + "/Wordings/" + wording.ImageUri); }
public static string GetFashionResultPath(Wording wording) { return(rootPath + "res/Wordings/" + wording.ImageUri); }
public Road(Wording w, string prefix) : base(w, prefix) { }
public Religion(Wording w, string prefix) : base(w, prefix) { }
public Culture(Wording w, string prefix) : base(w, prefix) { }
public ScenarioMode(Wording w, string prefix) : base(w, prefix) { }
public StartMode(Wording w, string prefix) : base(w, prefix) { }
public GameMode(Wording w, string prefix) : base(w, prefix) { }
public SceneEditGameWorld(Wording w, string prefix) : base(w, prefix) { }
public static string GetWordingPath(Wording wording) { return(rootPath + "res/Wordings/" + wording.ImageUri); }
public StrongholdType(Wording w, string prefix) : base(w, prefix) { }
public Character(Wording w, string prefix) : base(w, prefix) { }
public Force(Wording w, string prefix) : base(w, prefix) { }
public static string GetFashionResultPath(Wording wording) { return(GetRootPath() + "/Wordings/" + wording.ImageUri); }
public TileMapImageInfo(Wording w, string prefix) : base(w, prefix) { }
public void BytecodeApi_Text_Wording() { string str = Create.AlphaNumericString(100); Assert.AreEqual(Wording.Rot13(Wording.Rot13(str)), str); }
/// <summary> /// Converts the <see cref="TimeSpan" />? value to a human readable <see cref="string" /> based on the specified parameters used for the <see cref="Wording.FormatTimeSpan(TimeSpan, int, string)" /> method. /// </summary> /// <param name="value">The <see cref="TimeSpan" />? value to convert.</param> /// <returns> /// A <see cref="string" /> with the result of the conversion. /// </returns> public override string Convert(TimeSpan?value) { return(value == null ? null : Wording.FormatTimeSpan(value.Value, MaxElements, Separator)); }