-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f953646
commit 9fa7af1
Showing
5 changed files
with
99 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlazorDialog | ||
{ | ||
public abstract class BlazorDialogBase : ComponentBase | ||
{ | ||
[Parameter] public string Id { get; protected set; } | ||
[Parameter] protected bool IsShowing { get; set; } | ||
|
||
|
||
public async Task Show() | ||
{ | ||
this.IsShowing = true; | ||
await Invoke(() => StateHasChanged()); | ||
|
||
} | ||
|
||
//public Task Show(TInput input) | ||
//{ | ||
// return dialogService.ShowDialog<TInput>(this.Id, input); | ||
//} | ||
|
||
//public void Hide<TResult>(TResult result) | ||
//{ | ||
// dialogService.HideDialog(this.Id, result); | ||
//} | ||
|
||
//public void Hide() | ||
//{ | ||
// dialogService.HideDialog(this.Id); | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlazorDialog | ||
{ | ||
public class BlazorDialogService2 | ||
{ | ||
private Dictionary<string, BlazorDialogBase> registeredDialogs = new Dictionary<string, BlazorDialogBase>(); | ||
|
||
internal void Register(BlazorDialogBase blazorDialog) | ||
{ | ||
registeredDialogs[blazorDialog.Id] = blazorDialog; | ||
} | ||
|
||
|
||
internal void Unregister(BlazorDialogBase blazorDialog) | ||
{ | ||
registeredDialogs.Remove(blazorDialog.Id); | ||
} | ||
|
||
public void HideDialog(string dialogId) | ||
{ | ||
registeredDialogs[dialogId].Hide(); | ||
} | ||
|
||
public void HideDialog(string dialogId, object result) | ||
{ | ||
registeredDialogs[dialogId].Hide(result); | ||
} | ||
|
||
public async Task ShowDialog(string dialogId) | ||
{ | ||
await ShowDialog<object>(dialogId, null); | ||
} | ||
|
||
public async Task<TResult> ShowDialog<TResult>(string dialogId) | ||
{ | ||
return await ShowDialog<TResult>(dialogId, null); | ||
} | ||
|
||
public async Task ShowDialog(string dialogId, object input) | ||
{ | ||
await ShowDialog<object>(dialogId, input); | ||
} | ||
|
||
public async Task<TResult> ShowDialog<TResult>(string dialogId, object input) | ||
{ | ||
//if (taskCompletionSources.ContainsKey(dialogId)) | ||
//{ | ||
// taskCompletionSources[dialogId].SetCanceled(); | ||
//} | ||
//taskCompletionSources[dialogId] = new TaskCompletionSource<object>(); | ||
//_dialogStates.ShowDialog(dialogId, input); | ||
//return (TResult)await taskCompletionSources[dialogId].Task; | ||
|
||
return (TResult)await registeredDialogs[dialogId].Show(input); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.