/// <summary> /// Specifies the getting of exact command. /// </summary> /// <param name="command">Specifies the input text with which the command is chosen.</param> /// <param name="printer">The printer of messages for the chosen command.</param> /// <param name="gameSaver">The object for saving game state.</param> /// <returns>A command object.</returns> public IHangmanCommand GetCommand(string command, IPrinter printer, ISaveLoadManager gameSaver) { // The string command will come from a ConsoleInputParser/Reader and it will be validated there; switch (command) { case "restart": return new RestartCommand(printer); case "top": return new ShowScoreboardCommand(); case "help": return new GetHelpCommand(); case "exit": return new ExitGameCommand(printer); case "save": return new SaveCommand(gameSaver); case "load": return new LoadCommand(gameSaver, printer); case "finishGame": return new NormalGameEndCommand(printer); case "cheater": return new CheaterGameEndCommand(printer); default: return new HandleLetterCommand(command, printer); } }
/// <summary> /// Initializes a new instance of the <see cref="Scoreboard"/> class. /// </summary> /// <param name="printer">The object used to show messages.</param> /// <param name="sorter">The object used to sort scores.</param> /// <param name="scoresDataManager">The object from which scores are read and written in.</param> public Scoreboard(IPrinter printer, ISorter sorter, IDataManager<Dictionary<string, int>> scoresDataManager) { this.Score = new Dictionary<string, int>(); this.printer = printer; this.sorter = sorter; this.scoresDataManager = scoresDataManager; }
public CommandFactoryWithLazyLoading(IPhonebookRepository data, IPrinter printer, IPhoneNumberSanitizer sanitizer) { // TODO: Complete member initialization this.data = data; this.printer = printer; this.sanitizer = sanitizer; }
public Grid(IPrinter thePrinter) { printer = thePrinter; Rows = 6; Columns = 7; Cells = new States[Columns, Rows]; }
/// <summary> /// Connects and prints all paths + shortest paths using appropriate format. /// </summary> /// <param name="printerStrategy">The result printer strategy</param> public void PrintResult(IPrinter printerStrategy) { var allPaths = new List<DoubleLinkedList<int>>(); this.ConnectAllPathsDFS(this.parentNode, new DoubleLinkedList<int>(), ref allPaths); printerStrategy.PrintResult(allPaths, this.parentNode); }
public CrossAppDomainCleanUp(AppDomain toWatch, IPrinter printer) { if (toWatch == null) throw new ArgumentNullException("toWatch"); if (printer == null) throw new ArgumentNullException("printer"); (new PermissionSet(PermissionState.Unrestricted)).Assert(); var current = toWatch; AppDomainSetup adSetup = new AppDomainSetup(); adSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //#if RAZOR4 // currently not signed! var strongNames = new StrongName[0]; //#else // var strongNames = new[] { // FromAssembly(typeof(RazorEngine.Templating.RazorEngineService).Assembly), // FromAssembly(typeof(System.Web.Razor.RazorTemplateEngine).Assembly) // }; //#endif _domain = AppDomain.CreateDomain( "CleanupHelperDomain_" + Guid.NewGuid().ToString(), null, current.SetupInformation, new PermissionSet(PermissionState.Unrestricted), strongNames); var initHelper = new InitHelper() { Domain = _domain, Current = current }; _helper = ExecutionContextLessThread.DefaultCallFunc(new Func<CleanupHelper>(initHelper.CreateHelper)); }
static void Main(string[] args) { // Try to parse options from command line var options = new Options(); if (Parser.Default.ParseArguments(args, options)) { try { _collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(options.TeamCollection)); _buildServer = _collection.GetService<IBuildServer>(); _commonStructureService = _collection.GetService<ICommonStructureService>(); _printer = new TabbedPrinter(); PrintDefinitions(options); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("An error occured:"); Console.WriteLine(ex.Message); Console.WriteLine(); } } else { Console.WriteLine("Couldn't read options"); Console.WriteLine(); } }
public ChangePhoneCommand(string[] arguments, ISanitizer sanitizer, IPhonebookRepository phonebookDatabase, IPrinter printer) { this.phonebookDatabase = phonebookDatabase; this.sanitizer = sanitizer; this.arguments = arguments; this.printer = printer; }
public void Print(IPrinter printer) { for (var i = 0; i < cells.Length; i++) { printer.PrintCell(i/Width, i%Width, cells[i]); } }
public BorrowController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { if(display == null) throw new ArgumentException("Display object was not provided to begin the application"); if (reader == null) throw new ArgumentException("Reader object was not provided to begin the application"); if (scanner == null) throw new ArgumentException("Scanner object was not provided to begin the application"); if (printer == null) throw new ArgumentException("Printer object was not provided to begin the application"); if (bookDAO == null) throw new ArgumentException("BookDAO object was not provided to begin the application"); if (loanDAO == null) throw new ArgumentException("LoanDAO object was not provided to begin the application"); if (memberDAO == null) throw new ArgumentException("MemberDAO object was not provided to begin the application"); _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDAO = bookDAO; _loanDAO = loanDAO; _memberDAO = memberDAO; _ui = new BorrowControl(this); _reader.Listener = this; _scanner.Listener = this; _bookList = new List<IBook>(); _loanList = new List<ILoan>(); _state = EBorrowState.CREATED; }
private static void PrintAlbumsCountWithXPath(XmlDocument xmlDocument, string xPathQuery, IPrinter printer) { Dictionary<string, int> nodes = new Dictionary<string, int>(); var artists = xmlDocument.SelectNodes(xPathQuery); foreach (var artist in artists) { var currentNode = (XmlNode)artist; if (!nodes.ContainsKey(currentNode.InnerText)) { nodes.Add(currentNode.InnerText, 1); } else { var value = nodes[currentNode.InnerText]; nodes[currentNode.InnerText] = ++value; } } List<string> results = new List<string>(); results.Add("With XPath"); foreach (var node in nodes) { results.Add(string.Format("Artist: {0}, albums: {1}", node.Key, node.Value)); } printer.Print(results); }
/// <summary> /// Initializes a new instance of the <see cref="HangmanGame"/> class. /// Provides methods for running the game, ending the game and executing commands. /// </summary> public HangmanGame() { this.printer = new ConsolePrinter(); this.context = new GameContext(SimpleRandomWordProvider.Instance, new Scoreboard(new ConsolePrinter(), new SelectionSorter(), new TextFileScoreboardDataManager<Dictionary<string, int>>())); this.commandFactory = new CommandFactory(); this.gameSaver = new SaveLoadManager(this.printer, new XmlGameStateManager<SaveLoadManager>()); this.commandExecutioner = new HangmanCommandInvoker(); }
public GameEngine(IPrinter printer, IReader inputReader, CommandFactory commandFactory, Validator validator, Game game) { this.Scoreboard = Scoreboard.Instance; this.Printer = printer; this.InputReader = inputReader; this.CommandFactory = commandFactory; this.Validator = validator; this.Game = game; }
public BorrowControlTests() { _display = Substitute.For<IDisplay>(); _reader = Substitute.For<ICardReader>(); _scanner = Substitute.For<IScanner>(); _printer = Substitute.For<IPrinter>(); _bookDao = Substitute.For<IBookDAO>(); _loanDao = Substitute.For<ILoanDAO>(); _memberDao = Substitute.For<IMemberDAO>(); }
public static void Print(string path, IPrinter printer) { using (StreamReader reader = new StreamReader(path)) { while (!reader.EndOfStream) { printer.Print(reader.ReadLine()); } } }
public void Dispose() { _display = null; _reader = null; _scanner = null; _printer = null; _bookDao = null; _loanDao = null; _memberDao = null; }
/// <summary> /// Initializes a new instance of the BullsAndCowsGame class. /// </summary> /// <param name="randomNumberProvider">The randomNumberProvider used to generate random numbers.</param> /// <param name="scoreboard">The scoreboard used to hold player's scores.</param> /// <param name="printer">The printer used for printing messages and different objects.</param> /// <param name="commandProcessor">The first command processor in the chain of responsibility.</param> public BullsAndCowsGame( IRandomNumberProvider randomNumberProvider, ScoreBoard scoreboard, IPrinter printer, ICommandProcessor commandProcessor) { this.RandomNumberProvider = randomNumberProvider; this.ScoreBoard = scoreboard; this.Printer = printer; this.CommandProcessor = commandProcessor; }
public bool InitializePrinter(PrinterParameter parameter) { if (printer != null) { printer.Dispose(); } printer = PrinterFactory.CreateInstance(parameter); return true; }
/// <summary> /// Initializes a new instance of the <see cref="Game" /> class. /// </summary> public Game() { this.engine = new Engine(); this.menuPrinter = new MenuPrinter(); this.playfieldPrinter = new PlayfieldPrinter(); this.messagePrinter = new MessagePrinter(); this.scoreboardPrinter = new ScoreboardPrinter(); this.reader = new Reader(); this.colors = new BalloonColor(); this.statistics = new OrderedMultiDictionary<int, string>(true); }
public Scenario04CompleteScans() { _bookDao = new BookDao(new BookHelper()); _loanDao = new LoanDao(new LoanHelper()); _memberDao = new MemberDao(new MemberHelper()); _display = new MainWindow(); _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); }
public Scenario02SwipeBorrowerCard() { _bookDao = new BookDao(new BookHelper()); _loanDao = new LoanDao(new LoanHelper()); _memberDao = new MemberDao(new MemberHelper()); _display = new MainWindow(); _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); }
public BorrowControlIntegration() { _bookDao = new BookDao(new BookHelper()); _loanDao = new LoanDao(new LoanHelper()); _memberDao = new MemberDao(new MemberHelper()); _display = new MainWindow(); _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); }
public MainMenuController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDAO = bookDAO; _loanDAO = loanDAO; _memberDAO = memberDAO; }
public BorrowController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { _display = display; _reader = reader; _scanner = scanner; _printer = printer; _ui = new BorrowControl(this); _state = EBorrowState.CREATED; }
private static void PrintAlbumsCount(XmlElement root, IPrinter printer) { var albums = GetUniqueNodes(root, "artist"); List<string> results = new List<string>(); foreach (var album in albums) { var albumCount = GetAlbumsCount(album["artist"].InnerText, root); results.Add(string.Format("Artist: {0}, albums: {1}", album["artist"].InnerText, albumCount)); } printer.Print(results); }
public MainMenuController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDao, ILoanDAO loanDao, IMemberDAO memberDao, ICardReaderEvents cardReaderEvents) { CardReaderEvents = cardReaderEvents; _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDao = bookDao; _loanDao = loanDao; _memberDao = memberDao; }
public TimeAndMemory(bool diagnosticModeOn, IPrinter printer) { _diagnosticModeOn = diagnosticModeOn; _printer = printer; if (!_diagnosticModeOn) return; _cpuTimeBegin = GetCpuTimeTicks(); _sw = Stopwatch.StartNew(); DoFullCollect(); _heapSizeStart = GC.GetTotalMemory(false); _privateBytesStart = Process.GetCurrentProcess().PrivateMemorySize64; }
public SuperMegaPrinterMachine( IPrinter printer, IScan scanner, IStaple stapler, IFax fax, ICopy copier) { _printer = printer; _scanner = scanner; _stapler = stapler; _fax = fax; _copier = copier; }
/// <summary> /// Initializes a new instance of the <see cref="CommonPrinter"/> class. /// </summary> /// <param name="print">The print.</param> public CommonPrinter(IPrinter print) { this.printer = print; this.InitPrint(); this.printDocument1.DocumentName = print.GetDocName(); printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController(); //this.printDocument1.DocumentName = ""; this.printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(100, 100, 100, 100); // // printDocument1 // printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage); }
public Spinner(List<IController> controller, SheetMap map, IConnectionInfo connectionInfo, IPrinter printer, IForm form) { _mainForm = form; _connectionInfo = connectionInfo; _controllers = controller; _map = map; _printer = printer; _controllers.ForEach( ctrl => ctrl.SheetRequest.Subscribe( wnd => CurrentController = _controllers.FirstOrDefault(_map.GetControllerPredicate(wnd)))); _controllers.ForEach(ctrl => WireUpModels(ctrl.GetCoreEventModel())); }
public Log(IPrinter p) { printer = p; }
public Story(IPrinter printer, string introduction) : this(printer, introduction, "To be defined", "To be continued") { }
public Story(IPrinter printer, string introduction, string main) : this(printer, introduction, main, "To be continued") { }
public static void SetDoubleFont(this IPrinter printer) => printer.SetFont(FontMode.DoubleWidth | FontMode.DoubleHeight);
public static void SetFontA(this IPrinter printer) => printer.SetFont();
public BreadthFirstSearch(Map map, IPrinter printer) : base(map, printer) { }
public Task1(ILogger <Task1> logger, IPrinter printer, MatrixParallel matrixParallel) { _logger = logger; _printer = printer; _matrixParallel = matrixParallel; }
private static void PrintWith(IPrinter printer) { printer.Print(); }
// Advantages of using custom middleware is that we can utilize the DI framework to implement complex logic // in different classes instead of implement them all in one place /// <summary> /// /// </summary> /// <param name="next"></param> /// <param name="myPrinter"></param> public CustomMiddleware(RequestDelegate next, IPrinter myPrinter) { _next = next; _myPrinter = myPrinter; }
public MultiFunctionMachine(IPrinter printer, IScanner scanner) { this.printer = printer ?? throw new ArgumentNullException(paramName: nameof(printer)); this.scanner = scanner ?? throw new ArgumentNullException(paramName: nameof(scanner)); }
public ASTPrinter(IPrinter printer) { _printer = printer; }
public void SetUp() { _printer = Substitute.For <IPrinter>(); _uut = new ReceiptController(_printer); }
public ChengerMoney() { _accountMenager = new AccountMenager(); _printer = new Printer(); }
public static void SetUnderlineFont(this IPrinter printer) => printer.SetFont(FontMode.Underline);
public DirectPrinter(ICommandEmitter emitter, IPrinter printer) { this.Emitter = emitter; this.Printer = printer; }
public Log(IPrinter p) : base(p) { }
// Constructor with dependency injection public PrintController(IPrinter printer) { _printer = printer; }
public MultiFunctionMachine(IPrinter printer, IScanner scanner) { _printer = printer; _scanner = scanner; }
public Task Execute(IPrinter printer, CancellationToken cancellationToken = default(CancellationToken)) { return(printer.PenUp()); }
public static void SetFontB(this IPrinter printer) => printer.SetFont(FontMode.FontB);
public Task1(IPrinter printer, ILogger <Task1> logger, IFileReader excelReader) { _printer = printer; _logger = logger; this.excelReader = excelReader; }
public static void SetEmphasizedFont(this IPrinter printer) => printer.SetFont(FontMode.Emphasized);
public Logger(IPrinter sourse) { Sourse = sourse; }
public Statistic(IPrinter printer) { this.printer = printer; }
public BankManager() { _accountsManager = new AccountsManager(); _printer = new Printer(); }
public Story(IPrinter printer) : this(printer, "Introduction to place here", "To be defined", "To be continued") { }
public void TurnOffBluetooth() { _Manager.Disconnect(); _Manager = null; _Mydevice = null; }
public override void doPrintSetup(IPageLayout2 pPageLayout) { CSpatialSubs oSpatialSubs = new CSpatialSubs(); //short shPageForm = 0; // see ms-help://ESRI.EDNv9.2/esricarto/html/esriPageFormID.htm for IPrinter::FormID constants int iPageFormID = 0; // see http://msdn.microsoft.com/en-us/library/ms776398(VS.85).aspx for IPaper::FormID constants //double dblPageWidth = 0; //double dblPageHeight = 0; IMxApplication pMxApp = (IMxApplication)this.App; IMxDocument pMxDoc = (IMxDocument)this.App.Document; IPrinter pPrinter = pMxApp.Printer; IPaper pPaper = pPrinter.Paper; try { pMxDoc.PageLayout.Page.Orientation = 1; pPaper.Orientation = 1; switch (this.MapSize) { case "34 x 44": //shPageForm = 5; // esriPageFormID.esriPageFormE; base.XFactor = 4; base.YFactor = 4; if (pPrinter.DriverName.ToUpper().Contains("DESIGNJET")) { iPageFormID = oSpatialSubs.getPaperFormID(pPaper, "34 x 44"); } else { iPageFormID = 26; } break; case "17 x 22": //shPageForm = 3; // esriPageFormID.esriPageFormC; base.XFactor = 2; base.YFactor = 2; if (pPrinter.DriverName.ToUpper().Contains("DESIGNJET")) { iPageFormID = oSpatialSubs.getPaperFormID(pPaper, "17 x 22"); } else { iPageFormID = 24; } break; case "11 x 17": //shPageForm = 2; // esriPageFormID.esriPageFormTabloid; base.XFactor = 1.3; //1.2941 base.YFactor = 1.5455; //1.5455 if (pPrinter.DriverName.ToUpper().Contains("DESIGNJET")) { iPageFormID = oSpatialSubs.getPaperFormID(pPaper, "11 x 17"); } else { iPageFormID = 17; } break; case "8.5 x 11": //shPageForm = 0; // esriPageFormID.esriPageFormLetter; base.XFactor = 1; base.YFactor = 1; if (pPrinter.DriverName.ToUpper().Contains("DESIGNJET")) { iPageFormID = oSpatialSubs.getPaperFormID(pPaper, "8.5 x 11 "); } else { iPageFormID = 1; } break; } pPaper.PrinterName = base.PrinterName; pPaper.FormID = (short)iPageFormID; double dblWidth = 0; double dblHeight = 0; pPaper.QueryPaperSize(out dblWidth, out dblHeight); pMxDoc.PageLayout.Page.PutCustomSize(dblWidth, dblHeight); pMxDoc.PageLayout.Page.FormID = (esriPageFormID)Enum.Parse(typeof(esriPageFormID), iPageFormID.ToString()); pMxDoc.ActiveView.PrinterChanged(pPrinter); //////---------------------------------------------------------------------------- //////Set the layout page size and orientation. //////---------------------------------------------------------------------------- //pPage = pMxDoc.PageLayout.Page; //pPage.Orientation = 1; //pPage.FormID = (esriPageFormID)Enum.Parse(typeof(esriPageFormID), iPageFormID.ToString()); ////---------------------------------------------------------------------------- ////Set the printer paper size and orientation. ////---------------------------------------------------------------------------- //pPrinter = pMxApp.Printer; //pPrinter.Paper.PrinterName = base.PrinterName; //pPrinter.Paper.FormID = shPageForm; //pPrinter.Paper.Orientation = 1; ////---------------------------------------------------------------------------- //// deal with the paper ////---------------------------------------------------------------------------- //pPaper = pMxApp.Paper; //pPaper.Orientation = 1; //pPaper.FormID = (short)iPageFormID; //pPaper.PrinterName = base.PrinterName; //pMxDoc.ActiveView.PrinterChanged(pPrinter); ////////---------------------------------------------------------------------------- ////////Set the layout page size and orientation. ////////---------------------------------------------------------------------------- ////pPage = pMxDoc.PageLayout.Page; ////pPage.Orientation = 1; ////pPage.FormID = esriPageFormID.esriPageFormCUSTOM; ////pPage.PutCustomSize(dblPageWidth + .1, dblPageHeight + .1); ////pPage.PrinterChanged(pPrinter); ////double dblWidth = 0; double dblHeight = 0; ////pPaper.QueryPaperSize(out dblWidth, out dblHeight); ////pPage.PutCustomSize(dblWidth, dblHeight); //(dblWidth, dblHeight); ////pPage.FormID = esriPageFormID.esriPageFormCUSTOM; ////pPage.PrinterChanged(pPrinter); ////pPage.PutCustomSize(dblWidth, dblHeight); ////pPage.PageToPrinterMapping = esriPageToPrinterMapping.esriPageMappingTile; //pMxApp.Printer = pPrinter; ////pMxDoc.PageLayout = (IPageLayout)pPage; //pMxDoc.PageLayout.Page.PutCustomSize(dblPageWidth - 1.8, dblPageHeight - 1.8); //pMxDoc.PageLayout.Page.FormID = esriPageFormID.esriPageFormSameAsPrinter; //pMxDoc.ActiveView.PrinterChanged(pPrinter); //pActiveView = (IActiveView)pMxDoc.ActiveView; //pActiveView.Refresh(); //pMxApp.Printer.Paper.PrinterName = base.PrinterName; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Errors: CPortraitLayout:doPrintSetup()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } finally { pMxDoc = null; pPrinter = null; pPaper = null; oSpatialSubs.Dispose(); } }
public static void SetDoubleWidthFont(this IPrinter printer) => printer.SetFont(FontMode.DoubleWidth);
void OnConnect(IPrinter printer) { _Mydevice = printer; }