public CommandDispatcher <TResult> WithCache(CacheConfig cacheConfig) { this.cacheConfig = cacheConfig; if (UseCache) { memoryCache = LayIMServiceLocator.GetService <IMemoryCache>(); } return(this); }
/// <summary> /// 获取当前用户ID /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetCurrentUserId(HttpContext context) { //先使用用户自定义的 var userFactory = LayIMServiceLocator.Options.UserFactory; if (userFactory == null) { //在使用框架自带的 userFactory = LayIMServiceLocator.GetService <ILayIMUserFactory>(); } if (userFactory == null) { return(null); } return(userFactory.GetUserId(context)); }
public static IApplicationBuilder UseLayIM(this IApplicationBuilder app, Action <LayIMOptions> initFunc = null) { var options = new LayIMOptions(); initFunc?.Invoke(options); app.UseMiddleware <LayIMMiddleware>(options); //设置全局配置 LayIMServiceLocator.SetOptions(options); app.UseFileServer(new FileServerOptions { RequestPath = options.ApiPrefix, FileProvider = new EmbeddedFileProvider(typeof(LayIMBuilderExtensions).GetTypeInfo().Assembly, LayIMEmbeddedFileNamespace), }); ILayIMAppBuilder appBuilder = LayIMServiceLocator.GetService <ILayIMAppBuilder>(); appBuilder?.Build(app); return(app); }
/// <summary> /// 获取当前用户ID /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetCurrentUserId(HttpContext context) { var userFactory = LayIMServiceLocator.GetService <ILayIMUserFactory>(); return(userFactory.GetUserId(context)); }
private static Lazy <TService> GetLazyService <TService>() { return(new Lazy <TService>(() => LayIMServiceLocator.GetService <TService>())); }