Exemplo n.º 1
0
        /// <summary>
        /// Notifies the component that file input value has changed.
        /// </summary>
        /// <param name="files">List of changed file(s).</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public async Task NotifyChange(FileEntry[] files)
        {
            // Unlike in other Edit components we cannot just call CurrentValueHandler since
            // we're dealing with complex types instead of a simple string as en element value.
            //
            // Because of that we're going to skip CurrentValueHandler and implement all the
            // update logic here.

            foreach (var file in files)
            {
                // So that method invocations on the file can be dispatched back here
                file.Owner = (IFileEntryOwner)(object)this;
            }

            InternalValue = files;

            // send the value to the validation for processing
            if (ParentValidation != null)
            {
                await ParentValidation.NotifyInputChanged <IFileEntry[]>(files);
            }

            await Changed.InvokeAsync(new(files) );

            await InvokeAsync(StateHasChanged);
        }
Exemplo n.º 2
0
        public Task NotifyChange(FileEntry[] files)
        {
            // Unlike in other Edit components we cannot just call CurrentValueHandler since
            // we're dealing with complex types instead of a simple string as en element value.
            //
            // Because of that we're going to skip CurrentValueHandler and implement all the
            // update logic here.

            foreach (var file in files)
            {
                // So that method invocations on the file can be dispatched back here
                file.Owner = (FileEdit)(object)this;
            }

            InternalValue = files;

            // send the value to the validation for processing
            ParentValidation?.NotifyInputChanged();

            return(Changed.InvokeAsync(new FileChangedEventArgs(files)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the parsing of an input value.
        /// </summary>
        /// <param name="value">Input value to be parsed.</param>
        /// <returns>Returns the awaitable task.</returns>
        protected async Task CurrentValueHandler(string value)
        {
            var empty = false;

            if (string.IsNullOrEmpty(value))
            {
                empty        = true;
                CurrentValue = default;
            }

            if (!empty)
            {
                var result = await ParseValueFromStringAsync(value);

                if (result.Success)
                {
                    CurrentValue = result.ParsedValue;
                }
            }

            // send the value to the validation for processing
            ParentValidation?.NotifyInputChanged();
        }