├── .gitattributes ├── .github ├── release-drafter.yml └── workflows │ ├── codeql-analysis.yml │ ├── draft-release-note.yml │ ├── pr-title-commit.yml │ ├── pull-request.yml │ └── release-package.yml ├── .gitignore ├── CHANGELOGS.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ComponentBuilder.sln ├── LICENSE ├── README.md ├── README.zh-cn.md ├── asset ├── BlazorComponentBase Lifecycle.drawio └── BlazorComponentBaseLifecycle.png ├── common.props ├── doc └── ComponentBuilder.Doc │ ├── ComponentBuilder.Doc.Client │ ├── ComponentBuilder.Doc.Client.csproj │ ├── Components │ │ └── Button.cs │ ├── Layout │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── Pages │ │ └── Home.razor │ ├── Program.cs │ ├── Routes.razor │ ├── _Imports.razor │ └── wwwroot │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ └── ComponentBuilder.Doc │ ├── ComponentBuilder.Doc.csproj │ ├── Components │ ├── App.razor │ ├── Pages │ │ └── Error.razor │ └── _Imports.razor │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── app.css │ ├── bootstrap │ ├── bootstrap.min.css │ └── bootstrap.min.css.map │ ├── favicon.png │ └── highlight │ ├── es │ ├── core.js │ ├── core.min.js │ ├── highlight.js │ ├── highlight.min.js │ ├── languages │ │ ├── csharp.js │ │ ├── csharp.min.js │ │ ├── css.js │ │ ├── css.min.js │ │ ├── diff.js │ │ ├── diff.min.js │ │ ├── http.js │ │ ├── http.min.js │ │ ├── javascript.js │ │ ├── javascript.min.js │ │ ├── json.js │ │ ├── json.min.js │ │ ├── less.js │ │ ├── less.min.js │ │ ├── markdown.js │ │ ├── markdown.min.js │ │ ├── plaintext.js │ │ ├── plaintext.min.js │ │ ├── powershell.js │ │ ├── powershell.min.js │ │ ├── scss.js │ │ ├── scss.min.js │ │ ├── shell.js │ │ ├── shell.min.js │ │ ├── sql.js │ │ ├── sql.min.js │ │ ├── typescript.js │ │ ├── typescript.min.js │ │ ├── wasm.js │ │ ├── wasm.min.js │ │ ├── xml.js │ │ ├── xml.min.js │ │ ├── yaml.js │ │ └── yaml.min.js │ └── package.json │ ├── highlight.js │ ├── highlight.min.js │ ├── languages │ ├── csharp.js │ ├── csharp.min.js │ ├── css.js │ ├── css.min.js │ ├── diff.js │ ├── diff.min.js │ ├── http.js │ ├── http.min.js │ ├── javascript.js │ ├── javascript.min.js │ ├── json.js │ ├── json.min.js │ ├── less.js │ ├── less.min.js │ ├── markdown.js │ ├── markdown.min.js │ ├── plaintext.js │ ├── plaintext.min.js │ ├── powershell.js │ ├── powershell.min.js │ ├── scss.js │ ├── scss.min.js │ ├── shell.js │ ├── shell.min.js │ ├── sql.js │ ├── sql.min.js │ ├── typescript.js │ ├── typescript.min.js │ ├── wasm.js │ ├── wasm.min.js │ ├── xml.js │ ├── xml.min.js │ ├── yaml.js │ └── yaml.min.js │ └── styles │ ├── vs.css │ ├── vs.min.css │ ├── vs2015.css │ └── vs2015.min.css ├── src └── ComponentBuilder │ ├── .vshistory │ ├── BlazorComponentBase.cs │ │ ├── 2021-11-18_16_16_41_072.cs │ │ ├── 2021-11-18_16_18_12_123.cs │ │ ├── 2021-11-18_16_20_08_982.cs │ │ ├── 2021-11-18_16_20_17_442.cs │ │ ├── 2021-11-18_16_20_44_444.cs │ │ ├── 2021-11-19_10_45_55_801.cs │ │ ├── 2021-11-19_10_48_01_049.cs │ │ ├── 2021-11-19_10_49_04_592.cs │ │ ├── 2021-11-19_10_51_21_676.cs │ │ ├── 2021-11-19_11_09_08_020.cs │ │ ├── 2021-11-19_11_37_28_823.cs │ │ ├── 2021-11-19_11_38_00_949.cs │ │ ├── 2021-11-19_13_43_51_470.cs │ │ ├── 2021-11-19_14_42_24_100.cs │ │ ├── 2021-11-19_14_42_43_249.cs │ │ ├── 2021-11-19_14_47_12_353.cs │ │ ├── 2021-11-19_14_47_20_285.cs │ │ ├── 2021-11-19_14_53_28_383.cs │ │ ├── 2021-11-19_14_55_01_196.cs │ │ ├── 2021-11-19_14_55_13_737.cs │ │ ├── 2021-11-19_15_04_37_622.cs │ │ ├── 2021-11-19_15_05_46_183.cs │ │ ├── 2021-11-19_15_05_54_454.cs │ │ ├── 2021-11-19_15_08_01_349.cs │ │ ├── 2021-11-19_15_09_44_725.cs │ │ ├── 2021-11-19_16_09_25_781.cs │ │ └── 2021-11-19_16_45_44_554.cs │ ├── ComponentBuilder.csproj │ │ ├── 2021-11-18_16_05_57_990.csproj │ │ ├── 2021-11-18_16_14_36_608.csproj │ │ ├── 2021-11-19_16_35_38_386.csproj │ │ └── 2021-11-19_16_36_42_415.csproj │ ├── ComponentBuilderDependencyInjectionExtentions.cs │ │ ├── 2021-11-19_13_46_15_771.cs │ │ ├── 2021-11-19_13_47_31_823.cs │ │ └── 2021-11-19_13_47_36_430.cs │ ├── ComponentBuilderExtensions.cs │ │ ├── 2021-11-19_11_05_55_522.cs │ │ ├── 2021-11-19_11_08_18_164.cs │ │ ├── 2021-11-19_11_32_55_592.cs │ │ ├── 2021-11-19_11_33_31_584.cs │ │ ├── 2021-11-19_11_40_33_685.cs │ │ ├── 2021-11-19_13_33_11_524.cs │ │ ├── 2021-11-19_13_33_43_298.cs │ │ ├── 2021-11-19_13_34_17_089.cs │ │ ├── 2021-11-19_13_34_28_371.cs │ │ ├── 2021-11-19_13_34_31_840.cs │ │ ├── 2021-11-19_13_34_53_431.cs │ │ ├── 2021-11-19_13_36_59_706.cs │ │ ├── 2021-11-19_13_37_16_204.cs │ │ ├── 2021-11-19_13_38_05_936.cs │ │ ├── 2021-11-19_13_38_49_525.cs │ │ ├── 2021-11-19_13_40_58_568.cs │ │ ├── 2021-11-19_13_41_08_747.cs │ │ ├── 2021-11-19_14_14_36_148.cs │ │ └── 2021-11-19_14_14_48_633.cs │ ├── CssClassAttribute.cs │ │ ├── 2021-11-18_16_35_59_286.cs │ │ ├── 2021-11-18_16_37_04_789.cs │ │ ├── 2021-11-18_16_37_21_369.cs │ │ ├── 2021-11-18_16_37_35_462.cs │ │ ├── 2021-11-18_16_50_53_955.cs │ │ ├── 2021-11-18_16_50_58_810.cs │ │ ├── 2021-11-18_16_51_07_323.cs │ │ ├── 2021-11-18_16_51_22_179.cs │ │ └── 2021-11-18_16_51_30_996.cs │ ├── ElementTagAttribute.cs │ │ ├── 2021-11-19_14_27_36_676.cs │ │ ├── 2021-11-19_14_28_34_495.cs │ │ ├── 2021-11-19_15_07_54_648.cs │ │ ├── 2021-11-19_15_08_02_770.cs │ │ └── 2021-11-19_15_09_21_891.cs │ └── IBlazorComponent.cs │ │ ├── 2021-11-18_16_16_28_347.cs │ │ ├── 2021-11-18_16_17_16_119.cs │ │ ├── 2021-11-18_16_18_11_789.cs │ │ ├── 2021-11-18_16_19_05_393.cs │ │ ├── 2021-11-18_16_20_32_443.cs │ │ ├── 2021-11-18_16_35_20_296.cs │ │ ├── 2021-11-18_16_35_36_802.cs │ │ └── 2021-11-18_16_53_49_316.cs │ ├── Abstractions │ ├── BlazorChildComponentCollection.cs │ ├── BlazorComponentBase.Form.cs │ ├── BlazorComponentBase.cs │ ├── IBlazorComponent.cs │ └── StyleProperty.cs │ ├── Attributes │ ├── BooleanCssClassAttribute.cs │ ├── ChildComponentAttribute.cs │ ├── CssClassAttribute.cs │ ├── HtmlAttributeAttribute.cs │ ├── HtmlTagAttribute.cs │ ├── NullCssClassAttribute.cs │ └── ParentComponentAttribute.cs │ ├── Builder │ ├── DefaultCssClassBuilder.cs │ ├── DefaultStyleBuilder.cs │ ├── ICssClassBuilder.cs │ └── IStyleBuilder.cs │ ├── ComponentBuilder.csproj │ ├── ComponentConfigurationBuilder.cs │ ├── Condition.cs │ ├── Definitions │ ├── Components │ │ ├── Buttons │ │ │ ├── ButtonComponentBase.cs │ │ │ ├── ButtonHtmlType.cs │ │ │ └── IHasButtonComponent.cs │ │ ├── IAnchorComponent.cs │ │ ├── IContainerComponent.cs │ │ ├── IFormComponent.cs │ │ └── IHasNavLinkComponent.cs │ └── Parameters │ │ ├── IHasActive.cs │ │ ├── IHasAdditionalAttributes.cs │ │ ├── IHasAdditionalClass.cs │ │ ├── IHasAdditionalStyle.cs │ │ ├── IHasChildContent.cs │ │ ├── IHasDisabled.cs │ │ ├── IHasEditContext.cs │ │ ├── IHasEventCallback.cs │ │ ├── IHasInputValue.cs │ │ ├── IHasOnActive.cs │ │ ├── IHasOnDisabled.cs │ │ ├── IHasOnSwitch.cs │ │ ├── IHasSwitch.cs │ │ └── IHasValueBound.cs │ ├── Enumeration.cs │ ├── Extensions │ ├── CollectionExtensions.cs │ ├── ComponentBuilderExtensions.cs │ ├── DependencyInjectionExtentions.cs │ ├── EventCallbackFactoryExtensions.cs │ ├── FluentRenderTreeBuilderExtensions.cs │ ├── InputValueExtensions.cs │ ├── ParameterExtensions.cs │ ├── ParseExtensions.cs │ ├── ReflectionExtensions.cs │ ├── RenderTreeBuilderExtensions.cs │ └── StringExtensions.cs │ ├── FluentClass │ ├── FluentClassProvider.cs │ └── IFluentClassProvider.cs │ ├── FluentRenderTree │ ├── FluentHtmlRenderTreeBuilderExtensions.cs │ ├── FluentRenderTreeBuilder.cs │ ├── IFluentAttributeBuilder.cs │ ├── IFluentCloseBuilder.cs │ ├── IFluentContentBuilder.cs │ ├── IFluentFrameBuilder.cs │ ├── IFluentOpenBuilder.cs │ ├── IFluentOpenComponentBuilder.cs │ ├── IFluentOpenElementBuilder.cs │ └── IFluentRegionBuilder.cs │ ├── HtmlHelper.cs │ ├── Interceptors │ ├── AssociationComponentInterceptor.cs │ ├── ChildContentInterceptor.cs │ ├── ComponentInterceptorBase.cs │ ├── ConsoleDiagnosticInterceptor.cs │ ├── CssClassAttributeInterceptor.cs │ ├── FormComponentInterceptor.cs │ ├── IComponentInterceptor.cs │ └── StyleAttributeInterceptor.cs │ ├── JSInterop │ ├── Console.cs │ ├── DomNode.cs │ ├── JSInteropExtensions.cs │ ├── JSInvokeMethodAction.cs │ ├── JSInvokeMethodFactory.cs │ ├── JSInvokeMethodFunc.cs │ ├── JSModule.cs │ ├── Singleton.cs │ └── Window.cs │ ├── RenderModeEnhance.cs │ ├── Rendering │ ├── DefaultComponentRender.cs │ ├── IComponentRenderer.cs │ └── NavLinkComponentRender.cs │ ├── Resolvers │ ├── CssClassAttributeResolver.cs │ ├── FluentCssClassResolver.cs │ ├── HtmlAttributeAttributeResolver.cs │ ├── HtmlTagAttributeResolver.cs │ └── IComponentResolver.cs │ └── Using.cs ├── templates ├── readme.md ├── src │ ├── .template.config │ │ └── template.json │ ├── MyRazorLibrary.sln │ ├── doc │ │ ├── MyRazorLibrary.Docs.ServerSideHost │ │ │ ├── MyRazorLibrary.Docs.ServerSideHost.csproj │ │ │ ├── Pages │ │ │ │ ├── _Host.cshtml │ │ │ │ └── _Layout.cshtml │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── _Imports.razor │ │ │ ├── appsettings.Development.json │ │ │ └── appsettings.json │ │ ├── MyRazorLibrary.Docs.Shared │ │ │ ├── App.razor │ │ │ ├── Layouts │ │ │ │ └── MainLayout.razor │ │ │ ├── MyRazorLibrary.Docs.Shared.csproj │ │ │ ├── Pages │ │ │ │ └── IndexPage.razor │ │ │ ├── _Imports.razor │ │ │ └── wwwroot │ │ │ │ ├── docs.css │ │ │ │ └── favicon.ico │ │ └── MyRazorLibrary.Docs.WebAssemblyHost │ │ │ ├── MyRazorLibrary.Docs.WebAssemblyHost.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── _Imports.razor │ │ │ └── wwwroot │ │ │ └── index.html │ └── src │ │ ├── MyRazorLibrary.Test │ │ ├── Cases │ │ │ └── DivTest.cs │ │ ├── MyRazorLibrary.Test.csproj │ │ ├── TestBase.cs │ │ └── Usings.cs │ │ └── MyRazorLibrary │ │ ├── Components │ │ └── Div.cs │ │ ├── DependencyInjectionExtensions.cs │ │ ├── MyRazorLibrary.csproj │ │ ├── Using.cs │ │ ├── _Imports.razor │ │ └── wwwroot │ │ ├── MyRazorLibrary.css │ │ └── MyRazorLibrary.js ├── templatepack.csproj └── vs.jpg └── test └── ComponentBuilder.Test ├── .vshistory ├── BlazorComponentExtensionsTest.cs │ ├── 2021-11-19_11_38_23_465.cs │ ├── 2021-11-19_11_41_04_433.cs │ ├── 2021-11-19_13_38_49_849.cs │ ├── 2021-11-19_13_43_03_185.cs │ └── 2021-11-19_13_43_11_705.cs ├── ComponentBuilder.Test.csproj │ ├── 2021-11-18_16_21_21_439.csproj │ └── 2021-11-18_16_34_01_664.csproj ├── ComponentBuilderExtensionsTest.cs │ └── 2021-11-19_13_52_31_325.cs ├── CssClassBuilderTest.cs │ ├── 2021-11-18_16_21_21_505.cs │ ├── 2021-11-18_16_28_58_355.cs │ ├── 2021-11-18_16_33_49_211.cs │ ├── 2021-11-18_16_57_10_071.cs │ ├── 2021-11-18_16_57_13_046.cs │ ├── 2021-11-19_10_47_36_905.cs │ └── 2021-11-19_10_47_48_902.cs └── CssClassResolverTest.cs │ ├── 2021-11-19_13_53_43_046.cs │ ├── 2021-11-19_13_54_30_580.cs │ ├── 2021-11-19_13_58_20_463.cs │ ├── 2021-11-19_14_03_22_868.cs │ ├── 2021-11-19_14_03_48_313.cs │ ├── 2021-11-19_14_04_59_185.cs │ ├── 2021-11-19_14_05_04_237.cs │ ├── 2021-11-19_14_09_13_063.cs │ ├── 2021-11-19_14_11_02_595.cs │ ├── 2021-11-19_15_18_27_617.cs │ └── 2021-11-19_15_59_11_175.cs ├── AutoTestBase.cs ├── ComponentAdditionalAttributeTest.cs ├── ComponentBuilder - Backup.Test.csproj ├── ComponentBuilder.Test.csproj ├── ComponentBuilderExtensionsTest.cs ├── ComponentEventCallbackTest.cs ├── Components ├── .vshistory │ └── Button.cs │ │ ├── 2021-11-19_15_06_40_068.cs │ │ ├── 2021-11-19_15_07_12_369.cs │ │ ├── 2021-11-19_15_07_29_823.cs │ │ ├── 2021-11-19_15_18_24_954.cs │ │ ├── 2021-11-19_15_24_21_722.cs │ │ ├── 2021-11-19_15_25_06_992.cs │ │ ├── 2021-11-19_15_45_27_968.cs │ │ ├── 2021-11-19_15_46_50_367.cs │ │ ├── 2021-11-19_15_46_52_383.cs │ │ ├── 2021-11-19_15_50_44_072.cs │ │ ├── 2021-11-19_15_51_13_758.cs │ │ ├── 2021-11-19_15_51_19_660.cs │ │ ├── 2021-11-19_15_52_32_376.cs │ │ ├── 2021-11-19_15_54_44_367.cs │ │ ├── 2021-11-19_16_04_01_747.cs │ │ ├── 2021-11-19_16_06_17_445.cs │ │ ├── 2021-11-19_16_10_18_452.cs │ │ ├── 2021-11-19_16_16_38_925.cs │ │ ├── 2021-11-19_16_17_03_160.cs │ │ ├── 2021-11-19_16_17_25_496.cs │ │ └── 2021-11-19_16_48_36_884.cs ├── Anchor.cs ├── AnchorTest.cs ├── Button.cs ├── ButtonTest.cs ├── Input.cs └── InputTest.cs ├── CssClassAttributeTest.cs ├── CssClassBuilderTest.cs ├── DynamicComponentEventTest.cs ├── EnumerationTest.cs ├── FluentCssClassTest.cs ├── FluentRenderTreeTest.cs ├── FormComponentTest.cs ├── HtmlAttributeResolverTest.cs ├── HtmlHelperTest.cs ├── HtmlTagAttributeTest.cs ├── ParentChildComponentTest.cs ├── RenderTreeBuilderExtensionTest.cs ├── StyleBuilderTest.cs ├── StylePropertyTest.cs ├── TestBase.cs └── Using.cs /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | 2 | name-template: 'v$RESOLVED_VERSION 🌈' 3 | tag-template: '$RESOLVED_VERSION' 4 | categories: 5 | - title: '🚀 Features' 6 | labels: 7 | - 'feature' 8 | - 'enhancement' 9 | - title: '🐛 BugFixes' 10 | labels: 11 | - 'fix' 12 | - 'bugfix' 13 | - 'bug' 14 | - title: '🧰 Maintainances' 15 | labels: 16 | - 'chore' 17 | - 'support' 18 | - 'other' 19 | - 'docs' 20 | change-template: '- (#$NUMBER) $TITLE - by @$AUTHOR' 21 | change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. 22 | exclude-labels: 23 | - 'skip-release' 24 | autolabeler: 25 | - label: 'bug' 26 | branch: 27 | - '/bugfix\/.+/' 28 | - label: 'feature' 29 | branch: 30 | - '/feature\/.+/' 31 | - label: 'document' 32 | branch: 33 | - '\/.+/(docs|doc)\/.+/' 34 | template: | 35 | $CHANGES -------------------------------------------------------------------------------- /.github/workflows/draft-release-note.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | # pull_request event is required only for autolabeler 9 | pull_request: 10 | # Only following types are handled by the action, but one can default to all as well 11 | types: [opened, reopened, synchronize] 12 | # pull_request_target event is required for autolabeler to support PRs from forks 13 | pull_request_target: 14 | types: [opened, reopened, synchronize] 15 | 16 | permissions: 17 | contents: read 18 | 19 | jobs: 20 | update_release_draft: 21 | permissions: 22 | # write permission is required to create a github release 23 | contents: write 24 | # write permission is required for autolabeler 25 | # otherwise, read permission is required at least 26 | pull-requests: write 27 | runs-on: ubuntu-latest 28 | steps: 29 | # (Optional) GitHub Enterprise requires GHE_HOST variable set 30 | #- name: Set GHE_HOST 31 | # run: | 32 | # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV 33 | 34 | # Drafts your next Release notes as Pull Requests are merged into "master" 35 | - uses: release-drafter/release-drafter@v5 36 | name: Draft release note 37 | # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml 38 | # with: 39 | # config-name: my-config.yml 40 | # disable-autolabeler: true 41 | id: release-drafter 42 | env: 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 | - name: See output 45 | run: | 46 | echo 'latest version: ${{ steps.release-drafter.name }}' 47 | -------------------------------------------------------------------------------- /.github/workflows/pr-title-commit.yml: -------------------------------------------------------------------------------- 1 | name: PR Title 2 | on: 3 | pull_request: 4 | types: 5 | - opened 6 | - edited 7 | - reopened 8 | jobs: 9 | lint-pr: 10 | name: Lint pull request title 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Lint pull request title 14 | uses: jef/conventional-commits-pr-action@v1 15 | with: 16 | token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: "PR" 2 | 3 | env: 4 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | jobs: 12 | DotNet: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup .NET Version 17 | uses: actions/setup-dotnet@v2 18 | with: 19 | dotnet-version: | 20 | 6.0.x 21 | 7.0.x 22 | - name: Build 23 | run: dotnet build 24 | - name: Test 25 | run: dotnet test 26 | 27 | 28 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teacher-zhou/ComponentBuilder/81bf547d1b030ae4612fc56d50f17f0f002f2fe5/CONTRIBUTING.md -------------------------------------------------------------------------------- /asset/BlazorComponentBaseLifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teacher-zhou/ComponentBuilder/81bf547d1b030ae4612fc56d50f17f0f002f2fe5/asset/BlazorComponentBaseLifecycle.png -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/ComponentBuilder.Doc.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | Default 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/Components/Button.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Definitions; 2 | 3 | using Microsoft.AspNetCore.Components; 4 | 5 | namespace ComponentBuilder.Doc.Client.Components 6 | { 7 | [HtmlTag("button")] 8 | [CssClass("btn")] 9 | public class Button : BlazorComponentBase, IHasChildContent, IHasAdditionalStyle 10 | { 11 | [Parameter] public RenderFragment? ChildContent { get; set; } 12 | [Parameter] public StyleProperty? AdditionalStyle { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 30 | 31 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder; 2 | 3 | using Markdig; 4 | 5 | using Microsoft.AspNetCore.Components; 6 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 7 | 8 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 9 | 10 | builder.Services.AddComponentBuilder(); 11 | await builder.Build().RunAsync(); 12 | 13 | public static class Code 14 | { 15 | public static MarkupString Create(string value) 16 | { 17 | var content = Markdown.ToHtml(value); 18 | return new MarkupString(content); 19 | } 20 | public const string BgRun = "background:#ccc"; 21 | } -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using ComponentBuilder.Doc.Client 10 | @using ComponentBuilder.Doc.Client.Components 11 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/wwwroot/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc.Client/wwwroot/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/ComponentBuilder.Doc.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/Components/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/Error" 2 | @using System.Diagnostics 3 | 4 | Error 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (ShowRequestId) 10 | { 11 |

