Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                IPalindromeChecker palindromeChecker = new PalindromeReader();
                IConsoleOutput output = new ConsoleOutput();
                IConsoleInput inputChecker = new ConsoleReader();

                Console.WriteLine("Welcome to my application\n");
                Console.WriteLine("Input a word or sentence\n");

                var readLine = Console.ReadLine();
                if (readLine != null)
                {
                    var inputSequence = inputChecker.GetInput(readLine.ToLower());
                    var sequenceChecker = palindromeChecker.CheckSequence(inputSequence);
                    Console.WriteLine(output.Display(sequenceChecker));
                }

                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Пример #2
0
        public void Parse_Toolkit_validate_with_default_example_set()
        {
            var consoleOutput = new ConsoleOutput();

            const string input =
                "?OTR:AAMDSyvyQvLg7pcAAAAAAQAAAAEAAADAVoV88L+aKOU6X25AixfPKDvijKUVHhGdSFZlQpA5XepzoyEqA8ATbjYPwjE7FZApV87oUx+QQog39bJ2GA/zYqrag/xrRzLZfE9K3E7PmUaeUZijLCQA5hTYemzV/crv8SQiLbasDmNDKNi8X/XQuGSPhFD2/jtl13MElkbDWWYiQzX2Ck4lhsHGp0gsNLBhOwkwPGRzmWB+1ltRvb9XqhTuF6S83qGy9iM7pm3yT048awWY4FOG24dukbja1jbNAAAAAAAAAAEAAAANXtnheROJlgrrv2dCFmJ6bYB4YqCkGD2qjQM8s6q391HnAAAAAA==.";

            string expectedOutput =
                "Data Message:" + Environment.NewLine +
                "	Version: 3" + Environment.NewLine +
                "	Flags: 0" + Environment.NewLine +
                "	Sender instance: 1261171266" + Environment.NewLine +
                "	Receiver instance: 4074827415" + Environment.NewLine +
                "	Sndr keyid: 1" + Environment.NewLine +
                "	Rcpt keyid: 1" + Environment.NewLine +
                "	DH y: 56857CF0BF9A28E53A5F6E408B17CF283BE28CA5151E119D4856654290395DEA73A3212A03C0136E360FC2313B15902957CEE8531F90428837F5B276180FF362AADA83FC6B4732D97C4F4ADC4ECF99469E5198A32C2400E614D87A6CD5FDCAEFF124222DB6AC0E634328D8BC5FF5D0B8648F8450F6FE3B65D773049646C35966224335F60A4E2586C1C6A7482C34B0613B09303C647399607ED65B51BDBF57AA14EE17A4BCDEA1B2F6233BA66DF24F4E3C6B0598E05386DB876E91B8DAD636CD" + Environment.NewLine +
                "	Counter: 1" + Environment.NewLine +
                "	Encrypted Message: 5ED9E1791389960AEBBF674216" + Environment.NewLine +
                "	MAC: 627A6D807862A0A4183DAA8D033CB3AAB7F751E7" + Environment.NewLine;

            Program.Parse(input);

            var output = consoleOutput.GetOuput();

            output.Should().Be(expectedOutput);
        }
