/// <inheritdoc /> protected override async Task <Result <bool, IError> > Run( IStateMonad stateMonad, CancellationToken cancellationToken) { var superstringResult = await String.Run(stateMonad, cancellationToken) .Map(async x => await x.GetStringAsync()); if (superstringResult.IsFailure) { return(superstringResult.ConvertFailure <bool>()); } var substringResult = await Substring.Run(stateMonad, cancellationToken) .Map(async x => await x.GetStringAsync()); if (substringResult.IsFailure) { return(substringResult.ConvertFailure <bool>()); } var ignoreCaseResult = await IgnoreCase.Run(stateMonad, cancellationToken); if (ignoreCaseResult.IsFailure) { return(ignoreCaseResult.ConvertFailure <bool>()); } var comparison = ignoreCaseResult.Value ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; var r = superstringResult.Value.Contains(substringResult.Value, comparison); return(r); }
/// <summary> /// Is /// </summary> /// <param name="s"></param> /// <param name="type"></param> /// <param name="action"></param> /// <param name="ignoreCase"></param> /// <param name="format"></param> /// <param name="numberStyle"></param> /// <param name="dateTimeStyle"></param> /// <param name="provider"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"></exception> public static bool Is(this string s, Type type, IgnoreCase ignoreCase = IgnoreCase.FALSE, Action <object> action = null, string format = null, NumberStyles?numberStyle = null, DateTimeStyles?dateTimeStyle = null, IFormatProvider provider = null) { if (type is null) { throw new ArgumentNullException(nameof(type)); } __unsupportedTypeCheck(type, out var typeIsAssignableFromEncoding); return(TypeIs.__enumIs(s, type, action, ignoreCase) || TypeIs.__charIs(s, type, action) || TypeIs.__numericIs(s, type, action, numberStyle, provider) || TypeIs.__booleanIs(s, type, action) || TypeIs.__dateTimeIs(s, type, action, format, dateTimeStyle, provider) || TypeIs.__dateTimeOffsetIs(s, type, action, format, dateTimeStyle, provider) || TypeIs.__timeSpanIs(s, type, action, format, provider) || TypeIs.__guidIs(s, type, action, format) || TypeIs.__versionIs(s, type, action) || TypeIs.__ipAddressIs(s, type, action) || TypeIs.__encodingIs(s, action, typeIsAssignableFromEncoding)); void __unsupportedTypeCheck(Type t, out bool flag) { flag = typeof(Encoding).IsAssignableFrom(t); if (!t.IsValueType && !flag && t == typeof(Version) && t == typeof(IPAddress)) { throw new ArgumentException("Unsupported type"); } } }
public override void Process(TagHelperContext context, TagHelperOutput output) { Name = Name.WithArraySuffix(); base.Process(context, output); if (!string.IsNullOrEmpty(Name)) { output.Attributes.Add($"data-{ElementName}-name", Name); } RenderFieldHeader(context, output); var id = GetDomId(); var datalistId = "suggestion-" + id ?? Guid.NewGuid().ToString(); var name = Name; output.Attributes.Add("data-aiplugs-tag-ignore-case", IgnoreCase.ToString().ToLower()); if (Ajax != null) { output.Attributes.Add($"data-aiplugs-tag-ajax-url", Ajax.Url ?? ""); if (Ajax.Headers != null) { foreach (var kv in Ajax.Headers) { output.Attributes.Add($"data-aiplugs-tag-ajax-headers-{kv.Key}", kv.Value); } } output.Attributes.Add("data-aiplugs-tag-ajax-label", Ajax.Label ?? "label"); output.Attributes.Add("data-aiplugs-tag-ajax-value", Ajax.Value ?? "value"); } RenderFieldFooter(context, output, name); output.Tag("div", () => { output.Attr("class", "aiplugs-tag__values"); output.Attr("data-target", "aiplugs-tag.items"); }, () => { RenderInput(context, output, name, target: false); output.Html("<template data-target=\"aiplugs-tag.template\">"); RenderValue(context, output, name); output.Html("</template>"); foreach (var value in Value ?? new string[0]) { RenderValue(context, output, name, value); } output.Tag("input", () => { output.Attr("list", datalistId); output.Attr("class", "aiplugs-tag__input val-ignore"); output.Attr("data-target", "aiplugs-tag.input"); output.Attr("data-action", "keydown->aiplugs-tag#onKeydown"); }); if (Ajax != null) { output.Html($"<datalist id=\"{datalistId}\" data-target=\"aiplugs-tag.suggestion\"></datalist>"); } }); }
public override XmlElement ToXml(XmlDocument doc) { var root = base.ToXml(doc); root["Comparison"].SetAttribute("ignoreCase", IgnoreCase.ToString()); root["Comparison"].SetAttribute("isContained", IsContained.ToString()); return(root); }
public static bool X(this IgnoreCase ignoreCase) { return(ignoreCase switch { IgnoreCase.TRUE => true, IgnoreCase.FALSE => false, _ => false });
/// <summary> /// Cast to /// </summary> /// <param name="str"></param> /// <param name="ignoreCase"></param> /// <param name="defaultVal"></param> /// <param name="format"></param> /// <param name="numberStyles"></param> /// <param name="dateTimeStyles"></param> /// <param name="formatProvider"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static T CastTo <T>(this string str, IgnoreCase ignoreCase, T defaultVal = default, string format = null, NumberStyles?numberStyles = null, DateTimeStyles?dateTimeStyles = null, IFormatProvider formatProvider = null) where T : struct { T result = default; return(str.Is <T>(ignoreCase, t => result = t, format, numberStyles, dateTimeStyles, formatProvider) ? result : defaultVal); }
protected override void Execute(CodeActivityContext context) { string inputString = InputString.Get(context); string suffixString = SuffixString.Get(context); bool ignoreCase = IgnoreCase.Get(context); var result = inputString.AppendSuffixIfMissing(suffixString, ignoreCase); Result.Set(context, result); }
protected override void Execute(CodeActivityContext context) { string inputString = InputString.Get(context); string prefixString = PrefixString.Get(context); bool ignoreCase = IgnoreCase.Get(context); var result = inputString.RemovePrefix(prefixString, ignoreCase); Result.Set(context, result); }
protected override void ProcessRecord() { var qualities = _dynLib.GetParameterValues <string>("Quality").ToList(); string cutoff = _dynLib.GetParameterValue <string>("Cutoff"); var ieq = new IgnoreCase(); if (!qualities.Contains(cutoff, ieq)) { qualities.Add(cutoff); } }
/// <summary> /// Cast to /// </summary> /// <param name="str"></param> /// <param name="type"></param> /// <param name="ignoreCase"></param> /// <param name="format"></param> /// <param name="numberStyles"></param> /// <param name="dateTimeStyles"></param> /// <param name="formatProvider"></param> /// <returns></returns> public static object CastToNullable(this string str, Type type, IgnoreCase ignoreCase, string format = null, NumberStyles?numberStyles = null, DateTimeStyles?dateTimeStyles = null, IFormatProvider formatProvider = null) { object result = default; return(str.IsNullable(type, (t) => result = t, () => result = null, ignoreCase.X(), format, numberStyles, dateTimeStyles, formatProvider) ? result : null); }
/// <summary> /// Cast to /// </summary> /// <param name="str"></param> /// <param name="ignoreCase"></param> /// <param name="format"></param> /// <param name="numberStyles"></param> /// <param name="dateTimeStyles"></param> /// <param name="formatProvider"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static T?CastToNullable <T>(this string str, IgnoreCase ignoreCase, string format = null, NumberStyles?numberStyles = null, DateTimeStyles?dateTimeStyles = null, IFormatProvider formatProvider = null) where T : struct { T?result = default; return(str.IsNullable <T>((t) => result = t, () => result = null, ignoreCase.X(), format, numberStyles, dateTimeStyles, formatProvider) ? result : null); }
/// <summary> /// Not In /// </summary> /// <param name="char"></param> /// <param name="case"></param> /// <param name="values"></param> /// <returns></returns> public static bool BeNotContainedIn(char @char, char[] values, IgnoreCase @case) { if (values is null || values.Length == 0) { return(true); } if (@case == IgnoreCase.FALSE) { return(BeNotContainedIn(@char, values)); } return(BeNotContainedIn(@char, IgnoreCaseHelper.FillChars(values))); }
/// <summary> /// / /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { int hashCode = (_srctype != null ? _srctype.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (_properties != null ? _properties.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (_array != null ? _array.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)_uObjMode; hashCode = (hashCode * 397) ^ (Parent != null ? Parent.GetHashCode() : 0); hashCode = (hashCode * 397) ^ IgnoreCase.GetHashCode(); return(hashCode); } }
public static bool TryToEnum <T>(this string s, IgnoreCase ignoreCase, out T value) where T : struct { var type = typeof(T); if (!type.GetTypeInfo().IsEnum) { throw new ArgumentException(); } // ReSharper disable once RedundantAssignment value = default(T); return(Enum.TryParse(s, ignoreCase == IgnoreCase.Yes, out value)); }
public override int GetHashCode() { unchecked // Overflow is fine { int hash = 17; hash = hash * 23 + (IgnoreCase ? IgnoreCase.GetHashCode() : 0); hash = hash * 23 + (Field != null ? Field.GetHashCode() : 0); hash = hash * 23 + (TargetName != null ? TargetName.GetHashCode() : 0); hash = hash * 23 + (TargetType != null ? TargetType.GetHashCode() : 0); return(hash); } }
/// <inheritdoc /> protected override async Task <Result <Array <T>, IError> > Run( IStateMonad stateMonad, CancellationToken cancellationToken) { var entityStreamResult = await Array.Run(stateMonad, cancellationToken); if (entityStreamResult.IsFailure) { return(entityStreamResult.ConvertFailure <Array <T> >()); } var ignoreCaseResult = await IgnoreCase.Run(stateMonad, cancellationToken); if (ignoreCaseResult.IsFailure) { return(ignoreCaseResult.ConvertFailure <Array <T> >()); } IEqualityComparer <string> comparer = ignoreCaseResult.Value ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; HashSet <string> usedKeys = new(comparer); var currentState = stateMonad.GetState().ToImmutableDictionary(); async IAsyncEnumerable <T> Filter(T element) { await using var scopedMonad = new ScopedStateMonad( stateMonad, currentState, new KeyValuePair <VariableName, object>(Variable, element !) ); var result = await KeySelector.Run(scopedMonad, cancellationToken) .Map(async x => await x.GetStringAsync()); if (result.IsFailure) { throw new ErrorException(result.Error); } if (usedKeys.Add(result.Value)) { yield return(element); } } var newStream = entityStreamResult.Value.SelectMany(Filter); return(newStream); }
public override int GetHashCode() { unchecked { var hashCode = Position; hashCode = (hashCode * 397) ^ (SearchText != null ? SearchText.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Filter.GetHashCode(); hashCode = (hashCode * 397) ^ Highlight.GetHashCode(); hashCode = (hashCode * 397) ^ UseRegex.GetHashCode(); hashCode = (hashCode * 397) ^ IgnoreCase.GetHashCode(); return(hashCode); } }
public static IAbstractFactory getAbstract(string choice) { if (IgnoreCase.equalIgnoreCase(choice, "Bank")) { return(new BankFactory()); } else if (IgnoreCase.equalIgnoreCase(choice, "Loan")) { return(new LoanFactory()); } throw new ArgumentOutOfRangeException(nameof(choice), choice, null); }
/// <summary>Export this pattern as XML</summary> public virtual XElement ToXml(XElement node) { node.Add ( Expr.ToXml(XmlTag.Expr, false), Active.ToXml(XmlTag.Active, false), PatnType.ToXml(XmlTag.PatnType, false), IgnoreCase.ToXml(XmlTag.IgnoreCase, false), Invert.ToXml(XmlTag.Invert, false), WholeLine.ToXml(XmlTag.WholeLine, false), SingleLine.ToXml(XmlTag.SingleLine, false) ); return(node); }
private bool ListsAreEquivalent(IgnoreCase ignoreCase, HashSet <string>?results) { HashSet <string>?expected = ignoreCase switch { IgnoreCase.DefaultDevUxTeamPackages => InsertionConstants.DefaultDevUxTeamPackages, IgnoreCase.SpecifiedFile => new HashSet <string>(File.ReadAllLines(Path.Combine(Directory.GetCurrentDirectory(), "Assets", "ignored.txt"))), _ => null, }; if (expected == null) { return(results == null); } return(results == null ? false : !expected.Except(results).Any()); }
public override int GetHashCode() { unchecked { var hashCode = Position; hashCode = (hashCode * 397) ^ (SearchText?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Filter.GetHashCode(); hashCode = (hashCode * 397) ^ Highlight.GetHashCode(); hashCode = (hashCode * 397) ^ UseRegex.GetHashCode(); hashCode = (hashCode * 397) ^ IgnoreCase.GetHashCode(); hashCode = (hashCode * 397) ^ (HighlightHue?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (IconKind?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ IsGlobal.GetHashCode(); hashCode = (hashCode * 397) ^ IsExclusion.GetHashCode(); return(hashCode); } }
public BankBase createBank(string bankName) { if (IgnoreCase.equalIgnoreCase(bankName, "ITAU")) { return(new BankItau()); } else if (IgnoreCase.equalIgnoreCase(bankName, "BANCO DO BRASIL")) { return(new BankOfBrazil()); } else if (IgnoreCase.equalIgnoreCase(bankName, "BRADESCO")) { return(new BankBradesco()); } throw new ArgumentOutOfRangeException(nameof(bankName), bankName, null); }
public LoanBase createLoan(string loanName) { if (IgnoreCase.equalIgnoreCase(loanName, "HOME")) { return(new HomeLoan()); } else if (IgnoreCase.equalIgnoreCase(loanName, "BUNISESS")) { return(new BunissessLoan()); } else if (IgnoreCase.equalIgnoreCase(loanName, "EDUCATION")) { return(new EducationLoan()); } throw new ArgumentOutOfRangeException(nameof(loanName), loanName, null); }
public void TestLoadFile(IgnoreCase ignoreCase) { IInsertionApiFactory apiFactory = new InsertionApiFactory(); IInsertionApi api = apiFactory.Create(TimeSpan.FromSeconds(75), TimeSpan.FromSeconds(4)); UpdateResults results; string assetsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Assets"); string manifestFile = Path.Combine(assetsDirectory, "manifest.json"); string defaultConfigFile = Path.Combine(assetsDirectory, "default.config"); results = ignoreCase switch { IgnoreCase.DefaultDevUxTeamPackages => api.UpdateVersions(manifestFile, defaultConfigFile, InsertionConstants.DefaultDevUxTeamPackages, null, null), IgnoreCase.SpecifiedFile => api.UpdateVersions(manifestFile, defaultConfigFile, Path.Combine(assetsDirectory, "ignored.txt"), null, null), _ => api.UpdateVersions(manifestFile, defaultConfigFile, (HashSet <string>?)null, null, null), }; Assert.IsTrue(ListsAreEquivalent(ignoreCase, results?.IgnoredNuGets), $"Mismatched ignore packages for {ignoreCase}"); }
public override string ToString() { StringBuilder builder = new StringBuilder(); builder.AppendLine("Exclusions:"); foreach (CheckBoxModel exclusion in mExclusions) { builder.AppendLine(String.Format("\t{0}: {1}", exclusion.Text, exclusion.Checked.ToString())); } builder.AppendLine("Pattern: " + Pattern); builder.AppendLine("Scope: " + Scope); builder.AppendLine("Search Dir: " + SearchDirectory); builder.AppendLine("Ignore Case: " + IgnoreCase.ToString()); builder.AppendLine("UseRegex: " + UseRegex.ToString()); builder.AppendLine("Search Subdirectories: " + SearchSubdirectories.ToString()); builder.AppendLine("Whole Word: " + WholeWord.ToString()); builder.AppendLine("Sort By File: " + SortByFile.ToString()); builder.AppendLine("File Name Search: " + FileNameSearch.ToString()); return(builder.ToString()); }
/// <inheritdoc /> protected override async Task <Result <bool, IError> > Run( IStateMonad stateMonad, CancellationToken cancellationToken) { var stringResult = await String.Run(stateMonad, cancellationToken).Map(x => x.GetStringAsync()); if (stringResult.IsFailure) { return(stringResult.ConvertFailure <bool>()); } var patternResult = await Pattern.Run(stateMonad, cancellationToken).Map(x => x.GetStringAsync()); if (patternResult.IsFailure) { return(patternResult.ConvertFailure <bool>()); } var ignoreCaseResult = await IgnoreCase.Run(stateMonad, cancellationToken); if (ignoreCaseResult.IsFailure) { return(ignoreCaseResult.ConvertFailure <bool>()); } var regexOptions = RegexOptions.None; if (ignoreCaseResult.Value) { regexOptions |= RegexOptions.IgnoreCase; } var isMatch = Regex.IsMatch(stringResult.Value, patternResult.Value, regexOptions); return(isMatch); }
/// <inheritdoc /> protected override async Task <Result <StringStream, IError> > Run( IStateMonad stateMonad, CancellationToken cancellationToken) { var stringResult = await String.Run(stateMonad, cancellationToken).Map(x => x.GetStringAsync()); if (stringResult.IsFailure) { return(stringResult.ConvertFailure <StringStream>()); } var patternResult = await Pattern.Run(stateMonad, cancellationToken).Map(x => x.GetStringAsync()); if (patternResult.IsFailure) { return(patternResult.ConvertFailure <StringStream>()); } var ignoreCaseResult = await IgnoreCase.Run(stateMonad, cancellationToken); if (ignoreCaseResult.IsFailure) { return(ignoreCaseResult.ConvertFailure <StringStream>()); } var currentState = stateMonad.GetState().ToImmutableDictionary(); var regexOptions = RegexOptions.None; if (ignoreCaseResult.Value) { regexOptions |= RegexOptions.IgnoreCase; } var regex = new Regex(patternResult.Value, regexOptions); var input = stringResult.Value; var sb = new StringBuilder(); var lastIndex = 0; foreach (Match match in regex.Matches(input)) { sb.Append(input, lastIndex, match.Index - lastIndex); await using var scopedMonad = new ScopedStateMonad( stateMonad, currentState, new KeyValuePair <VariableName, object>(Variable, new StringStream(match.Value)) ); var result = await Function.Run(scopedMonad, cancellationToken) .Map(x => x.GetStringAsync()); if (result.IsFailure) { return(result.ConvertFailure <StringStream>()); } sb.Append(result.Value); lastIndex = match.Index + match.Length; } sb.Append(input, lastIndex, input.Length - lastIndex); return(new StringStream(sb.ToString())); }
/// <summary> /// Is /// </summary> /// <param name="str"></param> /// <param name="action"></param> /// <param name="ignoreCase"></param> /// <param name="format"></param> /// <param name="numberStyle"></param> /// <param name="dateTimeStyle"></param> /// <param name="formatProvider"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static bool Is <T>(this string str, IgnoreCase ignoreCase = IgnoreCase.FALSE, Action <T> action = null, string format = null, NumberStyles?numberStyle = null, DateTimeStyles?dateTimeStyle = null, IFormatProvider formatProvider = null) where T : struct { return(str.Is(typeof(T), ignoreCase, ValueConverter.ConvertAct(action), format, numberStyle, dateTimeStyle, formatProvider)); }
/// <summary> /// Saves advanced find settings to isolated storage. /// </summary> public void SaveSettings() { string searchCategories = string.Empty; if (SearchCategories.Any(category => category.Selected)) { searchCategories = SearchCategories .Where(category => category.Selected) .Select(category => category.Name) .Aggregate((str1, str2) => str1 + "," + str2); } IsolatedStorageManager.WriteToIsolatedStorage("MeasurementSearchText", SearchText); IsolatedStorageManager.WriteToIsolatedStorage("MeasurementSearchIgnoreCase", IgnoreCase.ToString()); IsolatedStorageManager.WriteToIsolatedStorage("MeasurementSearchUseWildcards", UseWildcards.ToString()); IsolatedStorageManager.WriteToIsolatedStorage("MeasurementSearchUseRegex", UseRegex.ToString()); IsolatedStorageManager.WriteToIsolatedStorage("MeasurementSearchCategories", searchCategories); }
/// <summary> /// Query on Wolfram Alpha using the specified /// </summary> /// <param name="query">The query you would like to search for on Wolfram Alpha</param> /// <returns>The results of the query</returns> public QueryResult Query(string query) { //http://api.wolframalpha.com/v2/query?input=xx&appid=xxxxx RestRequest request = CreateRequest("query", query); //Output if (Formats.HasElements()) { request.AddParameter("format", string.Join(",", Formats)); } if (OutputUnit != Unit.NotSet) { request.AddParameter("units", OutputUnit.ToString().ToLower()); } if (Assumptions.HasElements()) { foreach (string assumption in Assumptions) { request.AddParameter("assumption", assumption); } } //Filtering if (IncludePodIDs.HasElements()) { foreach (string include in IncludePodIDs) { request.AddParameter("includepodid", include); } } if (ExcludePodIDs.HasElements()) { foreach (string exclude in ExcludePodIDs) { request.AddParameter("excludepodid", exclude); } } if (PodTitles.HasElements()) { foreach (string podTitle in PodTitles) { request.AddParameter("podtitle", podTitle); } } if (PodIndex.HasElements()) { request.AddParameter("podindex", string.Join(",", PodIndex)); } if (Scanners.HasElements()) { request.AddParameter("scanner", string.Join(",", Scanners)); } //Timeout if (ParseTimeout >= Epsilon) { request.AddParameter("parsetimeout", ParseTimeout.ToString(_culture)); } if (ScanTimeout >= Epsilon) { request.AddParameter("scantimeout", ScanTimeout.ToString(_culture)); } if (PodTimeout >= Epsilon) { request.AddParameter("podtimeout", PodTimeout.ToString(_culture)); } if (FormatTimeout >= Epsilon) { request.AddParameter("formattimeout", FormatTimeout.ToString(_culture)); } //Async if (UseAsync) { request.AddParameter("async", UseAsync.ToString().ToLower()); } //Location if (IpAddress != null) { request.AddParameter("ip", IpAddress.ToString()); } if (!string.IsNullOrEmpty(Location)) { request.AddParameter("location", Location); } if (GPSLocation != null) { request.AddParameter("latlong", GPSLocation.ToString()); } //Size if (Width >= 1f) { request.AddParameter("width", Width); } if (MaxWidth >= 1f) { request.AddParameter("maxwidth", MaxWidth); } if (PlotWidth >= 1f) { request.AddParameter("plotwidth", PlotWidth); } if (Magnification >= 0.1f) { request.AddParameter("mag", Magnification.ToString(_culture)); } //Misc if (!string.IsNullOrEmpty(Signature)) { request.AddParameter("sig", Signature); } if (ReInterpret.HasValue) { request.AddParameter("reinterpret", ReInterpret.ToString().ToLower()); } if (IgnoreCase.HasValue) { request.AddParameter("ignorecase", IgnoreCase.ToString().ToLower()); } if (EnableTranslate.HasValue) { request.AddParameter("translation", EnableTranslate.ToString().ToLower()); } QueryResult results = GetResponse <QueryResult>(request); return(results); }