public DocumentRepository(IMongoClient client) { _client = client; _logger = ConsoleFactory.CreateLogger(); _db = _client.GetDatabase(database); }
public DocumentController() { _logger = ConsoleFactory.CreateLogger(); //Want to prevent hardcoding of the mongoClient IP. //mongodb://localhost:27017/ _documentRepo = new DocumentRepository(new MongoClient("mongodb://localhost:27017")); }
//private List<User> _currentUsers = null; public VkAnalyser() { InitializeComponent(); //chartTest(); _cityDiag.Visible = false; _sexDiag.Visible = false; _peopleIdRb.Checked = true; _groupIdRb.Checked = false; _console = ConsoleFactory.getConsolePresenter(_consoleTb, this, ConsoleType.TextBox); }
public void Create() { ConsoleFactory factory = new ConsoleFactory(); iOutputStream stream = factory.Create(); Assert.IsNotNull(stream); stream.Standard("test"); stream.Error("test"); }
/// <summary> /// First string (tests[0]) Values: /// Total Words: 14 /// Total Characters: 89 /// Character count(minus line returns and spaces): 60 /// Most used word: the(2 times) /// Most used character: e(10 times) /// /// Second string (tests[1]) Values: /// Total Words: 45 /// Total Characters: 276 /// Character count(minus line returns and spaces): 230 /// Most used word: the(6 times) /// Most used character: t(24 times) /// </summary> private static void Process(string[] sentences) { foreach (var sentence in sentences) { DataProcessor.DisplayTotalWords(sentence); DataProcessor.DisplayTotalCharacters(sentence); DataProcessor.DisplayCharacterCount(sentence); DataProcessor.DisplayMostUsedWord(sentence); DataProcessor.DisplayMostUsedCharacters(sentence); ConsoleFactory.Log(""); } }
private static void Main(string[] args) { LogFactory.ForceConsoleMode = true; _log = LogFactory.Instance.GetLogger(typeof(Startup)); if (args.Length >= 1 && args.Any(a => a == "-d")) { IConsole console = ConsoleFactory.GetConsole(); console.StartAndWait(); } else if (args.Length >= 1 && args.Any(a => a == "-s")) { IConsole console = ConsoleFactory.GetConsole(); console.Stop(); } else { Manager m; try { m = new Manager(); m.Start(); } catch (Exception e) { _log.Submit(LogLevel.Fatal, "An error occurred when starting server!"); _log.SubmitException(e); return; } _log.Submit(LogLevel.Info, new string('-', 70)); _log.Submit(LogLevel.Info, "Nugetory started! Press [ENTER] to stop..."); _log.Submit(LogLevel.Info, new string('-', 70)); System.Console.ReadLine(); m.Stop(); } }
private static void Main(string[] args) { ConsoleFactory factory = new ConsoleFactory(); //Model contruction XmasModel model = factory.ConstructModel(new TestWorld1()); //View construction ThreadSafeEventManager evtman1 = new ThreadSafeEventManager(); ConsoleView view1 = new ConsoleView(model,new Point(0,0), new ConsoleWorldView((TileWorld)model.World,xe => xe is GrabberAgent), new ConsoleViewFactory(evtman1), evtman1); ThreadSafeEventManager evtman2 = new ThreadSafeEventManager(); ConsoleView view2 = new ConsoleView(model, new Point(0,24), new ConsoleWorldView((TileWorld)model.World), new ConsoleViewFactory(evtman2), evtman2); StreamWriter sw = File.CreateText("error.log"); List<XmasView> views = new List<XmasView>(); var loggerevtman = new ThreadSafeEventManager(); var logger = new Logger(sw, DebugLevel.Timing); views.Add(new ConsoleLoggerView(model,new LoggerViewFactory(loggerevtman,logger),loggerevtman,logger)); views.Add(view1); views.Add(view2); //Controller construction var listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 44444); var eisConverter = new ConsoleEisConversionTool(); var iilParser = new ConsoleIilActionParser(); var eisserver = new EISAgentServer(listener, eisConverter, iilParser); var humancontroller = new HumanInterfaceManager(new KeyboardSettings()); List<XmasController> controllers = new List<XmasController>(); controllers.Add(eisserver); controllers.Add(humancontroller); var engine = new XmasEngineManager(factory); engine.StartEngine(model,views,controllers); }
/// <summary> /// The main entry point for the example. /// </summary> /// <param name="pArgs">The arguments from the command line.</param> private static void Main(string[] pArgs) { WriteGreeting(); CliOptions options = CliOptions.WindowsStyle; List <Description> descs = DescriptionFactory.Create( options, new HelpResource(Help.ResourceManager), "/echo [/mode:string#] /address:string /database:string /username:string [/password:string] filename [output:string]" ); ConsoleFactory consoleFactory = new ConsoleFactory(); if (pArgs.Length == 0) { OutputHelp outputHelp = new OutputHelp(options, consoleFactory.Create()); outputHelp.Show(descs); return; } Request request = RequestFactory.Create(options, pArgs, descs, consoleFactory); }
private static void Main() { Process(DataFactory.GetSentences()); ConsoleFactory.EndApplication(); }
public StorageController() { _logger = ConsoleFactory.CreateLogger(); //Want to prevent hardcoding of the mongoClient IP. _dataStoreRepo = new StorageRepository(new MongoClient("mongodb://localhost:27017/")); }
/// <summary> /// Entry /// </summary> /// <param name="pArgs">The arguments from the command line.</param> private static void Main(string[] pArgs) { ConsoleFactory consoleFactory = new ConsoleFactory(); iOutputStream outS = consoleFactory.Create(); WriteGreeting(outS); CliOptions options = CliOptions.WindowsStyle; List <Description> descs = DescriptionFactory.Create( options, new HelpResource(Help.ResourceManager), "[/domains:string] [/limit:int] [/count] [/sort:string] [/desc] [/max:int] [/min:int] pattern" ); if (pArgs.Length == 0) { OutputHelp outputHelp = new OutputHelp(options, consoleFactory.Create()); outputHelp.Show(descs); return; } Request req = RequestFactory.Create(options, pArgs, descs, consoleFactory); if (!req.Valid) { return; } string pattern = req.Get <string>("pattern"); outS.Standard(pattern); outS.Standard(""); int max = req.Contains("max") ? Math.Min(req.Get <int>("max"), _MAX_LENGTH) :_MAX_LENGTH; int min = req.Contains("min") ? Math.Max(req.Get <int>("min"), 1) : 1; IEnumerable <string> domains = (from topLevel in getTopLevel(req) from domain in getPattern(req) where !domain.StartsWith("-") && !domain.EndsWith("-") && domain.Length <= max && domain.Length >= min let str = string.Format("{0}.{1}", domain, topLevel) where str.Length <= _MAX_LENGTH && !AnyLabelTooLong(domain, 63) select str).Distinct(); if (req.Contains("count")) { outS.Standard(domains.Count().ToString(CultureInfo.InvariantCulture)); return; } if (req.Contains("sort")) { string sort = req.Get <string>("sort").ToLower(); domains = sort == "width" ? domains.OrderBy(pDomain => pDomain.Length) : domains.OrderBy(pDomain => pDomain); if (req.Contains("desc")) { domains = domains.Reverse(); } } foreach (string domain in setLimit(req, domains)) { if (isFree(domain)) { outS.Standard(domain); } } }
public static void Main(string[] args) { var configFilepath = args[0]; var password = args[1]; // config var nodeConfig = ConfigDeserializer.Deserialize <NodeConfig>(configFilepath); var console = ConsoleFactory.Build(nodeConfig.IsMiningNode); var ipAddress = IpAddressProvider.GetLocalIpAddress(); var electionEndTime = nodeConfig.IsClassDemo ? DateTime.Now.AddSeconds(120) : nodeConfig.ElectionEndTime; // password check var voterDb = new VoterDatabaseFacade(nodeConfig.VoterDbFilepath); var foundMiner = voterDb.TryGetVoterEncryptedKeyPair(password, out var encryptedKeyPair); if (!foundMiner) { Console.WriteLine("incorrect password: you may not mine!"); return; } // blockchain var blockchain = new Blockchain(); // networking var registrarClientFactory = new RegistrarClientFactory(); var registrarClient = registrarClientFactory.Build(ipAddress, RegistrarPort); var registrationRequestFactory = new RegistrationRequestFactory(); var myConnectionInfo = new NodeConnectionInfo(ipAddress, nodeConfig.Port); var knownNodeStore = new KnownNodeStore(); var nodeClientFactory = new NodeClientFactory(); var handshakeRequestFactory = new HandshakeRequestFactory(blockchain); var nodeClientStore = new NodeClientStore(); var nodeServerFactory = new NodeServerFactory(); // votes var protoVoteFactory = new ProtoVoteFactory(); var voteForwarder = new VoteForwarder(nodeClientStore, protoVoteFactory); var voteMemoryPool = new VoteMemoryPool(voteForwarder, console); // blocks var merkleNodeFactory = new MerkleNodeFactory(); var merkleTreeFactory = new MerkleTreeFactory(merkleNodeFactory); var minerId = encryptedKeyPair.PublicKey.GetBase64String(); var blockFactory = new BlockFactory(merkleTreeFactory, minerId); var protoBlockFactory = new ProtoBlockFactory(protoVoteFactory); var blockForwarder = new BlockForwarder(nodeClientStore, protoBlockFactory); var voteValidator = new VoteValidator(blockchain, voterDb, electionEndTime); var blockValidator = new BlockValidator(blockFactory, voteValidator); var blockchainAdder = new BlockchainAdder(blockchain, voteMemoryPool, blockForwarder, console); // mining var difficultyTarget = TargetFactory.Build(BlockHeader.DefaultBits); var miner = new Miner( blockchain, voteMemoryPool, difficultyTarget, blockFactory, blockchainAdder, console); // interaction var voteSerializer = new VoteSerializer(); var electionAlgorithmFactory = new ElectionAlgorithmFactory(voteSerializer); var electionAlgorithm = electionAlgorithmFactory.Build(nodeConfig.ElectionType); var electionResultProvider = new ElectionResultProvider( electionAlgorithm, electionEndTime, voteMemoryPool, blockchain); var voterTerminal = new VoterTerminal.VoterTerminal( voterDb, nodeConfig.Candidates.ToArray(), voteSerializer, voteMemoryPool, electionResultProvider, blockchain); var votingBooth = new VoterTerminal.VoterBooth(voterTerminal, nodeConfig.ElectionType); // startup var nodeServer = nodeServerFactory.Build( myConnectionInfo, knownNodeStore, nodeClientFactory, nodeClientStore, voteMemoryPool, blockchain, miner, voteValidator, blockValidator, blockchainAdder, console); var boostrapper = new Bootstrapper( MinNetworkSize, knownNodeStore, nodeClientFactory, handshakeRequestFactory, nodeClientStore, registrarClient, registrationRequestFactory, nodeServer); Console.WriteLine("bootstrapping node network..."); boostrapper.Bootstrap(myConnectionInfo); Console.WriteLine($"{MinNetworkSize} nodes in network! bootstrapping complete"); if (nodeConfig.IsMiningNode) { Console.WriteLine("starting miner..."); miner.Start(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Press any key to quit"); Console.ReadKey(); } else { votingBooth.LaunchBooth(); } }
private CoreAppXmlConfiguration() : base("White", "Core", DefaultValues, new TraceLogger(typeof(CoreAppXmlConfiguration).Name)) { interceptors.Add(new FocusInterceptor()); interceptors.Add(new ScrollInterceptor()); LoggerFactory = new ConsoleFactory(LoggerLevel.Info); }