internal WeixinToolkitSettings(WeixinExtraXml xml, BaseAppSetting appsetting) { fCurrent = this; fEngine = new MessageEngine(); if (xml.Weixin.Normal != null) { fNormalDefault = new DefaultEngine(xml.Weixin.Normal.DefaultMessage); fAuthConfig = new WeixinAuthConfig(); string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\Auth.xml"); if (File.Exists(authFileName)) fAuthConfig.ReadXmlFromFile(authFileName); } else if (xml.Weixin.CorpApps != null) { fCorpDefault = new Dictionary<int, DefaultEngine>(); foreach (var item in xml.Weixin.CorpApps) fCorpDefault.Add(item.AppId, new DefaultEngine(item.DefaultMessage)); fCorpAuthConfig = new WeixinCorpAuthConfig(); string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\CorpAuth.xml"); if (File.Exists(authFileName)) fCorpAuthConfig.ReadXmlFromFile(authFileName); } else TkDebug.ThrowImpossibleCode(this); if (xml.Weixin.MessageLog != null) fLog = xml.Weixin.MessageLog.CreateObject(); }
private void MoveTo(Slot destination, Direction direction, IMessageLog log) { if (Position == destination) return; if (destination.Empty) { UpdateStateForValidMove(destination, log); return; } else { // Is the move blocked by another player? if (destination.Player != null) return; // Is the move blocked by a piece we don't control? if (destination.Piece.Owner != this) return; var pushSlot = Game.Board.GetSlotForDirection(destination, direction); // Is the push blocked by something behind it? if (pushSlot.Empty == false) return; Game.Board.MovePieceToSlot(destination, pushSlot, log); UpdateStateForValidMove(destination, log); } }
#pragma warning restore IDE0052 // Remove unread private members /// <summary> /// Initializes a new instance of the <see cref="MllpServer"/> class. /// </summary> /// <param name="endPoint">The <see cref="IPEndPoint"/> the server will listen on.</param> /// <param name="messageLog">The <see cref="IMessageLog"/> to use for logging incoming messages.</param> /// <param name="middleware">The message handling middleware.</param> /// <param name="cleanupInterval">The interval between cleaning up client connections.</param> /// <param name="parser">The <see cref="PipeParser"/> to use for parsing and encoding.</param> /// <param name="encoding">The <see cref="Encoding"/> to use for network transfers.</param> /// <param name="serverCertificate">The certificates to use for secure connections.</param> /// <param name="userCertificateValidationCallback">Optional certificate validation callback.</param> public MllpServer( IPEndPoint endPoint, IMessageLog messageLog, IHl7MessageMiddleware middleware, TimeSpan cleanupInterval = default, PipeParser?parser = null, Encoding?encoding = null, X509Certificate?serverCertificate = null, RemoteCertificateValidationCallback?userCertificateValidationCallback = null) { _messageLog = messageLog; _middleware = middleware; _parser = parser; _encoding = encoding ?? Encoding.ASCII; _serverCertificate = serverCertificate; _userCertificateValidationCallback = userCertificateValidationCallback; _listener = new TcpListener(endPoint); cleanupInterval = cleanupInterval == default ? TimeSpan.FromSeconds(5) : cleanupInterval; _timer = new Timer( CleanConnections, null, cleanupInterval, cleanupInterval); }
/// <summary> /// Imports users and groups from active directory. /// </summary> /// <param name="provider">IPrincipalProvider</param> /// <param name="messageLog">Provides message logging</param> public static void Import(IPrincipalProvider provider, IMessageLog messageLog) { AutoResetEvent importFinished = new AutoResetEvent(false); ImportAsync(provider, messageLog, (sender, e) => importFinished.Set()); importFinished.WaitOne(); }
private void AddSaveOpenFile(IMessageLog obj, string message, string name, string comment) { Console.WriteLine(); obj.AddMessage(message); obj.AddComment(message, name, comment); obj.OutputToFile(); Console.WriteLine("Log saved to file"); }
private void NewGame() { string playerName = "SCiENiDE"; // Create the Map. this.testMap = new Map <ITile>( Framework.Tools.GenerateMap(new Point(30, 30)), 0, "Testing Grounds"); this.testMap.ViewBoxTileCount = new Point(24, 15); // Create the Message Log. Rectangle logRect = new Rectangle( 0, this.testMap.ViewBoxTileCount.Y * Sprite.TileSize, this.testMap.ViewBoxTileCount.X * Sprite.TileSize, (ScreenHeight - 30) - this.testMap.ViewBoxTileCount.Y * Sprite.TileSize); this.messageLog = new MessageLog(logRect, this.testFont); // Create the player Actor. this.playerActor = new Actor( 0, playerName, 0, 11, Sprite.Player.HumanM, Flags.IsPlayerControl); (this.playerActor as SoundSourceObject).SoundReceiver = this.messageLog; this.actorQueue.Add(playerActor); bool outerBreak = false; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { if (!testMap[x, y].Flags.HasFlag(Flags.IsBlocked)) { playerActor.Spawn(this.testMap, new Point(x, y)); outerBreak = true; break; } } if (outerBreak) { break; } } // Indicate that we are currently in game. inGame = true; }
public override void Execute(Game game, IMessageLog log) { log.StartGame(game); for (int i = 0; i < game.Players.Count; i++) { var player = game.Players[i]; player.JumpTo(game.Board.StartingPositions[i]); log.AddPlayer(player); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Font for ASCII graphics this.asciiGraphicsFont = this.Content.Load <SpriteFont>("Fonts/BPmono40Bold"); this.logFont = this.Content.Load <SpriteFont>("Fonts/Consolas12"); #region Temporary code // Create a map to use for (test) playground. this.testMap = new MapContainer( MapUtilities.GenerateRandomMap(20, 20, VisualMode.ASCII)); this.testMap.LoadTileNeighboors(); // The Actor queue (for the turn system) specific to this map. this.queueHelper = new ActorQueueHelper(this.testMap); // Initialize VisualEngine for the game this.visualEngine = new VisualEngine( VisualMode.ASCII, 32, 16, 11, this.testMap, null, this.asciiGraphicsFont); this.visualEngine.DeltaTileDrawCoordinates = new Point(4, -6); this.visualEngine.ASCIIScale = 0.7f; // Initialize MessageLog. Rectangle logRect = new Rectangle( 0, this.visualEngine.MapDrawboxTileSize.Y * this.visualEngine.TileSize, ScreenWidth - 30, (ScreenHeight - 30) - (this.visualEngine.MapDrawboxTileSize.Y * this.visualEngine.TileSize)); this.messageLog = new MessageLog(logRect, this.logFont); // Create an actor (unit, character, etc.) for the player. this.actor = new Actor( "SCiENiDE", "@", new PropertyBag <int>(), this.testMap, Flags.IsPlayerControl, 85, Species.Human); //// TODO: Improve actor spawn/add to actorQueue. // "Spawn" the actor on the map, and add him to the map actor list. this.actor.Position = new Point(); this.queueHelper.AddActor(this.actor); #endregion }
#pragma warning restore IDE0052 // Remove unread private members private MllpHost( TcpClient client, IMessageLog messageLog, PipeParser parser, Encoding encoding, IHl7MessageMiddleware middleware) { _client = client; _messageLog = messageLog; _parser = parser; _encoding = encoding; _middleware = middleware; }
public void Tick(int ticks, IMessageLog log) { if (ticks % updateInterval == 0) { counter++; if (counter >= board.Width + board.Height) { counter = 0; } clearingRule.Apply(this, log); log.UpdateSweep(this); } }
public void MovePieceToSlot(Slot origin, Slot destination, IMessageLog log) { if (origin.Piece == null) { throw new InvalidOperationException("Cannot move piece because the origin slot is empty"); } destination.Piece = origin.Piece; origin.Piece = null; if (log != null) { log.MovePiece(origin, destination); } }
private void UpdateStateForValidMove(Slot destination, IMessageLog log = null) { if (Position != null) { Position.Player = null; } Position = destination; destination.Player = this; if (log != null) { log.MovePlayer(this, destination); } }
public RegexPreprocessor(IMessageLog messageHandler) { this.messageLog = messageHandler; this.predefined = new List<string>(); //this.defCol = new DefineCollectionNew(); this.reserved = new List<string>(); this.uniters = new Dictionary<char, char>(); this.macroSeparators = new List<char>(); this.parameterSeparators = new List<char>(); uniters['"'] = '"'; parameterSeparators.AddRange(" \t"); uniters['('] = ')'; uniters['['] = ']'; macroSeparators.Add(','); comments = new Regex(@"(//.*)|(/\*((.|\n)*?)\*/)", RegexOptions.Compiled | RegexOptions.Multiline); }
public RegexPreprocessor(IMessageLog messageHandler) { this.messageLog = messageHandler; this.predefined = new List <string>(); //this.defCol = new DefineCollectionNew(); this.reserved = new List <string>(); this.uniters = new Dictionary <char, char>(); this.macroSeparators = new List <char>(); this.parameterSeparators = new List <char>(); uniters['"'] = '"'; parameterSeparators.AddRange(" \t"); uniters['('] = ')'; uniters['['] = ']'; macroSeparators.Add(','); comments = new Regex(@"(//.*)|(/\*((.|\n)*?)\*/)", RegexOptions.Compiled | RegexOptions.Multiline); }
internal void Tick(IMessageLog log) { ticks++; sweep.Tick(ticks, log); if (ticks % 30 == 0) { foreach (var player in Players) { var slot = Board.AddNewPieceAtRandomEmptySlot(player); if (slot != null) { log.AddPiece(slot); } } } }
#pragma warning restore IDE0052 // Remove unread private members private MllpClient( string address, int port, IMessageLog messageLog, PipeParser parser, Encoding encoding, X509CertificateCollection?clientCertificates, RemoteCertificateValidationCallback? userCertificateValidationCallback) { _address = address; _port = port; _messageLog = messageLog; _parser = parser; _encoding = encoding; _clientCertificates = clientCertificates; _userCertificateValidationCallback = userCertificateValidationCallback; }
internal WeixinToolkitSettings(WeixinExtraXml xml, BaseAppSetting appsetting) { fCurrent = this; fEngine = new MessageEngine(); if (xml.Weixin.Normal != null) { fNormalDefault = new DefaultEngine(xml.Weixin.Normal.DefaultMessage); fAuthConfig = new WeixinAuthConfig(); string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\Auth.xml"); if (File.Exists(authFileName)) { fAuthConfig.ReadXmlFromFile(authFileName); } } else if (xml.Weixin.CorpApps != null) { fCorpDefault = new Dictionary <int, DefaultEngine>(); foreach (var item in xml.Weixin.CorpApps) { fCorpDefault.Add(item.AppId, new DefaultEngine(item.DefaultMessage)); } fCorpAuthConfig = new WeixinCorpAuthConfig(); string authFileName = Path.Combine(appsetting.XmlPath, @"Weixin\CorpAuth.xml"); if (File.Exists(authFileName)) { fCorpAuthConfig.ReadXmlFromFile(authFileName); } } else { TkDebug.ThrowImpossibleCode(this); } if (xml.Weixin.MessageLog != null) { fLog = xml.Weixin.MessageLog.CreateObject(); } }
public static async Task <MllpHost> Create( TcpClient tcpClient, IMessageLog messageLog, IHl7MessageMiddleware middleware, PipeParser?parser = null, Encoding?encoding = null, X509Certificate?serverCertificate = null, RemoteCertificateValidationCallback? userCertificateValidationCallback = null) { var host = new MllpHost( tcpClient, messageLog, parser ?? new PipeParser(), encoding ?? Encoding.ASCII, middleware); Stream stream = tcpClient.GetStream(); if (serverCertificate != null) { var ssl = new SslStream( stream, false, userCertificateValidationCallback); await ssl.AuthenticateAsServerAsync( serverCertificate, true, SslProtocols.Tls11 | SslProtocols.Tls12, false) .ConfigureAwait(false); host._stream = ssl; } else { host._stream = stream; } host._readThread = host.ReadStream(host._tokenSource.Token); return(host); }
private void MoveTo(Slot destination, Direction direction, IMessageLog log) { if (Position == destination) { return; } if (destination.Empty) { UpdateStateForValidMove(destination, log); return; } else { // Is the move blocked by another player? if (destination.Player != null) { return; } // Is the move blocked by a piece we don't control? if (destination.Piece.Owner != this) { return; } var pushSlot = Game.Board.GetSlotForDirection(destination, direction); // Is the push blocked by something behind it? if (pushSlot.Empty == false) { return; } Game.Board.MovePieceToSlot(destination, pushSlot, log); UpdateStateForValidMove(destination, log); } }
/// <summary> /// Imports users and groups from active directory. /// </summary> /// <param name="provider">IPrincipalProvider</param> /// <param name="messageLog">Provides message logging</param> /// <param name="workerCompleted">Action to perform on worker completed.</param> public static void ImportAsync(IPrincipalProvider provider, IMessageLog messageLog, RunWorkerCompletedEventHandler workerCompleted = null) { if (!ImportWorker.IsBusy) { // Set AD provider PrincipalProvider = provider; // Set message logs MessageLog = messageLog; if (ImportProfile.LogImportProcess) { MessageLog = new FileMessageLog(MessageLog, Path.GetDirectoryName(ImportProfile.LogPath), Path.GetFileName(ImportProfile.LogPath)); } // Run import if (workerCompleted != null) { ImportWorker.RunWorkerCompleted += workerCompleted; } ImportWorker.RunWorkerAsync(); } }
public Preprocessor(IMessageLog messageHandler, string[] predefined) { this.messageHandler = messageHandler; this.predefined = new List <string>(); this.predefined.AddRange(predefined); }
public MandrillSend(IMessageLog log, IConfigService configReader, BlobService blob) { _log = log; _configReader = configReader; _blob = blob; }
public abstract void Execute(Game game, IMessageLog log);
public override void Execute(Game game, IMessageLog log) { this.Player.Move(Direction, log); }
public JsonExceptionMiddleware(IMessageLog log) { _log = log; }
public void Move(Direction direction, IMessageLog log = null) { var slot = Game.Board.GetSlotForDirection(this.Position, direction); MoveTo(slot, direction, log); }
private void UpdateStateForValidMove(Slot destination, IMessageLog log = null) { if (Position != null) Position.Player = null; Position = destination; destination.Player = this; if(log != null) log.MovePlayer(this, destination); }
public void MovePieceToSlot(Slot origin, Slot destination, IMessageLog log) { if (origin.Piece == null) throw new InvalidOperationException("Cannot move piece because the origin slot is empty"); destination.Piece = origin.Piece; origin.Piece = null; if(log != null) log.MovePiece(origin, destination); }
internal void Tick(IMessageLog log) { ticks++; sweep.Tick(ticks, log); if (ticks % 30 == 0) { foreach (var player in Players) { var slot = Board.AddNewPieceAtRandomEmptySlot(player); if (slot != null) log.AddPiece(slot); } } }
public override void Execute(Game game, IMessageLog log) { game.RemovePlayer(player, log); }
public override void Execute(Game game, IMessageLog log) { game.Tick(log); }
public OldPreprocessor(IMessageLog messageHandler, string[] predefined) { this.messageHandler = messageHandler; this.predefined = new List<string>(); this.predefined.AddRange(predefined); }
public MessageLogControllerTests() { messageLog = A.Fake <IMessageLog>(); controller = new MessageLogController(messageLog); }
public static void SendError(this IMessageLog messageLog, Opcode opcode, int address, string format, params object[] args) { messageLog.SendError(opcode, address, string.Format(format, args)); }
public void Tick(int ticks, IMessageLog log) { if (ticks % updateInterval == 0) { counter++; if (counter >= board.Width + board.Height) counter = 0; clearingRule.Apply(this, log); log.UpdateSweep(this); } }
public static void SendWarning(this IMessageLog messageLog, string format, params object[] args) { messageLog.SendWarning(string.Format(format, args)); }
public void Apply(Sweep sweep, IMessageLog log) { List<Slot> slotsToClear = new List<Slot>(); Tuple<Slot, Slot> bounds = sweep.Bounds; IEnumerable<Slot> searchSet = null; if (bounds.Item1.X == bounds.Item2.X) searchSet = game.Board.Column(bounds.Item1.X); else searchSet = game.Board.Row(bounds.Item1.Y); List<Slot> currentRun = new List<Slot>(); foreach (var slot in searchSet) { if (slot.Piece == null) { if (currentRun.Count >= Target) slotsToClear.AddRange(currentRun); currentRun.Clear(); } else { if (currentRun.Count > 0 && currentRun.First().Piece.Owner != slot.Piece.Owner) { if (currentRun.Count >= Target) slotsToClear.AddRange(currentRun); currentRun.Clear(); } currentRun.Add(slot); } } if (currentRun.Count >= Target) slotsToClear.AddRange(currentRun); foreach (var slot in slotsToClear) { log.RemovePiece(slot); slot.Piece.Owner.Score++; slot.Piece = null; } if(slotsToClear.Count > 0) log.UpdateScores(game); }
/// <summary> /// Default constructor. /// </summary> /// <param name="messageLog">Logging provider</param> protected AbstractMessageLog(IMessageLog messageLog) { MessageLog = messageLog; }
public void RemovePlayer(Player player, IMessageLog log) { Board.RemovePlayerAndPieces(player); log.RemovePlayer(player); Players.Remove(player); }
public MessageLogController(IMessageLog messageLog) { this.messageLog = messageLog; }