12 | Request ID: @RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using ComponentBuilder.Doc 10 | @using ComponentBuilder.Doc.Client 11 | @using ComponentBuilder.Doc.Components 12 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/Program.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Doc.Client.Pages; 2 | using ComponentBuilder.Doc.Components; 3 | using ComponentBuilder; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add services to the container. 8 | builder.Services.AddRazorComponents() 9 | .AddInteractiveServerComponents() 10 | .AddInteractiveWebAssemblyComponents(); 11 | builder.Services.AddComponentBuilder(); 12 | var app = builder.Build(); 13 | 14 | // Configure the HTTP request pipeline. 15 | if (app.Environment.IsDevelopment()) 16 | { 17 | app.UseWebAssemblyDebugging(); 18 | } 19 | else 20 | { 21 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 22 | } 23 | 24 | app.UseStaticFiles(); 25 | app.UseAntiforgery(); 26 | 27 | app.MapRazorComponents() 28 | .AddInteractiveServerRenderMode() 29 | .AddInteractiveWebAssemblyRenderMode() 30 | .AddAdditionalAssemblies(typeof(ComponentBuilder.Doc.Client._Imports).Assembly); 31 | 32 | app.Run(); 33 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:56930", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 17 | "applicationUrl": "http://localhost:5168", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "IIS Express": { 23 | "commandName": "IISExpress", 24 | "launchBrowser": true, 25 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teacher-zhou/ComponentBuilder/81bf547d1b030ae4612fc56d50f17f0f002f2fe5/doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/favicon.png -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/diff.js: -------------------------------------------------------------------------------- 1 | /*! `diff` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar = (function () { 3 | 'use strict'; 4 | 5 | /* 6 | Language: Diff 7 | Description: Unified and context diff 8 | Author: Vasily Polovnyov 9 | Website: https://www.gnu.org/software/diffutils/ 10 | Category: common 11 | */ 12 | 13 | /** @type LanguageFn */ 14 | function diff(hljs) { 15 | const regex = hljs.regex; 16 | return { 17 | name: 'Diff', 18 | aliases: [ 'patch' ], 19 | contains: [ 20 | { 21 | className: 'meta', 22 | relevance: 10, 23 | match: regex.either( 24 | /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/, 25 | /^\*\*\* +\d+,\d+ +\*\*\*\*$/, 26 | /^--- +\d+,\d+ +----$/ 27 | ) 28 | }, 29 | { 30 | className: 'comment', 31 | variants: [ 32 | { 33 | begin: regex.either( 34 | /Index: /, 35 | /^index/, 36 | /={3,}/, 37 | /^-{3}/, 38 | /^\*{3} /, 39 | /^\+{3}/, 40 | /^diff --git/ 41 | ), 42 | end: /$/ 43 | }, 44 | { match: /^\*{15}$/ } 45 | ] 46 | }, 47 | { 48 | className: 'addition', 49 | begin: /^\+/, 50 | end: /$/ 51 | }, 52 | { 53 | className: 'deletion', 54 | begin: /^-/, 55 | end: /$/ 56 | }, 57 | { 58 | className: 'addition', 59 | begin: /^!/, 60 | end: /$/ 61 | } 62 | ] 63 | }; 64 | } 65 | 66 | return diff; 67 | 68 | })(); 69 | ; 70 | export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/diff.min.js: -------------------------------------------------------------------------------- 1 | /*! `diff` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar=(()=>{"use strict";return e=>{const a=e.regex;return{ 3 | name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10, 4 | match:a.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/) 5 | },{className:"comment",variants:[{ 6 | begin:a.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/), 7 | end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{ 8 | className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/, 9 | end:/$/}]}}})();export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/http.min.js: -------------------------------------------------------------------------------- 1 | /*! `http` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar=(()=>{"use strict";return e=>{const a="HTTP/([32]|1\\.[01])",n={ 3 | className:"attribute", 4 | begin:e.regex.concat("^",/[A-Za-z][A-Za-z0-9-]*/,"(?=\\:\\s)"),starts:{ 5 | contains:[{className:"punctuation",begin:/: /,relevance:0,starts:{end:"$", 6 | relevance:0}}]}},s=[n,{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0} 7 | }];return{name:"HTTP",aliases:["https"],illegal:/\S/,contains:[{ 8 | begin:"^(?="+a+" \\d{3})",end:/$/,contains:[{className:"meta",begin:a},{ 9 | className:"number",begin:"\\b\\d{3}\\b"}],starts:{end:/\b\B/,illegal:/\S/, 10 | contains:s}},{begin:"(?=^[A-Z]+ (.*?) "+a+"$)",end:/$/,contains:[{ 11 | className:"string",begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{ 12 | className:"meta",begin:a},{className:"keyword",begin:"[A-Z]+"}],starts:{ 13 | end:/\b\B/,illegal:/\S/,contains:s}},e.inherit(n,{relevance:0})]}}})() 14 | ;export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/json.min.js: -------------------------------------------------------------------------------- 1 | /*! `json` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar=(()=>{"use strict";return e=>{ 3 | const a=["true","false","null"],r={scope:"literal",beginKeywords:a.join(" ")} 4 | ;return{name:"JSON",keywords:{literal:a},contains:[{className:"attr", 5 | begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/, 6 | className:"punctuation",relevance:0 7 | },e.QUOTE_STRING_MODE,r,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE], 8 | illegal:"\\S"}}})();export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/plaintext.js: -------------------------------------------------------------------------------- 1 | /*! `plaintext` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar = (function () { 3 | 'use strict'; 4 | 5 | /* 6 | Language: Plain text 7 | Author: Egor Rogov (e.rogov@postgrespro.ru) 8 | Description: Plain text without any highlighting. 9 | Category: common 10 | */ 11 | 12 | function plaintext(hljs) { 13 | return { 14 | name: 'Plain text', 15 | aliases: [ 16 | 'text', 17 | 'txt' 18 | ], 19 | disableAutodetect: true 20 | }; 21 | } 22 | 23 | return plaintext; 24 | 25 | })(); 26 | ; 27 | export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/plaintext.min.js: -------------------------------------------------------------------------------- 1 | /*! `plaintext` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar=(()=>{"use strict";return t=>({name:"Plain text", 3 | aliases:["text","txt"],disableAutodetect:!0})})();export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/shell.js: -------------------------------------------------------------------------------- 1 | /*! `shell` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar = (function () { 3 | 'use strict'; 4 | 5 | /* 6 | Language: Shell Session 7 | Requires: bash.js 8 | Author: TSUYUSATO Kitsune 9 | Category: common 10 | Audit: 2020 11 | */ 12 | 13 | /** @type LanguageFn */ 14 | function shell(hljs) { 15 | return { 16 | name: 'Shell Session', 17 | aliases: [ 18 | 'console', 19 | 'shellsession' 20 | ], 21 | contains: [ 22 | { 23 | className: 'meta.prompt', 24 | // We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result. 25 | // For instance, in the following example, it would match "echo /path/to/home >" as a prompt: 26 | // echo /path/to/home > t.exe 27 | begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/, 28 | starts: { 29 | end: /[^\\](?=\s*$)/, 30 | subLanguage: 'bash' 31 | } 32 | } 33 | ] 34 | }; 35 | } 36 | 37 | return shell; 38 | 39 | })(); 40 | ; 41 | export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/languages/shell.min.js: -------------------------------------------------------------------------------- 1 | /*! `shell` grammar compiled for Highlight.js 11.9.0 */ 2 | var hljsGrammar=(()=>{"use strict";return s=>({name:"Shell Session", 3 | aliases:["console","shellsession"],contains:[{className:"meta.prompt", 4 | begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/, 5 | subLanguage:"bash"}}]})})();export default hljsGrammar; -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/es/package.json: -------------------------------------------------------------------------------- 1 | { "type": "module" } -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/diff.min.js: -------------------------------------------------------------------------------- 1 | /*! `diff` grammar compiled for Highlight.js 11.9.0 */ 2 | (()=>{var e=(()=>{"use strict";return e=>{const a=e.regex;return{name:"Diff", 3 | aliases:["patch"],contains:[{className:"meta",relevance:10, 4 | match:a.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/) 5 | },{className:"comment",variants:[{ 6 | begin:a.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/), 7 | end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{ 8 | className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/, 9 | end:/$/}]}}})();hljs.registerLanguage("diff",e)})(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/http.min.js: -------------------------------------------------------------------------------- 1 | /*! `http` grammar compiled for Highlight.js 11.9.0 */ 2 | (()=>{var e=(()=>{"use strict";return e=>{const n="HTTP/([32]|1\\.[01])",a={ 3 | className:"attribute", 4 | begin:e.regex.concat("^",/[A-Za-z][A-Za-z0-9-]*/,"(?=\\:\\s)"),starts:{ 5 | contains:[{className:"punctuation",begin:/: /,relevance:0,starts:{end:"$", 6 | relevance:0}}]}},s=[a,{begin:"\\n\\n",starts:{subLanguage:[],endsWithParent:!0} 7 | }];return{name:"HTTP",aliases:["https"],illegal:/\S/,contains:[{ 8 | begin:"^(?="+n+" \\d{3})",end:/$/,contains:[{className:"meta",begin:n},{ 9 | className:"number",begin:"\\b\\d{3}\\b"}],starts:{end:/\b\B/,illegal:/\S/, 10 | contains:s}},{begin:"(?=^[A-Z]+ (.*?) "+n+"$)",end:/$/,contains:[{ 11 | className:"string",begin:" ",end:" ",excludeBegin:!0,excludeEnd:!0},{ 12 | className:"meta",begin:n},{className:"keyword",begin:"[A-Z]+"}],starts:{ 13 | end:/\b\B/,illegal:/\S/,contains:s}},e.inherit(a,{relevance:0})]}}})() 14 | ;hljs.registerLanguage("http",e)})(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/json.min.js: -------------------------------------------------------------------------------- 1 | /*! `json` grammar compiled for Highlight.js 11.9.0 */ 2 | (()=>{var e=(()=>{"use strict";return e=>{const a=["true","false","null"],n={ 3 | scope:"literal",beginKeywords:a.join(" ")};return{name:"JSON",keywords:{ 4 | literal:a},contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/, 5 | relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0 6 | },e.QUOTE_STRING_MODE,n,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE], 7 | illegal:"\\S"}}})();hljs.registerLanguage("json",e)})(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/plaintext.js: -------------------------------------------------------------------------------- 1 | /*! `plaintext` grammar compiled for Highlight.js 11.9.0 */ 2 | (function(){ 3 | var hljsGrammar = (function () { 4 | 'use strict'; 5 | 6 | /* 7 | Language: Plain text 8 | Author: Egor Rogov (e.rogov@postgrespro.ru) 9 | Description: Plain text without any highlighting. 10 | Category: common 11 | */ 12 | 13 | function plaintext(hljs) { 14 | return { 15 | name: 'Plain text', 16 | aliases: [ 17 | 'text', 18 | 'txt' 19 | ], 20 | disableAutodetect: true 21 | }; 22 | } 23 | 24 | return plaintext; 25 | 26 | })(); 27 | 28 | hljs.registerLanguage('plaintext', hljsGrammar); 29 | })(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/plaintext.min.js: -------------------------------------------------------------------------------- 1 | /*! `plaintext` grammar compiled for Highlight.js 11.9.0 */ 2 | (()=>{var t=(()=>{"use strict";return t=>({name:"Plain text", 3 | aliases:["text","txt"],disableAutodetect:!0})})() 4 | ;hljs.registerLanguage("plaintext",t)})(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/shell.js: -------------------------------------------------------------------------------- 1 | /*! `shell` grammar compiled for Highlight.js 11.9.0 */ 2 | (function(){ 3 | var hljsGrammar = (function () { 4 | 'use strict'; 5 | 6 | /* 7 | Language: Shell Session 8 | Requires: bash.js 9 | Author: TSUYUSATO Kitsune 10 | Category: common 11 | Audit: 2020 12 | */ 13 | 14 | /** @type LanguageFn */ 15 | function shell(hljs) { 16 | return { 17 | name: 'Shell Session', 18 | aliases: [ 19 | 'console', 20 | 'shellsession' 21 | ], 22 | contains: [ 23 | { 24 | className: 'meta.prompt', 25 | // We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result. 26 | // For instance, in the following example, it would match "echo /path/to/home >" as a prompt: 27 | // echo /path/to/home > t.exe 28 | begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/, 29 | starts: { 30 | end: /[^\\](?=\s*$)/, 31 | subLanguage: 'bash' 32 | } 33 | } 34 | ] 35 | }; 36 | } 37 | 38 | return shell; 39 | 40 | })(); 41 | 42 | hljs.registerLanguage('shell', hljsGrammar); 43 | })(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/shell.min.js: -------------------------------------------------------------------------------- 1 | /*! `shell` grammar compiled for Highlight.js 11.9.0 */ 2 | (()=>{var s=(()=>{"use strict";return s=>({name:"Shell Session", 3 | aliases:["console","shellsession"],contains:[{className:"meta.prompt", 4 | begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/, 5 | subLanguage:"bash"}}]})})();hljs.registerLanguage("shell",s)})(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/languages/wasm.min.js: -------------------------------------------------------------------------------- 1 | /*! `wasm` grammar compiled for Highlight.js 11.9.0 */ 2 | (()=>{var e=(()=>{"use strict";return e=>{e.regex;const a=e.COMMENT(/\(;/,/;\)/) 3 | ;return a.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/, 4 | keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"] 5 | },contains:[e.COMMENT(/;;/,/$/),a,{match:[/(?:offset|align)/,/\s*/,/=/], 6 | className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{ 7 | match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{ 8 | begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword", 9 | 3:"title.function"}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/, 10 | className:"type"},{className:"keyword", 11 | match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/ 12 | },{className:"number",relevance:0, 13 | match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/ 14 | }]}}})();hljs.registerLanguage("wasm",e)})(); -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/styles/vs.css: -------------------------------------------------------------------------------- 1 | pre code.hljs { 2 | display: block; 3 | overflow-x: auto; 4 | padding: 1em 5 | } 6 | code.hljs { 7 | padding: 3px 5px 8 | } 9 | /* 10 | 11 | Visual Studio-like style based on original C# coloring by Jason Diamond 12 | 13 | */ 14 | .hljs { 15 | background: white; 16 | color: black 17 | } 18 | .hljs-comment, 19 | .hljs-quote, 20 | .hljs-variable { 21 | color: #008000 22 | } 23 | .hljs-keyword, 24 | .hljs-selector-tag, 25 | .hljs-built_in, 26 | .hljs-name, 27 | .hljs-tag { 28 | color: #00f 29 | } 30 | .hljs-string, 31 | .hljs-title, 32 | .hljs-section, 33 | .hljs-attribute, 34 | .hljs-literal, 35 | .hljs-template-tag, 36 | .hljs-template-variable, 37 | .hljs-type, 38 | .hljs-addition { 39 | color: #a31515 40 | } 41 | .hljs-deletion, 42 | .hljs-selector-attr, 43 | .hljs-selector-pseudo, 44 | .hljs-meta { 45 | color: #2b91af 46 | } 47 | .hljs-doctag { 48 | color: #808080 49 | } 50 | .hljs-attr { 51 | color: #f00 52 | } 53 | .hljs-symbol, 54 | .hljs-bullet, 55 | .hljs-link { 56 | color: #00b0e8 57 | } 58 | .hljs-emphasis { 59 | font-style: italic 60 | } 61 | .hljs-strong { 62 | font-weight: bold 63 | } -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/styles/vs.min.css: -------------------------------------------------------------------------------- 1 | pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#fff;color:#000}.hljs-comment,.hljs-quote,.hljs-variable{color:green}.hljs-built_in,.hljs-keyword,.hljs-name,.hljs-selector-tag,.hljs-tag{color:#00f}.hljs-addition,.hljs-attribute,.hljs-literal,.hljs-section,.hljs-string,.hljs-template-tag,.hljs-template-variable,.hljs-title,.hljs-type{color:#a31515}.hljs-deletion,.hljs-meta,.hljs-selector-attr,.hljs-selector-pseudo{color:#2b91af}.hljs-doctag{color:grey}.hljs-attr{color:red}.hljs-bullet,.hljs-link,.hljs-symbol{color:#00b0e8}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700} -------------------------------------------------------------------------------- /doc/ComponentBuilder.Doc/ComponentBuilder.Doc/wwwroot/highlight/styles/vs2015.min.css: -------------------------------------------------------------------------------- 1 | pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#1e1e1e;color:#dcdcdc}.hljs-keyword,.hljs-literal,.hljs-name,.hljs-symbol{color:#569cd6}.hljs-link{color:#569cd6;text-decoration:underline}.hljs-built_in,.hljs-type{color:#4ec9b0}.hljs-class,.hljs-number{color:#b8d7a3}.hljs-meta .hljs-string,.hljs-string{color:#d69d85}.hljs-regexp,.hljs-template-tag{color:#9a5334}.hljs-formula,.hljs-function,.hljs-params,.hljs-subst,.hljs-title{color:#dcdcdc}.hljs-comment,.hljs-quote{color:#57a64a;font-style:italic}.hljs-doctag{color:#608b4e}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-tag{color:#9b9b9b}.hljs-template-variable,.hljs-variable{color:#bd63c5}.hljs-attr,.hljs-attribute{color:#9cdcfe}.hljs-section{color:gold}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-bullet,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-selector-tag{color:#d7ba7d}.hljs-addition{background-color:#144212;display:inline-block;width:100%}.hljs-deletion{background-color:#600;display:inline-block;width:100%} -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-18_16_16_41_072.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder 8 | { 9 | internal class BlazorComponentBase 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-18_16_18_12_123.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 11 | { 12 | void IBlazorComponent.NotifyRefresh() 13 | { 14 | base.StateHasChanged(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-18_16_20_08_982.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace ComponentBuilder 10 | { 11 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 12 | { 13 | [Inject] protected ICssClassBuilder CssBuilder { get; set; } 14 | 15 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-18_16_20_17_442.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System.Threading.Tasks; 4 | 5 | namespace ComponentBuilder 6 | { 7 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 8 | { 9 | [Inject] protected ICssClassBuilder CssBuilder { get; set; } 10 | 11 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-18_16_20_44_444.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System.Threading.Tasks; 4 | 5 | namespace ComponentBuilder 6 | { 7 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 8 | { 9 | [Inject] protected ICssClassBuilder CssBuilder { get; set; } 10 | 11 | public string BuildCssClassString() 12 | { 13 | throw new System.NotImplementedException(); 14 | } 15 | 16 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-19_10_45_55_801.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace ComponentBuilder 7 | { 8 | /// 9 | /// Provides a base class for component that can build css class quickly. 10 | /// 11 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 12 | { 13 | #region Injection 14 | [Inject] protected ICssClassBuilder CssBuilder { get; set; } 15 | #endregion 16 | 17 | 18 | #region Parameters 19 | [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary Attributes { get; set; } = new Dictionary(); 20 | #endregion 21 | 22 | /// 23 | /// Build the css class for component by settings. 24 | /// 25 | /// Ignore all settings when class value of attribute in element is set. 26 | /// 27 | /// 28 | /// 29 | public string BuildCssClassString() 30 | { 31 | if (Attributes.TryGetValue("class", out object value)) 32 | { 33 | return value.ToString(); 34 | } 35 | } 36 | 37 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-19_10_48_01_049.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace ComponentBuilder 7 | { 8 | /// 9 | /// Provides a base class for component that can build css class quickly. 10 | /// 11 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 12 | { 13 | #region Injection 14 | [Inject] protected ICssClassBuilder CssBuilder { get; set; } 15 | #endregion 16 | 17 | 18 | #region Parameters 19 | [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary Attributes { get; set; } = new Dictionary(); 20 | #endregion 21 | 22 | /// 23 | /// Build the css class for component by settings. 24 | /// 25 | /// Ignore all settings when class value of attribute in element is set. 26 | /// 27 | /// 28 | /// 29 | public string BuildCssClassString() 30 | { 31 | if (Attributes.TryGetValue("class", out object value)) 32 | { 33 | return value.ToString(); 34 | } 35 | 36 | return CssBuilder.Build(); 37 | } 38 | 39 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-19_10_49_04_592.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace ComponentBuilder 7 | { 8 | /// 9 | /// Provides a base class for component that can build css class quickly. 10 | /// 11 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 12 | { 13 | #region Properties 14 | #region Injection 15 | [Inject] protected ICssClassBuilder CssBuilder { get; set; } 16 | #endregion 17 | 18 | 19 | #region Parameters 20 | [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary Attributes { get; set; } = new Dictionary(); 21 | #endregion 22 | #endregion 23 | 24 | #region Method 25 | #region Public 26 | /// 27 | /// Build the css class for component by settings. 28 | /// 29 | /// Ignore all settings when class value of attribute in element is set. 30 | /// 31 | /// 32 | /// 33 | public string BuildCssClassString() 34 | { 35 | if (Attributes.TryGetValue("class", out object value)) 36 | { 37 | return value.ToString(); 38 | } 39 | 40 | return CssBuilder.Build(); 41 | } 42 | 43 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 44 | #endregion 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/BlazorComponentBase.cs/2021-11-19_10_51_21_676.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.AspNetCore.Components; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace ComponentBuilder 7 | { 8 | /// 9 | /// Provides a base class for component that can build css class quickly. 10 | /// 11 | public abstract class BlazorComponentBase : ComponentBase, IBlazorComponent 12 | { 13 | #region Properties 14 | #region Injection 15 | [Inject] ICssClassBuilder CssBuilder { get; set; } 16 | #endregion 17 | 18 | 19 | #region Parameters 20 | [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary Attributes { get; set; } = new Dictionary(); 21 | #endregion 22 | #endregion 23 | 24 | #region Method 25 | 26 | #region Public 27 | /// 28 | /// Build the css class for component by settings. 29 | /// 30 | /// Ignore all settings when class value of attribute in element is set. 31 | /// 32 | /// 33 | /// 34 | public string BuildCssClassString() 35 | { 36 | if (Attributes.TryGetValue("class", out object value)) 37 | { 38 | return value.ToString(); 39 | } 40 | 41 | return CssBuilder.Build(); 42 | } 43 | 44 | public Task NotifyStateChanged() => InvokeAsync(StateHasChanged); 45 | #endregion 46 | 47 | #region Protected 48 | #endregion 49 | 50 | #region Private 51 | #endregion 52 | 53 | #endregion 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilder.csproj/2021-11-18_16_05_57_990.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilder.csproj/2021-11-18_16_14_36_608.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilder.csproj/2021-11-19_16_35_38_386.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilder.csproj/2021-11-19_16_36_42_415.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 8 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderDependencyInjectionExtentions.cs/2021-11-19_13_46_15_771.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder 8 | { 9 | internal class ComponentBuilderDependencyInjectionExtentions 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderDependencyInjectionExtentions.cs/2021-11-19_13_47_31_823.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace ComponentBuilder 10 | { 11 | public static class ComponentBuilderDependencyInjectionExtentions 12 | { 13 | public static IServiceCollection AddComponentBuilder(this IServiceCollection services) 14 | { 15 | services.AddScoped() 16 | .AddScoped(); 17 | return services; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderDependencyInjectionExtentions.cs/2021-11-19_13_47_36_430.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace ComponentBuilder 5 | { 6 | public static class ComponentBuilderDependencyInjectionExtentions 7 | { 8 | public static IServiceCollection AddComponentBuilder(this IServiceCollection services) 9 | { 10 | services.AddScoped() 11 | .AddScoped(); 12 | return services; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_11_05_55_522.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder 8 | { 9 | internal class BlazorComponentExtensions 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_11_08_18_164.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_11_32_55_592.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 18 | { 19 | attribute = field.GetCustomAttribute(); 20 | return attribute != null; 21 | } 22 | 23 | public static string GetEnumCssClass(this object @enum) 24 | { 25 | if (@enum is not Enum) 26 | { 27 | throw new InvalidOperationException($"This type is not a Enum type"); 28 | } 29 | 30 | var enumType = @enum.GetType(); 31 | 32 | var enumMember = enumType.GetField(enumType.Name); 33 | 34 | if (enumMember.GetCustomAttribute<>) 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_11_33_31_584.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 18 | { 19 | attribute = field.GetCustomAttribute(); 20 | return attribute != null; 21 | } 22 | 23 | public static string GetEnumCssClass(this object @enum) 24 | { 25 | if (@enum is not Enum) 26 | { 27 | throw new InvalidOperationException($"This type is not a Enum type"); 28 | } 29 | 30 | var enumType = @enum.GetType(); 31 | 32 | var enumMember = enumType.GetField(enumType.Name); 33 | 34 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 35 | { 36 | return cssClassAttribute.Css; 37 | } 38 | return enumMember.Name; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_11_40_33_685.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 18 | { 19 | attribute = field.GetCustomAttribute(); 20 | return attribute != null; 21 | } 22 | 23 | public static string GetEnumCssClass(this object @enum) 24 | { 25 | if (@enum is not Enum) 26 | { 27 | throw new InvalidOperationException($"This type is not a Enum type"); 28 | } 29 | 30 | var enumType = @enum.GetType(); 31 | 32 | var enumMember = enumType.GetField(enumType.Name); 33 | 34 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 35 | { 36 | return cssClassAttribute.Css; 37 | } 38 | return enumMember.Name.ToLower(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_13_33_11_524.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 18 | { 19 | attribute = field.GetCustomAttribute(); 20 | return attribute != null; 21 | } 22 | 23 | public static string GetEnumCssClass(this object @enum) 24 | { 25 | if (@enum is not Enum) 26 | { 27 | throw new InvalidOperationException($"This type is not a Enum type"); 28 | } 29 | 30 | var enumType = @enum.GetType(); 31 | 32 | var enumMember = enumType.GetTypeInfo().GetDeclaredField(@enum.ToString()); 33 | 34 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 35 | { 36 | return cssClassAttribute.Css; 37 | } 38 | return enumMember.Name.ToLower(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_13_33_43_298.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 18 | { 19 | attribute = field.GetCustomAttribute(); 20 | return attribute != null; 21 | } 22 | 23 | public static string GetEnumCssClass(this object @enum) 24 | { 25 | if (@enum is not Enum) 26 | { 27 | throw new InvalidOperationException($"This type is not a Enum type"); 28 | } 29 | 30 | var enumType = @enum.GetType(); 31 | 32 | var enumMember = enumType.GetField(@enum.ToString()); 33 | 34 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 35 | { 36 | return cssClassAttribute.Css; 37 | } 38 | return enumMember.Name.ToLower(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_13_34_17_089.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | public static class BlazorComponentExtensions 11 | { 12 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 13 | { 14 | attribute = type.GetCustomAttribute(); 15 | return attribute != null; 16 | } 17 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 18 | { 19 | attribute = field.GetCustomAttribute(); 20 | return attribute != null; 21 | } 22 | 23 | public static string GetEnumCssClass(this object @enum, bool original = default) 24 | { 25 | if (@enum is not Enum) 26 | { 27 | throw new InvalidOperationException($"This type is not a Enum type"); 28 | } 29 | 30 | var enumType = @enum.GetType(); 31 | 32 | var enumMember = enumType.GetField(@enum.ToString()); 33 | 34 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 35 | { 36 | return cssClassAttribute.Css; 37 | } 38 | return original ? enumMember.Name : enumMember.Name.ToLower(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_13_34_28_371.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder 9 | { 10 | /// 11 | /// The extensions of blazor component. 12 | /// 13 | public static class BlazorComponentExtensions 14 | { 15 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 16 | { 17 | attribute = type.GetCustomAttribute(); 18 | return attribute != null; 19 | } 20 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 21 | { 22 | attribute = field.GetCustomAttribute(); 23 | return attribute != null; 24 | } 25 | 26 | public static string GetEnumCssClass(this object @enum, bool original = default) 27 | { 28 | if (@enum is not Enum) 29 | { 30 | throw new InvalidOperationException($"This type is not a Enum type"); 31 | } 32 | 33 | var enumType = @enum.GetType(); 34 | 35 | var enumMember = enumType.GetField(@enum.ToString()); 36 | 37 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 38 | { 39 | return cssClassAttribute.Css; 40 | } 41 | return original ? enumMember.Name : enumMember.Name.ToLower(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_13_34_31_840.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace ComponentBuilder 5 | { 6 | /// 7 | /// The extensions of blazor component. 8 | /// 9 | public static class BlazorComponentExtensions 10 | { 11 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 12 | { 13 | attribute = type.GetCustomAttribute(); 14 | return attribute != null; 15 | } 16 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 17 | { 18 | attribute = field.GetCustomAttribute(); 19 | return attribute != null; 20 | } 21 | 22 | public static string GetEnumCssClass(this object @enum, bool original = default) 23 | { 24 | if (@enum is not Enum) 25 | { 26 | throw new InvalidOperationException($"This type is not a Enum type"); 27 | } 28 | 29 | var enumType = @enum.GetType(); 30 | 31 | var enumMember = enumType.GetField(@enum.ToString()); 32 | 33 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 34 | { 35 | return cssClassAttribute.Css; 36 | } 37 | return original ? enumMember.Name : enumMember.Name.ToLower(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ComponentBuilderExtensions.cs/2021-11-19_13_34_53_431.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace ComponentBuilder 5 | { 6 | /// 7 | /// The extensions of component builder. 8 | /// 9 | public static class ComponentBuilderExtensions 10 | { 11 | public static bool TryGetAttribute(this Type type, out TAttribute attribute) where TAttribute : Attribute 12 | { 13 | attribute = type.GetCustomAttribute(); 14 | return attribute != null; 15 | } 16 | public static bool TryGetAttribute(this FieldInfo field, out TAttribute attribute) where TAttribute : Attribute 17 | { 18 | attribute = field.GetCustomAttribute(); 19 | return attribute != null; 20 | } 21 | 22 | public static string GetEnumCssClass(this object @enum, bool original = default) 23 | { 24 | if (@enum is not Enum) 25 | { 26 | throw new InvalidOperationException($"This type is not a Enum type"); 27 | } 28 | 29 | var enumType = @enum.GetType(); 30 | 31 | var enumMember = enumType.GetField(@enum.ToString()); 32 | 33 | if (enumMember.TryGetAttribute(out var cssClassAttribute)) 34 | { 35 | return cssClassAttribute.Css; 36 | } 37 | return original ? enumMember.Name : enumMember.Name.ToLower(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_35_59_286.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder 8 | { 9 | internal class CssClassAttribute 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_37_04_789.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 6 | public class CssClassAttribute : Attribute 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_37_21_369.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 6 | public class CssClassAttribute : Attribute 7 | { 8 | public CssClassAttribute(string name) 9 | { 10 | Name = name; 11 | } 12 | 13 | public string Name { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_37_35_462.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 6 | public class CssClassAttribute : Attribute 7 | { 8 | public CssClassAttribute(string name) 9 | { 10 | Name = name; 11 | } 12 | 13 | public string Name { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_50_53_955.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | /// 6 | /// Declare a value of css class to build. 7 | /// 8 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 9 | public class CssClassAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of class by given css class name. 13 | /// 14 | /// 15 | public CssClassAttribute(string css) 16 | { 17 | Name = css; 18 | } 19 | 20 | public string Name { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_50_58_810.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | /// 6 | /// Declare a value of css class to build. 7 | /// 8 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 9 | public class CssClassAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of class by given css class name. 13 | /// 14 | /// 15 | public CssClassAttribute(string css) 16 | { 17 | Css = css; 18 | } 19 | 20 | public string Css { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_51_07_323.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | /// 6 | /// Declare a value of css class to build. 7 | /// 8 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 9 | public class CssClassAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of class by given css class name. 13 | /// 14 | /// 15 | public CssClassAttribute(string css) 16 | { 17 | Css = css; 18 | } 19 | 20 | /// 21 | /// Gets css class value. 22 | /// 23 | public string Css { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_51_22_179.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | /// 6 | /// Declare a value of css class to build. 7 | /// 8 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 9 | public class CssClassAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of class by given css class name. 13 | /// 14 | /// 15 | public CssClassAttribute(string css) 16 | { 17 | Css = css ?? throw new ArgumentNullException(nameof(css)); 18 | } 19 | 20 | /// 21 | /// Gets css class value. 22 | /// 23 | public string Css { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/CssClassAttribute.cs/2021-11-18_16_51_30_996.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | /// 6 | /// Declare a value of css class to build. 7 | /// 8 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] 9 | public class CssClassAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of class by given css class name. 13 | /// 14 | /// The css class value. 15 | public CssClassAttribute(string css) 16 | { 17 | Css = css ?? throw new ArgumentNullException(nameof(css)); 18 | } 19 | 20 | /// 21 | /// Gets css class value. 22 | /// 23 | public string Css { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ElementTagAttribute.cs/2021-11-19_14_27_36_676.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder 8 | { 9 | internal class HtmlElement 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ElementTagAttribute.cs/2021-11-19_14_28_34_495.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] 6 | public class HtmlElementAttribute : Attribute 7 | { 8 | public HtmlElementAttribute(string elementName) 9 | { 10 | ElementName = elementName; 11 | } 12 | 13 | public string ElementName { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ElementTagAttribute.cs/2021-11-19_15_07_54_648.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] 6 | public class ElementTagAttribute : Attribute 7 | { 8 | public ElementTagAttribute(string name) 9 | { 10 | ElementName = name; 11 | } 12 | 13 | public string ElementName { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ElementTagAttribute.cs/2021-11-19_15_08_02_770.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] 6 | public class ElementTagAttribute : Attribute 7 | { 8 | public ElementTagAttribute(string name) 9 | { 10 | Name = name; 11 | } 12 | 13 | public string Name { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/ElementTagAttribute.cs/2021-11-19_15_09_21_891.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ComponentBuilder 4 | { 5 | /// 6 | /// Provides html element name for component to render. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] 9 | public class ElementTagAttribute : Attribute 10 | { 11 | /// 12 | /// Initializes a new instance of class. 13 | /// 14 | /// Element tag name. 15 | public ElementTagAttribute(string name) 16 | { 17 | Name = name; 18 | } 19 | 20 | public string Name { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_16_28_347.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace ComponentBuilder 4 | { 5 | public interface IBlazorComponent : IComponent 6 | { 7 | void StateHasChanged(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_17_16_119.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace ComponentBuilder 4 | { 5 | public interface IBlazorComponent : IComponent 6 | { 7 | void StateHasChanged(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_18_11_789.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | 3 | namespace ComponentBuilder 4 | { 5 | public interface IBlazorComponent : IComponent 6 | { 7 | void NotifyRefresh(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_19_05_393.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System.Threading.Tasks; 3 | 4 | namespace ComponentBuilder 5 | { 6 | public interface IBlazorComponent : IComponent 7 | { 8 | Task NotifyStateChanged(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_20_32_443.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System.Threading.Tasks; 3 | 4 | namespace ComponentBuilder 5 | { 6 | public interface IBlazorComponent : IComponent 7 | { 8 | Task NotifyStateChanged(); 9 | 10 | string BuildCssClassString(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_35_20_296.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System.Threading.Tasks; 3 | 4 | namespace ComponentBuilder 5 | { 6 | /// 7 | /// Represents a blazor component. 8 | /// 9 | public interface IBlazorComponent : IComponent 10 | { 11 | /// 12 | /// Notify component's state has been changed. 13 | /// 14 | /// 15 | Task NotifyStateChanged(); 16 | 17 | /// 18 | /// Build all css class as string. 19 | /// 20 | /// 21 | string BuildCssClassString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_35_36_802.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System.Threading.Tasks; 3 | 4 | namespace ComponentBuilder 5 | { 6 | /// 7 | /// Represents a blazor component. 8 | /// 9 | public interface IBlazorComponent : IComponent 10 | { 11 | /// 12 | /// Notify component's state has been changed. 13 | /// 14 | /// 15 | Task NotifyStateChanged(); 16 | 17 | /// 18 | /// Build all css class as string. 19 | /// 20 | /// A string seperated by space for each item. 21 | string BuildCssClassString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ComponentBuilder/.vshistory/IBlazorComponent.cs/2021-11-18_16_53_49_316.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System.Threading.Tasks; 3 | 4 | namespace ComponentBuilder 5 | { 6 | /// 7 | /// Represents a blazor component. 8 | /// 9 | public interface IBlazorComponent : IComponent 10 | { 11 | /// 12 | /// Notify component's state has been changed. 13 | /// 14 | /// 15 | Task NotifyStateChanged(); 16 | 17 | /// 18 | /// Build all css class as string. 19 | /// 20 | /// A string separated by space for each item. 21 | string BuildCssClassString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Abstractions/IBlazorComponent.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// Represents a blazor component. 5 | /// 6 | public interface IBlazorComponent : IHasAdditionalAttributes, IComponent, IDisposable 7 | { 8 | /// 9 | /// Gets the child components. 10 | /// 11 | BlazorComponentCollection ChildComponents { get; } 12 | 13 | /// 14 | /// Asynchronously notifies the component that its state has changed and renders the component. 15 | /// 16 | Task NotifyStateChanged(); 17 | 18 | /// 19 | /// Returns the properties of the component. 20 | /// 21 | /// Key/value pairs containing HTML attributes. 22 | IEnumerable> GetAttributes(); 23 | } 24 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Abstractions/StyleProperty.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// Generate css style. 5 | /// 6 | public class StyleProperty : Dictionary 7 | { 8 | /// 9 | /// 10 | /// 11 | public StyleProperty() 12 | { 13 | } 14 | 15 | /// 16 | /// 17 | /// 18 | public StyleProperty(IDictionary dictionary) : base(dictionary) 19 | { 20 | } 21 | 22 | /// 23 | /// 24 | /// 25 | public StyleProperty(IEnumerable> collection) : base(collection) 26 | { 27 | } 28 | 29 | /// 30 | /// Convert style string with semi-comma(;) for each item. 31 | /// 32 | public override string ToString() => string.Join(";", this.Where(m => m.Value switch 33 | { 34 | bool value => value, 35 | object value => value is not null 36 | }).Select(m => $"{m.Key}:{m.Value}")); 37 | 38 | /// 39 | /// Convert style string(key1:value1;key2:value2...) to class. 40 | /// 41 | public static implicit operator StyleProperty(string? styleString) 42 | { 43 | ArgumentException.ThrowIfNullOrEmpty(styleString, nameof(styleString)); 44 | 45 | var dic = styleString.Trim().Split(';').Select(key => 46 | { 47 | var name = key.Split(":")[0].Trim(); 48 | var value = key.Split(":")[1].Trim(); 49 | 50 | return new KeyValuePair(name, value); 51 | }); 52 | return new(dic); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Attributes/BooleanCssClassAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// Apply to parameter of component weither to use CSS when true or false. 5 | /// 6 | /// 7 | /// Apply specified CSS string when parameter value is true. 8 | /// Apply specified CSS string when parameter value is false. It can be default string. 9 | [AttributeUsage(AttributeTargets.Property)] 10 | public class BooleanCssClassAttribute(string trueClass, string? falseClass = default) : CssClassAttribute 11 | { 12 | /// 13 | /// Gets the CSS string when parameter is true. 14 | /// 15 | public string TrueClass { get; } = trueClass; 16 | /// 17 | /// Gets the CSS string when parameter is false. 18 | /// 19 | public string? FalseClass { get; } = falseClass; 20 | } 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Attributes/HtmlTagAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | namespace ComponentBuilder; 4 | 5 | /// 6 | /// Defines the HTML tag name for component to generate. 7 | /// 8 | /// The name of HTML tag. 9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] 10 | public class HtmlTagAttribute([NotNull] string name) : Attribute 11 | { 12 | 13 | /// 14 | /// Gets the name of HTML tag. 15 | /// 16 | public string Name { get; } = name ?? throw new ArgumentNullException(nameof(name)); 17 | } 18 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Attributes/NullCssClassAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | namespace ComponentBuilder; 4 | 5 | /// 6 | /// Specified parameter a CSS string to generate when value is null. 7 | /// 8 | /// The CSS class string when parameter value is null. 9 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] 10 | public class NullCssClassAttribute([NotNull]string cssClass) : CssClassAttribute(cssClass){} 11 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Attributes/ParentComponentAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// Represents component is parent component, and automatically creating a cascading parameter for this component. 5 | /// 6 | /// The name of cascading value. 7 | [AttributeUsage(AttributeTargets.Class)] 8 | public class ParentComponentAttribute(string? name = default) : Attribute 9 | { 10 | /// 11 | /// Gets the name of cascading value. 12 | /// 13 | public string? Name => name; 14 | /// 15 | /// Gets or sets a vlaue wheither the value of cascading is fixed. 16 | /// 17 | public bool IsFixed { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Builder/DefaultStyleBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Builder; 2 | 3 | /// 4 | /// Default implementation. 5 | /// 6 | internal class DefaultStyleBuilder : IStyleBuilder 7 | { 8 | private readonly ICollection _styles; 9 | 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public DefaultStyleBuilder() 14 | { 15 | _styles = new List(); 16 | } 17 | 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | public IStyleBuilder Append(string? value) 24 | { 25 | if (string.IsNullOrEmpty(value)) 26 | { 27 | return this; 28 | } 29 | 30 | _styles.Add(value); 31 | return this; 32 | } 33 | 34 | 35 | /// 36 | /// Clear css class string in container. 37 | /// 38 | public void Clear() => _styles.Clear(); 39 | 40 | /// 41 | /// 42 | /// 43 | /// 44 | public override string ToString() => string.Join(";", _styles); 45 | } 46 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Builder/IStyleBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// Provides a container for generating styles. 5 | /// 6 | public interface IStyleBuilder 7 | { 8 | /// 9 | /// Append a new style value to the generator. 10 | /// 11 | /// The style value. 12 | IStyleBuilder Append(string? value); 13 | /// 14 | /// Clear all styles. 15 | /// 16 | void Clear(); 17 | /// 18 | /// Converts a string to a style and concatenates all values in this builder. 19 | /// 20 | /// Each entry is composed of semicolons (;) A delimited series of strings. 21 | string ToString(); 22 | } 23 | -------------------------------------------------------------------------------- /src/ComponentBuilder/ComponentBuilder.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | An automation framework to build Blazor Component Library faster and easily. Both supports the razor component or RenderTreeBuilder fragment building modes. 6 | 7 | Blazor Component Razor Automation Framework 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/Buttons/ButtonComponentBase.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | namespace ComponentBuilder.Definitions; 5 | 6 | /// 7 | /// Defines a button component with basic parameters. 8 | /// 9 | [HtmlTag("button")] 10 | public abstract class ButtonComponentBase : BlazorComponentBase, IHasButtonComponent 11 | { 12 | /// 13 | [Parameter][HtmlAria("disable")]public bool Disabled { get; set; } 14 | 15 | /// 16 | [Parameter]public RenderFragment? ChildContent { get; set; } 17 | 18 | /// 19 | /// HTML type of button. Default is . 20 | /// 21 | [Parameter][HtmlAttribute("type")] public ButtonHtmlType HtmlType { get; set; } = ButtonHtmlType.Button; 22 | /// 23 | [Parameter]public EventCallback OnClick { get; set; } 24 | /// 25 | [Parameter]public bool Active { get; set; } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/Buttons/ButtonHtmlType.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// The HTML type of button. 5 | /// 6 | public enum ButtonHtmlType 7 | { 8 | /// 9 | /// A normal button. 10 | /// 11 | Button, 12 | /// 13 | /// A submit button can trigger form onsubmit event. 14 | /// 15 | Submit, 16 | /// 17 | /// Reset and clear the value of input controls in form. 18 | /// 19 | Reset, 20 | } 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/Buttons/IHasButtonComponent.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Defines a button component with <button> HTML tag. 5 | /// 6 | [HtmlTag("button")] 7 | public interface IHasButtonComponent : IBlazorComponent, IHasDisabled, IHasChildContent, IHasActive 8 | { 9 | /// 10 | /// HTML type of button. Default is . 11 | /// 12 | [HtmlAttribute("type")] public ButtonHtmlType HtmlType { get; set; } 13 | /// 14 | /// Performs a callback action when clicking the button. 15 | /// 16 | [HtmlAttribute("onclick")] EventCallback OnClick { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/IAnchorComponent.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Provide generative < a> Hyperlinked component of the element. 4 | /// 5 | [HtmlTag("a")] 6 | public interface IAnchorComponent 7 | { 8 | /// 9 | /// The href link of anchor. 10 | /// 11 | [HtmlAttribute] public string? Href { get; set; } 12 | /// 13 | /// Specify where to open the linked document. 14 | /// 15 | [HtmlAttribute] public AnchorTarget Target { get; set; } 16 | } 17 | 18 | /// 19 | /// Anchor (< a>) target of the element. 20 | /// 21 | public enum AnchorTarget 22 | { 23 | /// 24 | /// This is the default value. It opens linked documents in the same frame. 25 | /// 26 | [HtmlAttribute(value: "_self")] Self = 0, 27 | /// 28 | /// It opens the link in a new window. 29 | /// 30 | [HtmlAttribute(value: "_blank")] Blank = 1, 31 | /// 32 | /// It opens the linked document in the parent frame set. 33 | /// 34 | [HtmlAttribute(value: "_parant")] Parent = 2, 35 | /// 36 | /// It opens the linked document in the entire body of the window. 37 | /// 38 | [HtmlAttribute(value: "_top")] Top = 3 39 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/IContainerComponent.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Indicates that components that implement the interface are automatically added as containers. This interface is used for container components that are required by components during dynamic service invocation. 5 | /// 6 | public interface IContainerComponent:IComponent 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/IFormComponent.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Provides components to support forms and validation. 5 | /// 6 | [HtmlTag("form")] 7 | public interface IFormComponent : IHasEditContext, IHasChildContent 8 | { 9 | /// 10 | /// Specifies the top-level model object for the form. An editing context is constructed for the model. 11 | /// 12 | object? Model { get; set; } 13 | /// 14 | /// The callback that will be invoked when the form is submitted. 15 | /// 16 | EventCallback OnSubmit { get; set; } 17 | 18 | /// 19 | /// Gets a bool value represents form is submitting. 20 | /// 21 | public bool IsSubmitting { get; set; } 22 | } 23 | 24 | /// 25 | /// The arguments when submit the form. 26 | /// 27 | /// The edit context. 28 | /// A bool value represents validation result of form. 29 | public class FormEventArgs(EditContext context,bool valid) : EventArgs 30 | { 31 | /// 32 | /// Gets the instance of class. 33 | /// 34 | public EditContext EditContext => context; 35 | /// 36 | /// Gets a bool value represents form validation result. 37 | /// 38 | public bool Valid => valid; 39 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Components/IHasNavLinkComponent.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.Routing; 2 | 3 | namespace ComponentBuilder.Definitions; 4 | 5 | /// 6 | /// Provides navigation links for components. 7 | /// 8 | public interface IHasNavLinkComponent : IHasChildContent 9 | { 10 | /// 11 | /// Gets or sets the behavior of a matching navigation link. 12 | /// 13 | NavLinkMatch Match { get; set; } 14 | 15 | /// 16 | /// Gets a Boolean value indicating that the link matches the url. 17 | /// 18 | bool IsActive { get; set; } 19 | 20 | /// 21 | /// Gets the CSS string when the uri link matches. 22 | /// 23 | string? ActiveCssClass => "active"; 24 | } 25 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasActive.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Provides a parameter of component can be actived. 5 | /// 6 | public interface IHasActive 7 | { 8 | /// 9 | /// Represents a status of component is actived. 10 | /// 11 | [CssClass("active")] bool Active { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasAdditionalAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Define an additional attribute for the component to catch unmatched html attribute values. 4 | /// 5 | public interface IHasAdditionalAttributes 6 | { 7 | /// 8 | /// Gets or sets an additional property in an element that automatically catches unmatched html property values. 9 | /// 10 | IDictionary AdditionalAttributes { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasAdditionalClass.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Provides additional CSS classes for the components to append. 4 | /// 5 | public interface IHasAdditionalClass 6 | { 7 | /// 8 | /// Gets or sets the string of additional CSS classes to append. 9 | /// 10 | /// Typically, this value is appended to the end of all CSS parameters after they have been built. 11 | /// 12 | /// 13 | string? AdditionalClass { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasAdditionalStyle.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Provides additional styles for the component to append. 4 | /// 5 | public interface IHasAdditionalStyle 6 | { 7 | /// 8 | /// Gets or sets additional style strings to append. 9 | /// 10 | /// Typically, this value is appended to the end of all style parameters after they have been built. 11 | /// 12 | /// 13 | StyleProperty? AdditionalStyle { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasChildContent.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Provide UI fragments for components to support child content. 5 | /// 6 | public interface IHasChildContent 7 | { 8 | /// 9 | /// Gets or sets a fragment of UI content. 10 | /// 11 | RenderFragment? ChildContent { get; set; } 12 | } 13 | 14 | /// 15 | /// Provide UI fragments for components to support child content with specified value. 16 | /// 17 | /// The type of value。 18 | public interface IHasChildContent 19 | { 20 | /// 21 | /// Gets or sets a fragment of UI content with type of value. 22 | /// 23 | RenderFragment? ChildContent { get; set; } 24 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasDisabled.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Defines a parameter that has disabled HTML attribute. 5 | /// 6 | public interface IHasDisabled 7 | { 8 | /// 9 | /// Set true to generate HTML 'disabled' attribute. 10 | /// 11 | [HtmlAttribute] bool Disabled { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasEditContext.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Provides a component with an edit context. 5 | /// 6 | public interface IHasEditContext 7 | { 8 | /// 9 | /// Gets or sets the editing context. 10 | /// 11 | EditContext? EditContext { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasEventCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Represents a parameter with a callback event. 5 | /// 6 | public interface IHasEventCallback : IBlazorComponent 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasInputValue.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | 3 | namespace ComponentBuilder.Definitions; 4 | /// 5 | /// A binding value that represents the interaction with the user. 6 | /// 7 | /// This interface simplifies the interaction of input components. 8 | /// 9 | /// 10 | /// The type of the bound value. 11 | public interface IHasInputValue : IHasValueBound 12 | { 13 | /// 14 | /// Gets the cascade parameter from Form. 15 | /// 16 | EditContext? CascadedEditContext { get; } 17 | 18 | /// 19 | /// Gets or sets an expression that identifies the bound value. 20 | /// 21 | Expression>? ValueExpression { get; set; } 22 | } 23 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasOnActive.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Provides a parameter that the component has a callback event that can be activated. 4 | /// 5 | public interface IHasOnActive : IHasActive, IHasEventCallback 6 | { 7 | /// 8 | /// A callback function that is executed when the component state is activated. 9 | /// 10 | EventCallback OnActive { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasOnDisabled.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Provides a component with deactivated events. 5 | /// 6 | public interface IHasOnDisabled : IHasDisabled, IHasEventCallback 7 | { 8 | /// 9 | /// A callback function when a component is disabled. 10 | /// 11 | EventCallback OnDisabled { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasOnSwitch.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Provides components with switchable events. 4 | /// 5 | public interface IHasOnSwitch : IHasSwitch, IHasEventCallback 6 | { 7 | /// 8 | /// Specifies the switchable callback method for the component index. 9 | /// 10 | EventCallback OnSwitch { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasSwitch.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | /// 3 | /// Indicates that you can switch between components. 4 | /// 5 | public interface IHasSwitch 6 | { 7 | /// 8 | /// Gets or sets the switching component index. 9 | /// 10 | int? SwitchIndex { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Definitions/Parameters/IHasValueBound.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Definitions; 2 | 3 | /// 4 | /// Provides bidirectional binding for components. 5 | /// 6 | /// The value type. 7 | public interface IHasValueBound:IBlazorComponent 8 | { 9 | /// 10 | /// Gets or sets the value to bind. 11 | /// 12 | /// 13 | /// @bind-Value="model.PropertyName" 14 | /// 15 | TValue? Value { get; set; } 16 | /// 17 | /// Gets or sets the callback method for updating the binding value. 18 | /// 19 | EventCallback ValueChanged { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Enumeration.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// An abstract class that represents an enumeration pattern. 5 | /// 6 | public abstract class Enumeration 7 | { 8 | /// 9 | /// Initializes a new instance of the class. 10 | /// 11 | /// The value. 12 | protected Enumeration(string value) => Value = value; 13 | 14 | /// 15 | /// Gets the value of the enumeration. 16 | /// 17 | public string Value { get; } 18 | 19 | /// 20 | /// Gets the enumeration member. 21 | /// 22 | /// An array of strings. 23 | public IEnumerable GetMembers() 24 | => GetType().GetFields(System.Reflection.BindingFlags.Static).Select(m => ((Enumeration?)m.GetValue(this))?.Value); 25 | } 26 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Extensions/ParseExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | /// 3 | /// The extensions to parse value. 4 | /// 5 | public static class ParseExtensions 6 | { 7 | /// 8 | /// Parse any value to specified value type. 9 | /// 10 | /// The type of value. 11 | /// The value to parse. 12 | /// Return default value if parse failed. 13 | /// true to throw exception when parsing failed. 14 | /// 15 | public static TValue? Parse(this object? value, TValue? defaultValue = default, bool throwIfFailed=default) 16 | { 17 | if (value is null) 18 | { 19 | return defaultValue; 20 | } 21 | 22 | var valueType = typeof(TValue); 23 | 24 | try 25 | { 26 | var nullableValueType = Nullable.GetUnderlyingType(valueType); 27 | if (nullableValueType is null) 28 | { 29 | return (TValue?)Convert.ChangeType(value, valueType); 30 | } 31 | 32 | return (TValue?)Convert.ChangeType(value, nullableValueType); 33 | } 34 | catch 35 | { 36 | if (throwIfFailed) 37 | { 38 | throw; 39 | } 40 | return defaultValue; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// The extensions of string. 5 | /// 6 | public static class StringExtensions 7 | { 8 | /// 9 | /// Indicates whether the specified string is not null or an empty string (""). 10 | /// 11 | /// The string to test. 12 | /// true if the value parameter is not null or an empty string (""); otherwise, false. 13 | public static bool IsNotNullOrEmpty(this string? value) => !string.IsNullOrEmpty(value); 14 | /// 15 | /// Indicates whether a specified string is not null, empty, or consists only of white-space characters. 16 | /// 17 | /// The string to test. 18 | /// true if the value parameter is not null or System.String.Empty, or if value consists exclusively of white-space characters. 19 | public static bool IsNotNullOrWhiteSpace(this string? value) => !string.IsNullOrWhiteSpace(value); 20 | } 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentClass/IFluentClassProvider.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentClass; 2 | /// 3 | /// A provider that provides smooth CSS classes from parameters. 4 | /// 5 | public interface IFluentClassProvider 6 | { 7 | /// 8 | /// Create a series of strings for the CSS class. 9 | /// 10 | /// A collection of strings representing a CSS class. 11 | IEnumerable Create(); 12 | } 13 | -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentCloseBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | /// 3 | /// Provides a constructor that closes the flag. 4 | /// 5 | public interface IFluentCloseBuilder : IDisposable 6 | { 7 | /// 8 | /// Mark a previously attached region, element, or component as closed. 9 | /// Call this method when must with previous Element(), Component() or Region() match. 10 | /// 11 | IFluentOpenBuilder Close(); 12 | } 13 | 14 | /// 15 | /// Provides a constructor to close component tags. 16 | /// 17 | /// Component type. 18 | public interface IFluentCloseBuilder : IFluentCloseBuilder, IDisposable where TComponent : IComponent 19 | { 20 | /// 21 | /// Mark a previously attached region, or component as closed. 22 | /// Call this method when must with previous Component() or Region() match. 23 | /// 24 | new IFluentOpenComponentBuilder Close(); 25 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentContentBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | 3 | /// 4 | /// A constructor that provides the content of an element. 5 | /// 6 | public interface IFluentContentBuilder :IFluentOpenBuilder, IFluentCloseBuilder 7 | { 8 | /// 9 | /// Add fragment content to this element or component. 10 | /// 11 | /// The content fragment to insert the inner element. 12 | IFluentContentBuilder Content(RenderFragment? fragment); 13 | } 14 | 15 | /// 16 | /// Provides a constructor that adds subcontent for the specified component type. 17 | /// 18 | /// Component type. 19 | public interface IFluentContentBuilder : IFluentContentBuilder,IFluentOpenComponentBuilder 20 | where TComponent : IComponent 21 | { 22 | /// 23 | /// Add an arbitrary code snippet to the component's ChildContent parameter. 24 | /// 25 | /// The content fragment to insert the inner element. 26 | IFluentAttributeBuilder ChildContent(RenderFragment? fragment); 27 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentFrameBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | 3 | /// 4 | /// Constructors that provide additional features of the render tree. 5 | /// 6 | public interface IFluentFrameBuilder: IFluentContentBuilder, IFluentCloseBuilder 7 | { 8 | /// 9 | /// Assigns the specified key value to the current element or component. 10 | /// 11 | /// The key value. 12 | IFluentAttributeBuilder Key(object? value); 13 | 14 | /// 15 | /// Captures a reference to an element or component. 16 | /// 17 | /// Actions that capture an element or component reference after rendering the component. 18 | IFluentAttributeBuilder Ref(Action captureReferenceAction); 19 | 20 | /// 21 | /// Adds a frame to indicate the rendering mode on the closed component frame. 22 | /// 23 | /// mode. 24 | IFluentAttributeBuilder RenderMode(IComponentRenderMode mode); 25 | } 26 | -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentOpenBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | /// 3 | /// Provides a constructor to create an element or component start tag. 4 | /// 5 | public interface IFluentOpenBuilder : IFluentOpenElementBuilder,IFluentOpenComponentBuilder,IFluentCloseBuilder 6 | { 7 | /// 8 | /// Add fragment content. 9 | /// 10 | /// The content fragment to insert the inner element. 11 | /// A sequence representing the location of the source code. 12 | IFluentOpenBuilder Content(RenderFragment? fragment, int? sequence = default); 13 | } 14 | -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentOpenComponentBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | 3 | /// 4 | /// Provides constructor functionality for creating components. 5 | /// 6 | public interface IFluentOpenComponentBuilder : IDisposable 7 | { 8 | /// 9 | /// Creates a component start tag that implements the interface component type. 10 | /// 11 | /// Component type to create. 12 | /// A sequence representing source code. 13 | IFluentAttributeBuilder Component(Type componentType, int? sequence = default); 14 | } 15 | 16 | /// 17 | /// Provides constructor functionality for creating components. 18 | /// 19 | /// Component type. 20 | public interface IFluentOpenComponentBuilder : IFluentOpenComponentBuilder 21 | where TComponent : IComponent 22 | { 23 | /// 24 | /// Creates a component start tag that implements the interface component type. 25 | /// 26 | /// A sequence representing source code. 27 | IFluentAttributeBuilder Component(int? sequence = default); 28 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentOpenElementBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | 3 | /// 4 | /// Provides constructors for creating HTML elements. 5 | /// 6 | public interface IFluentOpenElementBuilder : IDisposable 7 | { 8 | /// 9 | /// Creates the opening tag of an HTML element. 10 | /// 11 | /// The name of the HTML element. 12 | /// A sequence representing source code. 13 | IFluentAttributeBuilder Element(string name, int? sequence = default); 14 | } 15 | -------------------------------------------------------------------------------- /src/ComponentBuilder/FluentRenderTree/IFluentRegionBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.FluentRenderTree; 2 | 3 | /// 4 | /// Provides a constructor for creating a new scope. 5 | /// 6 | public interface IFluentRegionBuilder:IDisposable 7 | { 8 | /// 9 | /// Create a new scope. 10 | /// 11 | /// The starting range of a new source code location. 12 | IFluentOpenBuilder Region(int sequence); 13 | } -------------------------------------------------------------------------------- /src/ComponentBuilder/Interceptors/ChildContentInterceptor.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Definitions; 2 | 3 | namespace ComponentBuilder.Interceptors; 4 | 5 | /// 6 | /// Represents an interceptor to add ChildContent parameter into content of . 7 | /// 8 | internal class ChildContentInterceptor : ComponentInterceptorBase 9 | { 10 | /// 11 | public override void InterceptOnContentBuilding(IBlazorComponent component, RenderTreeBuilder builder, int sequence) 12 | { 13 | if ( component is IHasChildContent content ) 14 | { 15 | builder.AddContent(sequence, content.ChildContent); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Interceptors/ComponentInterceptorBase.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Interceptors; 2 | 3 | /// 4 | /// Provides an abstract base class for an empty implementation of the interface. 5 | /// 6 | public abstract class ComponentInterceptorBase : IComponentInterceptor 7 | { 8 | /// 9 | public virtual int Order => 1000; 10 | 11 | /// 12 | public virtual void InterceptOnAttributesBuilding(IBlazorComponent component, IDictionary attributes) 13 | { 14 | } 15 | 16 | /// 17 | public virtual void InterceptOnAfterRender(IBlazorComponent component, in bool firstRender) 18 | { 19 | } 20 | 21 | /// 22 | public virtual void InterceptOnInitialized(IBlazorComponent component) 23 | { 24 | } 25 | 26 | /// 27 | public virtual void InterceptOnParameterSet(IBlazorComponent component) 28 | { 29 | } 30 | 31 | /// 32 | public virtual void InterceptOnSetParameters(IBlazorComponent component, in ParameterView parameters) 33 | { 34 | } 35 | 36 | /// 37 | public virtual void InterceptOnDisposing(IBlazorComponent component) 38 | { 39 | } 40 | 41 | /// 42 | public virtual void InterceptOnContentBuilding(IBlazorComponent component, RenderTreeBuilder builder, int sequence) 43 | { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Interceptors/CssClassAttributeInterceptor.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Interceptors; 2 | 3 | /// 4 | /// Represents an interceptor to add class attribute. 5 | /// 6 | internal class CssClassAttributeInterceptor : ComponentInterceptorBase 7 | { 8 | /// 9 | public override void InterceptOnAttributesBuilding(IBlazorComponent component, IDictionary attributes) 10 | { 11 | if (component is not BlazorComponentBase blazorComponent) 12 | { 13 | return; 14 | } 15 | 16 | var value = blazorComponent.GetCssClassString(); 17 | 18 | var list = new List(); 19 | if (value.IsNotNullOrEmpty()) 20 | { 21 | list.Add(value!); 22 | } 23 | 24 | if (component is IHasAdditionalClass additionalCssClass && !string.IsNullOrWhiteSpace(additionalCssClass.AdditionalClass)) 25 | { 26 | list.Add(additionalCssClass.AdditionalClass); 27 | } 28 | 29 | var css = string.Join(" ", list); 30 | if (css.IsNotNullOrEmpty()) 31 | { 32 | attributes.AddOrUpdate(new("class", css), allowNullValue: false); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Interceptors/StyleAttributeInterceptor.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Interceptors; 2 | 3 | /// 4 | /// Represents an interceptor to add style attribute. 5 | /// 6 | internal class StyleAttributeInterceptor : ComponentInterceptorBase 7 | { 8 | /// 9 | public override void InterceptOnAttributesBuilding(IBlazorComponent component, IDictionary attributes) 10 | { 11 | if(component is not BlazorComponentBase blazorComponent) 12 | { 13 | return; 14 | } 15 | var style = blazorComponent.GetStyleString(); 16 | if ( style.IsNotNullOrEmpty() ) 17 | { 18 | attributes.AddOrUpdate(new("style", style!), allowNullValue: false); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ComponentBuilder/JSInterop/DomNode.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | 3 | namespace ComponentBuilder.JSInterop; 4 | 5 | /// 6 | /// DOM node. 7 | /// 8 | public abstract class Interop:IAsyncDisposable 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The global JS object. 14 | /// The customize module. 15 | /// The internal module. 16 | protected Interop(IJSRuntime globalJS, IJSObjectReference? customizeModule = default, IJSObjectReference? internalModule = default) 17 | { 18 | GlobalJS = globalJS; 19 | CustomizeModule = customizeModule; 20 | InternalModule = internalModule; 21 | } 22 | 23 | /// 24 | /// Gets the global JS object. 25 | /// 26 | protected IJSRuntime GlobalJS { get; } 27 | 28 | /// 29 | /// Get custom JS function modules. 30 | /// 31 | protected IJSObjectReference? CustomizeModule { get; } 32 | /// 33 | /// Get internal JS function modules. 34 | /// 35 | protected IJSObjectReference? InternalModule { get; } 36 | /// 37 | 38 | public virtual ValueTask DisposeAsync() => ValueTask.CompletedTask; 39 | } 40 | -------------------------------------------------------------------------------- /src/ComponentBuilder/JSInterop/JSModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | 3 | namespace ComponentBuilder.JSInterop; 4 | 5 | /// 6 | /// Represents the exported JS module object. 7 | /// 8 | public interface IJSModule 9 | { 10 | /// 11 | /// Gets instance. 12 | /// 13 | public Window Window { get; } 14 | /// 15 | /// Gets the exported module. 16 | /// 17 | public IJSObjectReference Module { get; } 18 | } 19 | 20 | internal class JSModule : IJSModule 21 | { 22 | internal JSModule(Window js, IJSObjectReference module) 23 | { 24 | Window = js; 25 | Module = module; 26 | } 27 | 28 | /// 29 | public Window Window { get; } 30 | /// 31 | public IJSObjectReference Module { get; } 32 | } 33 | -------------------------------------------------------------------------------- /src/ComponentBuilder/JSInterop/Singleton.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.JSInterop; 2 | 3 | internal static class Singleton where T : class 4 | { 5 | static object _locker = new(); 6 | static T? _instance; 7 | 8 | public static T? Create(params object?[]? args) 9 | { 10 | if (_instance == null) 11 | { 12 | lock (_locker) 13 | { 14 | if (_instance is null) 15 | { 16 | _instance = (T?)Activator.CreateInstance(typeof(T), args); 17 | } 18 | } 19 | } 20 | return _instance; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/ComponentBuilder/RenderModeEnhance.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder; 2 | 3 | /// 4 | /// The enhancement of render mode. 5 | /// 6 | public static class RenderModeEnhance 7 | { 8 | /// 9 | /// Gets an that represents rendering interactively on the server via Blazor Server hosting without server-side prerendering. 10 | /// 11 | public static IComponentRenderMode InteractiveServerWithoutPrerender => new InteractiveServerRenderMode(false); 12 | /// 13 | /// Gets an that represents rendering interactively on the client via Blazor WebAssembly hosting without server-side prerendering. 14 | /// 15 | public static IComponentRenderMode InteractiveWebAssemblyWithoutPrerender => new InteractiveWebAssemblyRenderMode(false); 16 | /// 17 | /// Gets an that means the render mode will be determined automatically based on a policy without server-side prerendering. 18 | /// 19 | public static IComponentRenderMode InteractiveAutoWithoutPrerender => new InteractiveAutoRenderMode(false); 20 | } 21 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Rendering/IComponentRenderer.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Rendering; 2 | 3 | /// 4 | /// Provides component rendering based on render tree. 5 | /// 6 | public interface IComponentRenderer 7 | { 8 | /// 9 | /// Use to render the component. 10 | /// 11 | /// The component to render. 12 | /// instance. 13 | /// Return true if you need to continue rendering the next component from the pipeline, otherwise return false. 14 | bool Render(IBlazorComponent component, RenderTreeBuilder builder); 15 | } 16 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Rendering/NavLinkComponentRender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.Routing; 2 | 3 | namespace ComponentBuilder.Rendering; 4 | /// 5 | /// Components that implement the interface are rendered as components. 6 | /// 7 | public class NavLinkComponentRender : IComponentRenderer 8 | { 9 | /// 10 | public bool Render(IBlazorComponent component, RenderTreeBuilder builder) 11 | { 12 | if ( component is IHasNavLinkComponent navLink ) 13 | { 14 | builder.OpenComponent(0); 15 | builder.AddAttribute(1, nameof(NavLink.Match), navLink.Match); 16 | builder.AddAttribute(2, nameof(NavLink.ActiveClass), navLink.ActiveCssClass); 17 | builder.AddAttribute(3, nameof(NavLink.ChildContent), navLink.ChildContent); 18 | builder.AddMultipleAttributes(4, component.GetAttributes()!); 19 | builder.CloseComponent(); 20 | return false; 21 | } 22 | return true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Resolvers/FluentCssClassResolver.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.FluentClass; 2 | 3 | namespace ComponentBuilder.Resolvers; 4 | 5 | /// 6 | /// A parser for which component parameters can parse . 7 | /// 8 | public class FluentCssClassResolver : IParameterClassResolver 9 | { 10 | /// 11 | public IEnumerable Resolve(IBlazorComponent component) 12 | { 13 | var componentType = component.GetType(); 14 | 15 | var list = new List(); 16 | 17 | foreach ( var parameter in componentType.GetProperties().Where(m => typeof(IFluentClassProvider).IsAssignableFrom(m.PropertyType)) ) 18 | { 19 | if ( parameter.GetValue(component) is IFluentClassProvider builder ) 20 | { 21 | list.AddRange(builder.Create().Where(x => !string.IsNullOrEmpty(x))); 22 | } 23 | } 24 | return list; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Resolvers/HtmlTagAttributeResolver.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace ComponentBuilder.Resolvers; 4 | 5 | /// 6 | /// Provides recognition of the attribute. 7 | /// 8 | public interface IHtmlTagAttributeResolver : IComponentResolver 9 | { 10 | 11 | } 12 | 13 | /// 14 | /// The parsing component tags the attribute and creates the corresponding HTML element name. 15 | /// 16 | class HtmlTagAttributeResolver : IHtmlTagAttributeResolver 17 | { 18 | /// 19 | public string Resolve(IBlazorComponent component) 20 | { 21 | if (component is null) 22 | { 23 | throw new ArgumentNullException(nameof(component)); 24 | } 25 | 26 | var type = component.GetType(); 27 | 28 | HtmlTagAttribute? attribute = type.GetCustomAttribute(); 29 | 30 | attribute??= type.GetInterfaces().SingleOrDefault(m => m.IsDefined(typeof(HtmlTagAttribute)))?.GetCustomAttribute(); 31 | 32 | return attribute?.Name ?? "div"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/ComponentBuilder/Resolvers/IComponentResolver.cs: -------------------------------------------------------------------------------- 1 | namespace ComponentBuilder.Abstrations; 2 | 3 | /// 4 | /// A component parser that returns results. 5 | /// 6 | /// The resolved result type. 7 | public interface IComponentResolver : IComponentResolver 8 | { 9 | /// 10 | /// Resove component. 11 | /// 12 | /// Component to resolve. 13 | /// is null。 14 | /// The resolved result. 15 | public TResult Resolve(IBlazorComponent component); 16 | } 17 | 18 | /// 19 | /// The component resolver. 20 | /// 21 | public interface IComponentResolver { } -------------------------------------------------------------------------------- /src/ComponentBuilder/Using.cs: -------------------------------------------------------------------------------- 1 | global using Microsoft.AspNetCore.Components; 2 | global using Microsoft.AspNetCore.Components.Web; 3 | global using Microsoft.AspNetCore.Components.Rendering; 4 | global using Microsoft.AspNetCore.Components.Forms; 5 | global using System; 6 | global using System.Collections.Generic; 7 | global using System.Threading.Tasks; 8 | global using ComponentBuilder.Abstrations; 9 | global using ComponentBuilder.Definitions; 10 | global using ComponentBuilder; -------------------------------------------------------------------------------- /templates/src/.template.config/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "author": "playermaker", 4 | "classifications": [ "Razor", "Component","Blazor","Solution" ], 5 | "identity": "BlazorLibrarySolution", 6 | "name": "Blazor Component Library Solution", 7 | "shortName": "blazor-sln", 8 | "tags": { 9 | "language": "C#", 10 | "type": "solution" 11 | }, 12 | "sourceName": "MyRazorLibrary", 13 | "defaultName": "BlazorComponentSolution", 14 | "description": "To create a solution for blazor component library including online demo site" 15 | } -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/MyRazorLibrary.Docs.ServerSideHost.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0;net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace MyRazorLibrary.Docs.ServerSideHost.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace MyRazorLibrary.Docs.ServerSideHost.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | MyRazorLibrary 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | @RenderBody() 19 | 20 |
21 | 22 | An error has occurred. This application may no longer respond until reloaded. 23 | 24 | 25 | An unhandled exception has occurred. See browser dev tools for details. 26 | 27 | Reload 28 | 🗙 29 |
30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | builder.Services.AddRazorPages(); 5 | builder.Services.AddServerSideBlazor(); 6 | 7 | builder.Services.AddMyRazorLibrary(); 8 | 9 | var app = builder.Build(); 10 | 11 | // Configure the HTTP request pipeline. 12 | if ( !app.Environment.IsDevelopment() ) 13 | { 14 | app.UseExceptionHandler("/Error"); 15 | } 16 | 17 | 18 | app.UseStaticFiles(); 19 | 20 | app.UseRouting(); 21 | 22 | app.MapBlazorHub(); 23 | app.MapFallbackToPage("/_Host"); 24 | 25 | app.Run(); 26 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:8066", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "ComponentLibrary.Docs.ServerSideHost": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "http://localhost:5272", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using MyRazorLibrary.Docs.ServerSideHost 10 | @using MyRazorLibrary.Docs.Shared -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.ServerSideHost/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.Shared/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | Not found 9 | 10 |