Пример #3
0
 internal PoshConsolePipeline(IList<Command> commands, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
 {
     TaskSource = new TaskCompletionSource<PoshConsolePipelineResults>();
     Commands = new Collection<Command>(commands);
     Input = input;
     IsScript = Commands.First().IsScript;
     Output = output;
 }
Пример #4
0
 public static ConsoleOutput CreateInstance(AWSModel.ConsoleOutput consoleOutput)
 {
     ConsoleOutput output = new ConsoleOutput();
     output.InstanceId = consoleOutput.InstanceId;
     output.Output = consoleOutput.Output;
     output.Timestamp = consoleOutput.Timestamp;
     return output;
 }
Пример #5
0
        static void Main()
        {
            var console = new ConsoleOutput();
            console.Start();

            var tzShapeReader = new TimeZoneShapeFileReader(@".\Data\tz_world.shp");

            TimeZoneDataBuilder.CreateGeohashData(console, tzShapeReader, @"..\..\..\GeoTimeZone\");

            console.Stop();
        }
Пример #6
0
        public void MacKey_Toolkit_validate_with_default_example_set()
        {
            var consoleOutput = new ConsoleOutput();

            const string arguments = "8863A4479AE2857FB9BE657E3B7E37C4";
            string expectedOutput =
                "AES key: 8863A4479AE2857FB9BE657E3B7E37C4" + Environment.NewLine +
                "MAC key: A43167D308BA9DE0127F3124A55BEA9A608C10C4" + Environment.NewLine;

            Program.Main(new string[] {arguments});

            var output = consoleOutput.GetOuput();

            output.Should().Be(expectedOutput);
        }
Пример #7
0
        public void StartAllTasks(int countTasks, int countItems)
        {
            var token = _tokenSource.Token;
            var m = new MyTask();

            for (var i = 1; i <= countTasks; i++)
            {
                var t = Task.Factory.StartNew(iteration => m.DoSomeWork((int)iteration, countItems, token), i, token);
                _tasks.Add(t);

            }
            char ch = Console.ReadKey().KeyChar;
            if (ch == 'c' || ch == 'C')
            {
                _tokenSource.Cancel();
            }

            try
            {
                Task.WaitAll(_tasks.ToArray());

            }
            catch (AggregateException e)
            {
                Console.WriteLine("\nИсключения в потоках");

                foreach (var v in e.InnerExceptions)
                {
                    if (!(v is TaskCanceledException))
                        Console.WriteLine("   Exception: {0}", v.GetType().Name);
                }

                Console.WriteLine();
            }
            finally
            {
                _tokenSource.Dispose();
            }

            var output= new ConsoleOutput();
            output.OutputCountItem(_tasks);
        }
Пример #8
0
        public static void Main()
        {
            var outputMethod = new DbOutput<Seznamka>();
            //foreach (var scraper in HoroscopeScrapers)
            //{
            //    if (scraper.ShouldScrapeNow())
            //    {
            //        outputMethod.Out(scraper.Scrape());
            //    }
            //}

            var console = new ConsoleOutput<Seznamka>();
            foreach (var scraper in SeznamkyScrapers)
            {
                if (scraper.ShouldScrapeNow())
                {
                    outputMethod.Out(scraper.Scrape());
                }
            }
        }
Пример #9
0
 //private static final String TAG ="TJS";
 // プリプロセッサでは未定义の时この值が入る
 // create a member if not exists
 //public static int mCompactVariantArrayMagic;
 //public static VariantArrayStack mVariantArrayStack;
 // static 关系はここで初期化
 public static void Initialize()
 {
     // mStorage = null; // 事前に设定されるので、ここで初期化するのはまずい
     NULL_ARG = new Variant[0];
     IsTarminating = false;
     mWarnOnNonGlobalEvalOperator = false;
     mUnaryAsteriskIgnoresPropAccess = false;
     mNativeClassNames = new AList<string>();
     mGlobalStringMap = new GlobalStringMap();
     //mCompactVariantArrayMagic = 0;
     //mVariantArrayStack = new VariantArrayStack();
     mEvalOperatorIsOnGlobal = false;
     EnableDebugMode = true;
     mConsoleOutput = null;
     mMessageMapper = new MessageMapper();
     RandomGeneratorNI.SetRandomBits128(null);
     //ArrayNI.register();
     mVAPool = new VariantPool();
     CompileState.mEnableDicFuncQuickHack = true;
     Variant.Initialize();
     DictionaryObject.Initialize();
     ArrayObject.Initialize();
     ByteCodeLoader.Initialize();
     CustomObject.Initialize();
     MathClass.Initialize();
     LexicalAnalyzer.Initialize();
     try
     {
         mArrayClass = new ArrayClass();
         mDictionayClass = new DictionaryClass();
     }
     catch (VariantException)
     {
     }
     catch (TJSException)
     {
     }
 }
Пример #10
0
        private void GenerateZBuffer(Group scene)
        {
            zBuffer.SetAllToValue(outOfBoundsValue);
            colourBuffer.SetAllToValue(RenderBackgroundColour);

            foreach (Camera camera in scene.Cameras)
            {
                if (camera.DrawIcon)
                {
                    Matrix4x4 modelToView = this.WorldToView * camera.Icon.ModelToWorld;

                    foreach (Face face in camera.Icon.Faces)
                    {
                        AddFaceToZBuffer
                        (
                            face,
                            3,
                            ref modelToView,
                            ref this.ViewToScreen,
                            ref ScreenToWindow
                        );
                    }
                }
            }

            foreach (Light light in scene.Lights)
            {
                if (light.DrawIcon)
                {
                    Matrix4x4 modelToView = this.WorldToView * light.Icon.ModelToWorld;

                    foreach (Face face in light.Icon.Faces)
                    {
                        AddFaceToZBuffer
                        (
                            face,
                            3,
                            ref modelToView,
                            ref this.ViewToScreen,
                            ref ScreenToWindow
                        );
                    }
                }
            }

            foreach (Mesh mesh in scene.Meshes)
            {
                if (mesh.Visible && mesh.DrawFaces)
                {
                    Matrix4x4 modelToView = this.WorldToView * mesh.ModelToWorld;

                    foreach (Face face in mesh.Faces)
                    {
                        if (face.Visible)
                        {
                            AddFaceToZBuffer
                            (
                                face,
                                mesh.Dimension,
                                ref modelToView,
                                ref this.ViewToScreen,
                                ref ScreenToWindow
                            );
                        }
                    }
                }
            }

            foreach (SceneObject sceneObject in scene.SceneObjects)
            {
                if (sceneObject.HasDirectionArrows && sceneObject.DisplayDirectionArrows)
                {
                    Arrow directionForward = sceneObject.DirectionArrows.SceneObjects[0] as Arrow;
                    Arrow directionUp      = sceneObject.DirectionArrows.SceneObjects[1] as Arrow;
                    Arrow directionRight   = sceneObject.DirectionArrows.SceneObjects[2] as Arrow;

                    Matrix4x4 directionForwardModelToView = this.WorldToView * directionForward.ModelToWorld;
                    Matrix4x4 directionUpModelToView      = this.WorldToView * directionUp.ModelToWorld;
                    Matrix4x4 directionRightModelToView   = this.WorldToView * directionRight.ModelToWorld;

                    foreach (Face face in directionForward.Faces)
                    {
                        AddFaceToZBuffer
                        (
                            face,
                            3,
                            ref directionForwardModelToView,
                            ref this.ViewToScreen,
                            ref ScreenToWindow
                        );
                    }
                    foreach (Face face in directionUp.Faces)
                    {
                        AddFaceToZBuffer
                        (
                            face,
                            3,
                            ref directionUpModelToView,
                            ref this.ViewToScreen,
                            ref ScreenToWindow
                        );
                    }
                    foreach (Face face in directionRight.Faces)
                    {
                        AddFaceToZBuffer
                        (
                            face,
                            3,
                            ref directionRightModelToView,
                            ref this.ViewToScreen,
                            ref ScreenToWindow
                        );
                    }
                }
            }

            ConsoleOutput.DisplayMessageFromObject(this, "Generated Z buffer.");
        }
Пример #11
0
 public void TearDown()
 {
     _obj = null;
     _obj2 = null;
 }
Пример #12
0
 public static void SetConsoleOutput(ConsoleOutput console)
 {
     mConsoleOutput = console;
 }
Пример #13
0
 /// <summary>
 /// Text has been received from one of the build tasks that needs to be displayed.
 /// </summary>
 /// <param name="sender">The object that sent this event.</param>
 /// <param name="text">The text received from the console application.</param>
 private void Console_StandardTextReceived(object sender, string text)
 {
     ConsoleOutput?.Invoke(this, text);
 }
        public void TestConsoleOutputInterface()
        {
            IOutputBehavior consoleOutput = new ConsoleOutput();

            OutputServices.CreateOutput(consoleOutput);
        }
Пример #15
0
 public void Ctor_FileLogCreated_NoError()
 {
     ILogOutput         outLog         = new ConsoleOutput();
     ILogEntryFormatter entryFormatter = new FileFormatter();
     Log uut = new Log(outLog, entryFormatter);
 }
Пример #16
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            Portable.Initialise();

            if (!Portable.IsProcessIsolationEnabled())
            {
                Console.WriteLine("Worker is disabled in portable.ini");
                Console.WriteLine("Press 'Enter' to exit");
                Console.Read();
                return;
            }

            int    port = 8037; // Default Port;
            string token;

            if (args.Length != 0)
            {
                foreach (string argument in args)
                {
                    if (argument.StartsWith("--port"))
                    {
                        string value = argument.TrimStart("--port=".ToCharArray());
                        if (int.TryParse(value, out var parsedPort))
                        {
                            port = parsedPort;
                        }
                    }

                    if (argument.StartsWith("--token"))
                    {
                        token = argument.TrimStart("--token=".ToCharArray());
                        TokenService.RegisterToken(token);
                    }
                }
            }

            if (!TokenService.IsTokenSet())
            {
                ConsoleOutput.WriteLine("# HandBrake Worker", ConsoleColor.DarkYellow);
                ConsoleOutput.WriteLine("*** Please note, this application should not be run standalone. To run the GUI, please use 'HandBrake.exe' *** ", ConsoleColor.Red);
                Console.WriteLine();
            }

            Console.WriteLine("Worker: Starting HandBrake Engine ...");
            router = new ApiRouter();
            router.TerminationEvent += Router_TerminationEvent;

            Console.WriteLine("Worker: Starting Web Server on port {0} ...", port);

            Dictionary <string, Func <HttpListenerRequest, string> > apiHandlers = RegisterApiHandlers();
            HttpServer webServer = new HttpServer(apiHandlers, port, TokenService);

            if (webServer.Run().Result)
            {
                Console.WriteLine("Worker: Server Started");
                manualResetEvent.WaitOne();
                webServer.Stop();
            }
            else
            {
                Console.WriteLine("Worker is exiting ...");
            }
        }
Пример #17
0
 // Autoscrolls to end whenever console updates
 private void ScrollToBottom(object sender, TextChangedEventArgs args)
 {
     ConsoleOutput.ScrollToEnd();
 }
Пример #18
0
 public void Write(string[] arrayInput)
 {
     ConsoleOutput.WritetoConsole(arrayInput);
 }
Пример #19
0
 internal PoshConsolePipeline(string script, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
     : this(new[] { new Command(script, true, true) }, input, output)
 {
 }
Пример #20
0
 /// <summary>
 /// Invoke the specified command in a pipeline asynchronously, optionally providing input to the first command, and with the specified output handling.
 /// </summary>
 /// <param name="command">The Command from which the pipeline will be constructed.</param>
 /// <param name="isScript">Whether the command is a script (defaults to true). You should set this to false if you are just naming a command.</param>
 /// <param name="useLocalScope">Whether the command should use it's own local scope -- only valid for scripts (defaults to false)</param>
 /// <param name="input">Optional Pipeline Input. If this is specified, your first command must accept pipeline input</param>
 /// <param name="output">Optionally: what to print to the console (prints everything, by default, as though the user had typed the commands in the console)</param>
 /// <returns>A Task which returns the <see cref="PoshConsolePipelineResults"/> results, including the pipeline output</returns>
 public Task<PoshConsolePipelineResults> InvokeAsync(string command, bool isScript = true, bool useLocalScope = false, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
 {
     return Runner.Invoke(new[] { new Command(command, isScript, useLocalScope) }, input, output);
 }
Пример #21
0
 /// <summary>
 /// Invoke the specified command in a pipeline asynchronously, optionally providing input to the first command, and with the specified output handling.
 /// </summary>
 /// <param name="command">The Command from which the pipeline will be constructed.</param>
 /// <param name="input">Optional Pipeline Input. If this is specified, your first command must accept pipeline input</param>
 /// <param name="output">Optionally: what to print to the console (prints everything, by default, as though the user had typed the commands in the console)</param>
 /// <returns>A Task which returns the <see cref="PoshConsolePipelineResults"/> results, including the pipeline output</returns>
 public Task<PoshConsolePipelineResults> InvokeAsync(Command command, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
 {
     return Runner.Invoke(new []{command}, input, output);
 }
Пример #22
0
 /// <summary>
 /// Invoke the specified script, synchronously, and return the pipeline output.
 /// </summary>
 /// <param name="script">The script from which the pipeline will be constructed. Can be just a command name, but is executed as though typed on the console.</param>
 /// <param name="output">Optionally: what to print to the console (prints everything, by default, as though the user had typed the commands in the console)</param>
 /// <returns>The pipeline output</returns>
 public Collection<PSObject> Invoke(string script, ConsoleOutput output = ConsoleOutput.Default)
 {
     return Runner.Invoke(new[] { new Command(script, true) }, null, output).GetAwaiter().GetResult().Output;
 }
Пример #23
0
 /// <summary>
 /// Raises the ConsoleOutput event
 /// </summary>
 /// <param name="e">the string that was read from the console-stream</param>
 protected virtual void OnConsoleOutput(string e)
 {
     ConsoleOutput?.Invoke(this, e);
 }
Пример #24
0
        // Code to deal multiple versions of the GAME_MASTER protos.

        static ErrorCode GenerateCode(string basePath, string inputFolder, string outputFolder)
        {
            #region Validate Parameters

            if (!Directory.Exists(basePath))
            {
                ConsoleOutput.OutputError($"basePath not found: \"{basePath}\"");
                return(ErrorCode.BaseFolderDoesNotExist);
            }

            string inputPath = Path.Combine(basePath, inputFolder);
            if (!Directory.Exists(inputPath))
            {
                ConsoleOutput.OutputError($"inputFolder not found: \"{inputFolder}\"");
                return(ErrorCode.InputFolderDoesNotExist);
            }

            string outputPath = Path.Combine(basePath, outputFolder);
            if (!Directory.Exists(outputPath))
            {
                ConsoleOutput.OutputWarning($"outputFolder not found, creating \"{outputFolder}\"...");
                Directory.CreateDirectory(outputPath);
                if (!Directory.Exists(outputPath))
                {
                    ConsoleOutput.OutputError($"Could not create outputFolder: \"{outputFolder}\"");
                    return(ErrorCode.OutputFolderCouldNotBeCreated);
                }
            }

            #endregion Validate Parameters

            try
            {
                ErrorCode result = ErrorCode.Success;
                using (StreamWriter writer = new StreamWriter(Path.Combine(basePath, inputFolder, ProjFile)))
                {
                    writer.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
                    writer.WriteLine("  <!-- ======================================================================= -->");
                    writer.WriteLine("  <!-- =============== This file is generated by GM_protogen. ================ -->");
                    writer.WriteLine("  <!-- ======================================================================= -->");
                    writer.WriteLine();

                    string[] folders = Directory.GetDirectories(inputPath);
                    Array.Sort(folders, new VersionComparer());
                    foreach (var folderPath in folders)
                    {
                        ErrorCode errorCode = GenerateCode(writer, basePath, folderPath, outputPath, folderPath == folders[0]);

                        if (errorCode != ErrorCode.Success)
                        {
                            result = errorCode;
                        }
                    }

                    writer.WriteLine("</Project>");
                }

                return(result);
            }
            catch (Exception ex)
            {
                ConsoleOutput.OutputException(ex);

                return(ErrorCode.Exception);
            }
        }
Пример #25
0
        public async Task <RunResult> Run(WorkspaceRequest request, Budget budget = null)
        {
            var workspace = request.Workspace;

            budget = budget ?? new Budget();

            using (var operation = Log.OnEnterAndConfirmOnExit())
                using (var console = await ConsoleOutput.Capture())
                {
                    workspace = await _transformer.TransformAsync(workspace);

                    if (workspace.Files.Length != 1)
                    {
                        throw new ArgumentException($"{nameof(workspace)} should have exactly one source file.");
                    }

                    var options = CreateOptions(workspace);

                    ScriptState <object> state         = null;
                    Exception            userException = null;

                    var buffer = new StringBuilder(workspace.GetSourceFiles().Single().Text.ToString());

                    try
                    {
                        state = await Run(buffer, options, budget);

                        if (state != null &&
                            console.IsEmpty())
                        {
                            state = await EmulateConsoleMainInvocation(state, buffer, options, budget);
                        }

                        budget.RecordEntry(UserCodeCompletedBudgetEntryName);
                    }
                    catch (Exception ex)
                    {
                        userException = ex;
                    }

                    budget.RecordEntryAndThrowIfBudgetExceeded();

                    var diagnostics = await ExtractDiagnostics(
                        workspace,
                        request.ActiveBufferId,
                        options);

                    var output =
                        console.StandardOutput == ""
                        ? Array.Empty <string>()
                        : console.StandardOutput
                        .Replace("\r\n", "\n")
                        .Split(new[] { '\n' });

                    output = ProcessOutputLines(output,
                                                diagnostics.DiagnosticsInActiveBuffer.GetCompileErrorMessages());

                    var result = new RunResult(
                        succeeded: !userException.IsConsideredRunFailure(),
                        output: output,
                        exception: (userException ?? state?.Exception).ToDisplayString(),
                        diagnostics: diagnostics.DiagnosticsInActiveBuffer,
                        requestId: request.RequestId);

                    operation.Complete(budget);

                    return(result);
                }
        }
Пример #26
0
        static ErrorCode GenerateCode(StreamWriter writer, string basePath, string inputPath, string outputPath, bool current)
        {
            string inputFolder       = GetFolderName(inputPath);
            string inputRelativePath = MakeRelativePath(basePath, inputPath);

            #region Get the list of .proto files.

            var fileDescriptorSet = new FileDescriptorSet
            {
                AllowNameOnlyImport = true,
            };
            fileDescriptorSet.AddImportPath(inputPath);

            var inputFiles = new List <string>();
            foreach (var path in Directory.EnumerateFiles(inputPath, "*.proto", SearchOption.AllDirectories))
            {
                inputFiles.Add(MakeRelativePath(inputPath, path));
            }

            bool error = false;
            foreach (var proto in inputFiles)
            {
                if (!fileDescriptorSet.Add(proto, true))
                {
                    error = true;
                    ConsoleOutput.OutputError($"Error Loading: {proto}");
                }
            }
            if (error)
            {
                return(ErrorCode.InvalidProto);
            }

            fileDescriptorSet.Process();
            var errors = fileDescriptorSet.GetErrors();
            if (errors.Length > 0)
            {
                foreach (var err in errors)
                {
                    ConsoleOutput.OutputError(err.ToString());
                }

                return(ErrorCode.FileDescriptorSetProcessFailure);
            }

            #endregion Get the list of .proto files.

            #region Generate the files.

            Dictionary <string, string> options = new Dictionary <string, string>();
            if (!current)
            {
                string version = inputFolder;
                options.Add("PROTO_VERSION", version);
                outputPath = Path.Combine(outputPath, version);
            }
            string outputRelativePath = MakeRelativePath(basePath, outputPath);

            writer.WriteLine($"<!-- {outputRelativePath} -->");
            writer.WriteLine("  <ItemGroup>");


            foreach (var file in GM_CSharpCodeGenerator.Default.Generate(fileDescriptorSet, null, options))
            {
                var filePath   = Path.Combine(outputPath, file.Name);
                var fileFolder = Path.GetDirectoryName(filePath);
                if (!Directory.Exists(fileFolder))
                {
                    ConsoleOutput.OutputWarning($"Output directory does not exist, creating... {fileFolder}");
                    Directory.CreateDirectory(fileFolder);
                }

                File.WriteAllText(filePath, file.Text);

                writer.WriteLine($"    <Compile Include=\"{Path.Combine(outputRelativePath, file.Name)}\">");
                writer.WriteLine($"      <Visible>true</Visible>");
                writer.WriteLine($"    </Compile>");

                ConsoleOutput.OutputSuccess($"generated: {filePath}");
            }
            writer.WriteLine("  </ItemGroup>");

            writer.WriteLine("  <ItemGroup>");
            foreach (var file in fileDescriptorSet.Files)
            {
                writer.WriteLine($"    <None Include=\"{Path.Combine(inputRelativePath, file.Name)}\">");
                writer.WriteLine($"      <Visible>true</Visible>");
                writer.WriteLine($"    </None>");
            }
            writer.WriteLine("  </ItemGroup>");
            writer.WriteLine();

            ConsoleOutput.OutputSuccess($"generated: {ProjFile}");

            #endregion Generate the files.

            return(ErrorCode.Success);
        }
Пример #27
0
        public override List <ResultsGroup> Run()
        {
            List <ResultsGroup> results = new List <ResultsGroup>();

            foreach (SnapshotConfig snapshotConfig in _vmConfig.Snapshots)
            {
                ResultsGroup group = new ResultsGroup(
                    _vmConfig.Name, snapshotConfig.Name, snapshotConfig.Description);
                results.Add(group);

                DriverTaskInstance driverTaskInstance = new DriverTaskInstance(
                    _config,
                    _logpath,
                    _simulationOnly,
                    _vmConfig,
                    _installersConfig,
                    snapshotConfig);

                List <InstallerConfigProxy> uninstallConfigs = new List <InstallerConfigProxy>();

                foreach (InstallerConfigProxy installerConfigProxy in _installersConfig)
                {
                    InstallerConfig installerConfig = installerConfigProxy.Instance;
                    InstallerConfig.OnRewrite = new EventHandler <ReflectionResolverEventArgs>(
                        delegate(object sender, ReflectionResolverEventArgs args)
                    {
                        object[] objs = { snapshotConfig, _vmConfig, _installersConfig };
                        ReflectionResolver resolver = new ReflectionResolver(objs);
                        string result = null;
                        if (resolver.TryResolve(args.VariableType + "Config", args.VariableName, out result))
                        {
                            args.Result = result;
                        }
                    });

                    DriverTaskInstance.DriverTaskInstanceOptions installOptions = new DriverTaskInstance.DriverTaskInstanceOptions();
                    installOptions.Install   = installerConfig.Install;
                    installOptions.Uninstall = false;
                    installOptions.PowerOff  = false;

                    if (installerConfig.Install)
                    {
                        if (driverTaskInstance.InstallUninstall(installerConfig, installOptions))
                        {
                            uninstallConfigs.Add(installerConfigProxy);
                        }
                    }
                    else
                    {
                        ConsoleOutput.WriteLine("Skipping '{0}' on '{1}:{2}'", installerConfig.Name,
                                                _vmConfig.Name, snapshotConfig.Name);
                    }

                    group.AddRange(driverTaskInstance.Results);
                }

                foreach (InstallerConfigProxy installerConfigProxy in uninstallConfigs)
                {
                    InstallerConfig installerConfig = installerConfigProxy.Instance;
                    InstallerConfig.OnRewrite = new EventHandler <ReflectionResolverEventArgs>(
                        delegate(object sender, ReflectionResolverEventArgs args)
                    {
                        object[] objs = { snapshotConfig, _vmConfig, _installersConfig };
                        ReflectionResolver resolver = new ReflectionResolver(objs);
                        string result = null;
                        if (resolver.TryResolve(args.VariableType + "Config", args.VariableName, out result))
                        {
                            args.Result = result;
                        }
                    });

                    DriverTaskInstance.DriverTaskInstanceOptions uninstallOptions = new DriverTaskInstance.DriverTaskInstanceOptions();
                    uninstallOptions.Install   = false;
                    uninstallOptions.Uninstall = installerConfig.UnInstall;
                    uninstallOptions.PowerOff  = false;

                    if (installerConfig.UnInstall)
                    {
                        driverTaskInstance.InstallUninstall(installerConfig, uninstallOptions);
                        group.AddRange(driverTaskInstance.Results);
                    }
                    else
                    {
                        ConsoleOutput.WriteLine("Skipping '{0}' on '{1}:{2}'", installerConfig.Name,
                                                _vmConfig.Name, snapshotConfig.Name);
                    }
                }

                if (snapshotConfig.PowerOff)
                {
                    try
                    {
                        driverTaskInstance.PowerOff();
                    }
                    catch (Exception ex)
                    {
                        ConsoleOutput.WriteLine("Error powering off '{0}:{1}'", _vmConfig.Name, snapshotConfig.Name);
                        ConsoleOutput.WriteLine(ex);
                    }
                }
            }
            return(results);
        }
Пример #28
0
        static ErrorCode GenerateCode(string inputBaseFolder, string projectBaseFolder, string codeOutputRelativeFolder)
        {
            #region Validate Parameters

            if (!Directory.Exists(inputBaseFolder))
            {
                ConsoleOutput.OutputError($"inputBaseFolder not found: \"{inputBaseFolder}\"");
                return(ErrorCode.InputBaseFolderDoesNotExist);
            }

            if (!Directory.Exists(projectBaseFolder))
            {
                ConsoleOutput.OutputWarning($"projectBaseFolder not found, creating \"{projectBaseFolder}\"...");
                Directory.CreateDirectory(projectBaseFolder);
                if (!Directory.Exists(projectBaseFolder))
                {
                    ConsoleOutput.OutputError($"Could not create projectBaseFolder: \"{projectBaseFolder}\"");
                    return(ErrorCode.ProjectBaseFolderCouldNotBeCreated);
                }
                else
                {
                    ConsoleOutput.OutputSuccess("Success");
                }
            }

            string codeOutputBaseFolder = Path.Combine(projectBaseFolder, codeOutputRelativeFolder);
            if (!Directory.Exists(codeOutputBaseFolder))
            {
                ConsoleOutput.OutputWarning($"codeOutputRelativeFolder not found, creating \"{codeOutputBaseFolder}\"...");
                Directory.CreateDirectory(codeOutputBaseFolder);
                if (!Directory.Exists(codeOutputBaseFolder))
                {
                    ConsoleOutput.OutputError($"Could not create codeOutputRelativeFolder: \"{codeOutputBaseFolder}\"");
                    return(ErrorCode.CodeOutputFolderCouldNotBeCreated);
                }
                else
                {
                    ConsoleOutput.OutputSuccess("Success");
                }
            }

            #endregion Validate Parameters

            try
            {
                ErrorCode result            = ErrorCode.Success;
                var       fileDescriptorSet = new FileDescriptorSet {
                    AllowNameOnlyImport = true
                };
                fileDescriptorSet.AddImportPath(inputBaseFolder);

                var inputFiles = new List <string>();
                foreach (var path in Directory.EnumerateFiles(inputBaseFolder, "*.proto", SearchOption.AllDirectories))
                {
                    inputFiles.Add(MakeRelativePath(inputBaseFolder, path));
                }

                bool error = false;
                foreach (var proto in inputFiles)
                {
                    if (!fileDescriptorSet.Add(proto, true))
                    {
                        error = true;
                        ConsoleOutput.OutputError($"Error Loading: {proto}");
                    }
                }
                if (error)
                {
                    return(ErrorCode.InvalidProto);
                }

                fileDescriptorSet.Process();
                var errors = fileDescriptorSet.GetErrors();
                if (errors.Length > 0)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (var err in errors)
                    {
                        stringBuilder.AppendLine(err.ToString());
                    }

                    ConsoleOutput.OutputError(stringBuilder.ToString());

                    return(ErrorCode.FileDescriptorSetProcessFailure);
                }

                #region Generate the files.

                Dictionary <string, string> options = new Dictionary <string, string>();

                using (StreamWriter writer = new StreamWriter(Path.Combine(projectBaseFolder, ProjFile)))
                {
                    writer.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
                    writer.WriteLine("  <!-- ======================================================================= -->");
                    writer.WriteLine("  <!-- =============== This file is generated by GM_protogen. ================ -->");
                    writer.WriteLine("  <!-- ======================================================================= -->");
                    writer.WriteLine();

                    writer.WriteLine("  <!-- Generated .cs files -->");
                    writer.WriteLine("  <ItemGroup>");
                    foreach (var file in GM_CSharpCodeGenerator.Default.Generate(fileDescriptorSet, null, options))
                    {
                        var filePath   = Path.Combine(codeOutputBaseFolder, file.Name);
                        var fileFolder = Path.GetDirectoryName(filePath);
                        if (!Directory.Exists(fileFolder))
                        {
                            ConsoleOutput.OutputWarning($"Output directory does not exist, creating... {fileFolder}");
                            Directory.CreateDirectory(fileFolder);
                        }

                        File.WriteAllText(filePath, file.Text);

                        writer.WriteLine($"    <Compile Include=\"{Path.Combine(codeOutputRelativeFolder, file.Name)}\">");
                        writer.WriteLine($"      <Visible>true</Visible>");
                        writer.WriteLine($"    </Compile>");

                        ConsoleOutput.OutputSuccess($"generated: {filePath}");
                    }
                    writer.WriteLine("  </ItemGroup>");

                    writer.WriteLine();

                    writer.WriteLine("</Project>");
                }

                ConsoleOutput.OutputSuccess($"generated: {ProjFile}");

                #endregion Generate the files.

                return(result);
            }
            catch (Exception ex)
            {
                ConsoleOutput.OutputException(ex);

                return(ErrorCode.Exception);
            }
        }
Пример #29
0
        public static void DoExercises()
        {
            #region Exercise 2

            ConsoleOutput.Title("2");
            if (YesNo())
            {
                Console.WriteLine("First name?");
                string inputFirstName = Console.ReadLine();
                Console.WriteLine("Last name?");
                string inputLastName = Console.ReadLine();
                Console.WriteLine("Phone number?");
                int inputPhone = int.Parse(Console.ReadLine());
                Console.WriteLine("Address?");
                string inputAddress = Console.ReadLine();
                Console.WriteLine("Profession?");
                string inputProfession = Console.ReadLine();

                Console.Write("{0, -10}", inputFirstName);
                Console.Write(" {0, -10}", inputLastName);
                Console.Write(" {0, 10}{1}", inputPhone, Environment.NewLine);
                Console.Write(inputAddress);
                Console.Write("{0, -15}", inputProfession);
            }

            #endregion Exercise 2

            #region Exercise 5

            ConsoleOutput.Title("5");
            if (YesNo())
            {
                Console.WriteLine("please input min integer and max integer separated by a space");
                string   input      = Console.ReadLine();
                string[] inputSplit = input.Split(new char[] { ' ' }, 2);
                int      minLimit   = Convert.ToInt32(inputSplit[0]);
                int      maxLimit   = Convert.ToInt32(inputSplit[1]);

                int[] results        = new int[(maxLimit - minLimit) - 1];
                int   resultsCounter = 0;

                for (int i = 1; i < (maxLimit - minLimit); i++)
                {
                    if ((minLimit + i) % 5 == 0)
                    {
                        resultsCounter++;
                        results[i - 1] = minLimit + i;
                    }
                }
                bool firstTicker = false;
                if (resultsCounter > 0)
                {
                    Console.WriteLine("There are {0} numbers divisible by 5 between {1} and {2}, here they are:", resultsCounter, minLimit, maxLimit);
                }
                else
                {
                    Console.WriteLine("There are no numbers divisble by 5 between {0} and {1}", minLimit, maxLimit);
                }
                for (int i = 0; i < results.Length; i++)
                {
                    if (results[i] != 0)
                    {
                        if (firstTicker)
                        {
                            Console.Write(", ");
                        }
                        firstTicker = true;
                        Console.Write(results[i]);
                    }
                    if (i == results.Length - 1)
                    {
                        Console.Write("." + Environment.NewLine);
                    }
                }
            }

            #endregion Exercise 5

            #region Exercise 6

            ConsoleOutput.Title("6");
            if (YesNo())
            {
                Console.Write("Enter 2 numbers to compare" + Environment.NewLine + "Number 1: ");
                double[] nums = new double[2];
                nums[0] = ConsoleInput.ReadDouble();
                Console.Write("Number 2: ");
                nums[1] = ConsoleInput.ReadDouble();
                if (nums[0] == nums[1])
                {
                    Console.WriteLine("These numbers are the same");
                }
                else
                {
                    Console.WriteLine("{1} is greater than {2}, {0}and their difference is:{0}{3}", Environment.NewLine, Math.Max(nums[0], nums[1]), Math.Min(nums[0], nums[1]), Math.Max(nums[0], nums[1]) - Math.Min(nums[0], nums[1]));
                }
            }

            #endregion Exercise 6

            #region Exercise 7

            ConsoleOutput.Title("7");
            if (YesNo())
            {
                Console.WriteLine("Input 5 numbers please, their sum  will be computed.");
                double[] nums = new double[5];
                double   sum  = 0;
                for (int i = 1; i <= 5; i++)
                {
                    Console.Write("Number {0}", i);
                    nums[i - 1] = ConsoleInput.ReadDouble();
                    sum        += nums[i - 1];
                }
                Console.WriteLine("The sum of these numbers is:" + Environment.NewLine + sum);
            }

            #endregion Exercise 7

            #region Exercise 8

            ConsoleOutput.Title("8");
            if (YesNo())
            {
                Console.WriteLine("Input numbers to compare and press Enter when you're finished");
                List <double> nums = new List <double>();
                // take input
                short count = 0;
                while (true)
                {
                    count++;
                    Console.Write("> ");
                    double num;
                    string input = Console.ReadLine();
                    if (Double.TryParse(input, out num))
                    {
                        nums.Add(num);
                    }
                    else
                    {
                        break;
                    }
                }
                // calculate sum
                double sum = 0;
                if (nums.Count > 0)
                {
                    for (int i = 0; i < nums.Count; i++)
                    {
                        sum += nums[i];
                    }
                }
                Console.WriteLine("The sum of the numbers you input is: " + Environment.NewLine + sum);
            }

            #endregion Exercise 8
        }
Пример #30
0
        private static bool ReflectionEmitInternal(
            Compilation compilation,
            string expectedOutput,
            bool peImageRequested,
            out ImmutableArray <byte> peImage,
            bool refEmitSupported,
            bool fallback,
            bool collectEmittedAssembly,
            bool peVerify,
            TempRoot tempRoot)
        {
            peImage = default(ImmutableArray <byte>);

            var success = false;
            var compilationDependencies = new List <ModuleData>();
            var diagnostics             = new DiagnosticBag();

            HostedRuntimeEnvironment.EmitReferences(compilation, compilationDependencies, diagnostics);

            // allow warnings
            if (diagnostics.HasAnyErrors())
            {
                // this will throw if there are errors
                diagnostics.Verify();
            }

            bool doExecute = expectedOutput != null;

            string fileName;
            string fileNameExt;
            string fileDir;

            TempFile outputFile;
            AssemblyBuilderAccess access;

            if (peImageRequested)
            {
                access = doExecute ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Save;

                // Until HostedExecutionEnvironment supports ref emit, we need to generate a unique temp file.
                // Otherwise, the file will be held open the next time we Emit this same compilation (done in CompileAndVerify).
                outputFile = tempRoot.CreateFile("RefEmit_", ".dll");

                fileNameExt = Path.GetFileName(outputFile.Path);
                fileName    = Path.GetFileNameWithoutExtension(fileNameExt);
                fileDir     = Path.GetDirectoryName(outputFile.Path);
            }
            else
            {
                outputFile = null;

                fileName    = CommonTestBase.GetUniqueName();
                fileNameExt = fileName + ".dll";
                fileDir     = null;

                access = collectEmittedAssembly ? AssemblyBuilderAccess.RunAndCollect : AssemblyBuilderAccess.Run;
            }

            var             assemblyName = new AssemblyIdentity(fileName).ToAssemblyName();
            AssemblyBuilder abuilder     = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, access, fileDir);
            ModuleBuilder   mbuilder     = abuilder.DefineDynamicModule("Module", fileNameExt, emitSymbolInfo: false);

            using (var assemblyManager = new RuntimeAssemblyManager())
            {
                assemblyManager.AddModuleData(compilationDependencies);

                DiagnosticBag emitDiagnostics = DiagnosticBag.GetInstance();
                MethodInfo    entryPoint;

                byte[] compiledAssemblyImage;

                success = compilation.Emit(
                    moduleBuilder: mbuilder,
                    assemblyLoader: new AssemblyLoader(assemblyManager),
                    assemblySymbolMapper: null,
                    recoverOnError: !refEmitSupported && fallback,
                    diagnostics: emitDiagnostics,
                    cancellationToken: default(CancellationToken),
                    entryPoint: out entryPoint,
                    compiledAssemblyImage: out compiledAssemblyImage
                    );

                emitDiagnostics.Free();

                if (success && peImageRequested)
                {
                    if (fallback)
                    {
                        peImage = compiledAssemblyImage.AsImmutableOrNull();
                    }
                    else
                    {
                        abuilder.Save(fileNameExt);
                        peImage = CommonTestBase.ReadFromFile(outputFile.Path);
                    }
                }

                if (refEmitSupported)
                {
                    Assert.True(success, "Expected Ref.Emit success");
                    Assert.Null(compiledAssemblyImage);
                }
                else if (fallback)
                {
                    Assert.True(success, "Expected fallback to CCI");
                    Assert.NotNull(compiledAssemblyImage);
                }
                else
                {
                    Assert.False(success, "Expected emit failure but it succeeded");
                    Assert.Null(compiledAssemblyImage);
                }

                if (success)
                {
                    if (peVerify)
                    {
                        Assert.False(peImage.IsDefault);

                        // Saving AssemblyBuilder to disk changes its manifest module MVID.
                        Guid mvid;
                        using (var metadata = ModuleMetadata.CreateFromImage(peImage))
                        {
                            mvid = metadata.GetModuleVersionId();
                        }

                        assemblyManager.AddMainModuleMvid(mvid);
#if !(ARM)
                        Assert.Equal(String.Empty, CLRHelpers.PeVerify(peImage).Concat());
#endif
                    }

                    if (doExecute)
                    {
                        Assert.NotNull(entryPoint);
                        assemblyManager.AddMainModuleMvid(entryPoint.Module.ModuleVersionId);

                        Action main = GetEntryPointAction(entryPoint);
                        ConsoleOutput.AssertEqual(main, expectedOutput, "");
                    }
                }

                return(success);
            }
        }
Пример #31
0
    public Program(
        IFileSystem fileSystem,
        IMetadataReader metadataReader,
        TextWriter outputWriter,
        CancellationTokenSource cancellationTokenSource)
    {
        /* Composition Root. Out of process resources can be swapped with fakes in tests. */
        _outputWriter            = outputWriter;
        _cancellationTokenSource = cancellationTokenSource;
        var report            = new Report(_outputWriter);
        var cameraFilesFinder = new CameraFilesFinder(fileSystem);

        cameraFilesFinder.OnCameraFilesFound += report.HandleCameraFilesFound;
        var cameraFileFactory       = new CameraFileFactory();
        var cameraFileNameConverter =
            new CameraFileNameConverter(
                metadataReader,
                cameraFileFactory,
                fileSystem);
        var consoleOutput    = new ConsoleOutput(_outputWriter);
        var cameraFileCopier =
            new CameraFileTransferer(
                cameraFileNameConverter,
                fileSystem,
                (s, d, o) => fileSystem.File.Copy(s, d, o));

        cameraFileCopier.OnFileTransferred +=
            (_, args) => consoleOutput.HandleFileCopied(args.sourceFile, args.destinationFile);
        AssignEventHandlersForCameraFileTransferer(cameraFileCopier);
        var internalCopyingOrchestrator =
            new Orchestrator(
                cameraFilesFinder,
                cameraFileCopier,
                _cancellationTokenSource.Token);

        internalCopyingOrchestrator.OnError +=
            (_, args) => consoleOutput.HandleError(args.filePath, args.error);
        internalCopyingOrchestrator.OnError +=
            (_, args) => report.AddErrorForFile(args.filePath, args.error);
        internalCopyingOrchestrator.OnException +=
            (_, args) => consoleOutput.HandleException(args.filePath, args.exception);
        internalCopyingOrchestrator.OnException +=
            (_, args) => report.AddExceptionForFile(args.filePath, args.exception);
        IOrchestrator copyingOrchestrator =
            new ReportingOrchestratorDecorator(
                internalCopyingOrchestrator,
                report);
        var cameraFileMover =
            new CameraFileTransferer(
                cameraFileNameConverter,
                fileSystem,
                (s, d, o) => fileSystem.File.Move(s, d, o));

        cameraFileMover.OnFileTransferred +=
            (_, args) => consoleOutput.HandleFileMoved(args.sourceFile, args.destinationFile);
        AssignEventHandlersForCameraFileTransferer(cameraFileMover);
        var internalMovingOrchestrator =
            new Orchestrator(
                cameraFilesFinder,
                cameraFileMover,
                _cancellationTokenSource.Token);

        internalMovingOrchestrator.OnError +=
            (_, args) => consoleOutput.HandleError(args.filePath, args.error);
        internalMovingOrchestrator.OnError +=
            (_, args) => report.AddErrorForFile(args.filePath, args.error);
        internalMovingOrchestrator.OnException +=
            (_, args) => consoleOutput.HandleException(args.filePath, args.exception);
        internalMovingOrchestrator.OnException +=
            (_, args) => report.AddExceptionForFile(args.filePath, args.exception);
        IOrchestrator movingOrchestrator =
            new ReportingOrchestratorDecorator(
                internalMovingOrchestrator,
                report);

        _copyCommand = new CopyCommand(args => copyingOrchestrator.Execute(args));
        _moveCommand = new MoveCommand(args => movingOrchestrator.Execute(args));

        var fileChecker =
            new FileChecker(
                cameraFilesFinder,
                metadataReader,
                cameraFileFactory,
                new Commands.Check.Output.ConsoleOutput(_outputWriter));

        _checkCommand = new CheckCommand(args => fileChecker.Execute(args));

        void AssignEventHandlersForCameraFileTransferer(
            CameraFileTransferer cameraFileTransferer)
        {
            cameraFileTransferer.OnDirectoryCreated +=
                (_, directory) => consoleOutput.HandleCreatedDirectory(directory);
            cameraFileTransferer.OnFileSkipped +=
                (_, args) => consoleOutput.HandleFileSkipped(args.sourceFile, args.destinationFile);
            cameraFileTransferer.OnFileSkipped +=
                (_, args) => report.AddSkippedFile(args.sourceFile, args.destinationFile);
            cameraFileTransferer.OnFileTransferred +=
                (_, args) => report.IncrementTransferred(args.dryRun);
        }
    }
Пример #32
0
 /// <summary>
 /// Invoke the specified command in a pipeline asynchronously, optionally providing input to the first command, and with the specified output handling.
 /// </summary>
 /// <param name="command">The Command from which the pipeline will be constructed.</param>
 /// <param name="input">Optional Pipeline Input. If this is specified, your first command must accept pipeline input</param>
 /// <param name="output">Optionally: what to print to the console (prints everything, by default, as though the user had typed the commands in the console)</param>
 /// <returns>A Task which returns the <see cref="PoshConsolePipelineResults"/> results, including the pipeline output</returns>
 public Task <PoshConsolePipelineResults> InvokeAsync(Command command, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
 {
     return(Runner.Invoke(new [] { command }, input, output));
 }
Пример #33
0
 private void processAbort(FormStatus form)
 {
     ConsoleOutput.KillProcess();
 }
Пример #34
0
 /// <summary>
 /// Invoke the specified command in a pipeline asynchronously, optionally providing input to the first command, and with the specified output handling.
 /// </summary>
 /// <param name="command">The Command from which the pipeline will be constructed.</param>
 /// <param name="isScript">Whether the command is a script (defaults to true). You should set this to false if you are just naming a command.</param>
 /// <param name="useLocalScope">Whether the command should use it's own local scope -- only valid for scripts (defaults to false)</param>
 /// <param name="input">Optional Pipeline Input. If this is specified, your first command must accept pipeline input</param>
 /// <param name="output">Optionally: what to print to the console (prints everything, by default, as though the user had typed the commands in the console)</param>
 /// <returns>A Task which returns the <see cref="PoshConsolePipelineResults"/> results, including the pipeline output</returns>
 public Task <PoshConsolePipelineResults> InvokeAsync(string command, bool isScript = true, bool useLocalScope = false, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
 {
     return(Runner.Invoke(new[] { new Command(command, isScript, useLocalScope) }, input, output));
 }
Пример #35
0
        public Main()
        {
            DbConfiguration.SetConfiguration(new QueryLogDbConfiguration());
            try
            {
                #region Core preparing / initialization

                // Clear console, set console color & write copyright
                ConsoleUtils.Clear();

                // Prepare Console set title
                ConsoleHandler.Server.ConsoleHandler.PrepareConsole();

                #endregion // Core preparing / initialization

                ConsoleUtils.SetConsoleTitle("EvoMp GT-MP Server Core. All rights reserverd.");

                // Load Console params
                ParameterHandler.LoadParams();

                CheckDatabaseReset();

                // Load logo
                ParameterHandler.SetDefault("LogoPath", "./ServerFiles/Default_Logo.txt");
                string asciiLogoFile = ParameterHandler.GetValue("LogoPath");

                #region Logo, Copyright, Server informations

                ConsoleOutput.PrintLine("-", "~#E6E6E6~");

                // Write logo from logo file
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               ConsoleUtils.ParseTextFileForConsole($"{asciiLogoFile}", 2, 1));

                // No Logo defined -> message and use default Logo
                if (ParameterHandler.IsDefault("LogoPath"))
                {
                    ConsoleOutput.WriteCentredText(ConsoleType.Config,
                                                   $"Using logo file ~o~\"{Path.GetFullPath($"{asciiLogoFile}")}\"~;~.\n" +
                                                   $"Please start your server with the ~b~" +
                                                   $"logopath ~;~ " +
                                                   $"parameter.");
                }

                // GetServerGamemodes writes cfg message to if not setten
                string moduleTypesString =
                    string.Join(", ",
                                ModuleTypeHandler.GetServerGamemodes().ToList().ConvertAll(input => input.ToUpper()));

                const string leftServerInfo  = "~#90A4AE~";
                const string rightServerInfo = "~#ECEFF1~";

                // Tiny gray line & Empty
                ConsoleOutput.PrintLine(" ");

                // Small centered line with headline & developer
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               "".PadRight(80, '-') + "\n" +
                                               "Server information\n" +
                                               "".PadRight(80, '-'));

                ConsoleOutput.WriteCentredText(ConsoleType.Info,
                                               $"{leftServerInfo}{"Server mode:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{moduleTypesString}".PadRight(35)}\n" +
                                               $"{leftServerInfo}{"Runtime mode:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{(Debug ? "Debugging" : "Release")}".PadRight(35)}\n" +
                                               $"{leftServerInfo}{"Server name:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{API.getServerName()}{"".PadRight(ColorUtils.CleanUp(API.getServerName()).Length > 35 ? 0 : 35 - ColorUtils.CleanUp(API.getServerName()).Length)}\n" +
                                               $"{leftServerInfo}{"Server port:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{API.getServerPort():0000}".PadRight(35)}\n" +
                                               $"{leftServerInfo}{"Max players:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{API.getMaxPlayers():0000}".PadRight(35)}\n");

                // One empty lines
                ConsoleOutput.PrintLine(" ");

                // Small centered line with headline & developer
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               "".PadRight(80, '-') + "\n" +
                                               "Developer team\n" +
                                               "".PadRight(80, '-'));

                const string usernameColor   = "~#ECEFF1~";
                const string diTitleColor    = "~#03A9F4~";
                const string depyTitleColor  = "~#4FC3F7~";
                const string staffTitleColor = "~#B3E5FC~";

                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               $"{diTitleColor}{"Freeroam Director".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"Ruffo ~c~(Christian Groothoff)".PadRight(35 + 3)}\n" +
                                               $"{depyTitleColor}{"Freeroam Deputy".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"Koka".PadRight(35)}\n" +
                                               $"{depyTitleColor}{"Freeroam Staff".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"Sascha".PadRight(35)}\n" +
                                               $"{staffTitleColor}{"Freeroam Staff".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"James".PadRight(35)}\n"
                                               );

                ConsoleOutput.PrintLine(" ");

                // Startup parameters
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               "".PadRight(80, '-') + "\n" +
                                               "Startup Parameters\n" +
                                               "".PadRight(80, '-'));
                ParameterHandler.PrintArgs();

                ConsoleOutput.PrintLine(" ");
                ConsoleOutput.PrintLine("-");

                #endregion Logo, Copyright, Server informations

                // Only copy and then stop. Used for docker

                ParameterHandler.SetDefault("onlyCopy", "false");

                // Write information about Core startup
                ConsoleOutput.WriteLine(ConsoleType.Core, "Initializing EvoMp Core...");

                // Init ModuleStructurer
                ModuleStructurer moduleStructurer = new ModuleStructurer();

                // Copy modules & NuGet files to Server
                moduleStructurer.CopyModulesToServer();
                moduleStructurer.CopyNuGetPackagesToServer();

                // Write complete & loading modules message
                ConsoleOutput.WriteLine(ConsoleType.Core, "Initializing EvoMp Core completed.");

                if (!ParameterHandler.IsDefault("onlyCopy"))
                {
                    // Finish sequence
                    SharedEvents.OnOnCoreStartupCompleted();
                    ConsoleOutput.WriteLine(ConsoleType.Core, "Core startup completed");
                    ConsoleOutput.PrintLine("-");

                    ConsoleOutput.WriteLine(ConsoleType.Core, "OnlyCopy parameter has been detected! Stopping Server!");
                    Environment.Exit(0);
                }
                else
                {
                    SharedEvents.OnOnModuleLoadingStart(API);

                    // Load Modules
                    new ModuleLoader(API).Load();

                    // Finish sequence
                    SharedEvents.OnOnCoreStartupCompleted();
                    ConsoleOutput.WriteLine(ConsoleType.Core, "Core startup completed");
                    ConsoleOutput.PrintLine("-");
                }

                SharedEvents.OnOnAfterCoreStartupCompleted();
            }
            catch (Exception e)
            {
                //#if DEBUG
                ConsoleOutput.WriteException(e.ToString());
                Exception innerException = e.InnerException;
                while (innerException != null)
                {
                    ConsoleOutput.WriteException(innerException.ToString());
                    innerException = innerException.InnerException;
                }

                //throw lastInnerException;
//#endif
            }
        }
