实例介绍
Lara Web Engine
Lara Web Engine是一个专注于Web用户界面开发的轻量级C#服务器端渲染框架。与服务器端Blazor相比,Lara更加轻量级,安装更加简单。例如,任何类型的Blazor都需要一个完整的SDK,而Lara只是一个NuGet包。
示例应用程序:
using Integrative.Lara; using System; using System.Threading.Tasks; namespace SampleApp { public static class Program { public static async Task Main() { const int port = 8182; using var app = new Application(); app.PublishPage("/", () => new MyCounterComponent { Value = 5 }); await app.Start(new StartServerOptions { Port = port }); var address = $"http://localhost:{port}"; Console.WriteLine($"Listening on {address}/"); await app.WaitForShutdown(); } } internal class MyCounterComponent : WebComponent { private int _value; public int Value { get => _value; set => SetProperty(ref _value, value); } public MyCounterComponent() { ShadowRoot.Children = new Node[] { new HtmlDivElement() .Bind(this, x => x.InnerText = Value.ToString()), new HtmlButtonElement { InnerText = "Increase" } .Event("click", () => Value ) }; } } }
Lara不仅可以用于构建Web应用程序,还可以通过集成到现有的ASP.NET Core服务器或创建桌面容器应用程序来扩展其用途。为了使用Lara,您不需要下载任何仓库,只需要添加NuGet包即可开始。Lara工作原理是,在浏览器触发注册事件(例如,点击按钮)时,它会向服务器发送消息,服务器执行与事件关联的代码,操作服务器上的页面副本,并以JSON消息回复客户端与服务器之间的差异。
【实例截图】
【核心代码】
文件清单
└── lara-67fb43a3e0d1b5f7964e46b9552ad909dcf9de7a
├── Assets
│ └── Integrative.png
├── LICENSE
├── README.md
├── src
│ ├── Boilerplate
│ │ ├── Program.cs
│ │ ├── Wiki
│ │ │ ├── ComponentPropertyExample.cs
│ │ │ ├── ComposingComponent.cs
│ │ │ ├── ConditionalRenderComponent.cs
│ │ │ ├── DocumentContextExample.cs
│ │ │ ├── HttpContextExample.cs
│ │ │ ├── LoopComponent.cs
│ │ │ ├── RedBoxExample.cs
│ │ │ ├── SimpleComponent.cs
│ │ │ ├── UserInputComponent.cs
│ │ │ └── UserTextComponent.cs
│ │ └── WikiExamples.csproj
│ ├── LaraClient
│ │ ├── dist
│ │ │ └── lara-client.js.LICENSE.txt
│ │ ├── LaraClient.njsproj
│ │ ├── package.json
│ │ ├── package-lock.json
│ │ ├── README.md
│ │ ├── src
│ │ │ ├── Autocomplete.ts
│ │ │ ├── Blocker.ts
│ │ │ ├── blockUI.js
│ │ │ ├── ContentInterfaces.ts
│ │ │ ├── custom.d.ts
│ │ │ ├── DeltaInterfaces.ts
│ │ │ ├── index.ts
│ │ │ ├── Initializer.ts
│ │ │ ├── InputCollector.ts
│ │ │ ├── RegisteredEvents.ts
│ │ │ ├── Sequencer.ts
│ │ │ ├── SocketEvents.ts
│ │ │ └── Worker.ts
│ │ ├── tsconfig.json
│ │ └── webpack.config.js
│ ├── LaraClient.sln
│ ├── LaraDocumentation
│ │ ├── Content
│ │ │ └── Welcome.aml
│ │ ├── ContentLayout.content
│ │ ├── icons
│ │ │ └── Help.png
│ │ └── LaraDocumentation.shfbproj
│ ├── LaraUI
│ │ ├── Assets
│ │ │ └── Error.svg
│ │ ├── Autocomplete
│ │ │ ├── AutocompleteElement.cs
│ │ │ ├── AutocompleteEntry.cs
│ │ │ ├── AutocompleteOptions.cs
│ │ │ ├── AutocompletePayload.cs
│ │ │ ├── AutocompleteRegistry.cs
│ │ │ ├── AutocompleteResponse.cs
│ │ │ ├── AutocompleteService.cs
│ │ │ └── IAutocompleteProvider.cs
│ │ ├── Components
│ │ │ ├── ComponentRegistry.cs
│ │ │ ├── Fragment.cs
│ │ │ ├── LaraWebComponent.cs
│ │ │ ├── RenderIf.cs
│ │ │ ├── Shadow.cs
│ │ │ ├── Slot.cs
│ │ │ ├── SlottedCalculator.cs
│ │ │ ├── WebComponent.cs
│ │ │ └── WebComponentOptions.cs
│ │ ├── Delta
│ │ │ ├── AttributeEditedDelta.cs
│ │ │ ├── AttributeRemovedDelta.cs
│ │ │ ├── BaseDelta.cs
│ │ │ ├── ClearChildrenDelta.cs
│ │ │ ├── ContentArrayNode.cs
│ │ │ ├── ContentAttribute.cs
│ │ │ ├── ContentElementNode.cs
│ │ │ ├── ContentNode.cs
│ │ │ ├── ContentPlaceholder.cs
│ │ │ ├── ContentTextNode.cs
│ │ │ ├── ElementValue.cs
│ │ │ ├── EventResult.cs
│ │ │ ├── FocusDelta.cs
│ │ │ ├── NodeAddedDelta.cs
│ │ │ ├── NodeInsertedDelta.cs
│ │ │ ├── NodeLocator.cs
│ │ │ ├── NodeRemovedDelta.cs
│ │ │ ├── PlugOptions.cs
│ │ │ ├── RemoveElementDelta.cs
│ │ │ ├── RenderDelta.cs
│ │ │ ├── ReplaceDelta.cs
│ │ │ ├── ServerEventsDelta.cs
│ │ │ ├── SetCheckedDelta.cs
│ │ │ ├── SetIdDelta.cs
│ │ │ ├── SetValueDelta.cs
│ │ │ ├── SubmitJsDelta.cs
│ │ │ ├── SubscribeDelta.cs
│ │ │ ├── SwapChildrenDelta.cs
│ │ │ ├── TextModifiedDelta.cs
│ │ │ ├── UnRenderDelta.cs
│ │ │ └── UnsubscribeDelta.cs
│ │ ├── docfx.json
│ │ ├── DOM
│ │ │ ├── Attributes.cs
│ │ │ ├── BlockOptions.cs
│ │ │ ├── ChildrenBindingSubscription.cs
│ │ │ ├── Document.cs
│ │ │ ├── DocumentIdMap.cs
│ │ │ ├── DocumentWriter.cs
│ │ │ ├── DomSurgeon.cs
│ │ │ ├── DuplicateElementIdException.cs
│ │ │ ├── Element.cs
│ │ │ ├── ElementFactory.cs
│ │ │ ├── EventSettings.cs
│ │ │ ├── GlobalSerializer.cs
│ │ │ ├── HtmlReference.cs
│ │ │ ├── MessageRegistry.cs
│ │ │ ├── Node.cs
│ │ │ ├── NodeExtensions.cs
│ │ │ └── TextNode.cs
│ │ ├── Elements
│ │ │ ├── GenericElement.cs
│ │ │ ├── HtmlAnchorElement.cs
│ │ │ ├── HtmlBodyElement.cs
│ │ │ ├── HtmlButtonElement.cs
│ │ │ ├── HtmlColGroupElement.cs
│ │ │ ├── HtmlDivElement.cs
│ │ │ ├── HtmlHeadElement.cs
│ │ │ ├── HtmlHeadingElement.cs
│ │ │ ├── HtmlImageElement.cs
│ │ │ ├── HtmlInputElement.cs
│ │ │ ├── HtmlLabelElement.cs
│ │ │ ├── HtmlLiElement.cs
│ │ │ ├── HtmlLinkElement.cs
│ │ │ ├── HtmlMetaElement.cs
│ │ │ ├── HtmlMeterElement.cs
│ │ │ ├── HtmlOlElement.cs
│ │ │ ├── HtmlOptionElement.cs
│ │ │ ├── HtmlOptionGroupElement.cs
│ │ │ ├── HtmlParagraphElement.cs
│ │ │ ├── HtmlScriptElement.cs
│ │ │ ├── HtmlSelectElement.cs
│ │ │ ├── HtmlSpanElement.cs
│ │ │ ├── HtmlTableCellElement.cs
│ │ │ ├── HtmlTableElement.cs
│ │ │ ├── HtmlTableHeaderElement.cs
│ │ │ ├── HtmlTableRowElement.cs
│ │ │ ├── HtmlTableSectionElement.cs
│ │ │ ├── HtmlTextAreaElement.cs
│ │ │ └── HtmlTitleElement.cs
│ │ ├── GlobalSuppressions.cs
│ │ ├── Integrative.Lara.xml
│ │ ├── LaraUI.csproj
│ │ ├── LaraUI.csproj.DotSettings
│ │ ├── Main
│ │ │ ├── Application.cs
│ │ │ ├── BaseContext.cs
│ │ │ ├── BinaryServiceContent.cs
│ │ │ ├── BinaryServicePublished.cs
│ │ │ ├── Connection.cs
│ │ │ ├── Connections.cs
│ │ │ ├── GlobalConstants.cs
│ │ │ ├── IBinaryService.cs
│ │ │ ├── INavigation.cs
│ │ │ ├── IPageContext.cs
│ │ │ ├── IPage.cs
│ │ │ ├── IPublishedItem.cs
│ │ │ ├── IWebServiceContext.cs
│ │ │ ├── IWebService.cs
│ │ │ ├── JSBridge.cs
│ │ │ ├── LaraBinaryServiceAttribute.cs
│ │ │ ├── LaraPageAttribute.cs
│ │ │ ├── LaraUI.cs
│ │ │ ├── LaraWebServiceAttribute.cs
│ │ │ ├── Navigation.cs
│ │ │ ├── PageContext.cs
│ │ │ ├── PagePublished.cs
│ │ │ ├── Published.cs
│ │ │ ├── Session.cs
│ │ │ ├── SessionStorage.cs
│ │ │ ├── SingleElementPage.cs
│ │ │ ├── StaleConnectionsCollector.cs
│ │ │ ├── StaticContent.cs
│ │ │ ├── TemplateBuilder.cs
│ │ │ ├── WebServiceContent.cs
│ │ │ ├── WebServiceContext.cs
│ │ │ └── WebServicePublished.cs
│ │ ├── Middleware
│ │ │ ├── BaseHandler.cs
│ │ │ ├── BrowserAppController.cs
│ │ │ ├── ClientEventMessage.cs
│ │ │ ├── ClientLibraryHandler.cs
│ │ │ ├── ContentTypes.cs
│ │ │ ├── DefaultErrorPage.cs
│ │ │ ├── DiscardHandler.cs
│ │ │ ├── DiscardParameters.cs
│ │ │ ├── ErrorPages.cs
│ │ │ ├── EventParameters.cs
│ │ │ ├── FormFileCollection.cs
│ │ │ ├── FormFile.cs
│ │ │ ├── IModeController.cs
│ │ │ ├── KeepAliveHandler.cs
│ │ │ ├── LaraMiddleware.cs
│ │ │ ├── LocalhostFilter.cs
│ │ │ ├── MiddlewareCommon.cs
│ │ │ ├── NotFoundMiddleware.cs
│ │ │ ├── PostEventContext.cs
│ │ │ ├── PostEventHandler.cs
│ │ │ ├── PublishedItemHandler.cs
│ │ │ ├── Sequencer.cs
│ │ │ ├── ServerEvent.cs
│ │ │ ├── ServerEventsController.cs
│ │ │ ├── StatusCodeException.cs
│ │ │ └── StatusForbiddenException.cs
│ │ ├── NewVersionChecklist.txt
│ │ ├── pack.bat
│ │ ├── Reactive
│ │ │ ├── BindableBase.cs
│ │ │ ├── BindingExtensions.cs
│ │ │ ├── BindingOptions.cs
│ │ │ ├── BindingSubscription.cs
│ │ │ ├── CollectionUpdater.cs
│ │ │ └── ObsoleteElement.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ └── Tools
│ │ ├── ApplicationBuilderLaraExtensions.cs
│ │ ├── AssembliesReader.cs
│ │ ├── AsyncEvent.cs
│ │ ├── ClassEditor.cs
│ │ ├── DocumentLocal.cs
│ │ ├── LaraBuilder.cs
│ │ ├── LaraJson.cs
│ │ ├── LaraOptions.cs
│ │ ├── LaraTools.cs
│ │ ├── NoCurrentSessionException.cs
│ │ ├── SemaphoreSlimExtensions.cs
│ │ ├── ServerLauncher.cs
│ │ └── SessionLocal.cs
│ ├── LaraUI.sln
│ ├── LaraUI.sln.licenseheader
│ ├── SampleProject
│ │ ├── Assets
│ │ │ └── Coffee.svg
│ │ ├── Common
│ │ │ ├── CountryList.cs
│ │ │ ├── CountrySelector.cs
│ │ │ ├── SampleAppBootstrap.cs
│ │ │ └── Tools.cs
│ │ ├── Components
│ │ │ ├── CheckboxSample.cs
│ │ │ ├── CounterSample.cs
│ │ │ ├── KitchenSinkComponent.cs
│ │ │ ├── LockingSample.cs
│ │ │ ├── LongRunningSample.cs
│ │ │ ├── MultiselectSample.cs
│ │ │ ├── SelectSample.cs
│ │ │ ├── UploadSample.cs
│ │ │ └── WeekdayCombo.cs
│ │ ├── LaraSample.csproj
│ │ ├── Main
│ │ │ └── Program.cs
│ │ ├── Pages
│ │ │ ├── KitchenSinkPage.cs
│ │ │ ├── ServerEventsPage.cs
│ │ │ └── UploadFilePage.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ └── SampleProject.csproj
│ └── Tests
│ ├── Assets
│ │ ├── Compressible.bmp
│ │ └── pexels-photo-248673.jpeg
│ ├── Components
│ │ ├── AutocompleteTesting.cs
│ │ └── ComponentTesting.cs
│ ├── Delta
│ │ ├── AttributeEditTesting.cs
│ │ ├── DeltaTesting.cs
│ │ └── LocatorTesting.cs
│ ├── DOM
│ │ ├── AttributesTesting.cs
│ │ ├── BindingsTesting.cs
│ │ ├── BuilderTesting.cs
│ │ ├── ClassEditorTesting.cs
│ │ ├── DomOperationsTesting.cs
│ │ ├── ElementAttributes.cs
│ │ ├── EventsTesting.cs
│ │ ├── GlobalAttributesTesting.cs
│ │ └── LaraBuilderTesting.cs
│ ├── Main
│ │ ├── ButtonCounterPage.cs
│ │ ├── ConnectionsTesting.cs
│ │ ├── ConnectionTesting.cs
│ │ ├── MyPage.cs
│ │ ├── PublishedTesting.cs
│ │ ├── StaleTesting.cs
│ │ └── StaticContentTesting.cs
│ ├── Middleware
│ │ ├── DummyContext.cs
│ │ ├── DummyContextTesting.cs
│ │ ├── ErrorPagesTesting.cs
│ │ ├── EventParametersTesting.cs
│ │ ├── MiddlewareTesting.cs
│ │ ├── ServerEventsTesting.cs
│ │ ├── ToolsTesting.cs
│ │ └── WebServicesTesting.cs
│ └── Tests.csproj
└── support
└── jetbrains.svg
37 directories, 277 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论