-
Notifications
You must be signed in to change notification settings - Fork 1k
Implement dependency injection for application instance, server and n… #3022
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
Draft
wbtoms
wants to merge
10
commits into
OPCFoundation:master
Choose a base branch
from
wbtoms:IntroduceDependencyInjection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7b3e87b
Implement dependency injection for application instance, server and n…
wbtoms 76724a7
Adjustments after rebase
wbtoms 0d4d3df
Revert use of CommunityToolkit.Diagnostics for Guard
wbtoms 461cfd9
Adjust server applications
wbtoms 3532fa1
Set namespace of new classes/interfaces into the main project namespace
wbtoms e7c339f
Use <inheritdoc/> where needed
wbtoms 8871598
Update package version for Microsoft.Extensions.DependencyInjection
wbtoms cb51153
Rework dispose of ServerInternalData
wbtoms f2e48fa
Add test of server restart
wbtoms c4b74f7
Improve DI configuration
wbtoms 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,48 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Opc.Ua; | ||
using Opc.Ua.Configuration; | ||
using Opc.Ua.Server; | ||
|
||
namespace Quickstarts | ||
{ | ||
public interface IUAServer<T> where T : IStandardServer | ||
{ | ||
IApplicationInstance Application { get; } | ||
|
||
ApplicationConfiguration Configuration { get; } | ||
|
||
bool AutoAccept { get; set; } | ||
|
||
string Password { get; set; } | ||
|
||
ExitCode ExitCode { get; } | ||
|
||
T Server { get; } | ||
|
||
/// <summary> | ||
/// Load the application configuration. | ||
/// </summary> | ||
Task LoadAsync(string applicationName, string configSectionName); | ||
|
||
/// <summary> | ||
/// Load the application configuration. | ||
/// </summary> | ||
Task CheckCertificateAsync(bool renewCertificate); | ||
|
||
/// <summary> | ||
/// Create server instance and add node managers. | ||
/// </summary> | ||
void Create(IList<INodeManagerFactory> nodeManagerFactories); | ||
|
||
/// <summary> | ||
/// Start the server. | ||
/// </summary> | ||
Task StartAsync(); | ||
|
||
/// <summary> | ||
/// Stops the server. | ||
/// </summary> | ||
Task StopAsync(); | ||
} | ||
} |
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
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
44 changes: 44 additions & 0 deletions
44
Applications/Quickstarts.Servers/ReferenceServer/IReferenceServer.cs
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,44 @@ | ||
/* ======================================================================== | ||
* Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved. | ||
* | ||
* OPC Foundation MIT License 1.00 | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* The complete license agreement can be found here: | ||
* http://opcfoundation.org/License/MIT/1.00/ | ||
* ======================================================================*/ | ||
using System; | ||
using Opc.Ua; | ||
using Opc.Ua.Server; | ||
|
||
namespace Quickstarts.ReferenceServer | ||
{ | ||
public interface IReferenceServer : IReverseConnectServer | ||
{ | ||
ITokenValidator TokenValidator { get; set; } | ||
|
||
/// <summary> | ||
/// Creates an instance of the service host. | ||
/// </summary> | ||
ServiceHost CreateServiceHost(ServerBase server, params Uri[] addresses); | ||
} | ||
} |
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
Oops, something went wrong.
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.
previously LoadAsync created a new application instance, now it doesnt.
I need to check...
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.
Yes, now this object comes from the DI. This was the intension.
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.
Yeah but if you call load twice previously a new instance was created now the Same is reused. I need to Check If this could cause unwanted behaviour changes
Uh oh!
There was an error while loading. Please reload this page.
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.
I see, for this shadow config use case, right? I think this works becauce LoadApplicationConfiguration sets the application configuration to null before relaoding it so it is always a complete new instance of the configuration.
But what is the shadow configuration use case for excatly? do you know?