public FuzzyCache(IDictionary <string, TValue> pairs, DyanamicCacheDirection queryDirection = DyanamicCacheDirection.Both) : base(pairs, queryDirection) { }
public static HashCache <TKey, TValue> HashTree <TKey, TValue>(this IDictionary <TKey, TValue> dict, DyanamicCacheDirection direction = DyanamicCacheDirection.Both) { return(new HashCache <TKey, TValue>(dict, direction)); }
public static PrecisionCache <TValue> PrecisioTree <TValue>(this ConcurrentDictionary <string, TValue> dict, DyanamicCacheDirection direction = DyanamicCacheDirection.Both) { return(new PrecisionCache <TValue>(dict, direction)); }
public static FuzzyCache <TValue> FuzzyTree <TValue>(this ConcurrentDictionary <string, TValue> dict, DyanamicCacheDirection direction = DyanamicCacheDirection.Both) { return(new FuzzyCache <TValue>(dict, direction)); }
public HashCache(IDictionary <TKey, TValue> pairs, DyanamicCacheDirection queryDirection = DyanamicCacheDirection.Both) : base(pairs, queryDirection) { }
public DynamicCacheBuilder(IDictionary <TKey, TValue> pairs, DyanamicCacheDirection queryDirection = DyanamicCacheDirection.Both) { if (queryDirection != DyanamicCacheDirection.ValueToKey) { AnonymousRTD _r2d_handler = AnonymousRTD.UseDomain(typeof(TKey).GetDomain()); var key_builder = new Dictionary <TKey, string>(); foreach (var item in pairs) { key_builder[item.Key] = $"return {_r2d_handler.AddValue(item.Value)};"; } StringBuilder keyBuilder = new StringBuilder(); keyBuilder.Append(ScriptKeyAction(key_builder)); keyBuilder.Append("return default;"); var method = typeof(Func <TKey, TValue>).GetMethod("Invoke"); _r2d_handler.BodyAppend(FakeMethodOperator.RandomDomain() .UseMethod(method) .Unsafe() .StaticMethodBody(keyBuilder.ToString()) .Script); var type = _r2d_handler.Complie(); GetValue = NDelegate .UseDomain(typeof(TKey).GetDomain()) .Func <Func <TKey, TValue> >($"return {_r2d_handler.TypeName}.Invoke;", type)(); } if (queryDirection != DyanamicCacheDirection.KeyToValue) { AnonymousRTD _r2d_handler = AnonymousRTD.UseDomain(typeof(TKey).GetDomain()); var value_builder = new Dictionary <TValue, string>(); foreach (var item in pairs) { if (!value_builder.ContainsKey(item.Value)) { value_builder[item.Value] = $"return new {typeof(TKey).GetDevelopName()}[]{{{_r2d_handler.AddValue(item.Key)}"; } else { value_builder[item.Value] += $",{_r2d_handler.AddValue(item.Key)}"; } } var temp_value_buidler = new Dictionary <TValue, string>(); foreach (var item in value_builder) { temp_value_buidler[item.Key] = item.Value + "};"; } StringBuilder valueBuilder = new StringBuilder(); valueBuilder.Append(ScriptValueAction(temp_value_buidler)); valueBuilder.Append("return null;"); var method = typeof(Func <TValue, TKey[]>).GetMethod("Invoke"); _r2d_handler.Body(FakeMethodOperator.RandomDomain() .UseMethod(method) .Unsafe() .StaticMethodBody(valueBuilder.ToString()) .Script); var type = _r2d_handler.Complie(); GetKeys = NDelegate .UseDomain(typeof(TValue).GetDomain()) .Func <Func <TValue, TKey[]> >($"return {_r2d_handler.TypeName}.Invoke;", type)(); } }