-
Notifications
You must be signed in to change notification settings - Fork 55
Serialize Linq example files upload #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rorychatt
merged 1 commit into
Ivy-Interactive:main
from
EDeLeon9:Ivy-Example-for-NuGet-Serialize.Linq
Oct 7, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| **/.dockerignore | ||
| **/.env | ||
| **/.git | ||
| **/.gitignore | ||
| **/.project | ||
| **/.settings | ||
| **/.toolstarget | ||
| **/.vs | ||
| **/.vscode | ||
| **/.idea | ||
| **/*.*proj.user | ||
| **/*.dbmdl | ||
| **/*.jfm | ||
| **/azds.yaml | ||
| **/bin | ||
| **/charts | ||
| **/docker-compose* | ||
| **/Dockerfile* | ||
| **/node_modules | ||
| **/npm-debug.log | ||
| **/obj | ||
| **/secrets.dev.yaml | ||
| **/values.dev.yaml | ||
| LICENSE | ||
| README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| bin/ | ||
| obj/ | ||
| *.sln.iml | ||
| .idea/**/* | ||
| **/.idea/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //namespace SerializeLinq.Apps; | ||
|
|
||
| //[App(icon:Icons.PartyPopper, title:"Hello")] | ||
| //public class HelloApp : ViewBase | ||
| //{ | ||
| // public override object? Build() | ||
| // { | ||
| // var nameState = this.UseState<string>(); | ||
|
|
||
| // return Layout.Center() | ||
| // | (new Card( | ||
| // Layout.Vertical().Gap(6).Padding(2) | ||
| // | new Confetti(new IvyLogo()) | ||
| // | Text.H2("Hello " + (string.IsNullOrEmpty(nameState.Value) ? "there" : nameState.Value) + "!") | ||
| // | Text.Block("Welcome to the fantastic world of Ivy. Let's build something amazing together!") | ||
| // | nameState.ToInput(placeholder: "What is your name?") | ||
| // | new Separator() | ||
| // | Text.Markdown("You'd be a hero to us if you could ⭐ us on [Github](https://github.com/Ivy-Interactive/Ivy-Framework)") | ||
| // ) | ||
| // .Width(Size.Units(120).Max(500))); | ||
| // } | ||
| //} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||||||||||||||||
| using Serialize.Linq.Serializers; | ||||||||||||||||||||
| using System.Linq.Expressions; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| namespace SerializeLinq.Apps; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| [App(icon: Icons.Pencil, title: "Serialize Linq")] | ||||||||||||||||||||
| public class SerializeLinqApp : ViewBase | ||||||||||||||||||||
| { | ||||||||||||||||||||
| public override object? Build() | ||||||||||||||||||||
| { | ||||||||||||||||||||
| //Input states | ||||||||||||||||||||
| var value1State = this.UseState<int>(); | ||||||||||||||||||||
| var value2State = this.UseState<int>(); | ||||||||||||||||||||
| var operatorState = this.UseState<string>(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| //Serialization state | ||||||||||||||||||||
| var jsonState = this.UseState<string>(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| //Deserialization states | ||||||||||||||||||||
| var expressionState = this.UseState<string>(); | ||||||||||||||||||||
| var comparisonResultState = this.UseState<string>(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return Layout.Vertical() | ||||||||||||||||||||
| | Text.Block("Hello world!") | ||||||||||||||||||||
| //Inputs | ||||||||||||||||||||
| | (Layout.Horizontal() | ||||||||||||||||||||
| | value1State.ToNumberInput().Width(Size.Grow()) | ||||||||||||||||||||
| | operatorState.ToSelectInput(new string[] { "=", "<", "<=", ">", ">=", "!=" }.ToOptions()).Width(Size.Third()) | ||||||||||||||||||||
| | value2State.ToNumberInput().Width(Size.Grow())) | ||||||||||||||||||||
| //Serialize button | ||||||||||||||||||||
| | new Button("Serialize", () => | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Expression<Func<int, bool>> expression = null; | ||||||||||||||||||||
| switch (operatorState.Value) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| case "=": | ||||||||||||||||||||
| expression = val => value1State.Value == val; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case "<": | ||||||||||||||||||||
| expression = val => value1State.Value < val; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case "<=": | ||||||||||||||||||||
| expression = val => value1State.Value <= val; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case ">": | ||||||||||||||||||||
| expression = val => value1State.Value > val; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case ">=": | ||||||||||||||||||||
| expression = val => value1State.Value >= val; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case "!=": | ||||||||||||||||||||
| expression = val => value1State.Value != val; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (expression != null) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| var serializer = new ExpressionSerializer(new JsonSerializer()); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| //The result is a json representation of the expression | ||||||||||||||||||||
| jsonState.Set(serializer.SerializeText(expression)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| { | ||||||||||||||||||||
| jsonState.Set("Invalid expression"); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| //Serialization result | ||||||||||||||||||||
| | Text.Block(jsonState) | ||||||||||||||||||||
| //Deserialize button (only works with serialization result, works like a validation for the json result) | ||||||||||||||||||||
| | new Button("Deserialize Result", () => | ||||||||||||||||||||
| { | ||||||||||||||||||||
| try | ||||||||||||||||||||
| { | ||||||||||||||||||||
| var serializer = new ExpressionSerializer(new JsonSerializer()); | ||||||||||||||||||||
| Expression<Func<int, bool>> expression = (Expression<Func<int, bool>>)serializer.DeserializeText(jsonState.Value); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| //Expression definition (value1 + operator) | ||||||||||||||||||||
| expressionState.Set($"Expression: {expression}"); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| //Result of the expresion when using value2 | ||||||||||||||||||||
| comparisonResultState.Set($"The comparison is {expression.Compile()(value2State.Value).ToString().ToLower()}"); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| catch { } | ||||||||||||||||||||
|
||||||||||||||||||||
| catch { } | |
| catch (Exception ex) | |
| { | |
| // Log the exception for diagnostics | |
| Console.WriteLine($"Deserialization failed: {ex.Message}"); | |
| // Provide user feedback | |
| expressionState.Set("Deserialization failed."); | |
| comparisonResultState.Set(""); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Base runtime image | ||
| FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base | ||
| WORKDIR /app | ||
| EXPOSE 80 | ||
|
|
||
| # Build stage | ||
| FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build | ||
| ARG BUILD_CONFIGURATION=Release | ||
| WORKDIR /src | ||
|
|
||
| # Copy and restore | ||
| COPY ["SerializeLinq.csproj", "./"] | ||
| RUN dotnet restore "SerializeLinq.csproj" | ||
|
|
||
| # Copy everything and build | ||
| COPY . . | ||
| RUN dotnet build "SerializeLinq.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
|
||
| # Publish stage | ||
| FROM build AS publish | ||
| ARG BUILD_CONFIGURATION=Release | ||
| RUN dotnet publish "SerializeLinq.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true | ||
|
|
||
| # Final runtime image | ||
| FROM base AS final | ||
| WORKDIR /app | ||
| COPY --from=publish /app/publish . | ||
|
|
||
| # Set environment variables | ||
| ENV PORT=80 | ||
| ENV ASPNETCORE_URLS="http://+:80" | ||
|
|
||
| # Run the executable | ||
| ENTRYPOINT ["dotnet","./SerializeLinq.dll"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| global using Ivy; | ||
| global using Ivy.Apps; | ||
| global using Ivy.Auth; | ||
| global using Ivy.Chrome; | ||
| global using Ivy.Client; | ||
| global using Ivy.Core; | ||
| global using Ivy.Core.Hooks; | ||
| global using Ivy.Helpers; | ||
| global using Ivy.Hooks; | ||
| global using Ivy.Shared; | ||
| global using Ivy.Views; | ||
| global using Ivy.Views.Alerts; | ||
| global using Ivy.Views.Blades; | ||
| global using Ivy.Views.Builders; | ||
| global using Ivy.Views.Charts; | ||
| global using Ivy.Views.Dashboards; | ||
| global using Ivy.Views.Forms; | ||
| global using Ivy.Views.Tables; | ||
| global using Ivy.Widgets.Inputs; | ||
| global using Microsoft.Extensions.Configuration; | ||
| global using Microsoft.Extensions.DependencyInjection; | ||
| global using Microsoft.Extensions.Logging; | ||
| global using System.Collections.Immutable; | ||
| global using System.ComponentModel.DataAnnotations; | ||
| global using System.Globalization; | ||
| global using System.Reactive.Linq; | ||
|
|
||
| namespace SerializeLinq; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using SerializeLinq.Apps; | ||
| CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US"); | ||
| var server = new Server(); | ||
| #if DEBUG | ||
| server.UseHotReload(); | ||
| #endif | ||
| server.AddAppsFromAssembly(); | ||
| server.AddConnectionsFromAssembly(); | ||
| var chromeSettings = new ChromeSettings().DefaultApp<SerializeLinqApp>().UseTabs(preventDuplicates: true); | ||
| server.UseChrome(chromeSettings); | ||
| await server.RunAsync(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Hello | ||
|
|
||
| Web application created using [Ivy](https://github.com/Ivy-Interactive/Ivy). | ||
|
|
||
| Ivy is a web framework for building interactive web applications using C# and .NET. | ||
|
|
||
| ## Run | ||
|
|
||
| ``` | ||
| dotnet watch | ||
| ``` | ||
|
|
||
| ## Deploy | ||
|
|
||
| ``` | ||
| ivy deploy | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <NoWarn>CS8618;CS8603;CS8602;CS8604;CS9113</NoWarn> | ||
| <RootNamespace>SerializeLinq</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <EmbeddedResource Include="Assets/**/*" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="Ivy" Version="1.*" /> | ||
| <PackageReference Include="Serialize.Linq" Version="4.0.167" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Folder Include="Connections" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.5.2.0 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hello", "SerializeLinq.csproj", "{039638F3-A6D7-FB67-E733-27BD896EFDC4}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {039638F3-A6D7-FB67-E733-27BD896EFDC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {039638F3-A6D7-FB67-E733-27BD896EFDC4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {039638F3-A6D7-FB67-E733-27BD896EFDC4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {039638F3-A6D7-FB67-E733-27BD896EFDC4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {5F74B1AD-6C2E-4FDA-9DAF-9F7D8053687B} | ||
| EndGlobalSection | ||
| EndGlobal |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initializing reference types to null is unnecessary in C#. The variable can be declared without initialization since it's assigned in all switch cases.