private void TryConfigureCacheDefault(Func <CacheOptions, CacheOptions> configure) { var match = WildcardMatch.All(); _sitecore.Services.TryAdd(ServiceDescriptor.Singleton <IConfigureMatchingOptions <CacheOptions> >( new ConfigureMatchingOptions <CacheOptions>(match.Identifier, match, configure))); }
/// /// Converts a wildcard to a regex. /// /// The wildcard pattern to convert. /// A regex equivalent of the given wildcard. public static string WildcardToRegex(string pattern, WildcardMatch matchType) { string escapedPattern = Escape(pattern); escapedPattern = escapedPattern.Replace("\\*", ".*"); escapedPattern = escapedPattern.Replace("\\?", "."); switch (matchType) { case WildcardMatch.Exact: return("^" + escapedPattern + "$"); case WildcardMatch.Anywhere: return(escapedPattern); case WildcardMatch.StartsWith: return("^" + escapedPattern); case WildcardMatch.EndsWith: return(escapedPattern + "$"); default: throw new ArgumentOutOfRangeException("matchType"); } }
public static SitecoreCachingConfigBuilder ConfigureCache <T>( this SitecoreCachingConfigBuilder configBuilder, string storeName, CacheEntryPriority?defaultEntryPriority = null) { return(configBuilder.ConfigureCaches(WildcardMatch.Named <T>(), storeName, defaultEntryPriority)); }
List <IMyTerminalBlock> findBlocks() { List <IMyTerminalBlock> matches = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(matches, (x => (WildcardMatch.IsLike(blockPattern, (x as IMyTerminalBlock).CustomName, false) && (type == null || isInstanceOf(type, (x as IMyTerminalBlock)))) && (x as IMyTerminalBlock).HasAction(action))); return(matches); }
public SitecoreCachingConfigBuilder ConfigureCaches( WildcardMatch cacheNamePattern, Action <CacheOptions> configureCache) { Condition.Requires(cacheNamePattern, nameof(cacheNamePattern)).IsNotNull(); _sitecore.Services.ConfigureMatching(cacheNamePattern.Identifier, cacheNamePattern, configureCache); return(this); }
public SitecoreCachingConfigBuilder ConfigureCaches( WildcardMatch cacheNamePattern, string storeName, CacheEntryPriority?defaultEntryPriority = null) { Condition.Requires(cacheNamePattern, nameof(cacheNamePattern)).IsNotNull(); return(ConfigureCaches(cacheNamePattern, o => { o.StoreName = storeName; if (defaultEntryPriority != null) { o.EntryPriority = defaultEntryPriority.Value; } })); }
/// /// Converts a wildcard to a regex. /// /// The wildcard pattern to convert. /// A regex equivalent of the given wildcard. public static string WildcardToRegex(string pattern, WildcardMatch matchType) { string escapedPattern = Escape(pattern); escapedPattern = escapedPattern.Replace("\\*", ".*"); escapedPattern = escapedPattern.Replace("\\?", "."); switch (matchType) { case WildcardMatch.Exact: return escapedPattern; case WildcardMatch.Anywhere: return escapedPattern + "$"; case WildcardMatch.StartsWith: return "^" + escapedPattern; case WildcardMatch.EndsWith: return "^" + escapedPattern + "$"; default: throw new ArgumentOutOfRangeException("matchType"); } }
/// /// Initializes a wildcard with the given search pattern and options. /// /// The wildcard pattern to match. /// A combination of one or more /// . public WildCard(string pattern, RegexOptions options, WildcardMatch matchType) : base(WildcardToRegex(pattern, matchType), options) { }
/// /// Initializes a wildcard with the given search pattern. /// /// The wildcard pattern to match. public WildCard(string pattern, WildcardMatch matchType) : base(WildcardToRegex(pattern, matchType)) { }
public void Selections_are_implicitly_anchored(string data, string pattern, bool isMatch) { var predicate = isMatch ? "matches" : "does not match"; WildcardMatch.Like(data, pattern).ShouldBe(isMatch, $"'{pattern}' {predicate} '{data}'"); }
public SitecoreCachingConfigBuilder ConfigureCacheDefaults(Action <CacheOptions> configureCache) { return(ConfigureCaches(WildcardMatch.All(), configureCache)); }