-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from ztanczos/ModuleLoader.Abstractions
Create ModuleLoader.Abstractions
- Loading branch information
Showing
13 changed files
with
406 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,39 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.7.34031.279 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0991543E-FA51-4D1C-8756-F6D6FD64C612}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{95B79432-5E5D-4889-8719-D610D6CCC35E}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorganStanley.ComposeUI.ModuleLoader.Abstractions", "src\MorganStanley.ComposeUI.ModuleLoader.Abstractions\MorganStanley.ComposeUI.ModuleLoader.Abstractions.csproj", "{841D9BAC-DEE6-4E1A-A577-25B20633B110}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorganStanley.ComposeUI.ModuleLoader.Abstractions.Tests", "tests\MorganStanley.ComposeUI.ModuleLoader.Abstractions.Tests\MorganStanley.ComposeUI.ModuleLoader.Abstractions.Tests.csproj", "{81B6905B-EE74-4387-A5EB-11271A4458A4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{841D9BAC-DEE6-4E1A-A577-25B20633B110}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{841D9BAC-DEE6-4E1A-A577-25B20633B110}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{841D9BAC-DEE6-4E1A-A577-25B20633B110}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{841D9BAC-DEE6-4E1A-A577-25B20633B110}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{81B6905B-EE74-4387-A5EB-11271A4458A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{81B6905B-EE74-4387-A5EB-11271A4458A4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{81B6905B-EE74-4387-A5EB-11271A4458A4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{81B6905B-EE74-4387-A5EB-11271A4458A4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{841D9BAC-DEE6-4E1A-A577-25B20633B110} = {0991543E-FA51-4D1C-8756-F6D6FD64C612} | ||
{81B6905B-EE74-4387-A5EB-11271A4458A4} = {95B79432-5E5D-4889-8719-D610D6CCC35E} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {147A1BDA-77DE-4D1A-B8D5-6E8803E11F47} | ||
EndGlobalSection | ||
EndGlobal |
20 changes: 20 additions & 0 deletions
20
...ule-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/IModuleCatalog.cs
This file contains 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,20 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public interface IModuleCatalog | ||
{ | ||
IModuleManifest GetManifest(string moduleId); | ||
|
||
IEnumerable<string> GetModuleIds(); | ||
} |
22 changes: 22 additions & 0 deletions
22
...dule-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/IModuleLoader.cs
This file contains 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 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public interface IModuleLoader | ||
{ | ||
void RequestStart(StartRequest startupRequest); | ||
|
||
void RequestStop(StopRequest stopRequest); | ||
|
||
IObservable<LifetimeEvent> LifetimeEvents { get; } | ||
} |
28 changes: 28 additions & 0 deletions
28
...le-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/IModuleManifest.cs
This file contains 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 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public interface IModuleManifest | ||
{ | ||
string Id { get; } | ||
|
||
string Name { get; } | ||
|
||
string StartupType { get; } | ||
} | ||
|
||
public interface IModuleManifest<out TDetails> : IModuleManifest | ||
{ | ||
TDetails GetDetails(); | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
...ule-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/IStartupAction.cs
This file contains 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,18 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public interface IStartupAction | ||
{ | ||
Task InvokeAsync(StartupContext startupContext, Func<Task> next); | ||
} |
81 changes: 81 additions & 0 deletions
81
...dule-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/LifetimeEvent.cs
This file contains 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,81 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public abstract class LifetimeEvent | ||
{ | ||
protected LifetimeEvent(Guid instanceId) | ||
{ | ||
InstanceId = instanceId; | ||
} | ||
|
||
public Guid InstanceId { get; } | ||
|
||
public abstract LifetimeEventType EventType { get; } | ||
|
||
public sealed class Starting : LifetimeEvent | ||
{ | ||
internal Starting(Guid instanceId) | ||
: base(instanceId) | ||
{ } | ||
|
||
public override LifetimeEventType EventType => LifetimeEventType.Starting; | ||
} | ||
|
||
public sealed class Started : LifetimeEvent | ||
{ | ||
internal Started(Guid instanceId) | ||
: base(instanceId) | ||
{ } | ||
|
||
public override LifetimeEventType EventType => LifetimeEventType.Started; | ||
} | ||
|
||
public sealed class Stopping : LifetimeEvent | ||
{ | ||
internal Stopping(Guid instanceId) | ||
: base(instanceId) | ||
{ } | ||
|
||
public override LifetimeEventType EventType => LifetimeEventType.Stopping; | ||
} | ||
|
||
public sealed class Stopped : LifetimeEvent | ||
{ | ||
internal Stopped(Guid instanceId, bool isExpected = true) | ||
: base(instanceId) | ||
{ | ||
IsExpected = isExpected; | ||
} | ||
|
||
public override LifetimeEventType EventType => LifetimeEventType.Stopped; | ||
|
||
public bool IsExpected { get; set; } | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public enum LifetimeEventType | ||
{ | ||
Starting, | ||
Started, | ||
Stopping, | ||
Stopped | ||
} |
10 changes: 10 additions & 0 deletions
10
...poseUI.ModuleLoader.Abstractions/MorganStanley.ComposeUI.ModuleLoader.Abstractions.csproj
This file contains 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,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>MorganStanley.ComposeUI.ModuleLoader</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
26 changes: 26 additions & 0 deletions
26
...odule-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/StartRequest.cs
This file contains 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,26 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public sealed class StartRequest | ||
{ | ||
public StartRequest(string moduleId) | ||
{ | ||
ModuleId = moduleId; | ||
InstanceId = Guid.NewGuid(); | ||
} | ||
|
||
public Guid InstanceId { get; } | ||
|
||
public string ModuleId { get; } | ||
} |
47 changes: 47 additions & 0 deletions
47
...ule-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/StartupContext.cs
This file contains 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,47 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
using System.Collections.Concurrent; | ||
using System.Collections.Immutable; | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public sealed class StartupContext | ||
{ | ||
private readonly ConcurrentDictionary<Type, ImmutableList<object>> _properties = new(); | ||
|
||
public StartupContext(StartRequest startRequest) | ||
{ | ||
StartRequest = startRequest; | ||
} | ||
|
||
public StartRequest StartRequest { get; } | ||
|
||
public void AddProperty<T>(T value) | ||
{ | ||
ArgumentNullException.ThrowIfNull(value, nameof(value)); | ||
|
||
_properties.AddOrUpdate(typeof(T), | ||
(_) => ImmutableList<object>.Empty.Add(value), | ||
(_, list) => list.Add(value)); | ||
} | ||
|
||
public IEnumerable<T> GetProperties<T>() | ||
{ | ||
if (!_properties.TryGetValue(typeof(T), out var list)) | ||
{ | ||
return Enumerable.Empty<T>(); | ||
} | ||
|
||
return list.OfType<T>(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...module-loader/dotnet/src/MorganStanley.ComposeUI.ModuleLoader.Abstractions/StopRequest.cs
This file contains 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,18 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
namespace MorganStanley.ComposeUI.ModuleLoader; | ||
|
||
public struct StopRequest | ||
{ | ||
public Guid InstanceId; | ||
} |
13 changes: 13 additions & 0 deletions
13
...ader/dotnet/tests/MorganStanley.ComposeUI.ModuleLoader.Abstractions.Tests/GlobalUsings.cs
This file contains 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,13 @@ | ||
// Morgan Stanley makes this available to you under the Apache License, | ||
// Version 2.0 (the "License"). You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// See the NOTICE file distributed with this work for additional information | ||
// regarding copyright ownership. Unless required by applicable law or agreed | ||
// to in writing, software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
|
||
global using Xunit; |
29 changes: 29 additions & 0 deletions
29
...eLoader.Abstractions.Tests/MorganStanley.ComposeUI.ModuleLoader.Abstractions.Tests.csproj
This file contains 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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\MorganStanley.ComposeUI.ModuleLoader.Abstractions\MorganStanley.ComposeUI.ModuleLoader.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.