Sorry, there's nothing at this address.

11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.Shared/Layouts/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 4 | @Body -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.Shared/MyRazorLibrary.Docs.Shared.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0;net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.Shared/Pages/IndexPage.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | Index 3 |

Index

4 | 5 |
Hello MyRazorLibrary
-------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.Shared/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @using Microsoft.AspNetCore.Components.Routing 3 | @using Shared.Layouts -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.Shared/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teacher-zhou/ComponentBuilder/81bf547d1b030ae4612fc56d50f17f0f002f2fe5/templates/src/doc/MyRazorLibrary.Docs.Shared/wwwroot/favicon.ico -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.WebAssemblyHost/MyRazorLibrary.Docs.WebAssemblyHost.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0;net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.WebAssemblyHost/Program.cs: -------------------------------------------------------------------------------- 1 | using MyRazorLibrary.Docs.Shared; 2 | using Microsoft.AspNetCore.Components.Web; 3 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 4 | 5 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 6 | builder.RootComponents.Add("#app"); 7 | builder.RootComponents.Add("head::after"); 8 | 9 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 10 | 11 | builder.Services.AddMyRazorLibrary(); 12 | 13 | await builder.Build().RunAsync(); 14 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.WebAssemblyHost/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:30375", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "ComponentLibrary.Docs.WebAssemblyHost": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "http://localhost:5097", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.WebAssemblyHost/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using MyRazorLibrary.Docs.WebAssemblyHost 10 | -------------------------------------------------------------------------------- /templates/src/doc/MyRazorLibrary.Docs.WebAssemblyHost/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | MyRazorLibrary 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary.Test/Cases/DivTest.cs: -------------------------------------------------------------------------------- 1 | namespace MyRazorLibrary.Test.Cases; 2 | 3 | public class DivTest : TestBase
4 | { 5 | [Fact] 6 | public void Test_Render_Div() 7 | { 8 | GetComponent().Should().HaveTag("div"); 9 | } 10 | 11 | [Fact] 12 | public void Test_Render_With_Content() 13 | { 14 | GetComponent(m => m.AddChildContent("hello")).Should().HaveTag("div").And.HaveChildMarkup("hello"); 15 | } 16 | 17 | [Fact] 18 | public void Test_Has_AdditionalClass() 19 | { 20 | GetComponent(m => m.Add(p => p.AdditionalClass, "test-class")).Should().HaveClass("test-class"); 21 | } 22 | [Fact] 23 | public void Test_Has_AdditionalStyle() 24 | { 25 | GetComponent(m => m.Add(p => p.AdditionalStyle, "width:100px;font-size:2rem")).Should().HaveAttribute("style,","width:100px;font-size:2rem"); 26 | } 27 | } -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary.Test/MyRazorLibrary.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0;net7.0 5 | enable 6 | enable 7 | 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | all 19 | 20 | 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | all 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary.Test/TestBase.cs: -------------------------------------------------------------------------------- 1 | using Bunit; 2 | using Microsoft.AspNetCore.Components; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace MyRazorLibrary.Test; 6 | public class TestBase 7 | { 8 | private readonly ServiceProvider _provider; 9 | private readonly TestContext _testContext; 10 | 11 | public TestBase() 12 | { 13 | 14 | _testContext = new TestContext(); 15 | _testContext.Services.AddComponentBuilder(); 16 | _provider = _testContext.Services.BuildServiceProvider(); 17 | } 18 | 19 | protected TestContext TestContext => _testContext; 20 | 21 | protected TService? GetService() => _provider.GetService(); 22 | } 23 | 24 | public class TestBase : TestBase where TComponent : IComponent 25 | { 26 | protected IRenderedComponent GetComponent(Action> parameterBuilder) => TestContext.RenderComponent(parameterBuilder); 27 | 28 | protected IRenderedComponent GetComponent(params ComponentParameter[] parameters) => TestContext.RenderComponent(parameters); 29 | 30 | } -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary.Test/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; 2 | global using ComponentBuilder; 3 | global using FluentAssertions; 4 | global using FluentAssertions.BUnit; 5 | global using Bunit; 6 | using static Xunit.Assert; 7 | -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/Components/Div.cs: -------------------------------------------------------------------------------- 1 | namespace MyRazorLibrary; 2 | 3 | /// 4 | /// Represents a div HTML element. 5 | /// 6 | [HtmlTag("div")] 7 | public class Div : BlazorComponentBase, IHasChildContent, IHasAdditionalClass, IHasAdditionalStyle 8 | { 9 | /// 10 | [Parameter]public RenderFragment? ChildContent { get; set; } 11 | /// 12 | [Parameter]public string? AdditionalStyle { get; set; } 13 | /// 14 | [Parameter]public string? AdditionalClass { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/DependencyInjectionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Extensions.DependencyInjection; 2 | 3 | public static class DependencyInjectionExtensions 4 | { 5 | /// 6 | /// Change you name of extensions. 7 | /// 8 | /// 9 | /// 10 | public static IServiceCollection AddMyRazorLibrary(this IServiceCollection services) 11 | { 12 | return services.AddComponentBuilder(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/MyRazorLibrary.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0;net7.0 5 | enable 6 | enable 7 | 10 8 | 11 9 | 10 | 11 | 12 | enable 13 | enable 14 | 1024 15 | 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | DEBUG;TRACE 23 | 24 | 25 | 26 | 27 | false 28 | true 29 | TRACE 30 | true 31 | ..\..\pack 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/Using.cs: -------------------------------------------------------------------------------- 1 | global using ComponentBuilder; 2 | global using ComponentBuilder.Definitions; 3 | global using ComponentBuilder.Abstrations; 4 | global using ComponentBuilder.Fluent; 5 | global using ComponentBuilder.JSInterope; 6 | global using Microsoft.AspNetCore.Components; 7 | global using OneOf; -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using ComponentBuilder; 2 | @using ComponentBuilder.Definitions; 3 | @using ComponentBuilder.Abstrations; 4 | @using ComponentBuilder.Fluent; 5 | @using ComponentBuilder.JSInterope; 6 | @using Microsoft.AspNetCore.Components; 7 | @using OneOf; -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/wwwroot/MyRazorLibrary.css: -------------------------------------------------------------------------------- 1 | /* ****************************************** 2 | * import dist of the css from framework here 3 | ********************************************* 4 | 5 | @import 'app.css' 6 | 7 | */ 8 | 9 | .MyRazorLibrary{ 10 | font-size:24px; 11 | color:red; 12 | } -------------------------------------------------------------------------------- /templates/src/src/MyRazorLibrary/wwwroot/MyRazorLibrary.js: -------------------------------------------------------------------------------- 1 | /******************************* 2 | * Import js from framework 3 | ******************************** 4 | 5 | import * as {alias} from '{framework}' 6 | 7 | 8 | ************************************/ 9 | 10 | 11 | 12 | /***************************************************** 13 | * Write your own js as module and export them each 14 | ****************************************************** 15 | let example1 = { 16 | 17 | } 18 | 19 | let example2 = { 20 | 21 | } 22 | export default { example1, example2, ... } 23 | 24 | * */ -------------------------------------------------------------------------------- /templates/templatepack.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Template 5 | 0.2 6 | ComponentBuilder.Templates 7 | ComponentBuilder Solution Template 8 | A solution template provides to create blazor component library with online demo site 9 | playermaker 10 | dotnet-new;templates;ComponentBuilder;Blazor;Component 11 | 12 | net6.0;net7.0 13 | 14 | true 15 | false 16 | content 17 | $(NoWarn);NU5128 18 | true 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /templates/vs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teacher-zhou/ComponentBuilder/81bf547d1b030ae4612fc56d50f17f0f002f2fe5/templates/vs.jpg -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/BlazorComponentExtensionsTest.cs/2021-11-19_11_38_23_465.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder.Test 8 | { 9 | internal class BlazorComponentExtensionsTest 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/BlazorComponentExtensionsTest.cs/2021-11-19_11_41_04_433.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace ComponentBuilder.Test 10 | { 11 | public class BlazorComponentExtensionsTest 12 | { 13 | public BlazorComponentExtensionsTest() 14 | { 15 | 16 | } 17 | 18 | [Fact] 19 | public void TestEnumCssClassAttribute() 20 | { 21 | TestEnum.Class1.GetEnumCssClass().Should().Be("class1"); 22 | TestEnum.Class2.GetEnumCssClass().Should().Be("myclass"); 23 | } 24 | 25 | 26 | enum TestEnum 27 | { 28 | Class1, 29 | [CssClass("myclass")] Class2, 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/BlazorComponentExtensionsTest.cs/2021-11-19_13_38_49_849.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace ComponentBuilder.Test 10 | { 11 | public class BlazorComponentExtensionsTest 12 | { 13 | public BlazorComponentExtensionsTest() 14 | { 15 | 16 | } 17 | 18 | [Fact] 19 | public void TestEnumCssClassAttribute() 20 | { 21 | TestEnum.Class1.GetCssClass().Should().Be("class1"); 22 | TestEnum.Class2.GetCssClass().Should().Be("myclass"); 23 | } 24 | 25 | 26 | enum TestEnum 27 | { 28 | Class1, 29 | [CssClass("myclass")] Class2, 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/BlazorComponentExtensionsTest.cs/2021-11-19_13_43_03_185.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | 9 | namespace ComponentBuilder.Test 10 | { 11 | public class BlazorComponentExtensionsTest 12 | { 13 | public BlazorComponentExtensionsTest() 14 | { 15 | 16 | } 17 | 18 | [Fact] 19 | public void TestEnumCssClassAttribute() 20 | { 21 | TestEnum.Class1.GetCssClass().Should().Be("class1"); 22 | TestEnum.Class2.GetCssClass().Should().Be("myclass"); 23 | 24 | 25 | } 26 | 27 | enum TestEnum 28 | { 29 | Class1, 30 | [CssClass("myclass")] Class2, 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/BlazorComponentExtensionsTest.cs/2021-11-19_13_43_11_705.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Xunit; 3 | 4 | namespace ComponentBuilder.Test 5 | { 6 | public class BlazorComponentExtensionsTest 7 | { 8 | public BlazorComponentExtensionsTest() 9 | { 10 | 11 | } 12 | 13 | [Fact] 14 | public void TestEnumCssClassAttribute() 15 | { 16 | TestEnum.Class1.GetCssClass().Should().Be("class1"); 17 | TestEnum.Class2.GetCssClass().Should().Be("myclass"); 18 | 19 | 20 | } 21 | 22 | enum TestEnum 23 | { 24 | Class1, 25 | [CssClass("myclass")] Class2, 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/ComponentBuilder.Test.csproj/2021-11-18_16_21_21_439.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | all 15 | 16 | 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | all 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/ComponentBuilder.Test.csproj/2021-11-18_16_34_01_664.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | all 18 | 19 | 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | all 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/ComponentBuilderExtensionsTest.cs/2021-11-19_13_52_31_325.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Xunit; 3 | 4 | namespace ComponentBuilder.Test 5 | { 6 | public class BlazorComponentExtensionsTest : ComponentBuilderTestBase 7 | { 8 | public BlazorComponentExtensionsTest() 9 | { 10 | 11 | } 12 | 13 | [Fact] 14 | public void TestEnumCssClassAttribute() 15 | { 16 | TestEnum.Class1.GetCssClass().Should().Be("class1"); 17 | TestEnum.Class2.GetCssClass().Should().Be("myclass"); 18 | 19 | 20 | } 21 | 22 | enum TestEnum 23 | { 24 | Class1, 25 | [CssClass("myclass")] Class2, 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-18_16_21_21_505.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace ComponentBuilder.Test 5 | { 6 | public class UnitTest1 7 | { 8 | [Fact] 9 | public void Test1() 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-18_16_28_58_355.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using System; 3 | using Xunit; 4 | 5 | namespace ComponentBuilder.Test 6 | { 7 | public class CssClassBuilderTest 8 | { 9 | private readonly ICssClassBuilder 10 | public CssClassBuilderTest() 11 | { 12 | 13 | } 14 | [Fact] 15 | public void Test1() 16 | { 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-18_16_33_49_211.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test 7 | { 8 | public class CssClassBuilderTest 9 | { 10 | private readonly ICssClassBuilder _builder; 11 | public CssClassBuilderTest() 12 | { 13 | _builder = new DefaultCssClassBuilder(); 14 | } 15 | [Fact] 16 | public void TestAdd() 17 | { 18 | var result = _builder.Append("class1").Append("class2").Build(); 19 | result.Should().Be("class1 class2"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-18_16_57_10_071.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test 7 | { 8 | public class CssClassBuilderTest 9 | { 10 | private readonly ICssClassBuilder _builder; 11 | public CssClassBuilderTest() 12 | { 13 | _builder = new DefaultCssClassBuilder(); 14 | } 15 | 16 | [Fact] 17 | public void Given_Invoke_Append_When_Input_Null_Value_Then_Throw_ArgumentNullException() 18 | { 19 | Assert.Throws(() => _builder.Append(null)); 20 | } 21 | 22 | [Fact] 23 | public void TestAdd() 24 | { 25 | var result = _builder.Append("class1").Append("class2").Build(); 26 | result.Should().Be("class1 class2"); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-18_16_57_13_046.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test 7 | { 8 | public class CssClassBuilderTest 9 | { 10 | private readonly ICssClassBuilder _builder; 11 | public CssClassBuilderTest() 12 | { 13 | _builder = new DefaultCssClassBuilder(); 14 | } 15 | 16 | [Fact] 17 | public void Given_Invoke_Append_When_Input_Null_Value_Then_Throw_ArgumentNullException() 18 | { 19 | Assert.Throws(() => _builder.Append(null)); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-19_10_47_36_905.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test 7 | { 8 | public class CssClassBuilderTest 9 | { 10 | private readonly ICssClassBuilder _builder; 11 | public CssClassBuilderTest() 12 | { 13 | _builder = new DefaultCssClassBuilder(); 14 | } 15 | 16 | [Fact] 17 | public void Given_Invoke_Append_When_Input_Null_Value_Then_Throw_ArgumentNullException() 18 | { 19 | Assert.Throws(() => _builder.Append(null)); 20 | } 21 | 22 | [Fact] 23 | public void Given_Invoke_Append_When_Input_Value_Twice_Then_After_Build_Get_The_Result_Separated_For_Each_Item() 24 | { 25 | _builder.Append("first").Append("second").Build() 26 | .Should().Be("first secton"); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassBuilderTest.cs/2021-11-19_10_47_48_902.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test 7 | { 8 | public class CssClassBuilderTest 9 | { 10 | private readonly ICssClassBuilder _builder; 11 | public CssClassBuilderTest() 12 | { 13 | _builder = new DefaultCssClassBuilder(); 14 | } 15 | 16 | [Fact] 17 | public void Given_Invoke_Append_When_Input_Null_Value_Then_Throw_ArgumentNullException() 18 | { 19 | Assert.Throws(() => _builder.Append(null)); 20 | } 21 | 22 | [Fact] 23 | public void Given_Invoke_Append_When_Input_Value_Twice_Then_After_Build_Get_The_Result_Separated_For_Each_Item() 24 | { 25 | _builder.Append("first").Append("second").Build() 26 | .Should().Be("first second"); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_13_53_43_046.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder.Test 8 | { 9 | internal class CssClassResolverTest 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_13_54_30_580.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ComponentBuilder.Test 9 | { 10 | public class CssClassResolverTest : ComponentBuilderTestBase 11 | { 12 | private readonly ICssClassResolver _resolver; 13 | public CssClassResolverTest() 14 | { 15 | _resolver = GetService(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_13_58_20_463.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace ComponentBuilder.Test 11 | { 12 | public class CssClassResolverTest : ComponentBuilderTestBase 13 | { 14 | private readonly ICssClassResolver _resolver; 15 | public CssClassResolverTest() 16 | { 17 | _resolver = GetService(); 18 | } 19 | 20 | [Fact] 21 | public void When_Component_For_Parameter_Mark_CssClass_When_Input_A_String_Then_Combile_Two_Of_Them() 22 | { 23 | var testComponent = new TestComponent(); 24 | testComponent.Name = "abc"; 25 | 26 | var result = _resolver.Resolve(testComponent.GetType()); 27 | result.Should().Be("cssabc"); 28 | } 29 | } 30 | 31 | class TestComponent : BlazorComponentBase 32 | { 33 | [CssClass("css")] public string Name { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_14_03_22_868.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace ComponentBuilder.Test 11 | { 12 | public class CssClassResolverTest : ComponentBuilderTestBase 13 | { 14 | private readonly ICssClassResolver _resolver; 15 | public CssClassResolverTest() 16 | { 17 | _resolver = GetService(); 18 | } 19 | 20 | [Fact] 21 | public void Given_Invoke_Resolve_Method_When_Input_Null_Value_Then_Throw_ArgumentNullException() 22 | { 23 | Assert.Throws(() => _resolver.Resolve(null)); 24 | } 25 | 26 | [Fact] 27 | public void Given_Component_For_Parameter_Mark_CssClass_When_Input_A_String_Then_Combile_Two_Of_Them() 28 | { 29 | var testComponent = new TestComponent(); 30 | testComponent.Name = "abc"; 31 | 32 | var result = _resolver.Resolve(testComponent.GetType()); 33 | result.Should().Be("cssabc"); 34 | } 35 | } 36 | 37 | class TestComponent : BlazorComponentBase 38 | { 39 | [CssClass("css")] public string Name { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_14_03_48_313.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace ComponentBuilder.Test 11 | { 12 | public class CssClassResolverTest : ComponentBuilderTestBase 13 | { 14 | private readonly ICssClassResolver _resolver; 15 | public CssClassResolverTest() 16 | { 17 | _resolver = GetService(); 18 | } 19 | 20 | [Fact] 21 | public void Given_Invoke_Resolve_Method_When_Input_Null_Value_Then_Throw_ArgumentNullException() 22 | { 23 | Assert.Throws(() => _resolver.Resolve(null)); 24 | } 25 | 26 | [Fact] 27 | public void Given_Component_For_Parameter_Mark_CssClass_When_Input_A_String_Then_Combile_Two_Of_Them() 28 | { 29 | var testComponent = new TestComponent(); 30 | testComponent.Name = "abc"; 31 | 32 | var result = _resolver.Resolve(testComponent); 33 | result.Should().Be("cssabc"); 34 | } 35 | } 36 | 37 | class TestComponent : BlazorComponentBase 38 | { 39 | [CssClass("css")] public string Name { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_14_04_59_185.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace ComponentBuilder.Test 11 | { 12 | public class CssClassResolverTest : ComponentBuilderTestBase 13 | { 14 | private readonly ICssClassResolver _resolver; 15 | public CssClassResolverTest() 16 | { 17 | _resolver = GetService(); 18 | } 19 | 20 | [Fact] 21 | public void Given_Invoke_Resolve_Method_When_Input_Null_Value_Then_Throw_ArgumentNullException() 22 | { 23 | Assert.Throws(() => _resolver.Resolve(null)); 24 | } 25 | 26 | [Fact] 27 | public void Given_Component_For_Parameter_Mark_CssClass_When_Input_A_String_Then_Combile_Two_Of_Them() 28 | { 29 | var testComponent = new ComponentWithStringParameter(); 30 | testComponent.Name = "abc"; 31 | 32 | var result = _resolver.Resolve(testComponent); 33 | result.Should().Be("cssabc"); 34 | } 35 | } 36 | 37 | class ComponentWithStringParameter : BlazorComponentBase 38 | { 39 | [CssClass("css")] public string Name { get; set; } 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/.vshistory/CssClassResolverTest.cs/2021-11-19_14_05_04_237.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Abstrations; 2 | using FluentAssertions; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Xunit; 9 | 10 | namespace ComponentBuilder.Test 11 | { 12 | public class CssClassResolverTest : ComponentBuilderTestBase 13 | { 14 | private readonly ICssClassResolver _resolver; 15 | public CssClassResolverTest() 16 | { 17 | _resolver = GetService(); 18 | } 19 | 20 | [Fact] 21 | public void Given_Invoke_Resolve_Method_When_Input_Null_Value_Then_Throw_ArgumentNullException() 22 | { 23 | Assert.Throws(() => _resolver.Resolve(null)); 24 | } 25 | 26 | [Fact] 27 | public void Given_Component_For_Parameter_Mark_CssClass_When_Input_A_String_Then_Combile_Two_Of_Them() 28 | { 29 | var com = new ComponentWithStringParameter(); 30 | com.Name = "abc"; 31 | 32 | var result = _resolver.Resolve(com); 33 | result.Should().Be("cssabc"); 34 | } 35 | } 36 | 37 | class ComponentWithStringParameter : BlazorComponentBase 38 | { 39 | [CssClass("css")] public string Name { get; set; } 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/AutoTestBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace ComponentBuilder.Test; 4 | public abstract class AutoTestBase: TestBase 5 | { 6 | private readonly ServiceProvider _builder; 7 | 8 | protected AutoTestBase():base() 9 | { 10 | var services = new ServiceCollection(); 11 | 12 | services.AddComponentBuilder(); 13 | _builder = services.BuildServiceProvider(); 14 | 15 | TestContext.Services.AddComponentBuilder(); 16 | //_builder = TestContext.Services.BuildServiceProvider(); 17 | } 18 | 19 | protected T GetService() => _builder.GetService(); 20 | } 21 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/ComponentBuilder - Backup.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0;net7.0 5 | 10 6 | false 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | all 21 | 22 | 23 | runtime; build; native; contentfiles; analyzers; buildtransitive 24 | all 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/ComponentBuilder.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | false 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | all 24 | 25 | 26 | runtime; build; native; contentfiles; analyzers; buildtransitive 27 | all 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/ComponentEventCallbackTest.cs: -------------------------------------------------------------------------------- 1 | using ComponentBuilder.Definitions; 2 | 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.AspNetCore.Components.Web; 5 | 6 | namespace ComponentBuilder.Test; 7 | public class ComponentEventCallbackTest : AutoTestBase 8 | { 9 | [Fact] 10 | public void Invoke_Onclick_Event_When_OnClick_HasCallback_Then_OnClick_Invoke() 11 | { 12 | var clicked = false; 13 | GetComponent(m => m.Add(p => p.OnClick, HtmlHelper.Callback.Create(this, () => clicked = true))) 14 | .Find("div").Click() 15 | ; 16 | Assert.True(clicked); 17 | } 18 | } 19 | 20 | class ComponentEventCallback : BlazorComponentBase, IHasTest 21 | { 22 | [Parameter][HtmlAttribute("onclick")] public EventCallback OnClick { get; set; } 23 | [HtmlAttribute("ondbclick")] public EventCallback OnTest { get; set; } 24 | } 25 | 26 | interface IHasTest 27 | { 28 | [HtmlAttribute("ontest")] EventCallback OnTest { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/Components/.vshistory/Button.cs/2021-11-19_15_06_40_068.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder.Test.Components 8 | { 9 | internal class Button 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/Components/.vshistory/Button.cs/2021-11-19_15_07_12_369.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder.Test.Components 8 | { 9 | public class Button : BlazorComponentBase 10 | { 11 | } 12 | 13 | public class ComponentTest : ComponentBuilderTestBase 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/Components/.vshistory/Button.cs/2021-11-19_15_07_29_823.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ComponentBuilder.Test.Components 8 | { 9 | [HtmlElement("button")] 10 | public class Button : BlazorComponentBase 11 | { 12 | } 13 | 14 | public class ComponentTest : ComponentBuilderTestBase 15 | { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/Components/.vshistory/Button.cs/2021-11-19_15_18_24_954.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Bunit; 7 | using FluentAssertions.BUnit; 8 | using Xunit; 9 | 10 | namespace ComponentBuilder.Test.Components 11 | { 12 | [ElementTag("button")] 13 | public class Button : BlazorComponentBase 14 | { 15 | } 16 | 17 | public class ComponentTest : ComponentBuilderTestBase 18 | { 19 | TestContext context = new(); 20 | public ComponentTest() 21 | { 22 | 23 | } 24 | 25 | [Fact] 26 | public void TestButtonElement() 27 | { 28 | context.RenderComponent"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/Components/.vshistory/Button.cs/2021-11-19_16_06_17_445.cs: -------------------------------------------------------------------------------- 1 | using Bunit; 2 | using FluentAssertions.BUnit; 3 | using Microsoft.AspNetCore.Components; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test.Components 7 | { 8 | [ElementTag("button")] 9 | public class Button : BlazorComponentBase 10 | { 11 | 12 | [Parameter] [CssClass("block")] public bool Block { get; set; } 13 | 14 | } 15 | 16 | public class ComponentTest 17 | { 18 | TestContext context = new(); 19 | public ComponentTest() 20 | { 21 | context.Services.AddComponentBuilder(); 22 | } 23 | 24 | [Fact] 25 | public void TestCreateButtonComponent() 26 | { 27 | context.RenderComponent"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/ComponentBuilder.Test/Components/.vshistory/Button.cs/2021-11-19_16_10_18_452.cs: -------------------------------------------------------------------------------- 1 | using Bunit; 2 | using FluentAssertions.BUnit; 3 | using Microsoft.AspNetCore.Components; 4 | using Xunit; 5 | 6 | namespace ComponentBuilder.Test.Components 7 | { 8 | [ElementTag("button")] 9 | public class Button : BlazorComponentBase 10 | { 11 | 12 | [Parameter] [CssClass("block")] public bool Block { get; set; } 13 | 14 | } 15 | 16 | public class ComponentTest 17 | { 18 | TestContext context = new(); 19 | public ComponentTest() 20 | { 21 | context.Services.AddComponentBuilder(); 22 | } 23 | 24 | [Fact] 25 | public void TestCreateButtonComponent() 26 | { 27 | context.RenderComponent