5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/BlazorSample/Pages/IndexModel.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.AspNetCore.Components;
3 | using PropertyChanged;
4 | using TextCopy;
5 |
6 | namespace BlazorSample;
7 |
8 | [AddINotifyPropertyChangedInterface]
9 | #region Inject
10 | public partial class IndexModel :
11 | ComponentBase
12 | {
13 | [Inject]
14 | public IClipboard Clipboard { get; set; }
15 |
16 | public string Content { get; set; }
17 |
18 | public Task CopyTextToClipboard() =>
19 | Clipboard.SetTextAsync(Content);
20 |
21 | public async Task ReadTextFromClipboard() =>
22 | Content = await Clipboard.GetTextAsync();
23 | }
24 | #endregion
--------------------------------------------------------------------------------
/src/BlazorSample/Pages/_ViewImports.razor:
--------------------------------------------------------------------------------
1 | @layout MainLayout
2 |
--------------------------------------------------------------------------------
/src/BlazorSample/Program.cs:
--------------------------------------------------------------------------------
1 | using BlazorSample;
2 | using Microsoft.AspNetCore.Components.Web;
3 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
4 | using TextCopy;
5 |
6 | #region BlazorStartup
7 | var builder = WebAssemblyHostBuilder.CreateDefault();
8 | var serviceCollection = builder.Services;
9 | #region InjectClipboard
10 | serviceCollection.InjectClipboard();
11 | #endregion
12 | builder.RootComponents.Add