From d3dddd341042c6185ed5c7eb69d899a8181b5675 Mon Sep 17 00:00:00 2001 From: agracio Date: Mon, 29 Apr 2024 18:38:13 +0100 Subject: [PATCH] updating code --- README.md | 2 +- main.js | 45 ++++++++++--------- package.json | 4 +- src/ExternalLibrary/ExternalLibrary.csproj | 4 ++ src/ExternalLibrary/Libarary.cs | 19 ++++---- src/QuickStart.Core/QuickStart.Core.csproj | 2 +- .../QuickStart.Standard.csproj | 2 +- src/shared/ExternalLibarary.cs | 5 +-- src/shared/LocalMethods.cs | 2 +- 9 files changed, 44 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index fd0b351..45c531a 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ https://github.com/agracio/edge-js 1. Install dependencies `npm install` 2. Build `src\QuickStart.sln` by running `dotnet build src/QuickStart.sln` -3. To run the app using .NET Core use `npm start` or `npm run start:core` +3. To run the app using .NET Core use `npm start` 4. To run the app using .NET Standard use `npm run start:standard` diff --git a/main.js b/main.js index 500b634..e98ece6 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,7 @@ const path = require('path'); var net = process.argv[2]; -var namespace = 'QuickStart.' + net.charAt(0).toUpperCase() + net.substr(1); +var framework = net.charAt(0).toUpperCase() + net.substr(1); +var namespace = 'QuickStart.' + framework; if(net === 'core') net = ''; var version = net == 'standard' ? '2.0' : '7.0' @@ -61,28 +62,30 @@ var listCertificates = edge.func({ var getInlinePerson = edge.func({ source: function () {/* using System.Threading.Tasks; + using System; - public class Person + public class Person + { + public Person(string name, string email, int age) { - public Person(string name, string email, int age) - { - Name = name; - Email = email; - Age = age; - } - public string Name {get;set;} - public string Email {get;set;} - public int Age {get;set;} + Id = Guid.NewGuid(); + Name = name; + Email = email; + Age = age; } - - public class Startup + public Guid Id {get;} + public string Name {get;set;} + public string Email {get;set;} + public int Age {get;set;} + } + + public class Startup + { + public async Task Invoke(dynamic input) { - public async Task Invoke(dynamic input) - { - Person person = new Person(input.name, input.email, input.age); - return person; - } - } + return new Person(input.name, input.email, input.age); + } + } */} }); @@ -113,7 +116,7 @@ getCurrentTime('', function(error, result) { console.log(); }); -useDynamicInput('Node.Js', function(error, result) { +useDynamicInput({framework: framework, node: 'Node.Js'}, function(error, result) { if (error) throw error; console.log(localTypeName + '.UseDynamicInput'); console.log(result); @@ -142,7 +145,7 @@ try{ console.log(); console.log('### Calling external library methods using '+ namespace +'.dll wrapper'); console.log(); -getPerson('', function(error, result) { +getPerson({name: 'John Smith', email: 'john.smith@edge-js-quick-start.com', age: 35}, function(error, result) { if (error) throw error; console.log(externalTypeName + '.GetPersonInfo'); console.log(result); diff --git a/package.json b/package.json index c501ac4..2ebc38d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "main": "main.js", "scripts": { "start": "node main.js core", - "start:core": "node main.js core", "start:standard": "node main.js standard" }, "repository": "https://github.com/agracio/edge-js-quick-start", @@ -15,7 +14,8 @@ "tutorial", "demo", "Edge", - "Edge.js" + "Edge.js", + "edge-js" ], "license": "MIT", "dependencies": { diff --git a/src/ExternalLibrary/ExternalLibrary.csproj b/src/ExternalLibrary/ExternalLibrary.csproj index 9f5c4f4..cf6afd4 100644 --- a/src/ExternalLibrary/ExternalLibrary.csproj +++ b/src/ExternalLibrary/ExternalLibrary.csproj @@ -4,4 +4,8 @@ netstandard2.0 + + + + diff --git a/src/ExternalLibrary/Libarary.cs b/src/ExternalLibrary/Libarary.cs index 5e92297..c525ff6 100644 --- a/src/ExternalLibrary/Libarary.cs +++ b/src/ExternalLibrary/Libarary.cs @@ -4,17 +4,16 @@ namespace ExternalLibrary { public class Person { - public Guid Id => Guid.NewGuid(); - public string Name => "John Smith"; - public string Email => "john.smith@edge-js-quick-start.com"; - - } - - public class Library - { - public Person GetPerson() + public Person(string name, string email, int age) { - return new Person(); + Id = Guid.NewGuid(); + Name = name; + Email = email; + Age = age; } + public Guid Id {get;} + public string Name {get;} + public string Email {get;} + public int Age {get;} } } \ No newline at end of file diff --git a/src/QuickStart.Core/QuickStart.Core.csproj b/src/QuickStart.Core/QuickStart.Core.csproj index 116c710..ec2e376 100644 --- a/src/QuickStart.Core/QuickStart.Core.csproj +++ b/src/QuickStart.Core/QuickStart.Core.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/QuickStart.Standard/QuickStart.Standard.csproj b/src/QuickStart.Standard/QuickStart.Standard.csproj index bce09a3..656c227 100644 --- a/src/QuickStart.Standard/QuickStart.Standard.csproj +++ b/src/QuickStart.Standard/QuickStart.Standard.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/shared/ExternalLibarary.cs b/src/shared/ExternalLibarary.cs index 35df4a2..626f4e5 100644 --- a/src/shared/ExternalLibarary.cs +++ b/src/shared/ExternalLibarary.cs @@ -1,16 +1,13 @@ using System.Threading.Tasks; using ExternalLibrary; -using Newtonsoft.Json; namespace QuickStart { class ExternalMethods { - private readonly Library _library = new Library(); - public async Task GetPersonInfo(dynamic input) { - return await Task.Run(() =>JsonConvert.SerializeObject(_library.GetPerson(), Formatting.Indented)); + return await Task.Run(() => new Person(input.name, input.email, input.age)); } } } diff --git a/src/shared/LocalMethods.cs b/src/shared/LocalMethods.cs index 094673a..0ba77d9 100644 --- a/src/shared/LocalMethods.cs +++ b/src/shared/LocalMethods.cs @@ -21,7 +21,7 @@ public async Task GetCurrentTime(dynamic input) public async Task UseDynamicInput(dynamic input) { - return $".NET Standard welcomes {input}"; + return $".NET {input.framework} welcomes {input.node}"; } public async Task ThrowException(dynamic input) {