/// <summary> /// config ueditor /// </summary> /// <param name="builder"></param> /// <param name="optionsAction"></param> /// <returns></returns> public static IServiceCollection AddUEditor(this IServiceCollection builder, Action <UEditorOptions> optionsAction) { var options = new UEditorOptions(); optionsAction.Invoke(options); builder.AddSingleton(options); return(builder); }
public UEditorMiddleware(IHostEnvironment env, UEditorOptions options, IMemoryCache memoryCache) { _env = env; this._options = options; _memoryCache = memoryCache; UEditorJsonConfig jsonConfig = null; if (options.ConfigUrl.IsNullOrEmpty() && Handler.Config == null) { var resourceManager = new ResourceManager("Microex.AngularSpa.UEditor", typeof(UEditorMiddleware).GetTypeInfo().Assembly); jsonConfig = resourceManager.GetString("DefaultConfig.Json").ToObject <UEditorJsonConfig>(); } else { jsonConfig = new HttpClient().GetStringAsync(options.ConfigUrl).Result.ToObject <UEditorJsonConfig>(); } _options.JsonConfig = jsonConfig; Handler.WebRootPath = _env.ContentRootPath; Handler.Config = jsonConfig; }