### Install Docusaurus 2 Website Dependencies Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/README.md Installs all necessary project dependencies using Yarn. This command should be executed once after cloning the repository to set up the development environment. ```Shell $ yarn ``` -------------------------------- ### Install RarelySimple.AvatarScriptLink via .NET CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/getting-started/installation.md This command demonstrates how to install the RarelySimple.AvatarScriptLink NuGet package into a .NET project using the .NET Command Line Interface. It specifies a particular version (1.2.0) for installation. ```bash dotnet add package RarelySimple.AvatarScriptLink --version 1.2.0 ``` -------------------------------- ### Install RarelySimple.AvatarScriptLink via .NET CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/getting-started/installation.md This command installs the RarelySimple.AvatarScriptLink NuGet package into your .NET project using the .NET Command Line Interface. It specifies version 1.2.0 to ensure a consistent installation. ```Shell dotnet add package RarelySimple.AvatarScriptLink --version 1.2.0 ``` -------------------------------- ### Migrating ScriptLink to .NET 2.0: Hello World! (v1) Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/blog/2024-11-03-announcing-avatarscriptlink.net-2.0.0/index.mdx Illustrates the 'Hello World!' example implementation in AvatarScriptLink.NET version 1, showing direct method calls on the OptionObject2015. ```c# public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter) { return optionObject.ToReturnOptionObject(ErrorCode.Alert, "Hello World!"); } ``` -------------------------------- ### Simplify 'Hello, World!' ScriptLink response with AvatarScriptLink.NET Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/intro.md This example shows how AvatarScriptLink.NET simplifies the 'Hello, World!' response from the previous example. It leverages extension methods to significantly reduce the amount of boilerplate code needed to return an OptionObject. ```cs [WebMethod] public OptionObject RunScript(OptionObject optionObject, string parameter) { return optionObject.ToReturnOptionObject(ErrorCode.Informational, "Hello, World!"); } ``` -------------------------------- ### Migrating ScriptLink to .NET 2.0: Hello World! (v2 with Decorator) Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/blog/2024-11-03-announcing-avatarscriptlink.net-2.0.0/index.mdx Demonstrates the 'Hello World!' example in AvatarScriptLink.NET version 2, utilizing the new OptionObject2015Decorator to wrap the optionObject and access helper methods. ```c# public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter) { var decorator = new OptionObject2015Decorator(optionObject); return decorator.ToReturnOptionObject(ErrorCode.Alert, "Hello World!"); } ``` -------------------------------- ### Simplify 'Hello, World!' ScriptLink Response with AvatarScriptLink.NET Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/dotnet/RarelySimple.AvatarScriptLink/README.md This C# example shows how AvatarScriptLink.NET simplifies the 'Hello, World!' response. Instead of manually populating the OptionObject, it leverages the ToReturnOptionObject extension method for a more concise and cleaner implementation. ```C# [WebMethod] public OptionObject RunScript(OptionObject optionObject, string parameter) { return optionObject.ToReturnOptionObject(ErrorCode.Informational, "Hello, World!"); } ``` -------------------------------- ### C# Implementation of ScriptLink RunScript Method Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/blog/2020-02-04-creating-your-first-myavatar-scriptlink-api-using-c-sharp/index.mdx Provides a C# code example for the `RunScript` web method. This initial implementation demonstrates how to create and populate a `returnOptionObject` with basic information, including a 'Hello, World!' error message, before returning it. ```csharp [WebMethod] public OptionObject2015 RunScript(OptionObject2015 optionObject2015, string parameter) { OptionObject2015 returnOptionObject = new OptionObject2015() { EntityID = optionObject2015.EntityID, EpisodeNumber = optionObject2015.EpisodeNumber, ErrorCode = 3, ErrorMesg = "Hello, World!", Facility = optionObject2015.Facility, NamespaceName = optionObject2015.NamespaceName, OptionId = optionObject2015.OptionId, OptionStaffId = optionObject2015.OptionStaffId, OptionUserId = optionObject2015.OptionUserId, ParentNamespace = optionObject2015.ParentNamespace, ServerName = optionObject2015.ServerName, SystemCode = optionObject2012.SystemCode, SessionToken = optionObject2015.SessionToken }; return returnOptionObject; } ``` -------------------------------- ### Migrating ScriptLink to .NET 2.0: Hello World! (v2 Inline Decorator) Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/blog/2024-11-03-announcing-avatarscriptlink.net-2.0.0/index.mdx Shows an alternative, more concise implementation of the 'Hello World!' example in AvatarScriptLink.NET version 2, where the OptionObject2015Decorator is instantiated inline. ```c# public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter) { return new OptionObject2015Decorator(optionObject).ToReturnOptionObject(ErrorCode.Alert, "Hello World!"); } ``` -------------------------------- ### Run ASP.NET Core Application via dotnet CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/tutorials/hello-world-dotnet/index.mdx This Bash command executes the ASP.NET Core application from the command line. It uses `dotnet run` with the `--launch-profile https` argument to ensure the application starts with the HTTPS configuration defined in `launchSettings.json`, typically used in environments like Visual Studio Code. ```Bash dotnet run --launch-profile https ``` -------------------------------- ### Visual Basic FormObject Unit Testing Examples Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/data-model/formobject.mdx Illustrates how to create and test a FormObject in Visual Basic using two methods: a fluent builder pattern for constructing complex FormObjects with multiple rows and fields, and a simplified constructor for straightforward initialization. These examples are designed for unit testing environments, demonstrating assertions against the FormObject's properties. ```vbnet ' Available in v1.2 or later Public Sub TestMethod1WithFluentBuilder() Dim expected As String = "123" ' FieldObject and RowObject definitions here Dim formObject As FormObject.Builder() .FormId(expected) .CurrentRow() .RowId("123||1") .Field(fieldObject1) .Field(fieldObject2) .AddRow() .MultipleIteration() .OtherRow() .RowId("123||2") .Field(fieldObject3) .Field(fieldObject4) .AddRow() .OtherRow(rowObject) .Build() Assert.AreEqual(expected, formObject.FormId) End Sub Public Sub TestMethod1WithSimplifiedConstructor() Dim expected As String = "123" Dim formObject As New FormObject With { .FormId = expected } Assert.AreEqual(expected, formObject.FormId) End Sub ``` -------------------------------- ### Implement ScriptLink Web Service with OptionObject2015 Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/data-model/optionobject2015.mdx This example demonstrates how to create a basic web service using `OptionObject2015` to interact with myAvatar. It includes methods for retrieving a service version and processing a `RunScript` request, returning an `OptionObject2015` with an alert message. ```cs using RarelySimple.AvatarScriptLink.Objects; using System.Web.Services; namespace ScriptLinkDemo.Web.Api { /// /// Summary description for MyScriptLinkDemoService /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class MyScriptLinkDemoService : System.Web.Services.WebService { [WebMethod] public string GetVersion() { return "v.0.0.1"; } [WebMethod] public OptionObject2015 RunScript(OptionObject2015 optionObject2015, string parameters) { return optionObject2015.ToReturnOptionObject(ErrorCode.Alert, "Hello, World!"); } } } ``` ```vb Imports System.ComponentModel Imports System.Web.Services Imports RarelySimple.AvatarScriptLink.Objects _ _ _ Public Class MyScriptLinkDemoService Inherits System.Web.Services.WebService Public Function GetVersion() As String Return "v.0.0.1" End Function Public Function RunScript(ByVal optionObject2015 As OptionObject2015, ByVal parameters As String) As OptionObject2015 Return optionObject2015.ToReturnOptionObject(ErrorCode.Alert, "Hello, World!") End Function End Class ``` -------------------------------- ### C# FormObject Unit Testing Examples Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/data-model/formobject.mdx Demonstrates how to create and test a FormObject in C# using two distinct approaches: a fluent builder pattern for constructing complex FormObjects with multiple rows and fields, and a simplified constructor for basic initialization. Both examples are presented within the context of unit testing, showcasing assertions against the FormObject's properties. ```csharp // Available in v1.2 or later [TestMethod] public void TestMethod1WithFluentBuilder() { var expected = "123"; // FieldObject and RowObject definitions here FormObject formObject = FormObject.Builder() .FormId(expected) .CurrentRow() .RowId("123||1") .Field(fieldObject1) .Field(fieldObject2) .AddRow() .MultipleIteration() .OtherRow() .RowId("123||2") .Field(fieldObject3) .Field(fieldObject4) .AddRow() .OtherRow(rowObject) .Build(); Assert.AreEqual(expected, formObject.FormId); } [TestMethod] public void TestMethod1WithSimplifiedConstructor() { var expected = "123"; FormObject formObject = new FormObject() { FormId = expected }; Assert.AreEqual(expected, formObject.FormId); } ``` -------------------------------- ### Simplified ScriptLink 'Hello, World!' Response With AvatarScriptLink.NET Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/intro.md This example illustrates how AvatarScriptLink.NET simplifies the 'Hello, World!' response. It reduces boilerplate code by leveraging the framework's extension methods to return an OptionObject with an error code and message. ```cs [WebMethod] public OptionObject RunScript(OptionObject optionObject, string parameter) { return optionObject.ToReturnOptionObject(ErrorCode.Informational, "Hello, World!"); } ``` -------------------------------- ### Start Local Development Server for Docusaurus 2 Website Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/README.md Initiates a local development server for the Docusaurus 2 website and automatically opens it in a web browser. This command supports live reloading, reflecting most code changes instantly without server restarts. ```Shell $ yarn start ``` -------------------------------- ### Create Basic 'Hello, World!' ScriptLink Response (Traditional) Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/dotnet/RarelySimple.AvatarScriptLink/README.md This C# example demonstrates a basic 'Hello, World!' response for a myAvatar ScriptLink API using the traditional NTST.ScriptLinkService.Objects library. It manually populates an OptionObject with an error code, message, and copies various entity identifiers from the input optionObject. ```C# [WebMethod] public OptionObject RunScript(OptionObject optionObject, string parameter) { OptionObject returnOptionObject = new OptionObject(); returnOptionObject.ErrorCode = 3; returnOptionObject.ErrorMesg = "Hello, World!"; returnOptionObject.EntityID = optionObject.EntityID; returnOptionObject.EpisodeNumber = optionObject.EpisodeNumber; returnOptionObject.Facility = optionObject.Facility; returnOptionObject.OptionId = optionObject.OptionId; returnOptionObject.OptionStaffId = optionObject.OptionStaffId; returnOptionObject.OptionUserId = optionObject.OptionUserId; returnOptionObject.SystemCode = optionObject.SystemCode; return returnOptionObject; } ``` -------------------------------- ### Create .NET Web Project and Solution using dotnet CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/tutorials/hello-world-dotnet/index.mdx This snippet demonstrates how to initialize a new .NET solution and a web project, then add the project to the solution using the dotnet CLI. It also opens the project in Visual Studio Code, setting up the basic project structure for the API. ```Bash dotnet new sln --output ScriptLinkHelloWorldDemo cd ScriptLinkHelloWorldDemo dotnet new web --output ScriptLinkHelloWorldDemo dotnet sln add ScriptLinkHelloWorldDemo/ScriptLinkHelloWorldDemo.csproj code . ``` -------------------------------- ### Create .NET 8.0 Web Project with CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/tutorials/hello-world-dotnet/index.mdx This snippet demonstrates how to initialize a new .NET 8.0 solution and a web project using the .NET CLI. It then adds the project to the solution and opens the entire structure in Visual Studio Code for further development. ```Bash dotnet new sln --output ScriptLinkHelloWorldDemo cd ScriptLinkHelloWorldDemo dotnet new web --output ScriptLinkHelloWorldDemo dotnet sln add ScriptLinkHelloWorldDemo/ScriptLinkHelloWorldDemo.csproj code . ``` -------------------------------- ### Implement ScriptLink Web Service with OptionObject2015 Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/decorators/optionobject2015.mdx This example demonstrates how to create a web service compatible with myAvatar using the OptionObject2015 class. It includes methods for getting the service version and running a script, showcasing interoperability with the myAvatar system. ```cs using RarelySimple.AvatarScriptLink.Objects; using System.Web.Services; namespace ScriptLinkDemo.Web.Api { /// /// Summary description for MyScriptLinkDemoService /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class MyScriptLinkDemoService : System.Web.Services.WebService { [WebMethod] public string GetVersion() { return "v.0.0.1"; } [WebMethod] public OptionObject2015 RunScript(OptionObject2015 optionObject2015, string parameters) { return optionObject2015.ToReturnOptionObject(ErrorCode.Alert, "Hello, World!"); } } } ``` ```vb Imports System.ComponentModel Imports System.Web.Services Imports RarelySimple.AvatarScriptLink.Objects _ _ _ Public Class MyScriptLinkDemoService Inherits System.Web.Services.WebService Public Function GetVersion() As String Return "v.0.0.1" End Function Public Function RunScript(ByVal optionObject2015 As OptionObject2015, ByVal parameters As String) As OptionObject2015 Return optionObject2015.ToReturnOptionObject(ErrorCode.Alert, "Hello, World!") End Function End Class ``` -------------------------------- ### RowObject Usage Examples for Unit Testing Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/data-model/rowobject.mdx Examples demonstrating how to construct and manipulate `RowObject` instances using both a fluent builder pattern and a simplified constructor, primarily for unit testing scenarios. ```C# // Available in v1.2 or later [TestMethod] public void TestMethod1WithFluentBuilder() { var expected = "123||1"; RowObject rowObject = RowObject.Builder() .RowId(expected) .Field().FieldNumber("246.80").FieldValue("Sample").Enabled().AddField() .Edit() .Build(); Assert.AreEqual(expected, rowObject.RowId); } [TestMethod] public void TestMethod1WithSimplifiedConstructor() { var expected = "123||1"; FieldObject fieldObject = new FieldObject { FieldNumber = "246.80", FieldValue = "Sample", Enabled = "1" }; RowObject rowObject = new RowObject { RowId = expected, RowAction = "EDIT" }; rowObject.AddFieldObject(fieldObject); Assert.AreEqual(expected, rowObject.RowId); } ``` ```Visual Basic ' Available in v1.2 or later Public Sub TestMethod1WithFluentBuilder() Dim expected As String = "123||1" Dim rowObject As RowObject.Builder() .RowId(expected) .Field().FieldNumber("246.80").FieldValue("Sample").Enabled().AddField() .Edit() .Build(); Assert.AreEqual(expected, rowObject.RowId) End Sub Public Sub TestMethod1WithSimplifiedConstructor() Dim expected As String = "123||1" Dim fieldObject As New FieldObject With { .FieldNumber = "246.80", .FieldValue = "Sample", .Enabled = "1" } Dim rowObject As New RowObject With { .RowId = expected, .RowAction = "EDIT" } rowObject.AddFieldObject(fieldObject) Assert.AreEqual(expected, rowObject.RowId) End Sub ``` -------------------------------- ### Configure launchSettings.json for WSDL Auto-Launch Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/tutorials/hello-world-dotnet/index.mdx Modifies `launchSettings.json` to automatically open the WSDL endpoint in the browser upon application startup. It adds the `"launchUrl": "ScriptLinkService.asmx"` property within the `https` profile, streamlining development workflow by directly navigating to the service definition. ```JSON { // previous content "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "ScriptLinkService.asmx", "applicationUrl": "https://localhost:7140;http://localhost:5106", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, // following content } ``` -------------------------------- ### Create FieldObject for Unit Testing Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/data-model/fieldobject.mdx Examples demonstrating how to instantiate and initialize a FieldObject using both a fluent builder pattern and a simplified object initializer for unit testing purposes. These examples validate the FieldValue property after creation. ```C# // Available in v.1.2 or later [TestMethod] public void TestMethod1WithFluentBuilder() { var expected = "value"; FieldObject fieldObject = FieldObject.Builder() .FieldNumber("123.45").FieldValue(expected) .Enabled() .Build(); Assert.AreEqual(expected, fieldObject.FieldValue); } [TestMethod] public void TestMethod1WithSimplifiedConstructor() { var expected = "value"; FieldObject fieldObject = new FieldObject { FieldNumber = "123.45", FieldValue = expected, Enabled = "1" }; Assert.AreEqual(expected, fieldObject.FieldValue); } ``` ```Visual Basic ' Available in v.1.2 or later Public Sub TestMethod1WithFluentBuilder() Dim expected As String = "value" Dim fieldObject As FieldObject.Builder() .FieldNumber("123.45").FieldValue(expected) .Enabled() .Build() Assert.AreEqual(expected, fieldObject.FieldValue) End Sub Public Sub TestMethod1WithSimplifiedConstructor() Dim expected As String = "value" Dim fieldObject As New FieldObject With { .FieldNumber = "123.45", .FieldValue = expected, .Enabled = "1" } Assert.AreEqual(expected, fieldObject.FieldValue) End Sub ``` -------------------------------- ### Configure launchSettings.json for Automatic WSDL Launch Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/tutorials/hello-world-dotnet/index.mdx This JSON snippet modifies the `launchSettings.json` file to automatically open the WSDL endpoint in the browser upon application launch. By adding `'launchUrl': 'ScriptLinkService.asmx'` within the 'https' profile, it streamlines the development workflow for testing the SOAP service. ```JSON { // previous content "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "ScriptLinkService.asmx", "applicationUrl": "https://localhost:7140;http://localhost:5106", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, // following content } ``` -------------------------------- ### Unit Testing FieldObject Creation Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/data-model/fieldobject.mdx Examples demonstrating how to create and test FieldObject instances using both a fluent builder pattern and a simplified constructor, suitable for unit testing scenarios. These examples verify the FieldValue property after object creation. ```C# // Available in v.1.2 or later [TestMethod] public void TestMethod1WithFluentBuilder() { var expected = "value"; FieldObject fieldObject = FieldObject.Builder() .FieldNumber("123.45").FieldValue(expected) .Enabled() .Build(); Assert.AreEqual(expected, fieldObject.FieldValue); } [TestMethod] public void TestMethod1WithSimplifiedConstructor() { var expected = "value"; FieldObject fieldObject = new FieldObject { FieldNumber = "123.45", FieldValue = expected, Enabled = "1" }; Assert.AreEqual(expected, fieldObject.FieldValue); } ``` ```Visual Basic ' Available in v.1.2 or later Public Sub TestMethod1WithFluentBuilder() Dim expected As String = "value" Dim fieldObject As FieldObject.Builder() .FieldNumber("123.45").FieldValue(expected) .Enabled() .Build() Assert.AreEqual(expected, fieldObject.FieldValue) End Sub Public Sub TestMethod1WithSimplifiedConstructor() Dim expected As String = "value" Dim fieldObject As New FieldObject With { .FieldNumber = "123.45", .FieldValue = expected, .Enabled = "1" } Assert.AreEqual(expected, fieldObject.FieldValue) End Sub ``` -------------------------------- ### RowObject Unit Testing Examples (C# and Visual Basic) Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/decorators/rowobject.mdx These examples demonstrate how to create and test RowObject instances using two different approaches: a fluent builder pattern and a simplified constructor. They illustrate how to populate RowObject with FieldObject data and assert its properties, suitable for unit testing scenarios. ```C# // Available in v1.2 or later [TestMethod] public void TestMethod1WithFluentBuilder() { var expected = "123||1"; RowObject rowObject = RowObject.Builder() .RowId(expected) .Field().FieldNumber("246.80").FieldValue("Sample").Enabled().AddField() .Edit() .Build(); Assert.AreEqual(expected, rowObject.RowId); } [TestMethod] public void TestMethod1WithSimplifiedConstructor() { var expected = "123||1"; FieldObject fieldObject = new FieldObject { FieldNumber = "246.80", FieldValue = "Sample", Enabled = "1" }; RowObject rowObject = new RowObject { RowId = expected, RowAction = "EDIT" }; rowObject.AddFieldObject(fieldObject); Assert.AreEqual(expected, rowObject.RowId); } ``` ```Visual Basic ' Available in v1.2 or later Public Sub TestMethod1WithFluentBuilder() Dim expected As String = "123||1" Dim rowObject As RowObject.Builder() .RowId(expected) .Field().FieldNumber("246.80").FieldValue("Sample").Enabled().AddField() .Edit() .Build(); Assert.AreEqual(expected, rowObject.RowId) End Sub Public Sub TestMethod1WithSimplifiedConstructor() Dim expected As String = "123||1" Dim fieldObject As New FieldObject With { .FieldNumber = "246.80", .FieldValue = "Sample", .Enabled = "1" } Dim rowObject As New RowObject With { .RowId = expected, .RowAction = "EDIT" } rowObject.AddFieldObject(fieldObject) Assert.AreEqual(expected, rowObject.RowId) End Sub ``` -------------------------------- ### Add NuGet Packages with .NET CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/tutorials/hello-world-dotnet/index.mdx This snippet illustrates how to add essential NuGet packages, 'RarelySimple.AvatarScriptLink' and 'SoapCore', to a .NET project. It uses the `dotnet add package` command, which is a standard method for managing dependencies via the command line. ```Bash cd ScriptLinkHelloWorldDemo dotnet add package RarelySimple.AvatarScriptLink dotnet add package SoapCore ``` -------------------------------- ### Run ASP.NET Core Application via Command Line Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/tutorials/hello-world-dotnet/index.mdx Provides a bash command to execute the ASP.NET Core application using a specific launch profile (`https`). This is useful for running the application from the terminal, especially in environments like Visual Studio Code, ensuring consistent startup behavior. ```Bash dotnet run --launch-profile https ``` -------------------------------- ### SoapUI GetVersion SOAP Request Example Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/blog/2020-02-18-testing-your-scriptlink-api-with-soapui/index.mdx Illustrates the generic structure of a SOAP request for the 'GetVersion' method, as typically generated by SoapUI after importing the WSDL. ```XML ``` -------------------------------- ### Delete all rows in a multiple-iteration table Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/advanced/multiple-iteration-tables.md This example shows how to delete all RowObjects within a multiple-iteration table when their RowIds are not fixed. It iterates through FormObjects and their associated CurrentRow and OtherRows to delete each RowObject. ```cs var clone = _optionObject.Clone(); var miFormId = "123"; foreach (FormObject formObject in clone.Forms) { if (formObject.FormId == secondFormId) { if (formObject.CurrentRow != null && formObject.CurrentRow.RowId) formObject.DeleteRowObject(formObject.CurrentRow.RowId); foreach (RowObject rowObject in formObject.OtherRows) { if (rowObject.RowId != null) formObject.DeleteRowObject(rowObject.RowId); } } } return clone.ToReturnOptionObject(); ``` -------------------------------- ### SoapUI GetVersion SOAP Response Example Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/blog/2020-02-18-testing-your-scriptlink-api-with-soapui/index.mdx Shows the expected SOAP response structure for a successful 'GetVersion' API call, including the placeholder for the version number. ```XML 1.0.0.0 ``` -------------------------------- ### OptionObject2 Class Methods Reference Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/data-model/optionobject2.mdx Comprehensive documentation for the methods available on the `OptionObject2` class, detailing their purpose, parameters, and return types for integration with web services like myAvatar. ```APIDOC OptionObject2: SetRequiredFields(fields: List[str]) description: Sets the specified fields as required. SetUnlockedField(field: str) description: Set the specified field as unlocked. SetUnlockedFields(fields: List[str]) description: Set the specified fields as unlocked. ToHtmlString() -> str description: Returns a string with all of the contents of the OptionObject2 formatted in HTML. ToHtmlString(include_header_tags: bool) -> str description: Returns a string with all of the contents of the OptionObject2 formatted in HTML. Passing true will include HTML header tags. include_header_tags: If true, HTML header tags will be included in the output. ToJson() -> str description: Returns a string with all of the contents of the OptionObject2 formatted as JSON. ToOptionObject() -> OptionObject description: Transforms the OptionObject2 to an OptionObject. ToOptionObject2() -> OptionObject2 description: Creates a clone of the OptionObject2. ToOptionObject2015() -> OptionObject2015 description: Transforms the OptionObject2 as an OptionObject2015. ToReturnOptionObject() -> OptionObject2 description: Creates an OptionObject2 with the minimum information required to return. ToReturnOptionObject(error_code: int, message: str) -> OptionObject2 description: Creates an OptionObject2 with the minimum information required to return plus the provided Error Code and Message. error_code: The error code to associate with the return object. message: The error message to associate with the return object. ToXml() -> str description: Returns a string with all of the contents of the OptionObject2 formatted as XML. ``` -------------------------------- ### Read RowObjects in a multiple-iteration table Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/advanced/multiple-iteration-tables.md This C# example illustrates how to iterate through FormObjects and their associated RowObjects within a multiple-iteration table. This approach is suitable when you need to interact with multiple FieldObjects in each RowObject, such as for validation purposes. ```cs var clone = _optionObject.Clone(); var miFormId = "123"; foreach (FormObject formObject in clone.Forms) { if (formObject.FormId == secondFormId) { var selectedRow = formObject.CurrentRow; // read RowObject foreach (RowObject rowObject in formObject.OtherRows) { // read other RowObjects } } } return clone.ToReturnOptionObject(); ``` -------------------------------- ### Add NuGet Packages using dotnet CLI Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/tutorials/hello-world-dotnet/index.mdx This snippet shows how to add the 'RarelySimple.AvatarScriptLink' and 'SoapCore' NuGet packages to a .NET project using the dotnet CLI. These packages are essential for ScriptLink compatibility and SOAP service implementation, providing necessary functionalities for the API. ```Bash cd ScriptLinkHelloWorldDemo dotnet add package RarelySimple.AvatarScriptLink dotnet add package SoapCore ``` -------------------------------- ### Set FieldObject Value in C# Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/guides/working-with-fieldobjects.mdx This example shows how to update the value of a FieldObject. The `SetFieldValue` method is used to assign a new string value to a specified field number. This action automatically updates the `RowAction` to `EDIT` for you. ```cs var clone = _optionObject.Clone(); clone.SetFieldValue("123.45", "My new value."); return clone.ToReturnOptionObject(); ``` -------------------------------- ### Implement ScriptLinkService ASMX Web Service in C# Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/tutorials/hello-world-dotnet-framework/index.mdx This C# code defines the `ScriptLinkService` ASMX web service, which is crucial for myAvatar ScriptLink compatibility. It includes the `GetVersion` method to return the API version and the `RunScript` method to process `OptionObject2015` objects, demonstrating a basic 'Hello World!' alert. The implementation leverages `RarelySimple.AvatarScriptLink.Objects` for data handling and `System.Web.Services` for web service functionality. ```C# using RarelySimple.AvatarScriptLink.Objects; using System.Web.Services; namespace ScriptLinkHelloWorldDemo.api { /// /// Summary description for ScriptLinkService /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class ScriptLinkService : System.Web.Services.WebService { [WebMethod] public string GetVersion() { return "0.1.0"; } [WebMethod] public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter) { return optionObject.ToReturnOptionObject(ErrorCode.Alert, "Hello World!"); } } } ``` -------------------------------- ### Configure ASP.NET Core for ScriptLink Service Integration Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/tutorials/hello-world-dotnet/index.mdx Updates `Program.cs` to integrate the `ScriptLinkService` into an ASP.NET Core application. It configures `SoapCore` for SOAP endpoints and registers the `IScriptLinkService2015` interface with the `ScriptLinkService` implementation for dependency injection. This sets up the API's routing and service resolution. ```C# using Microsoft.Extensions.DependencyInjection.Extensions; using SoapCore; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSoapCore(); builder.Services.TryAddSingleton(); var app = builder.Build(); app.UseHttpsRedirection(); app.UseRouting(); app.UseEndpoints(endpoints => { _ = endpoints.UseSoapEndpoint("/ScriptLinkService.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer); // Optional Alternative // _ = endpoints.UseSoapEndpoint("/ScriptLinkService.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer); }); app.Run(); ``` -------------------------------- ### Read RowObjects in a multiple-iteration table Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/advanced/multiple-iteration-tables.md This example illustrates how to iterate through FormObjects and their associated RowObjects within a multiple-iteration table. It's useful for scenarios requiring interaction with multiple FieldObjects in each RowObject, such as validating values across rows. ```cs var clone = _optionObject.Clone(); var miFormId = "123"; foreach (FormObject formObject in clone.Forms) { if (formObject.FormId == secondFormId) { var selectedRow = formObject.CurrentRow; // read RowObject foreach (RowObject rowObject in formObject.OtherRows) { // read other RowObjects } } } return clone.ToReturnOptionObject(); ``` -------------------------------- ### Read all values of a single field Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/advanced/multiple-iteration-tables.md This snippet demonstrates how to retrieve all values associated with a specific field number from a multiple-iteration table. It clones the OptionObject, uses a form ID to get field values, and then returns the modified OptionObject. ```cs var clone = _optionObject.Clone(); var miFormId = "123"; List values = optionObject.GetFieldValues(miFormId); // work with values return clone.ToReturnOptionObject(); ``` -------------------------------- ### Simplified C# ScriptLink 'Hello, World!' Response with AvatarScriptLink.NET Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/dotnet/RarelySimple.AvatarScriptLink.Net/README.md Illustrates the simplified approach to creating a ScriptLink 'Hello, World!' response using the `RarelySimple.AvatarScriptLink.Net` library. It leverages `OptionObject2015Decorator` and fluent methods to set the error code and message, significantly reducing boilerplate code compared to the traditional method. ```C# // Uncomment annotation for .NET Framework *.asmx // [WebMethod] public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter) { var decorator = new OptionObject2015Decorator(optionObject); // Do work return decorator.Return() .WithErrorCode(ErrorCode.Alert) .WithErrorMesg("Hello World!") .AsOptionObject2015(); } ``` -------------------------------- ### Set Multiple FieldObjects Status in C# Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/guides/working-with-fieldobjects.mdx This example shows how to efficiently set the status for a list of FieldObjects in a single operation. Methods like `SetEnabledFields`, `SetLockedFields`, and `SetRequiredFields` accept a list of field numbers. This streamlines bulk status updates. ```cs var clone = _optionObject.Clone(); List fieldNumbers = new List() { "123.45", "123.46", "123.54" }; clone.SetEnabledFields(fieldNumbers) // or clone.SetDisabledFields(fieldNumbers) clone.SetLockedFields(fieldNumbers) // or clone.SetUnlockedFields(fieldNumbers) clone.SetRequiredFields(fieldNumbers); // or clone.SetOptionalFields(fieldNumbers) return clone.ToReturnOptionObject(); ``` -------------------------------- ### Implement IScriptLinkService2015 for ScriptLink Service in C# Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/docs/dotnet/tutorials/hello-world-dotnet/index.mdx This C# code defines the `ScriptLinkService` class, inheriting from `IScriptLinkService2015`. It implements `GetVersion` to return '0.1.0' and `RunScript` to process an `OptionObject2015`, returning a 'Hello World!' alert. This forms the core logic for a ScriptLink-compatible service. ```C# using RarelySimple.AvatarScriptLink.Net.Decorators; using RarelySimple.AvatarScriptLink.Objects; using RarelySimple.AvatarScriptLink.Services; namespace ScriptLinkHelloWorldDemo { public class ScriptLinkService : IScriptLinkService2015 { public string GetVersion() { return "0.1.0"; } public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter) { var decorator = new OptionObject2015(optionObject); return decorator.Return() .WithErrorCode(ErrorCode.Alert) .WithErrorMesg("Hello World!") .AsOptionObject2015(); } } } ``` -------------------------------- ### OptionObject2 Class Methods Reference Source: https://github.com/rarelysimple/rarelysimple.avatarscriptlink/blob/main/docs/versioned_docs/version-1.2.0/dotnet/data-model/optionobject2.mdx Detailed documentation for the methods available on the `OptionObject2` class, including their parameters and descriptions. These methods facilitate interaction with form objects, row objects, and field objects. ```APIDOC OptionObject2: Methods: AddFormObject(formObject: FormObject) Description: Adds a FormObject to the OptionObject2. AddFormObject(formId: string, isMultipleIteration: bool) Description: Creates a FormObject with specified FormId and adds to the OptionObject2015. The second parameter specifies whether the FormObject should be flagged as a Multiple Iteration form. AddRowObject(formId: string, rowObject: RowObject) Description: Adds a RowObject to the FormObject with the specified FormId. Builder() Description: Initializes a builder for constructing a OptionObject2. Clone90() Description: Clones the OptionObject2. DeleteRowObject(rowObject: RowObject) Description: Marks a RowObject for deletion. DeleteRowObject(rowId: string) Description: Marks a RowObject for deletion by specified RowId. DisableAllFieldObjects() Description: Sets all FieldObjects as disabled. DisableAllFieldObjects(fieldNumbers: List of string) Description: Sets all FieldObjects as disabled except for any listed to be excluded. Equals(other: OptionObjectBase) Description: Used to compare two OptionObject2 to determine if they are equal. Returns bool. Equals(other: object) Description: Used to compare OptionObject2 to an object to determine if they are equal. Returns bool. GetCurrentRowId(formId: string) Description: Returns the CurrentRow RowId of the form matching the FormId. GetFieldValue(fieldNumber: string) Description: Returns the first value of the field matching the Field Number. GetFieldValue(fieldNumber: string, formId: string, rowId: string) Description: Returns the value of the FieldObject matching the Field Number on the specified FormObject and RowObject. GetFieldValues(fieldNumber: string) Description: Returns the values of the field matching the Field Number. GetHashCode() Description: Overrides the GetHashCode method for a OptionObjectBase. GetMultipleIterationStatus(formId: string) Description: Returns the Multiple Iteration Status of the form matching the FormId. GetParentRowId(formId: string) Description: Returns the CurrentRow ParentRowId of the form matching the FormId. Initialize() Description: Initializes an empty OptionObject2. IsFieldEnabled(fieldNumber: string) Description: Returns whether the specified field is enabled. IsFieldLocked(fieldNumber: string) Description: Returns whether the specified field is locked. IsFieldModified(fieldNumber: string) Description: Returns whether the specified field is modified. IsFieldPresent(fieldNumber: string) Description: Returns whether the specified field is present. IsFieldRequired(fieldNumber: string) Description: Returns whether the specified field is required. IsFormPresent(formId: string) Description: Returns whether the specified form is present. IsRowMarkedForDeletion(rowId: string) Description: Returns whether the specified RowObject is marked for deletion. IsRowPresent(rowId: string) Description: Returns whether the specified row is present SetDisabledField(fieldNumber: string) Description: Sets the specified field as disabled. SetDisabledFields(fieldNumbers: List of string) Description: Sets the specified fields as disabled. SetEnabledField(fieldNumber: string) Description: Sets the specified field as enabled. SetEnabledFields(fieldNumbers: List of string) Description: Sets the specified fields as enabled. SetFieldValue(fieldNumber: string, value: string) Description: Sets the FieldValue of a FieldObject in the OptionObject2 on the first form's CurrentRow. SetFieldValue(fieldNumber: string, value: string, formId: string, rowId: string) Description: Sets the FieldValue of a FieldObject in the OptionObject2. SetLockedField(fieldNumber: string) Description: Sets the specified field as locked. SetLockedFields(fieldNumbers: List of string) Description: Sets the specified fields as disabled. SetOptionalField(fieldNumber: string) Description: Set the specified field as not required and enables if disabled. SetOptionalFields(fieldNumbers: List of string) Description: Set the specified fields as not required and enables if disabled. SetRequiredField(fieldNumber: string) Description: Sets the specified field as required. ```