public CoinGroupSet(INTMinerRoot root) { _root = root; Global.Access <AddCoinGroupCommand>( Guid.Parse("2dd8f7e9-c79d-4621-954f-9fc45b0207dd"), "添加币组", LogEnum.Log, action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } CoinGroupData entity = new CoinGroupData().Update(message.Input); _dicById.Add(entity.Id, entity); var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>(); repository.Add(entity); Global.Happened(new CoinGroupAddedEvent(entity)); }); Global.Access <RemoveCoinGroupCommand>( Guid.Parse("e52874f4-37d8-4d49-a637-5b95aa89367e"), "移除币组", LogEnum.Log, action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } CoinGroupData entity = _dicById[message.EntityId]; _dicById.Remove(entity.GetId()); var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>(); repository.Remove(message.EntityId); Global.Happened(new CoinGroupRemovedEvent(entity)); }); Global.Logger.InfoDebugLine(this.GetType().FullName + "接入总线"); }
public CoinGroupSet(INTMinerRoot root, bool isUseJson) { _root = root; _isUseJson = isUseJson; _root.ServerContextWindow <AddCoinGroupCommand>("添加币组", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } CoinGroupData entity = new CoinGroupData().Update(message.Input); if (ReferenceEquals(entity, message.Input)) { return; } _dicById.Add(entity.Id, entity); var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>(isUseJson); repository.Add(entity); VirtualRoot.Happened(new CoinGroupAddedEvent(entity)); }); _root.ServerContextWindow <RemoveCoinGroupCommand>("移除币组", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } CoinGroupData entity = _dicById[message.EntityId]; _dicById.Remove(entity.GetId()); var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>(isUseJson); repository.Remove(message.EntityId); VirtualRoot.Happened(new CoinGroupRemovedEvent(entity)); }); }
public CoinGroupSet(IServerContext context) { _context = context; context.AddCmdPath <AddCoinGroupCommand>("添加币组", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } CoinGroupData entity = new CoinGroupData().Update(message.Input); if (ReferenceEquals(entity, message.Input)) { return; } _dicById.Add(entity.Id, entity); var repository = context.CreateServerRepository <CoinGroupData>(); repository.Add(entity); VirtualRoot.RaiseEvent(new CoinGroupAddedEvent(message.MessageId, entity)); }, location: this.GetType()); context.AddCmdPath <RemoveCoinGroupCommand>("移除币组", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } CoinGroupData entity = _dicById[message.EntityId]; _dicById.Remove(entity.GetId()); var repository = context.CreateServerRepository <CoinGroupData>(); repository.Remove(message.EntityId); VirtualRoot.RaiseEvent(new CoinGroupRemovedEvent(message.MessageId, entity)); }, location: this.GetType()); }