Пример #36
0
 /// <summary>
 /// Invoke the specified script, synchronously, and return the pipeline output.
 /// </summary>
 /// <param name="script">The script from which the pipeline will be constructed. Can be just a command name, but is executed as though typed on the console.</param>
 /// <param name="output">Optionally: what to print to the console (prints everything, by default, as though the user had typed the commands in the console)</param>
 /// <returns>The pipeline output</returns>
 public Collection <PSObject> Invoke(string script, ConsoleOutput output = ConsoleOutput.Default)
 {
     return(Runner.Invoke(new[] { new Command(script, true) }, null, output).GetAwaiter().GetResult().Output);
 }
Пример #37
0
 public void SetUp()
 {
     _obj = new ConsoleOutput();
     _obj2 = new ConsoleReader();
 }
Пример #38
0
        public Task <PoshConsolePipelineResults> Invoke(IList <Command> commands, IEnumerable input = null, ConsoleOutput output = ConsoleOutput.Default)
        {
            var pipeline = new PoshConsolePipeline(commands, input, output);

            // Even though CommandQueue is threaded
            // We NEED to ensure that our sets of commands stay together
            CommandQueue.Post(pipeline);
            return(pipeline.Task);
        }
Пример #39
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(YalfForm));
     System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Node0");
     this.btnDump = new System.Windows.Forms.Button();
     this.btnClean = new System.Windows.Forms.Button();
     this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     this.tbRegexHelp = new System.Windows.Forms.TextBox();
     this.lblThreadList = new System.Windows.Forms.Label();
     this.lstThreadList = new System.Windows.Forms.ListBox();
     this.txtStatus = new System.Windows.Forms.TextBox();
     this.txtLogContext = new System.Windows.Forms.TextBox();
     this.label4 = new System.Windows.Forms.Label();
     this.btnCsvDump = new System.Windows.Forms.Button();
     this.txtCsvFolder = new System.Windows.Forms.TextBox();
     this.label3 = new System.Windows.Forms.Label();
     this.pnlMainOptions = new System.Windows.Forms.Panel();
     this.label7 = new System.Windows.Forms.Label();
     this.chkUseThreadGroupDisplay = new System.Windows.Forms.CheckBox();
     this.chkShowRegExHelp = new System.Windows.Forms.CheckBox();
     this.lblLastLogEntry = new System.Windows.Forms.Label();
     this.lblFirstLogEntry = new System.Windows.Forms.Label();
     this.txtTimeStampTo = new System.Windows.Forms.TextBox();
     this.label6 = new System.Windows.Forms.Label();
     this.txtTimeStampFrom = new System.Windows.Forms.TextBox();
     this.label5 = new System.Windows.Forms.Label();
     this.btnSaveFilters = new System.Windows.Forms.Button();
     this.btnLoadFilters = new System.Windows.Forms.Button();
     this.chkSingleLineFormat = new System.Windows.Forms.CheckBox();
     this.chkHideMethodReturnValue = new System.Windows.Forms.CheckBox();
     this.chkHodeMethodParameters = new System.Windows.Forms.CheckBox();
     this.chkHideDuration = new System.Windows.Forms.CheckBox();
     this.chkHideTimestamp = new System.Windows.Forms.CheckBox();
     this.chkHideExitMethod = new System.Windows.Forms.CheckBox();
     this.chkHideEnterMethod = new System.Windows.Forms.CheckBox();
     this.btnApplyFilters = new System.Windows.Forms.Button();
     this.ExcludedKeyList = new System.Windows.Forms.TextBox();
     this.label2 = new System.Windows.Forms.Label();
     this.IncludedKeyList = new System.Windows.Forms.TextBox();
     this.label1 = new System.Windows.Forms.Label();
     this.btnLoad = new System.Windows.Forms.Button();
     this.btnSave = new System.Windows.Forms.Button();
     this.chkIgnoreCase = new System.Windows.Forms.CheckBox();
     this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
     this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
     this.saveSettingsFileDialog = new System.Windows.Forms.SaveFileDialog();
     this.openSettingsFileDialog = new System.Windows.Forms.OpenFileDialog();
     this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
     this.tvFilter = new YalfPerver.MyTreeView();
     this.consoleOutput = new YalfPerver.ConsoleOutput();
     ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
     this.splitContainer1.Panel1.SuspendLayout();
     this.splitContainer1.Panel2.SuspendLayout();
     this.splitContainer1.SuspendLayout();
     this.pnlMainOptions.SuspendLayout();
     this.SuspendLayout();
     //
     // btnDump
     //
     this.btnDump.Location = new System.Drawing.Point(12, 8);
     this.btnDump.Name = "btnDump";
     this.btnDump.Size = new System.Drawing.Size(41, 23);
     this.btnDump.TabIndex = 0;
     this.btnDump.Text = "dump";
     this.btnDump.UseVisualStyleBackColor = true;
     this.btnDump.Click += new System.EventHandler(this.btnDump_Click);
     //
     // btnClean
     //
     this.btnClean.Location = new System.Drawing.Point(55, 8);
     this.btnClean.Name = "btnClean";
     this.btnClean.Size = new System.Drawing.Size(41, 23);
     this.btnClean.TabIndex = 1;
     this.btnClean.Text = "clean";
     this.btnClean.UseVisualStyleBackColor = true;
     this.btnClean.Click += new System.EventHandler(this.btnClean_Click);
     //
     // splitContainer1
     //
     this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     | System.Windows.Forms.AnchorStyles.Left)
     | System.Windows.Forms.AnchorStyles.Right)));
     this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
     this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
     this.splitContainer1.Location = new System.Drawing.Point(0, 12);
     this.splitContainer1.MinimumSize = new System.Drawing.Size(600, 400);
     this.splitContainer1.Name = "splitContainer1";
     //
     // splitContainer1.Panel1
     //
     this.splitContainer1.Panel1.Controls.Add(this.tbRegexHelp);
     this.splitContainer1.Panel1.Controls.Add(this.tvFilter);
     this.splitContainer1.Panel1.Controls.Add(this.lblThreadList);
     this.splitContainer1.Panel1.Controls.Add(this.lstThreadList);
     this.splitContainer1.Panel1.Controls.Add(this.txtStatus);
     this.splitContainer1.Panel1.Controls.Add(this.txtLogContext);
     this.splitContainer1.Panel1.Controls.Add(this.label4);
     this.splitContainer1.Panel1.Controls.Add(this.btnCsvDump);
     this.splitContainer1.Panel1.Controls.Add(this.txtCsvFolder);
     this.splitContainer1.Panel1.Controls.Add(this.label3);
     this.splitContainer1.Panel1.Controls.Add(this.pnlMainOptions);
     //
     // splitContainer1.Panel2
     //
     this.splitContainer1.Panel2.Controls.Add(this.consoleOutput);
     this.splitContainer1.Size = new System.Drawing.Size(1370, 738);
     this.splitContainer1.SplitterDistance = 686;
     this.splitContainer1.TabIndex = 3;
     //
     // tbRegexHelp
     //
     this.tbRegexHelp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     | System.Windows.Forms.AnchorStyles.Right)));
     this.tbRegexHelp.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.tbRegexHelp.Font = new System.Drawing.Font("Consolas", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.tbRegexHelp.Location = new System.Drawing.Point(3, 491);
     this.tbRegexHelp.Multiline = true;
     this.tbRegexHelp.Name = "tbRegexHelp";
     this.tbRegexHelp.ReadOnly = true;
     this.tbRegexHelp.Size = new System.Drawing.Size(676, 240);
     this.tbRegexHelp.TabIndex = 12;
     this.tbRegexHelp.Text = resources.GetString("tbRegexHelp.Text");
     this.tbRegexHelp.WordWrap = false;
     //
     // lblThreadList
     //
     this.lblThreadList.AutoSize = true;
     this.lblThreadList.Location = new System.Drawing.Point(363, 3);
     this.lblThreadList.Name = "lblThreadList";
     this.lblThreadList.Size = new System.Drawing.Size(46, 13);
     this.lblThreadList.TabIndex = 29;
     this.lblThreadList.Text = "Threads";
     //
     // lstThreadList
     //
     this.lstThreadList.FormattingEnabled = true;
     this.lstThreadList.IntegralHeight = false;
     this.lstThreadList.Location = new System.Drawing.Point(366, 19);
     this.lstThreadList.Name = "lstThreadList";
     this.lstThreadList.Size = new System.Drawing.Size(313, 108);
     this.lstThreadList.TabIndex = 21;
     this.lstThreadList.SelectedIndexChanged += new System.EventHandler(this.lstThreadList_SelectedIndexChanged);
     //
     // txtStatus
     //
     this.txtStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     | System.Windows.Forms.AnchorStyles.Left)));
     this.txtStatus.BackColor = System.Drawing.SystemColors.ControlDark;
     this.txtStatus.Font = new System.Drawing.Font("Consolas", 8F);
     this.txtStatus.ForeColor = System.Drawing.SystemColors.ControlLight;
     this.txtStatus.Location = new System.Drawing.Point(3, 517);
     this.txtStatus.Multiline = true;
     this.txtStatus.Name = "txtStatus";
     this.txtStatus.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     this.txtStatus.Size = new System.Drawing.Size(356, 0);
     this.txtStatus.TabIndex = 20;
     //
     // txtLogContext
     //
     this.txtLogContext.Location = new System.Drawing.Point(69, 465);
     this.txtLogContext.Name = "txtLogContext";
     this.txtLogContext.Size = new System.Drawing.Size(210, 20);
     this.txtLogContext.TabIndex = 19;
     this.txtLogContext.Text = "YalfDump";
     //
     // label4
     //
     this.label4.AutoSize = true;
     this.label4.Location = new System.Drawing.Point(0, 468);
     this.label4.Name = "label4";
     this.label4.Size = new System.Drawing.Size(64, 13);
     this.label4.TabIndex = 18;
     this.label4.Text = "Log Context";
     //
     // btnCsvDump
     //
     this.btnCsvDump.Location = new System.Drawing.Point(285, 488);
     this.btnCsvDump.Name = "btnCsvDump";
     this.btnCsvDump.Size = new System.Drawing.Size(75, 23);
     this.btnCsvDump.TabIndex = 17;
     this.btnCsvDump.Text = "Create [F12]";
     this.btnCsvDump.UseVisualStyleBackColor = true;
     this.btnCsvDump.Click += new System.EventHandler(this.btnCsvDump_Click);
     //
     // txtCsvFolder
     //
     this.txtCsvFolder.Location = new System.Drawing.Point(69, 491);
     this.txtCsvFolder.Name = "txtCsvFolder";
     this.txtCsvFolder.Size = new System.Drawing.Size(210, 20);
     this.txtCsvFolder.TabIndex = 14;
     this.txtCsvFolder.Text = "C:\\Temp";
     //
     // label3
     //
     this.label3.AutoSize = true;
     this.label3.Location = new System.Drawing.Point(0, 494);
     this.label3.Name = "label3";
     this.label3.Size = new System.Drawing.Size(61, 13);
     this.label3.TabIndex = 13;
     this.label3.Text = "Save folder";
     //
     // pnlMainOptions
     //
     this.pnlMainOptions.Controls.Add(this.label7);
     this.pnlMainOptions.Controls.Add(this.chkUseThreadGroupDisplay);
     this.pnlMainOptions.Controls.Add(this.chkShowRegExHelp);
     this.pnlMainOptions.Controls.Add(this.lblLastLogEntry);
     this.pnlMainOptions.Controls.Add(this.lblFirstLogEntry);
     this.pnlMainOptions.Controls.Add(this.txtTimeStampTo);
     this.pnlMainOptions.Controls.Add(this.label6);
     this.pnlMainOptions.Controls.Add(this.txtTimeStampFrom);
     this.pnlMainOptions.Controls.Add(this.label5);
     this.pnlMainOptions.Controls.Add(this.btnSaveFilters);
     this.pnlMainOptions.Controls.Add(this.btnLoadFilters);
     this.pnlMainOptions.Controls.Add(this.chkSingleLineFormat);
     this.pnlMainOptions.Controls.Add(this.chkHideMethodReturnValue);
     this.pnlMainOptions.Controls.Add(this.chkHodeMethodParameters);
     this.pnlMainOptions.Controls.Add(this.chkHideDuration);
     this.pnlMainOptions.Controls.Add(this.chkHideTimestamp);
     this.pnlMainOptions.Controls.Add(this.chkHideExitMethod);
     this.pnlMainOptions.Controls.Add(this.chkHideEnterMethod);
     this.pnlMainOptions.Controls.Add(this.btnApplyFilters);
     this.pnlMainOptions.Controls.Add(this.ExcludedKeyList);
     this.pnlMainOptions.Controls.Add(this.label2);
     this.pnlMainOptions.Controls.Add(this.IncludedKeyList);
     this.pnlMainOptions.Controls.Add(this.label1);
     this.pnlMainOptions.Controls.Add(this.btnLoad);
     this.pnlMainOptions.Controls.Add(this.btnSave);
     this.pnlMainOptions.Controls.Add(this.btnDump);
     this.pnlMainOptions.Controls.Add(this.btnClean);
     this.pnlMainOptions.Controls.Add(this.chkIgnoreCase);
     this.pnlMainOptions.Location = new System.Drawing.Point(3, 3);
     this.pnlMainOptions.MinimumSize = new System.Drawing.Size(212, 47);
     this.pnlMainOptions.Name = "pnlMainOptions";
     this.pnlMainOptions.Size = new System.Drawing.Size(362, 457);
     this.pnlMainOptions.TabIndex = 0;
     //
     // label7
     //
     this.label7.AutoSize = true;
     this.label7.Location = new System.Drawing.Point(7, 156);
     this.label7.Name = "label7";
     this.label7.Size = new System.Drawing.Size(74, 13);
     this.label7.TabIndex = 28;
     this.label7.Text = "&Included Keys";
     //
     // chkUseThreadGroupDisplay
     //
     this.chkUseThreadGroupDisplay.AutoSize = true;
     this.chkUseThreadGroupDisplay.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkUseThreadGroupDisplay.Location = new System.Drawing.Point(168, 430);
     this.chkUseThreadGroupDisplay.Name = "chkUseThreadGroupDisplay";
     this.chkUseThreadGroupDisplay.Size = new System.Drawing.Size(106, 17);
     this.chkUseThreadGroupDisplay.TabIndex = 27;
     this.chkUseThreadGroupDisplay.Text = "&Group by Thread";
     this.toolTip1.SetToolTip(this.chkUseThreadGroupDisplay, "Gorup logs by thread.  A Thread selection window is displayed when this option is" +
     " chosen");
     this.chkUseThreadGroupDisplay.UseVisualStyleBackColor = true;
     this.chkUseThreadGroupDisplay.CheckedChanged += new System.EventHandler(this.chkUseThreadGroupDisplay_CheckedChanged);
     //
     // chkShowRegExHelp
     //
     this.chkShowRegExHelp.AutoSize = true;
     this.chkShowRegExHelp.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkShowRegExHelp.Checked = true;
     this.chkShowRegExHelp.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkShowRegExHelp.Location = new System.Drawing.Point(153, 155);
     this.chkShowRegExHelp.Name = "chkShowRegExHelp";
     this.chkShowRegExHelp.Size = new System.Drawing.Size(113, 17);
     this.chkShowRegExHelp.TabIndex = 26;
     this.chkShowRegExHelp.Text = "Show RegEx &Help";
     this.toolTip1.SetToolTip(this.chkShowRegExHelp, "Turn RegEx help on or off.  Turn off to regain more screen real estate.");
     this.chkShowRegExHelp.UseVisualStyleBackColor = true;
     this.chkShowRegExHelp.CheckedChanged += new System.EventHandler(this.chkShowRegExHelp_CheckedChanged);
     //
     // lblLastLogEntry
     //
     this.lblLastLogEntry.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.lblLastLogEntry.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.lblLastLogEntry.ForeColor = System.Drawing.SystemColors.MenuHighlight;
     this.lblLastLogEntry.Location = new System.Drawing.Point(235, 127);
     this.lblLastLogEntry.Name = "lblLastLogEntry";
     this.lblLastLogEntry.Size = new System.Drawing.Size(121, 13);
     this.lblLastLogEntry.TabIndex = 25;
     this.lblLastLogEntry.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // lblFirstLogEntry
     //
     this.lblFirstLogEntry.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     this.lblFirstLogEntry.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.lblFirstLogEntry.ForeColor = System.Drawing.SystemColors.MenuHighlight;
     this.lblFirstLogEntry.Location = new System.Drawing.Point(83, 127);
     this.lblFirstLogEntry.Name = "lblFirstLogEntry";
     this.lblFirstLogEntry.Size = new System.Drawing.Size(121, 13);
     this.lblFirstLogEntry.TabIndex = 24;
     this.lblFirstLogEntry.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     //
     // txtTimeStampTo
     //
     this.txtTimeStampTo.Location = new System.Drawing.Point(235, 106);
     this.txtTimeStampTo.Name = "txtTimeStampTo";
     this.txtTimeStampTo.Size = new System.Drawing.Size(121, 20);
     this.txtTimeStampTo.TabIndex = 23;
     this.toolTip1.SetToolTip(this.txtTimeStampTo, "Enter time in hh:mm:ss.fff format or leave blank for all");
     //
     // label6
     //
     this.label6.AutoSize = true;
     this.label6.Location = new System.Drawing.Point(207, 107);
     this.label6.Name = "label6";
     this.label6.Size = new System.Drawing.Size(25, 13);
     this.label6.TabIndex = 22;
     this.label6.Text = "and";
     //
     // txtTimeStampFrom
     //
     this.txtTimeStampFrom.Location = new System.Drawing.Point(83, 106);
     this.txtTimeStampFrom.Name = "txtTimeStampFrom";
     this.txtTimeStampFrom.Size = new System.Drawing.Size(121, 20);
     this.txtTimeStampFrom.TabIndex = 21;
     this.toolTip1.SetToolTip(this.txtTimeStampFrom, "Enter time in hh:mm:ss.fff format or leave blank for all");
     //
     // label5
     //
     this.label5.AutoSize = true;
     this.label5.Location = new System.Drawing.Point(3, 109);
     this.label5.Name = "label5";
     this.label5.Size = new System.Drawing.Size(79, 13);
     this.label5.TabIndex = 20;
     this.label5.Text = "Times between";
     //
     // btnSaveFilters
     //
     this.btnSaveFilters.Location = new System.Drawing.Point(86, 381);
     this.btnSaveFilters.Name = "btnSaveFilters";
     this.btnSaveFilters.Size = new System.Drawing.Size(75, 23);
     this.btnSaveFilters.TabIndex = 18;
     this.btnSaveFilters.Text = "Save Filters";
     this.btnSaveFilters.UseVisualStyleBackColor = true;
     this.btnSaveFilters.Click += new System.EventHandler(this.btnSaveFilters_Click);
     //
     // btnLoadFilters
     //
     this.btnLoadFilters.Location = new System.Drawing.Point(5, 381);
     this.btnLoadFilters.Name = "btnLoadFilters";
     this.btnLoadFilters.Size = new System.Drawing.Size(75, 23);
     this.btnLoadFilters.TabIndex = 17;
     this.btnLoadFilters.Text = "Load Filters";
     this.btnLoadFilters.UseVisualStyleBackColor = true;
     this.btnLoadFilters.Click += new System.EventHandler(this.btnLoadFilters_Click);
     //
     // chkSingleLineFormat
     //
     this.chkSingleLineFormat.AutoSize = true;
     this.chkSingleLineFormat.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkSingleLineFormat.Location = new System.Drawing.Point(47, 430);
     this.chkSingleLineFormat.Name = "chkSingleLineFormat";
     this.chkSingleLineFormat.Size = new System.Drawing.Size(113, 17);
     this.chkSingleLineFormat.TabIndex = 16;
     this.chkSingleLineFormat.Text = "&Single Line Format";
     this.chkSingleLineFormat.UseVisualStyleBackColor = true;
     this.chkSingleLineFormat.CheckedChanged += new System.EventHandler(this.chkSingleLineFormat_CheckedChanged);
     //
     // chkHideMethodReturnValue
     //
     this.chkHideMethodReturnValue.AutoSize = true;
     this.chkHideMethodReturnValue.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkHideMethodReturnValue.Checked = true;
     this.chkHideMethodReturnValue.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkHideMethodReturnValue.Location = new System.Drawing.Point(173, 60);
     this.chkHideMethodReturnValue.Name = "chkHideMethodReturnValue";
     this.chkHideMethodReturnValue.Size = new System.Drawing.Size(145, 17);
     this.chkHideMethodReturnValue.TabIndex = 7;
     this.chkHideMethodReturnValue.Text = "Hide method return &value";
     this.chkHideMethodReturnValue.UseVisualStyleBackColor = true;
     //
     // chkHodeMethodParameters
     //
     this.chkHodeMethodParameters.AutoSize = true;
     this.chkHodeMethodParameters.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkHodeMethodParameters.Checked = true;
     this.chkHodeMethodParameters.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkHodeMethodParameters.Location = new System.Drawing.Point(9, 60);
     this.chkHodeMethodParameters.Name = "chkHodeMethodParameters";
     this.chkHodeMethodParameters.Size = new System.Drawing.Size(141, 17);
     this.chkHodeMethodParameters.TabIndex = 6;
     this.chkHodeMethodParameters.Text = "Hide method &parameters";
     this.chkHodeMethodParameters.UseVisualStyleBackColor = true;
     //
     // chkHideDuration
     //
     this.chkHideDuration.AutoSize = true;
     this.chkHideDuration.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkHideDuration.Checked = true;
     this.chkHideDuration.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkHideDuration.Location = new System.Drawing.Point(59, 82);
     this.chkHideDuration.Name = "chkHideDuration";
     this.chkHideDuration.Size = new System.Drawing.Size(91, 17);
     this.chkHideDuration.TabIndex = 8;
     this.chkHideDuration.Text = "Hide &Duration";
     this.chkHideDuration.UseVisualStyleBackColor = true;
     //
     // chkHideTimestamp
     //
     this.chkHideTimestamp.AutoSize = true;
     this.chkHideTimestamp.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkHideTimestamp.Checked = true;
     this.chkHideTimestamp.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkHideTimestamp.Location = new System.Drawing.Point(216, 82);
     this.chkHideTimestamp.Name = "chkHideTimestamp";
     this.chkHideTimestamp.Size = new System.Drawing.Size(102, 17);
     this.chkHideTimestamp.TabIndex = 9;
     this.chkHideTimestamp.Text = "Hide &Timestamp";
     this.chkHideTimestamp.UseVisualStyleBackColor = true;
     //
     // chkHideExitMethod
     //
     this.chkHideExitMethod.AutoSize = true;
     this.chkHideExitMethod.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkHideExitMethod.Checked = true;
     this.chkHideExitMethod.CheckState = System.Windows.Forms.CheckState.Checked;
     this.chkHideExitMethod.Location = new System.Drawing.Point(212, 40);
     this.chkHideExitMethod.Name = "chkHideExitMethod";
     this.chkHideExitMethod.Size = new System.Drawing.Size(106, 17);
     this.chkHideExitMethod.TabIndex = 5;
     this.chkHideExitMethod.Text = "Hide E&xit method";
     this.chkHideExitMethod.UseVisualStyleBackColor = true;
     //
     // chkHideEnterMethod
     //
     this.chkHideEnterMethod.AutoSize = true;
     this.chkHideEnterMethod.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkHideEnterMethod.Location = new System.Drawing.Point(36, 40);
     this.chkHideEnterMethod.Name = "chkHideEnterMethod";
     this.chkHideEnterMethod.Size = new System.Drawing.Size(114, 17);
     this.chkHideEnterMethod.TabIndex = 4;
     this.chkHideEnterMethod.Text = "Hide &Enter method";
     this.chkHideEnterMethod.UseVisualStyleBackColor = true;
     //
     // btnApplyFilters
     //
     this.btnApplyFilters.Location = new System.Drawing.Point(282, 426);
     this.btnApplyFilters.Name = "btnApplyFilters";
     this.btnApplyFilters.Size = new System.Drawing.Size(75, 23);
     this.btnApplyFilters.TabIndex = 15;
     this.btnApplyFilters.Text = "&Apply [F5]";
     this.btnApplyFilters.UseVisualStyleBackColor = true;
     this.btnApplyFilters.Click += new System.EventHandler(this.btnApplyFilters_Click);
     //
     // ExcludedKeyList
     //
     this.ExcludedKeyList.Location = new System.Drawing.Point(5, 285);
     this.ExcludedKeyList.Multiline = true;
     this.ExcludedKeyList.Name = "ExcludedKeyList";
     this.ExcludedKeyList.Size = new System.Drawing.Size(352, 92);
     this.ExcludedKeyList.TabIndex = 13;
     //
     // label2
     //
     this.label2.AutoSize = true;
     this.label2.Location = new System.Drawing.Point(3, 263);
     this.label2.Name = "label2";
     this.label2.Size = new System.Drawing.Size(77, 13);
     this.label2.TabIndex = 12;
     this.label2.Text = "Excluded &Keys";
     //
     // IncludedKeyList
     //
     this.IncludedKeyList.Location = new System.Drawing.Point(5, 172);
     this.IncludedKeyList.Multiline = true;
     this.IncludedKeyList.Name = "IncludedKeyList";
     this.IncludedKeyList.Size = new System.Drawing.Size(352, 92);
     this.IncludedKeyList.TabIndex = 11;
     //
     // label1
     //
     this.label1.AutoSize = true;
     this.label1.Location = new System.Drawing.Point(3, 172);
     this.label1.Name = "label1";
     this.label1.Size = new System.Drawing.Size(140, 13);
     this.label1.TabIndex = 10;
     this.label1.Text = "&Include Keys (executed first)";
     //
     // btnLoad
     //
     this.btnLoad.Location = new System.Drawing.Point(142, 8);
     this.btnLoad.Name = "btnLoad";
     this.btnLoad.Size = new System.Drawing.Size(42, 23);
     this.btnLoad.TabIndex = 3;
     this.btnLoad.Text = "load";
     this.btnLoad.UseVisualStyleBackColor = true;
     this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
     //
     // btnSave
     //
     this.btnSave.Location = new System.Drawing.Point(98, 8);
     this.btnSave.Name = "btnSave";
     this.btnSave.Size = new System.Drawing.Size(42, 23);
     this.btnSave.TabIndex = 2;
     this.btnSave.Text = "save";
     this.btnSave.UseVisualStyleBackColor = true;
     this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
     //
     // chkIgnoreCase
     //
     this.chkIgnoreCase.AutoSize = true;
     this.chkIgnoreCase.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     this.chkIgnoreCase.Location = new System.Drawing.Point(274, 155);
     this.chkIgnoreCase.Name = "chkIgnoreCase";
     this.chkIgnoreCase.Size = new System.Drawing.Size(83, 17);
     this.chkIgnoreCase.TabIndex = 14;
     this.chkIgnoreCase.Text = "Ignore &Case";
     this.chkIgnoreCase.UseVisualStyleBackColor = true;
     //
     // saveFileDialog
     //
     this.saveFileDialog.DefaultExt = "ylf";
     this.saveFileDialog.FileName = "dump";
     this.saveFileDialog.Filter = "Yalf dump files (*.ylf)|*.ylf";
     //
     // openFileDialog
     //
     this.openFileDialog.DefaultExt = "ylf";
     this.openFileDialog.Filter = "Yalf dump files (*.yalf, *.ylf)|*.yalf;*.ylf|(All Files *.*)|*.*";
     //
     // saveSettingsFileDialog
     //
     this.saveSettingsFileDialog.DefaultExt = "yfc";
     this.saveSettingsFileDialog.FileName = "yalfFilters.yfc";
     this.saveSettingsFileDialog.Filter = "Yalf filter config files (*.yfc)|*.yfc|(All Files *.*)|*.*";
     this.saveSettingsFileDialog.Title = "Save Yalf Config";
     //
     // openSettingsFileDialog
     //
     this.openSettingsFileDialog.DefaultExt = "yfc";
     this.openSettingsFileDialog.FileName = "yalfFilters.yfc";
     this.openSettingsFileDialog.Filter = "Yalf filter config files (*.yfc)|*.yfc|(All Files *.*)|*.*";
     this.openSettingsFileDialog.Title = "Load Yalf Config";
     //
     // tvFilter
     //
     this.tvFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     | System.Windows.Forms.AnchorStyles.Right)));
     this.tvFilter.BorderStyle = System.Windows.Forms.BorderStyle.None;
     this.tvFilter.CheckBoxes = true;
     this.tvFilter.Location = new System.Drawing.Point(366, 136);
     this.tvFilter.Name = "tvFilter";
     treeNode1.Checked = true;
     treeNode1.Name = "Node0";
     treeNode1.Text = "Node0";
     this.tvFilter.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
     treeNode1});
     this.tvFilter.Size = new System.Drawing.Size(313, 343);
     this.tvFilter.TabIndex = 4;
     this.tvFilter.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.tvFilter_AfterCheck);
     this.tvFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tvFilter_KeyDown);
     //
     // consoleOutput
     //
     this.consoleOutput.Dock = System.Windows.Forms.DockStyle.Fill;
     this.consoleOutput.Location = new System.Drawing.Point(0, 0);
     this.consoleOutput.Name = "consoleOutput";
     this.consoleOutput.Size = new System.Drawing.Size(676, 734);
     this.consoleOutput.TabIndex = 0;
     //
     // YalfForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize = new System.Drawing.Size(1370, 750);
     this.Controls.Add(this.splitContainer1);
     this.KeyPreview = true;
     this.Name = "YalfForm";
     this.Text = "Yalf dump";
     this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
     this.Load += new System.EventHandler(this.YalfForm_Load);
     this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.YalfForm_KeyUp);
     this.splitContainer1.Panel1.ResumeLayout(false);
     this.splitContainer1.Panel1.PerformLayout();
     this.splitContainer1.Panel2.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
     this.splitContainer1.ResumeLayout(false);
     this.pnlMainOptions.ResumeLayout(false);
     this.pnlMainOptions.PerformLayout();
     this.ResumeLayout(false);
 }
