Пример #1
0
 private static void CheckIsNull(DrawerConfig options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
 }
Пример #2
0
        /// <summary>
        /// 创建并打开一个简单抽屉,没有返回值
        /// </summary>
        /// <param name="config">抽屉参数</param>
        /// <returns></returns>
        public async Task <DrawerRef> CreateAsync(DrawerConfig config)
        {
            CheckIsNull(config);
            DrawerRef drawerRef = new DrawerRef(config, this);
            await OnOpenEvent.Invoke(drawerRef);

            return(drawerRef);
        }
Пример #3
0
 internal Task CloseAsync(DrawerConfig options)
 {
     CheckIsNull(options);
     if (OnClose != null)
     {
         return(OnClose.Invoke(options));
     }
     return(Task.CompletedTask);
 }
        private async Task DrawerService_OnCreate(DrawerConfig arg)
        {
            arg.Visible = true;
            if (!_drawerConfigs.Contains(arg))
            {
                _drawerConfigs.Add(arg);
            }

            await InvokeAsync(StateHasChanged);
        }
Пример #5
0
        private async Task <DrawerRef> HandleCreate(DrawerConfig config)
        {
            if (OnCreate != null)
            {
                config.DrawerService = this;
                await OnCreate.Invoke(config);

                DrawerRef drawerRef = new DrawerRef(config, this);
                return(drawerRef);
            }
            return(null);
        }
Пример #6
0
        /// <summary>
        /// Create a drawer from an existing component template
        /// </summary>
        /// <typeparam name="T">Component template type</typeparam>
        /// <typeparam name="TComponentParameter">Component template parameter object type</typeparam>
        /// <param name="config">DrawerConfig</param>
        /// <param name="parameter">Component template parameter object</param>
        /// <returns>DrawerRef object</returns>
        public async Task <DrawerRef> CreateAsync <T, TComponentParameter>(DrawerConfig config, TComponentParameter parameter) where T : DrawerTemplate <TComponentParameter>
        {
            CheckIsNull(config);

            RenderFragment child = (builder) =>
            {
                builder.OpenComponent <T>(0);
                builder.AddAttribute(1, "Config", parameter);
                builder.AddAttribute(2, "DrawerConfig", config);
                builder.CloseComponent();
            };

            config.ChildContent = child;

            return(await HandleCreate(config));
        }
Пример #7
0
        /// <summary>
        /// 创建并打开一个模板抽屉
        /// </summary>
        /// <typeparam name="TComponent"></typeparam>
        /// <typeparam name="TContentParams"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="config"></param>
        /// <param name="contentParams"></param>
        /// <returns></returns>
        public async Task <DrawerRef <TResult> > CreateAsync <TComponent, TContentParams, TResult>(DrawerConfig config, TContentParams contentParams) where TComponent : DrawerTemplate <TContentParams, TResult>
        {
            CheckIsNull(config);

            DrawerRef <TResult> drawerRef = new DrawerRef <TResult>(config, this);
            await OnOpenEvent.Invoke(drawerRef);

            RenderFragment child = (builder) =>
            {
                builder.OpenComponent <TComponent>(0);
                builder.AddAttribute(1, "DrawerRef", drawerRef);
                builder.AddAttribute(2, "Config", contentParams);
                builder.CloseComponent();
            };

            config.ChildContent = child;

            return(drawerRef);
        }
Пример #8
0
 internal DrawerRef(DrawerConfig config, DrawerService service) : base(config, service)
 {
 }
Пример #9
0
 /// <summary>
 /// Create a drawer from the config
 /// </summary>
 /// <param name="config">DrawerConfig</param>
 /// <returns>DrawerRef object</returns>
 public async Task <DrawerRef> CreateAsync(DrawerConfig config)
 {
     CheckIsNull(config);
     return(await HandleCreate(config));
 }
Пример #10
0
 internal DrawerRef(DrawerConfig config, DrawerService service)
 {
     _config  = config;
     _service = service;
 }
Пример #11
0
 internal DrawerRef(DrawerConfig config)
 {
     _config = config;
 }
 private async Task DrawerService_OnClose(DrawerConfig arg)
 {
     arg.Visible = false;
     await InvokeAsync(StateHasChanged);
 }