Skip to content

Commit

Permalink
https://github.com/morganstanley/ComposeUI/issues/47
Browse files Browse the repository at this point in the history
Create code skeleton for UICompse project and plugin prototypes
  • Loading branch information
polyanic committed Jul 7, 2022
1 parent 6509538 commit b990e5a
Show file tree
Hide file tree
Showing 93 changed files with 8,206 additions and 0 deletions.
8 changes: 8 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ Morgan Stanley ComposeUI
Copyright 2021 Morgan Stanley

This product includes software developed at Morgan Stanley (http://www.morganstanley.com).

=======================================================================
Software under third_party
=======================================================================
Software libraries are provided as nuget packages
and their content is not part of ComposeUI. Their
licenses can be found under the respective software repositories.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
********************************************************************************************************
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.
********************************************************************************************************
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Common\MorganStanley.ComposeUI.Common.BasicModels\MorganStanley.ComposeUI.Common.BasicModels.csproj" />
<ProjectReference Include="..\MorganStanley.ComposeUI.Playground.Interfaces\MorganStanley.ComposeUI.Playground.Interfaces.csproj" />
<ProjectReference Include="..\MorganStanley.ComposeUI.Playground.Utilities\MorganStanley.ComposeUI.Playground.Utilities.csproj" />
</ItemGroup>

</Project>
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.Playground.Interfaces
{
public interface ITextService
{
public void Send(string text);

public event Action<string> SentTextEvent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace MorganStanley.ComposeUI.Playground.Interfaces
{
public interface ITimeService
{
IObservable<DateTime> TimeObservable { get; }
}
}
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.Playground.Interfaces
{
public static class IoCNames
{
public const string TimeServiceName = "TimeService";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
********************************************************************************************************
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.
********************************************************************************************************
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="ITimeService.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Common\MorganStanley.ComposeUI.Common.Interfaces\MorganStanley.ComposeUI.Common.Interfaces.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
********************************************************************************************************
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.
********************************************************************************************************
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Common\MorganStanley.ComposeUI.Common.Utilities\MorganStanley.ComposeUI.Common.Utilities.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
********************************************************************************************************
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.
********************************************************************************************************
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Common\MorganStanley.ComposeUI.Common.VisualUtils\MorganStanley.ComposeUI.Common.VisualUtils.csproj" />
<ProjectReference Include="..\MorganStanley.ComposeUI.Playground.Utilities\MorganStanley.ComposeUI.Playground.Utilities.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
********************************************************************************************************
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.
********************************************************************************************************
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(OutDir)\$(AssemblyName).dll&quot; &quot;$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\Services\$(ProjectName)\&quot; /R /Y /I" />
<Exec Command="xcopy &quot;$(OutDir)\$(AssemblyName).pdb&quot; &quot;$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\Services\$(ProjectName)\&quot; /R /Y /I" />
</Target>

<ItemGroup>
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.Interfaces\MorganStanley.ComposeUI.Playground.Interfaces.csproj" />
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.Utilities\MorganStanley.ComposeUI.Playground.Utilities.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/// ********************************************************************************************************
///
/// 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 NP.Utilities;
using NP.Utilities.Attributes;
using NP.Utilities.BasicServices;

namespace MockAuthentication;

[Implements(typeof(IAuthenticationService), IsSingleton = true)]
public class MockAuthenticationService : VMBase, IAuthenticationService
{
[Part]
private ILog? Log { get; set; }

private string? _currentUserName;
public string? CurrentUserName
{
get => _currentUserName;
private set
{
if (_currentUserName == value)
return;

_currentUserName = value;

OnPropertyChanged(nameof(CurrentUserName));
OnPropertyChanged(nameof(IsAuthenticated));
}
}

// Is authenticated is true if and only if the CurrentUserName is not zero
public bool IsAuthenticated => CurrentUserName != null;

public bool Authenticate(string userName, string password)
{
if (IsAuthenticated)
{
throw new Exception("Already Authenticated");
}

CurrentUserName =
(userName == "nick" && password == "1234") ? userName : null;

if (IsAuthenticated)
{
Log?.Log
(
LogKind.Info,
nameof(IAuthenticationService),
$"Authenticated user '{userName}'");
}

return IsAuthenticated;
}

public void Logout()
{
if (!IsAuthenticated)
{
throw new Exception("Already logged out");
}

CurrentUserName = null;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
********************************************************************************************************
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.
********************************************************************************************************
-->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="TimeService.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Reactive" Version="5.0.0" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(OutDir)\$(AssemblyName).dll&quot; &quot;$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\Services\$(ProjectName)\&quot; /R /Y /I" />
<Exec Command="xcopy &quot;$(OutDir)\$(AssemblyName).pdb&quot; &quot;$(SolutionDir)\bin\$(Configuration)\net6.0\Plugins\Services\$(ProjectName)\&quot; /R /Y /I" />
</Target>

<ItemGroup>
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.Interfaces\MorganStanley.ComposeUI.Playground.Interfaces.csproj" />
<ProjectReference Include="..\..\..\MorganStanley.ComposeUI.Playground.Utilities\MorganStanley.ComposeUI.Playground.Utilities.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using MorganStanley.ComposeUI.Playground.Interfaces;
using NP.Utilities.Attributes;
using System.Reactive.Linq;

namespace MorganStanley.ComposeUI.Plugins.TimeService
{
[Implements(typeof(ITimeService), IsSingleton = true)]
public class TimeService : ITimeService
{
public IObservable<DateTime> TimeObservable
{
get
{
int delaySeconds = 5 - DateTime.Now.Second % 5;

return
Observable
.Interval(TimeSpan.FromSeconds(5))
.Delay(TimeSpan.FromSeconds(delaySeconds))
.Select(l => DateTime.Now);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// ********************************************************************************************************
///
/// 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 NP.Utilities.Attributes;
using MorganStanley.ComposeUI.Playground.Interfaces;
using System.Reactive.Linq;

namespace MorganStanley.ComposeUI.Plugins.TimeService
{
[HasFactoryMethods]
public static class TimeServicesFactory
{
[FactoryMethod(isSingleton:true, partKey:IoCNames.TimeServiceName)]
public static IObservable<DateTime> CreateTimeService()
{
var dateTime = DateTime.Now;

int delaySeconds = 5 - DateTime.Now.Second % 5;

return Observable
.Interval(TimeSpan.FromSeconds(5))
.Delay(TimeSpan.FromSeconds(delaySeconds))
.Select(l => DateTime.Now);
}
}
}
Loading

0 comments on commit b990e5a

Please sign in to comment.