/// <summary> /// Create the link to the Windows 7 HID driver. /// </summary> /// <returns></returns> private bool createProviderHandler() { try { // Close any open connections. disconnectProviderHandler(); // Reconnect with the new API. this.pProviderHandler = OutputFactory.createProviderHandler(Settings.Default.output); this.pProviderHandler.OnConnect += pProviderHandler_OnConnect; this.pProviderHandler.OnDisconnect += pProviderHandler_OnDisconnect; return(true); } catch (Exception pError) { // Tear down. try { this.disconnectProviderHandler(); } catch { } // Report the error. showMessage(pError.Message, MessageType.Error); //MessageBox.Show(pError.Message, "WiiTUIO", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }
private static int GenerateSharedCode(string inputPath, string outputBasePath) { if (!File.Exists(inputPath)) { Console.Error.WriteLine("Input path is not an existing file."); return(ExitFailure); } if (!Directory.Exists(outputBasePath)) { Console.Error.WriteLine("Output path base is not an existing directory."); return(ExitFailure); } var input = LoadFromString <List <ConstantCollection> >(File.ReadAllText(inputPath)); foreach (ConstantCollection col in input) { col.SourcePath = inputPath; // This isn't set by YamlDotNet, so it's added manually foreach (Dictionary <string, string> outputInfo in col.Outputs) { IOutputFile output = OutputFactory.CreateByType(outputInfo, col); string filePath = Path.Combine(outputBasePath, output.GetPath()); using (StreamWriter writer = new StreamWriter(filePath)) { Console.WriteLine("Writing file '{0}'", filePath); writer.Write(output.GetContent()); } } } return(ExitSuccess); }
private Mock <NotesController> GetNoteController(Mock <DefaultContext> db, User user) { var httpContext = MockHelper.GetHttpContextWithUserId(user.Id); var userManager = MockHelper.GetUserManagerWithUser(db.Object); userManager.Setup(um => um.GetUserAsync(It.Is <ClaimsPrincipal>(t => true))).ReturnsAsync(user); var signInManager = new Mock <SignInManager <User> >(userManager.Object, new HttpContextAccessor { HttpContext = httpContext.Object }, new Mock <IUserClaimsPrincipalFactory <User> >().Object, null, null, null ); Func <object, JsonResult> toJson = (data) => { return(new JsonResult(data)); }; var manager = new CryptographManager(); var modelsFactory = new ModelsFactory(); var outputFactory = new OutputFactory(manager); var notesManager = new NotesManager(db.Object, manager, modelsFactory, userManager.Object); var notesValidator = new NotesViewModelValidator(db.Object, manager, modelsFactory); var ctrlNotes = new Mock <NotesController>(userManager.Object, outputFactory, notesManager, notesValidator); ctrlNotes.Setup(ctrl => ctrl.Json(It.IsAny <object>())).Returns(toJson); ctrlNotes.Object.ControllerContext = new ControllerContext() { HttpContext = httpContext.Object }; return(ctrlNotes); }
public static void LoadMods() { var owmlGo = new GameObject(); owmlGo.AddComponent <OwmlBehaviour>(); var owmlConfig = JsonHelper.LoadJsonObject <OwmlConfig>(ConfigPath); var owmlDefaultConfig = JsonHelper.LoadJsonObject <OwmlConfig>(DefaultConfigPath); var owmlManifest = JsonHelper.LoadJsonObject <ModManifest>(ManifestPath); if (owmlConfig == null || owmlManifest == null) { // Everything is wrong and can't write to console... return; } var logger = new ModLogger(owmlConfig, owmlManifest); logger.Log("Got config!"); var console = OutputFactory.CreateOutput(owmlConfig, logger, owmlManifest); console.WriteLine("Mod loader has been initialized."); var modSorter = new ModSorter(console); var modFinder = new ModFinder(owmlConfig, console); var harmonyHelper = new HarmonyHelper(logger, console); var events = new ModEvents(logger, console, harmonyHelper); var inputHandler = new ModInputHandler(logger, console, harmonyHelper, owmlConfig, events); var menus = new ModMenus(console, events, inputHandler, owmlManifest, owmlConfig, owmlDefaultConfig); var owo = new Owo(modFinder, logger, console, owmlConfig, menus, harmonyHelper, inputHandler, modSorter); owo.LoadMods(); }
/// <summary> /// Get user controller /// </summary> /// <param name="db">Database context</param> /// <param name="user">User</param> /// <returns></returns> private Mock <UserController> GetUserController(User user, UserManager <User> userManager) { var httpContext = MockHelper.GetHttpContextWithUserId(user != null ? user.Id : ""); var signInManager = new Mock <SignInManager <User> >(userManager, new HttpContextAccessor { HttpContext = httpContext.Object }, new Mock <IUserClaimsPrincipalFactory <User> >().Object, null, null, null); Func <object, JsonResult> toJson = (data) => { return(new JsonResult(data)); }; var manager = new CryptographManager(); var outputFactory = new OutputFactory(manager); var modelsFactory = new ModelsFactory(); var userService = new UserService(userManager); var usersValidator = new UserViewModelValidator(userManager, new ModelsFactory()); var userCtrl = new Mock <UserController>(signInManager.Object, userManager, outputFactory, userService, usersValidator); userCtrl.Object.ControllerContext = new ControllerContext() { HttpContext = httpContext.Object }; userCtrl.Setup(uCtrl => uCtrl.Json(It.IsAny <object>())).Returns(toJson); return(userCtrl); }
public void OutputWriterObtained() { OutputFactory outputFactory = new OutputFactory(); IOutputWriter outWriter = outputFactory.CreateOutputWriter(); Debug.Write("Test OutputWriterObtained"); Assert.IsNotNull(outWriter); }
public void OutputWriterWriteOutputRun() { OutputFactory outputFactory = new OutputFactory(); IOutputWriter outWriter = outputFactory.CreateOutputWriter(); Debug.Write("Test OutputWriterOutputRun"); Assert.IsTrue(outWriter.WriteOutput("Hello World from Testing")); }
public void OutputWriterCustomProcessingRun() { OutputFactory outputFactory = new OutputFactory(); IOutputWriter outWriter = outputFactory.CreateOutputWriter(); Debug.Write("Test OutputWriterObtained"); Assert.IsTrue(outWriter.CustomProcessing()); }
private static int GenerateSharedCode(string inputPath, string outputBasePath) { var inputFiles = inputPath.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(path => path.Trim()); var errors = new StringBuilder(); foreach (var inputFile in inputFiles) { if (!File.Exists(inputPath)) { _ = errors.AppendLine($"File {inputFile} does not exist."); } } if (errors.Length > 0) { Console.Error.WriteLine(errors.ToString()); return(ExitFailure); } if (!Directory.Exists(outputBasePath)) { Console.Error.WriteLine("Output path base is not an existing directory."); return(ExitFailure); } var collections = new List <ConstantCollection>(); foreach (var inputFile in inputFiles) { var inputFileContent = File.ReadAllText(inputFile); var deserializedInput = LoadFromString <List <ConstantCollection> >(inputFileContent); deserializedInput.ForEach(collection => collection.SourcePath = inputFile); collections.AddRange(deserializedInput); } foreach (var collection in collections) { ReplaceVariablesWithValues(collection.StringConstants); foreach (Dictionary <string, string> outputInfo in collection.Outputs) { var output = OutputFactory.CreateByType(outputInfo, collection); var filePath = Path.Combine(outputBasePath, output.GetPath()); using (var writer = new StreamWriter(filePath)) { Console.WriteLine($"Writing file '{filePath}'"); writer.Write(output.GetContent()); } } } GenerateSupportedPlatformsReadmeFile(outputBasePath); return(ExitSuccess); }
public ComponentInstanceViewModelFactory( TestComponentInstanceFactory componentInstanceFactory, OutputFactory outputFactory, OperationViewModelFactory operationViewModelFactory, BackgroundTasks backgroundTasks, OperationMachinesByControlObject operationMachinesByControlObject, ApplicationEvents applicationEvents) { _componentInstanceFactory = componentInstanceFactory; _outputFactory = outputFactory; _operationViewModelFactory = operationViewModelFactory; _backgroundTasks = backgroundTasks; _operationMachinesByControlObject = operationMachinesByControlObject; _applicationEvents = applicationEvents; }
private IModHelper CreateModHelper(IModData modData) { var logger = new ModLogger(_owmlConfig, modData.Manifest); var console = OutputFactory.CreateOutput(_owmlConfig, _logger, modData.Manifest); var assets = new ModAssets(console, modData.Manifest); var storage = new ModStorage(console, modData.Manifest); var events = new ModEvents(logger, console, _harmonyHelper); var interaction = new ModInteraction(_modList, new InterfaceProxyFactory(), modData.Manifest); return(new ModHelper.ModHelper(logger, console, _harmonyHelper, events, assets, storage, _menus, modData.Manifest, modData.Config, _owmlConfig, interaction)); }
static void Main(string[] args) { var owmlConfig = GetOwmlConfig(); var owmlManifest = GetOwmlManifest(); var writer = OutputFactory.CreateOutput(owmlConfig, null, owmlManifest); var modFinder = new ModFinder(owmlConfig, writer); var outputListener = new OutputListener(owmlConfig); var pathFinder = new PathFinder(owmlConfig, writer); var owPatcher = new OWPatcher(owmlConfig, writer); var vrPatcher = new VRPatcher(owmlConfig, writer); var app = new App(owmlConfig, owmlManifest, writer, modFinder, outputListener, pathFinder, owPatcher, vrPatcher); app.Run(args); }
public static OutputResponse CreateOutPut(AnalysisRequest request, RootNode rootNode) { if (request == null) { throw new ArgumentNullException("request"); } if (rootNode == null) { throw new ArgumentNullException("rootNode"); } IOutputProvider outputProvider = OutputFactory.CreateProvider(request.OutPutType); return(outputProvider.Create(rootNode, request.OutPutFolder)); }
public static OutputResponse CreateOutput(AnalysisRequest request, RootNode rootNode) { if (request == null) { throw new ArgumentNullException("request"); } if (rootNode == null) { throw new ArgumentNullException("rootNode"); } var outputProvider = OutputFactory.CreateProvider(request.OutputType); return(outputProvider.Create(rootNode, Path.Combine(Directory.GetCurrentDirectory(), request.OutputFolder))); }
public ComponentInstanceViewModel( string instanceName, OutputFactory outputFactory, OperationEntries operationEntries, CoreTestComponent testComponentInstance, BackgroundTasks backgroundTasks, OperationMachinesByControlObject operationMachinesByControlObject, Capabilities.CustomGui customUi) { _instanceName = instanceName; _outputFactory = outputFactory; _operationEntries = operationEntries; _testComponentInstance = testComponentInstance; _customUi = customUi; _backgroundTasks = backgroundTasks; _operationMachinesByControlObject = operationMachinesByControlObject; }
public async void Initialize() { InputFactory.InputType inputType = InputFactory.getType(Settings.Default.input); OutputFactory.OutputType outputType = OutputFactory.getType(Settings.Default.output); switch (inputType) { case InputFactory.InputType.POINTER: this.cbiPointer.IsSelected = true; break; case InputFactory.InputType.PEN: this.cbiPen.IsSelected = true; break; } this.cbConnectOnStart.IsChecked = Settings.Default.connectOnStart; Application.Current.Exit += appWillExit; wiiPair = new WiiCPP.WiiPair(); wiiPair.addListener(this); Settings.Default.PropertyChanged += Settings_PropertyChanged; if (!Settings.Default.pairedOnce) { this.tbConnect.Visibility = Visibility.Hidden; this.tbPair.Visibility = Visibility.Visible; } else { this.tbConnect.Visibility = Visibility.Visible; this.tbPair.Visibility = Visibility.Hidden; } //this.cbWindowsStart.IsChecked = await ApplicationAutostart.IsAutostartAsync("Touchmote"); // Create the providers. this.createProvider(); this.createProviderHandler(); if (Settings.Default.connectOnStart) { this.connectProvider(); } }
public void GetCode(CodeFormat format, TextWriter writer) { IOutputProvider output; switch (format) { case CodeFormat.Disassemble: output = OutputFactory.GetDisassembleOutputProvider(); break; case CodeFormat.ControlFlowDecompile: output = OutputFactory.GetDecompileCFOutputProvider(); break; case CodeFormat.FullDecompile: output = OutputFactory.GetDecompileFullOutputProvider(); break; case CodeFormat.FullDecompileAnnotate: output = OutputFactory.GetDecompileFullAnnotateOutputProvider(); break; case CodeFormat.CodePath: output = OutputFactory.GetCodePathOutputProvider(); break; case CodeFormat.Variables: output = OutputFactory.GetVariablesOutputProvider(); break; case CodeFormat.ScruffDecompile: output = OutputFactory.GetScruffDecompileOutputProvider(); break; case CodeFormat.ScruffHeader: output = OutputFactory.GetScruffHeaderOutputProvider(); break; default: throw new ArgumentOutOfRangeException("format"); } output.Process(_file, writer); }
static void Main(string[] args) { // Instantiate the Factory OutputFactory outputFactory = new OutputFactory(); // Ask Factory to instantiate the specific output writer based on configuration IOutputWriter outWriter = outputFactory.CreateOutputWriter(); // Execute the output writer's functions directly outWriter.CustomProcessing(); outWriter.WriteOutput("Hello World"); // Invoke another class's functionality with OutputWriter injected dynamically at run time (Dependency Injection) TestRunner testRunr = new TestRunner(outWriter, "Hello World"); // Execute the output writer's functions directly testRunr.CustomProcessing(); testRunr.WriteOutput(); //TODO: establish Web API connection to the service // Get the service URI //var actionUrl = .Action("Content", "Import", new //{ // httproute = true, // area = "Orchard.ImportExport" //}); //IServiceProvider service = new CHAPITest.Controllers.CHAPIController(); //CHAPITest.Controllers.CHAPIController.GetURL //string uri = Url.Action("POST", "CHAPIController", new { }, HttpWebRequest.Url.Scheme); //var url = new UrlHelper(HttpContext.Current.Request.RequestContext); //item.Url = url.Action("POST", "CHAPI"); //// Call REST client with input string //RESTClient restClient = new RESTClient("/api/CHAPI", "Hello, World", HTTPVerb.POST); //string result = restClient.MakeRequest(); }
static void Run(CommandLineOptions options) { if (options.CreatorType == CreatorType.StronglyTyped) { // Register all the class maps in this assembly (Person and Address objects in Sample namespace) MapRegistrar.Register(Assembly.GetExecutingAssembly()); } //else //{ // if (options.OutputType == OutputType.Xml) // { // Console.WriteLine("Error: Cannot use Xml output with dynamic object creation, add -c StronglyTyped to the command line arguments."); // return; // } //} using (IDataSource ds = DataSourceFactory.Create(options.DataSourceType)) { ds.Initialise(options.DataSource); dynamic people = null; //if (options.OutputType == OutputType.Xml) //{ // // Bit hacky this, but need to use strongly typed objects for Xml serialisation // people = CreatorFactory.Create<Person>(options.CreatorType) // .GetObjects(ds).Cast<Person>().ToArray(); //} //else //{ // people = CreatorFactory.Create<Person>(options.CreatorType) // .GetObjects(ds); //} people = CreatorFactory.Create <Person>(options.CreatorType) .GetObjects(ds); var outputter = OutputFactory.Create <Person>(options.OutputType); Console.WriteLine(outputter.Output(people)); } }
private static void Configure( ComponentLocation componentLocation, ApplicationBootstrap bootstrap, ApplicationContext applicationContext, BackgroundTasks backgroundTasks) { var operationsOutputViewModel = new OperationsOutputViewModel(); var operationPropertiesViewModel = new OperationPropertiesViewModel(); var scriptOperationsViewModel = new ScriptOperationsViewModel(operationPropertiesViewModel); var operationsViewModel = new OperationsViewModel(operationPropertiesViewModel); var operationViewsViewModel = new OperationViewsViewModel(new OperationsViewInitialization[] { operationsViewModel, scriptOperationsViewModel }); var componentInstancesViewModel = new ComponentInstancesViewModel(operationsViewModel, operationViewsViewModel); var operationMachinesByControlObject = new OperationMachinesByControlObject(); var outputFactory = new OutputFactory(operationsOutputViewModel); var testComponentViewModelFactory = new TestComponentViewModelFactory( componentInstancesViewModel, outputFactory, new WpfOperationViewModelFactory(applicationContext, scriptOperationsViewModel, new PropertySetBuilderFactory()), backgroundTasks, operationMachinesByControlObject, bootstrap); var componentsViewModel = new ComponentsViewModel(testComponentViewModelFactory); var topMenuBarViewModel = new TopMenuBarViewModel( componentInstancesViewModel, operationsOutputViewModel, new PersistentModelContentBuilderFactory(operationsOutputViewModel, operationMachinesByControlObject)); var factoryRepositories = componentLocation.LoadComponentRoots(); AddAllInstanceFactories(factoryRepositories, componentsViewModel); bootstrap.SetOperationPropertiesViewDataContext(operationPropertiesViewModel); bootstrap.SetTopMenuBarContext(topMenuBarViewModel); bootstrap.SetOperationsViewDataContext(operationsViewModel); bootstrap.SetScriptOperationsViewDataContext(scriptOperationsViewModel); bootstrap.SetOperationsOutputViewDataContext(operationsOutputViewModel); bootstrap.SetComponentsViewDataContext(componentsViewModel); bootstrap.SetComponentInstancesViewDataContext(componentInstancesViewModel); bootstrap.SetOperationsViewsViewDataContext(operationViewsViewModel); return; }
static void Main(string[] args) { ArgsResult argsResult = ParseArgs(args); if (argsResult.IsHelp) { Console.WriteLine("Help:"); Console.WriteLine("Use 2 arguments. First argument is path of config file, second argument is path of result test"); Console.WriteLine("Example:"); Console.WriteLine("\tRestTest.ConsoleApp C:\\\\folder\\config.json .\\result.json"); Console.ReadKey(); return; } var factory = new OutputFactory(); IOutput output = factory.Create(argsResult); try { RT rt = new RT(argsResult.ConfigPath); rt.OnTestFinished += output.OnTestFinished; rt.Start(); output.AllTestsFinished(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } finally { if (!argsResult.ContinueAfterFinished) { Console.ReadKey(); } } }
static void Main(string[] args) { try { var inputfile = args[0]; if (string.IsNullOrEmpty(inputfile)) { Console.WriteLine("Error. Please provide a file path"); Console.ReadLine(); Environment.Exit(0); } var inputfileLocation = Environment.CurrentDirectory + "\\" + inputfile.Replace("./", ""); var outputfileLocation = Environment.CurrentDirectory + "\\sorted-names-list.txt"; var fileProcessor = new FileProcessor(inputfileLocation, outputfileLocation); IDataReader inputFile = new FileReader(fileProcessor); var data = inputFile.GetData(); ISorter sortEngine = new Sorter(); var sortedList = sortEngine.GetSortedData(data, new char[] { ' ' }); // use a factory. We can extend the factory to support sending to other outputs if required.Open/Closed principal var output = new OutputFactory(fileProcessor); foreach (var writers in output.GetWriters()) { writers.WriteData(sortedList); } } catch (Exception ex) { // to do logging Console.WriteLine(ex.Message); } }
public ConfigurationAppStarter() { var processorsFactory = new ProcessorFactory(); LogMonitorConfiguration configuration = LogMonitorConfiguration.Instance; this.processors = new List <IProcessor>(); // Set to right "context" Environment.CurrentDirectory = Path.GetDirectoryName(typeof(Kernel).Assembly.Location); foreach (ParserElement parser in configuration.Parser) { processors.Add(processorsFactory.Create(parser.ScriptPath, parser.Pattern)); } var outputFactory = new OutputFactory( GraphiteConfiguration.Instance == null ? null : GraphiteConfiguration.Instance.Graphite, GraphiteConfiguration.Instance == null ? null : GraphiteConfiguration.Instance.StatsD); this.outputFilter = outputFactory.CreateFilter( configuration.Output.Cast <IOutputConfiguration>()); }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json"); IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); OutputFactory factory = null; // output handler is specified in appsettings.json configuration file var outputHandlerType = config["OutputHandler"]; switch (outputHandlerType?.ToLower()) { case "console": factory = new ConsoleOutputFactory(); break; case "database": factory = new DatabaseOutputFactory(); break; case "mobile": factory = new MobileOutputFactory(); break; default: factory = new ConsoleOutputFactory(); break; } RunHelloWorld(config["HelloWorldApiBaseUrl"], factory.GetOutputHandler()).GetAwaiter().GetResult(); }
// Here, we can inject the OutputType using Dependency Inject. Constructor injection. public BankApp() { output = OutputFactory.GetInstance(OutputType.Console); }
static void Main(string[] args) { OutputFactory output = new OutputFactory(); output.CreateFile(12, Enumerators.EnumTipoOutputFile.SqliteFile); }