Пример #40
0
 public void Write(string stringText)
 {
     ConsoleOutput.WritetoConsole(stringText);
 }
Пример #41
0
        private static async Task RunWrexAsync(CmdOptions cmdOptions)
        {
            var validation = cmdOptions.Validate();

            if (!validation.IsValid)
            {
                var indent = new string(' ', 2);
                var errors = String.Join(Environment.NewLine, validation.ErrorMessages.Select(x => indent + x));
                throw new Exception(cmdOptions.CustomErrorWithUsage(errors));
            }

            Console.WriteLine(cmdOptions.GetHeader(new HelpText()));
            Console.WriteLine();

            try
            {
                var wrex = new Wrex(cmdOptions.GetWrexOptions());
                var consoleOut = new ConsoleOutput();

                if (cmdOptions.Verbose)
                {
                    const string OptionsText = "Options:";
                    Console.WriteLine(OptionsText);
                    Console.WriteLine(new string('-', OptionsText.Length));
                    Console.WriteLine();
                    consoleOut.PrintWrexOptions(wrex.Options);
                    Console.WriteLine();
                    const string ProgressText = "Progress:";
                    Console.WriteLine(ProgressText);
                    Console.WriteLine(new string('-', ProgressText.Length));
                    Console.WriteLine();
                }

                var cancelSource = new CancellationTokenSource();
                var progressDisplayTask = Task.Run(() => consoleOut.StartProgressWriter(wrex, cancelSource.Token));
                await wrex.RunAsync(
                    null,
                    ex =>
                        {
                            if (cmdOptions.Verbose)
                            {
                                consoleOut.HandleError(ex);
                            }
                            else
                            {
                                NoOp();
                            }
                        });

                cancelSource.Cancel();
                await progressDisplayTask;

                var analyzer = new WrexAnalyzer(wrex);
                var summary = analyzer.GetSummary();
                consoleOut.PrintSummary(summary, wrex);
                consoleOut.PrintStatusDistribution(analyzer.GetStatusDistribution(), wrex);
                consoleOut.PrintResponseTimeHistogram(analyzer.GetReponseTimeDistribution(summary), wrex);
                if (cmdOptions.Verbose)
                {
                    consoleOut.PrintSampleResponse(wrex);
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                lock (Console.Out)
                {
                    Console.WriteLine();
                    Console.WriteLine();
                    ExtendedConsole.WriteErrorLine("Error: " + ex.Message);
                    if (cmdOptions.Verbose)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Details: ");
                        Console.WriteLine(ex.StackTrace);
                    }
                }
            }
        }
Пример #42
0
 public static void FinalizeApplication()
 {
     mGlobalStringMap = null;
     if (mNativeClassNames != null)
     {
         mNativeClassNames.Clear();
     }
     mNativeClassNames = null;
     mConsoleOutput = null;
     mMessageMapper = null;
     mStorage = null;
     mArrayClass = null;
     mDictionayClass = null;
     mVAPool = null;
     NULL_ARG = null;
     ArrayObject.FinalizeApplication();
     ByteCodeLoader.FinalizeApplication();
     CustomObject.FinalizeApplication();
     DictionaryObject.FinalizeApplication();
     MathClass.FinalizeApplication();
     Variant.FinalizeApplication();
     LexicalAnalyzer.FinalizeApplication();
 }