增加Prism 框架
This commit is contained in:
1 parent
2cd6b8db86
commit
726eb6de16
99 files changed
+12527
No files matched your search
@@ -0,0 +1,8 @@
|
||||
using System.Windows.Markup;
|
||||
|
||||
[assembly: XmlnsDefinition("Trade.Framework", "Trade.Framework")]
|
||||
[assembly: XmlnsDefinition("Trade.Framework", "Trade.Framework.Extensions")]
|
||||
[assembly: XmlnsDefinition("Trade.Framework", "Trade.Framework.Controls")]
|
||||
|
||||
|
||||
[assembly: XmlnsPrefix("Nexus.Framework", "tf")]
|
||||
@@ -0,0 +1,17 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Trade.Framework.Controls;
|
||||
|
||||
public class UserControlBase: UserControl
|
||||
{
|
||||
public UserControlBase()
|
||||
{
|
||||
ViewModelLocator.SetAutoWireViewModel(this, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Trade.Framework.Controls;
|
||||
|
||||
public class WindowBase : Window
|
||||
{
|
||||
public WindowBase()
|
||||
{
|
||||
ViewModelLocator.SetAutoWireViewModel(this, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Trade.Framework.Extensions;
|
||||
|
||||
public class DISource : MarkupExtension
|
||||
{
|
||||
internal static Func<Type, string, object> Resolver { get; set; }
|
||||
|
||||
public Type Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return Resolver?.Invoke(Type, Name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Prism.Autofac;
|
||||
using Prism.Ioc;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Trade.Framework.Extensions;
|
||||
|
||||
namespace Trade.Framework;
|
||||
|
||||
public abstract class FrameworkApplication : PrismApplication
|
||||
{
|
||||
|
||||
protected FrameworkApplication()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
DISource.Resolver = Resolve;
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
|
||||
private object Resolve(Type type, string name)
|
||||
{
|
||||
if (type == null || Container is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
return Container.Resolve(type, name);
|
||||
}
|
||||
|
||||
return Container.Resolve(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Logger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Trade.Framework.Services;
|
||||
|
||||
public interface IUserManager : ISingletonDependency
|
||||
{
|
||||
|
||||
}
|
||||
public class UserManager: IUserManager
|
||||
{
|
||||
public UserManager(ILoggerFacade logger)
|
||||
{
|
||||
logger.Info("Stat UserManager");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Autofac;
|
||||
using MAX.Core;
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Infrastructure;
|
||||
using MAX.Core.Reflections;
|
||||
using Prism.Ioc;
|
||||
using Prism.Modularity;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Trade.Framework;
|
||||
|
||||
public class Startup : IStartup
|
||||
{
|
||||
public int Priority => IntPriority.Highest;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Register(ContainerBuilder builder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultTargetFramework)-windows</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MAX.Core\MAX.Core.csproj" />
|
||||
<ProjectReference Include="..\MAX.Framework\MAX.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user