ntminer il y a 6 ans
Parent
commit
cc6529b691

+ 3 - 3
src/AppModels/AppContext.cs

@@ -10,7 +10,7 @@ namespace NTMiner {
         public static ExtendedNotifyIcon NotifyIcon;
         public static Action<RemoteDesktopInput> RemoteDesktop;
 
-        private static readonly List<IPathId> _contextHandlers = new List<IPathId>();
+        private static readonly List<IMessagePathId> _contextHandlers = new List<IMessagePathId>();
 
         private AppContext() {
         }
@@ -19,7 +19,7 @@ namespace NTMiner {
         /// <summary>
         /// 命令窗口。使用该方法的代码行应将前两个参数放在第一行以方便vs查找引用时展示出参数信息
         /// </summary>
-        public static IPathId CmdPath<TCmd>(string description, LogEnum logType, Action<TCmd> action)
+        public static IMessagePathId CmdPath<TCmd>(string description, LogEnum logType, Action<TCmd> action)
             where TCmd : ICmd {
             return VirtualRoot.CreatePath(description, logType, action).AddToCollection(_contextHandlers);
         }
@@ -27,7 +27,7 @@ namespace NTMiner {
         /// <summary>
         /// 事件响应
         /// </summary>
-        public static IPathId EventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action)
+        public static IMessagePathId EventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action)
             where TEvent : IEvent {
             return VirtualRoot.CreatePath(description, logType, action).AddToCollection(_contextHandlers);
         }

+ 1 - 1
src/AppModels/AppModels.csproj

@@ -111,7 +111,7 @@
     <Compile Include="Vms\FileWriterSelectViewModel.cs" />
     <Compile Include="Vms\FragmentWriterViewModel.cs" />
     <Compile Include="Vms\GpuStatusBarViewModel.cs" />
-    <Compile Include="Vms\PathIdsWindowViewModel.cs" />
+    <Compile Include="Vms\MessagePathIdsWindowViewModel.cs" />
     <Compile Include="Vms\KernelOutputSelectViewModel.cs" />
     <Compile Include="Vms\KernelInputSelectViewModel.cs" />
     <Compile Include="Vms\LocalIpConfigViewModel.cs" />

+ 4 - 4
src/AppModels/Vms/PathIdsWindowViewModel.cs → src/AppModels/Vms/MessagePathIdsWindowViewModel.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 
 namespace NTMiner.Vms {
-    public class PathIdsWindowViewModel : ViewModelBase {
-        private readonly ObservableCollection<IPathId> _handlerIds = new ObservableCollection<IPathId>();
+    public class MessagePathIdsWindowViewModel : ViewModelBase {
+        private readonly ObservableCollection<IMessagePathId> _handlerIds = new ObservableCollection<IMessagePathId>();
 
-        public PathIdsWindowViewModel() {
+        public MessagePathIdsWindowViewModel() {
             VirtualRoot.SMessageDispatcher.Connected += (handlerId)=> {
                 UIThread.Execute(() => {
                     _handlerIds.Add(handlerId);
@@ -19,7 +19,7 @@ namespace NTMiner.Vms {
             };
         }
 
-        public IEnumerable<IPathId> HandlerIds {
+        public IEnumerable<IMessagePathId> HandlerIds {
             get {
                 return _handlerIds;
             }

+ 1 - 1
src/AppModels/Vms/StartStopMineButtonViewModel.cs

@@ -43,7 +43,7 @@ namespace NTMiner.Vms {
             if (IsAutoStart && !this.MinerProfile.IsMining) {
                 this.MinerProfile.IsMining = true;
                 int n = MinerProfile.AutoStartDelaySeconds;
-                IPathId handler = null;
+                IMessagePathId handler = null;
                 handler = AppContext.EventPath<Per1SecondEvent>("挖矿倒计时", LogEnum.None,
                 action: message => {
                     if (NTMinerRoot.IsAutoStartCanceled) {

+ 3 - 3
src/AppViews0/AppViews0.csproj

@@ -101,8 +101,8 @@
     <Compile Include="PackagesWindow.xaml.cs">
       <DependentUpon>PackagesWindow.xaml</DependentUpon>
     </Compile>
-    <Compile Include="PathIdsWindow.xaml.cs">
-      <DependentUpon>PathIdsWindow.xaml</DependentUpon>
+    <Compile Include="MessagePathIdsWindow.xaml.cs">
+      <DependentUpon>MessagePathIdsWindow.xaml</DependentUpon>
     </Compile>
     <Compile Include="Ucs\BrandTag.xaml.cs">
       <DependentUpon>BrandTag.xaml</DependentUpon>
@@ -466,7 +466,7 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="PathIdsWindow.xaml">
+    <Page Include="MessagePathIdsWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>

+ 4 - 4
src/AppViews0/PathIdsWindow.xaml → src/AppViews0/MessagePathIdsWindow.xaml

@@ -1,5 +1,5 @@
 <blankWindow:BlankWindow
-	x:Class="NTMiner.Views.PathIdsWindow"
+	x:Class="NTMiner.Views.MessagePathIdsWindow"
 	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 	xmlns:blankWindow="http://NTMiner.com"
@@ -8,7 +8,7 @@
 	xmlns:vm="clr-namespace:NTMiner.Vms;assembly=AppModels"
 	xmlns:controls="clr-namespace:NTMiner.Controls;assembly=NTMinerWpf"
 	mc:Ignorable="d"
-	Title="处理器标识"
+	Title="消息路径标识"
 	Width="1340"
 	Height="800"
 	Background="#EEECEF"
@@ -16,7 +16,7 @@
 	WindowStartupLocation="CenterScreen"
 	TextOptions.TextFormattingMode="Display">
 	<blankWindow:BlankWindow.DataContext>
-		<vm:PathIdsWindowViewModel></vm:PathIdsWindowViewModel>
+		<vm:MessagePathIdsWindowViewModel></vm:MessagePathIdsWindowViewModel>
 	</blankWindow:BlankWindow.DataContext>
 	<Grid>
 		<Grid.RowDefinitions>
@@ -24,7 +24,7 @@
 			<RowDefinition Height="*"></RowDefinition>
 		</Grid.RowDefinitions>
 		<WrapPanel>
-			<TextBlock FontSize="14" Padding="4" FontWeight="Bold">处理器标识</TextBlock>
+			<TextBlock FontSize="14" Padding="4" FontWeight="Bold">消息路径标识</TextBlock>
 			<TextBlock FontSize="14" Padding="4" FontWeight="Bold" Text="{Binding HandlerIds.Count}"></TextBlock>
 		</WrapPanel>
 		<WrapPanel HorizontalAlignment="Right">

+ 4 - 4
src/AppViews0/PathIdsWindow.xaml.cs → src/AppViews0/MessagePathIdsWindow.xaml.cs

@@ -3,14 +3,14 @@ using System.ComponentModel;
 using System.Windows.Input;
 
 namespace NTMiner.Views {
-    public partial class PathIdsWindow : BlankWindow {
-        public PathIdsWindowViewModel Vm {
+    public partial class MessagePathIdsWindow : BlankWindow {
+        public MessagePathIdsWindowViewModel Vm {
             get {
-                return (PathIdsWindowViewModel)this.DataContext;
+                return (MessagePathIdsWindowViewModel)this.DataContext;
             }
         }
 
-        public PathIdsWindow() {
+        public MessagePathIdsWindow() {
             InitializeComponent();
         }
 

+ 1 - 1
src/MinerClient/App.xaml.cs

@@ -73,7 +73,7 @@ namespace NTMiner {
                     ConsoleWindow.Instance.Show();
                     NotiCenterWindow.Instance.Show();
                     if (DevMode.IsDevMode) {
-                        PathIdsWindow window = new PathIdsWindow();
+                        MessagePathIdsWindow window = new MessagePathIdsWindow();
                         window.Show();
                     }
                     if (!NTMiner.Windows.Role.IsAdministrator) {

+ 2 - 2
src/NTMiner/INTMinerRoot.cs

@@ -11,8 +11,8 @@ using System.Collections.Generic;
 
 namespace NTMiner {
     public interface INTMinerRoot {
-        IPathId ServerContextCmdPath<TCmd>(string description, LogEnum logType, Action<TCmd> action) where TCmd : ICmd;
-        IPathId ServerContextEventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action) where TEvent : IEvent;
+        IMessagePathId ServerContextCmdPath<TCmd>(string description, LogEnum logType, Action<TCmd> action) where TCmd : ICmd;
+        IMessagePathId ServerContextEventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action) where TEvent : IEvent;
         
         void ReInitMinerProfile();
 

+ 3 - 3
src/NTMiner/NTMinerRoot.cs

@@ -26,12 +26,12 @@ using System.Threading.Tasks;
 
 namespace NTMiner {
     public partial class NTMinerRoot : INTMinerRoot {
-        private readonly List<IPathId> _serverContextHandlers = new List<IPathId>();
+        private readonly List<IMessagePathId> _serverContextHandlers = new List<IMessagePathId>();
 
         /// <summary>
         /// 命令窗口。使用该方法的代码行应将前两个参数放在第一行以方便vs查找引用时展示出参数信息
         /// </summary>
-        public IPathId ServerContextCmdPath<TCmd>(string description, LogEnum logType, Action<TCmd> action)
+        public IMessagePathId ServerContextCmdPath<TCmd>(string description, LogEnum logType, Action<TCmd> action)
             where TCmd : ICmd {
             return VirtualRoot.CreatePath(description, logType, action).AddToCollection(_serverContextHandlers);
         }
@@ -39,7 +39,7 @@ namespace NTMiner {
         /// <summary>
         /// 事件响应
         /// </summary>
-        public IPathId ServerContextEventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action)
+        public IMessagePathId ServerContextEventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action)
             where TEvent : IEvent {
             return VirtualRoot.CreatePath(description, logType, action).AddToCollection(_serverContextHandlers);
         }

+ 3 - 3
src/NTMiner/NTMinerRoot.partials.MinerProcess.cs

@@ -34,7 +34,7 @@ namespace NTMiner {
                                 Write.UserWarn("应用超频,如果CPU性能较差耗时可能超过1分钟,请耐心等待");
                                 var cmd = new CoinOverClockCommand(mineContext.MainCoin.GetId());
                                 // N卡超频当cpu性能非常差时较耗时,所以这里弄个回调
-                                DelegatePath<CoinOverClockDoneEvent> callback = null;
+                                MessagePath<CoinOverClockDoneEvent> callback = null;
                                 callback = VirtualRoot.CreateEventPath<CoinOverClockDoneEvent>("超频完成后继续流程", LogEnum.DevConsole,
                                     message => {
                                         if (mineContext != Instance.CurrentMineContext) {
@@ -123,7 +123,7 @@ namespace NTMiner {
             #endregion
 
             #region KernelProcessDaemon
-            private static DelegatePath<Per1MinuteEvent> _kernelProcessDaemon = null;
+            private static MessagePath<Per1MinuteEvent> _kernelProcessDaemon = null;
             private static void KernelProcessDaemon(IMineContext mineContext, Action clear) {
                 if (_kernelProcessDaemon != null) {
                     VirtualRoot.DeletePath(_kernelProcessDaemon);
@@ -317,7 +317,7 @@ namespace NTMiner {
                         VirtualRoot.Happened(new StartingMineFailedEvent($"管道型进程创建失败 lasterr:{lasterr}"));
                     }
                     else {
-                        Bus.DelegatePath<MineStopedEvent> closeHandle = null;
+                        Bus.MessagePath<MineStopedEvent> closeHandle = null;
                         bool isHWriteOutHasClosed = false;
                         KernelProcessDaemon(mineContext, () => {
                             if (!isHWriteOutHasClosed) {

+ 4 - 4
src/NTMinerBus/Bus/IMessageDispatcher.cs

@@ -4,11 +4,11 @@ namespace NTMiner.Bus {
     public interface IMessageDispatcher {
         void Dispatch<TMessage>(TMessage message);
 
-        void Connect<TMessage>(DelegatePath<TMessage> handler);
+        void Connect<TMessage>(MessagePath<TMessage> handler);
 
-        void Disconnect(IPathId handlerId);
+        void Disconnect(IMessagePathId handlerId);
 
-        event Action<IPathId> Connected;
-        event Action<IPathId> Disconnected;
+        event Action<IMessagePathId> Connected;
+        event Action<IMessagePathId> Disconnected;
     }
 }

+ 1 - 1
src/NTMinerBus/Bus/IPathId.cs → src/NTMinerBus/Bus/IMessagePathId.cs

@@ -2,7 +2,7 @@
 
 namespace NTMiner.Bus {
     
-    public interface IPathId {
+    public interface IMessagePathId {
         Type MessageType { get; }
         bool IsEnabled { get; set; }
         Type Location { get; }

+ 8 - 8
src/NTMinerBus/Bus/MessageDispatcher.cs

@@ -4,11 +4,11 @@
 
     public class MessageDispatcher : IMessageDispatcher {
         private readonly Dictionary<Type, List<object>> _handlers = new Dictionary<Type, List<object>>();
-        private readonly Dictionary<string, List<IPathId>> _paths = new Dictionary<string, List<IPathId>>();
+        private readonly Dictionary<string, List<IMessagePathId>> _paths = new Dictionary<string, List<IMessagePathId>>();
         private readonly object _locker = new object();
 
-        public event Action<IPathId> Connected;
-        public event Action<IPathId> Disconnected;
+        public event Action<IMessagePathId> Connected;
+        public event Action<IMessagePathId> Disconnected;
 
         #region IMessageDispatcher Members
         public void Dispatch<TMessage>(TMessage message) {
@@ -20,7 +20,7 @@
             if (_handlers.ContainsKey(messageType)) {
                 var messageHandlers = _handlers[messageType].ToArray();
                 foreach (var messageHandler in messageHandlers) {
-                    var tMessageHandler = (DelegatePath<TMessage>)messageHandler;
+                    var tMessageHandler = (MessagePath<TMessage>)messageHandler;
                     if (!tMessageHandler.IsEnabled) {
                         continue;
                     }
@@ -45,7 +45,7 @@
             }
         }
 
-        public void Connect<TMessage>(DelegatePath<TMessage> handler) {
+        public void Connect<TMessage>(MessagePath<TMessage> handler) {
             if (handler == null) {
                 throw new ArgumentNullException(nameof(handler));
             }
@@ -54,10 +54,10 @@
 
                 var handlerId = handler;
                 if (!_paths.ContainsKey(handlerId.Path)) {
-                    _paths.Add(handlerId.Path, new List<IPathId> { handlerId });
+                    _paths.Add(handlerId.Path, new List<IMessagePathId> { handlerId });
                 }
                 else {
-                    List<IPathId> handlerIds = _paths[handlerId.Path];
+                    List<IMessagePathId> handlerIds = _paths[handlerId.Path];
                     if (handlerIds.Count == 1) {
                         Write.DevWarn($"重复的路径:{handlerIds[0].Path} {handlerIds[0].Description}");
                     }
@@ -83,7 +83,7 @@
             }
         }
 
-        public void Disconnect(IPathId handlerId) {
+        public void Disconnect(IMessagePathId handlerId) {
             if (handlerId == null) {
                 return;
             }

+ 2 - 2
src/NTMinerBus/Bus/MessageDispatcherExtensions.cs

@@ -2,11 +2,11 @@
 
 namespace NTMiner.Bus {
     public static class MessageDispatcherExtensions {
-        public static DelegatePath<TMessage> Connect<TMessage>(this IMessageDispatcher dispatcher, Type location, string description, LogEnum logType, Action<TMessage> action) {
+        public static MessagePath<TMessage> Connect<TMessage>(this IMessageDispatcher dispatcher, Type location, string description, LogEnum logType, Action<TMessage> action) {
             if (action == null) {
                 throw new ArgumentNullException(nameof(action));
             }
-            DelegatePath<TMessage> handler = new DelegatePath<TMessage>(location, description, logType, action);
+            MessagePath<TMessage> handler = new MessagePath<TMessage>(location, description, logType, action);
             dispatcher.Connect(handler);
             return handler;
         }

+ 1 - 1
src/NTMinerBus/Bus/MessageHandlerExtensions.cs

@@ -3,7 +3,7 @@
 namespace NTMiner.Bus {
     public static class MessageHandlerExtensions {
 
-        public static IPathId AddToCollection(this IPathId handler, List<IPathId> handlers) {
+        public static IMessagePathId AddToCollection(this IMessagePathId handler, List<IMessagePathId> handlers) {
             if (!handlers.Contains(handler)) {
                 handlers.Add(handler);
             }

+ 2 - 2
src/NTMinerBus/Bus/DelegatePath`1.cs → src/NTMinerBus/Bus/MessagePath`1.cs

@@ -2,13 +2,13 @@
 using System.ComponentModel;
 
 namespace NTMiner.Bus {
-    public class DelegatePath<TMessage> : IPathId, INotifyPropertyChanged {
+    public class MessagePath<TMessage> : IMessagePathId, INotifyPropertyChanged {
         private readonly Action<TMessage> _path;
         private bool _isEnabled;
 
         public event PropertyChangedEventHandler PropertyChanged;
 
-        public DelegatePath(Type location, string description, LogEnum logType, Action<TMessage> path) {
+        public MessagePath(Type location, string description, LogEnum logType, Action<TMessage> path) {
             this.IsEnabled = true;
             MessageType = typeof(TMessage);
             Location = location;

+ 2 - 2
src/NTMinerBus/NTMinerBus.csproj

@@ -36,7 +36,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Bus\Cmd.cs" />
-    <Compile Include="Bus\DelegatePath`1.cs" />
+    <Compile Include="Bus\MessagePath`1.cs" />
     <Compile Include="Bus\DirectBus\DirectBus.cs" />
     <Compile Include="Bus\DirectBus\DirectCommandBus.cs" />
     <Compile Include="Bus\DirectBus\DirectEventBus.cs" />
@@ -47,7 +47,7 @@
     <Compile Include="Bus\ICmdBus.cs" />
     <Compile Include="Bus\IEvent.cs" />
     <Compile Include="Bus\IEventBus.cs" />
-    <Compile Include="Bus\IPathId.cs" />
+    <Compile Include="Bus\IMessagePathId.cs" />
     <Compile Include="Bus\IMessage.cs" />
     <Compile Include="Bus\IMessageDispatcher.cs" />
     <Compile Include="Bus\MessageDispatcher.cs" />

+ 5 - 5
src/NTMinerWpf/WindowExtension.cs

@@ -98,9 +98,9 @@ namespace NTMiner {
             if (window.Resources == null) {
                 window.Resources = new ResourceDictionary();
             }
-            List<IPathId> contextHandlers = (List<IPathId>)window.Resources["ntminer_contextHandlers"];
+            List<IMessagePathId> contextHandlers = (List<IMessagePathId>)window.Resources["ntminer_contextHandlers"];
             if (contextHandlers == null) {
-                contextHandlers = new List<IPathId>();
+                contextHandlers = new List<IMessagePathId>();
                 window.Resources.Add("ntminer_contextHandlers", contextHandlers);
                 window.Closed += UiElement_Closed;
             }
@@ -118,9 +118,9 @@ namespace NTMiner {
             if (window.Resources == null) {
                 window.Resources = new ResourceDictionary();
             }
-            List<IPathId> contextHandlers = (List<IPathId>)window.Resources["ntminer_contextHandlers"];
+            List<IMessagePathId> contextHandlers = (List<IMessagePathId>)window.Resources["ntminer_contextHandlers"];
             if (contextHandlers == null) {
-                contextHandlers = new List<IPathId>();
+                contextHandlers = new List<IMessagePathId>();
                 window.Resources.Add("ntminer_contextHandlers", contextHandlers);
                 window.Closed += UiElement_Closed; ;
             }
@@ -129,7 +129,7 @@ namespace NTMiner {
 
         private static void UiElement_Closed(object sender, EventArgs e) {
             Window uiElement = (Window)sender;
-            List<IPathId> contextHandlers = (List<IPathId>)uiElement.Resources["ntminer_contextHandlers"];
+            List<IMessagePathId> contextHandlers = (List<IMessagePathId>)uiElement.Resources["ntminer_contextHandlers"];
             foreach (var handler in contextHandlers) {
                 VirtualRoot.DeletePath(handler);
             }

+ 4 - 4
src/NTMinerlib/VirtualRoot.partials.Bus.cs

@@ -27,7 +27,7 @@ namespace NTMiner {
         }
 
         // 修建消息(命令或事件)的运动路径
-        public static DelegatePath<TMessage> CreatePath<TMessage>(string description, LogEnum logType, Action<TMessage> action) {
+        public static MessagePath<TMessage> CreatePath<TMessage>(string description, LogEnum logType, Action<TMessage> action) {
             StackTrace ss = new StackTrace(false);
             // 0是CreatePath,1是CreateCmdPath或CreateEventPath,2是当地
             Type location = ss.GetFrame(2).GetMethod().DeclaringType;
@@ -37,7 +37,7 @@ namespace NTMiner {
         /// <summary>
         /// 创建命令路径
         /// </summary>
-        public static DelegatePath<TCmd> CreateCmdPath<TCmd>(Action<TCmd> action, LogEnum logType = LogEnum.DevConsole)
+        public static MessagePath<TCmd> CreateCmdPath<TCmd>(Action<TCmd> action, LogEnum logType = LogEnum.DevConsole)
             where TCmd : ICmd {
             MessageTypeAttribute messageTypeDescription = MessageTypeAttribute.GetMessageTypeDescription(typeof(TCmd));
             string description = "处理" + messageTypeDescription.Description;
@@ -47,13 +47,13 @@ namespace NTMiner {
         /// <summary>
         /// 创建事件路径
         /// </summary>
-        public static DelegatePath<TEvent> CreateEventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action)
+        public static MessagePath<TEvent> CreateEventPath<TEvent>(string description, LogEnum logType, Action<TEvent> action)
             where TEvent : IEvent {
             return CreatePath(description, logType, action);
         }
 
         // 拆除消息(命令或事件)的运动路径
-        public static void DeletePath(IPathId handler) {
+        public static void DeletePath(IMessagePathId handler) {
             if (handler == null) {
                 return;
             }