Esempio n. 1
0
        public static string Dump(GameFiles.Script sc)
        {
            var d = new Dumper(sc);

            using var s = new StringWriter();
            d.Dump(s, true, true, true, true, true);
            return(s.ToString());
        }
Esempio n. 2
0
        public int Problem1(string input)
        {
            var map = Mapper.ConvertToMap(input, Convert);

            for (var loop = 0; loop < 10; loop++)
            {
                var newMap = new TileState[map.GetLength(0), map.GetLength(1)];

                for (var i = 0; i < map.GetLength(0); i++)
                {
                    for (var j = 0; j < map.GetLength(1); j++)
                    {
                        var surrounding = GetNeighbours(map, i, j);
                        var current     = map[i, j];
                        newMap[i, j] = current;

                        if (current == TileState.Open && surrounding.Count(it => it == TileState.Trees) >= 3)
                        {
                            newMap[i, j] = TileState.Trees;
                        }

                        if (current == TileState.Trees && surrounding.Count(it => it == TileState.Lumber) >= 3)
                        {
                            newMap[i, j] = TileState.Lumber;
                        }

                        if (current == TileState.Lumber && (!surrounding.Any(it => it == TileState.Lumber) || !surrounding.Any(it => it == TileState.Trees)))
                        {
                            newMap[i, j] = TileState.Open;
                        }
                    }
                }

                map = newMap;
                Console.WriteLine("After" + (loop + 1) + " minutes");
                Dumper.DumpMap(map, ConvertBack);
            }

            var totalTrees  = 0;
            var totalLumber = 0;

            for (var i = 0; i < map.GetLength(0); i++)
            {
                for (var j = 0; j < map.GetLength(1); j++)
                {
                    if (map[i, j] == TileState.Trees)
                    {
                        totalTrees++;
                    }
                    else if (map[i, j] == TileState.Lumber)
                    {
                        totalLumber++;
                    }
                }
            }

            return(totalTrees * totalLumber);
        }
Esempio n. 3
0
        static public void AddDumper(string nameSubs)
        {
            if (!nameSubs.Contains("."))
            {
                if (!dumps.ContainsKey(nameSubs))
                {
                    Dumper dump = new Dumper(MainWindow.project, nameSubs, MainWindow.project.subs[nameSubs].main);
                    if (!dump.Status)
                    {
                        throw new ArgumentException("Subsystem " + nameSubs + " not supported!");
                    }
                    dump.Connect();
                    if (!dump.isConnected())
                    {
                        throw new ArgumentException("Subsystem " + nameSubs + " not connected!");
                    }
                    dumps.Add(nameSubs, dump);
                }
                else
                {
                    throw new ArgumentException("Subsystem " + nameSubs + " is used!");
                }
                return;
            }
            if (masters.ContainsKey(nameSubs))
            {
                throw new ArgumentException("Subsystem and modbus" + nameSubs + " is used!");
            }
            string sub    = nameSubs.Substring(0, nameSubs.IndexOf("."));
            string modbus = nameSubs.Substring(nameSubs.IndexOf(".") + 1);

            if (!MainWindow.project.subs.ContainsKey(sub))
            {
                throw new ArgumentException("Subsystem " + sub + " is not loaded!");
            }
            Subsystem Sub = MainWindow.project.subs[sub];

            foreach (ModbusDevice md in Sub.modbuses)
            {
                if (md.isMaster())
                {
                    continue;
                }
                if (md.name.CompareTo(modbus) != 0)
                {
                    continue;
                }
                MasterModbus master = new MasterModbus(Sub, md);
                master.Connect();
                if (!master.IsConnected())
                {
                    throw new ArgumentException("Subsystem " + sub + " modbus " + modbus + " not connected!");
                }
                masters.Add(nameSubs, master);
                return;
            }
            throw new ArgumentException("Subsystem and modbus " + nameSubs + " not founded!");
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //var image = new Bitmap(@"C:\Users\kiwo_000\Downloads\Pkr\870727716_2ea9.bmp");
            //var result2 = ScreenRecognition.recognizeScreen(image);

            //var screenSize = new Size(650, 490);
            //var targetSize = new Size(433, 328);
            var screenSize = new Size(816, 577);
            var targetSize = new Size(816, 577);

            Console.Write("Press any key to get the list of open tables...");
            Console.ReadKey();

            var party = new WindowExtractor("Party", title =>
            {
                var startIndex = title.IndexOf("Heads Up Hyper Turbo (") + 22;
                var endIndex   = title.IndexOf(") Table");
                return(startIndex > 0 && endIndex > startIndex ? title.Substring(startIndex, endIndex - startIndex) : null);
            });

            while (true)
            {
                var windows = InteractionFacade.GetWindowList(screenSize, targetSize, party).ToArray();
                foreach (WindowInfo window in windows)
                {
                    var tableNumber = window.TableName;
                    Console.WriteLine($"\n{tableNumber} ({window.Size.Width}x{window.Size.Height})");

                    try
                    {
                        var result = PartyRecognition.recognizeScreenParty(window.Bitmap, window.Title);
                        foreach (var s in ScreenRecognition.print(result))
                        {
                            Console.WriteLine(s);
                        }
                        var result2 = PartyRecognition.recognizeBetSizeParty(window.Bitmap);
                        Console.WriteLine($"Hero entered bet size: {result2}");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine(ex.StackTrace);
                        Dumper.SaveBitmap(window.Bitmap, tableNumber, false);
                    }
                }
                Console.Write("\n\n");
                Console.Write("Press S to save images or any key to get the list of open tables...");
                var key = Console.ReadKey();
                if (key.KeyChar == 'S' || key.KeyChar == 's')
                {
                    foreach (WindowInfo window in windows)
                    {
                        Dumper.SaveBitmap(window.Bitmap, window.TableName + Guid.NewGuid().ToString().Substring(0, 6), false);
                    }
                }
            }
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void SetUp()
        {
            _homeDir   = _testDirectory.directory("home-dir").toPath();
            _configDir = _testDirectory.directory("config-dir").toPath();
            _archive   = _testDirectory.file("some-archive.dump").toPath();
            _dumper    = mock(typeof(Dumper));
            PutStoreInDirectory(_homeDir.resolve("data/databases/foo.db"));
            _databaseDirectory = _homeDir.resolve("data/databases/foo.db");
        }
Esempio n. 6
0
        public void OnGUI()
        {
            try
            {
                if (Event.current.type != EventType.KeyUp)
                {
                    return;
                }
                if (!Event.current.alt)
                {
                    return;
                }

                switch (Event.current.keyCode)
                {
                case KeyCode.F1:
                    TranslateConfig.Reload();
                    Resource.Reload();
                    ReTranslation();
                    Logger.Log(LogLevel.Info, $"Config reloaded.");
                    break;

                case KeyCode.F5:
                    TranslateConfig.IsDumpingText = !TranslateConfig.IsDumpingText;
                    Logger.Log(LogLevel.Info, $"Dumping text {(TranslateConfig.IsDumpingText ? "Enabled" : "Disabled")}.");
                    break;

                case KeyCode.F6:
                    TranslateConfig.IsDumpingTexture = !TranslateConfig.IsDumpingTexture;
                    Logger.Log(LogLevel.Info, $"Dumping texture {(TranslateConfig.IsDumpingTexture ? "Enabled" : "Disabled")}.");
                    break;

                case KeyCode.F7:
                    TranslateConfig.IsDumpingUI = !TranslateConfig.IsDumpingUI;
                    Logger.Log(LogLevel.Info, $"Dumping ui {(TranslateConfig.IsDumpingUI ? "Enabled" : "Disabled")}.");
                    break;

                case KeyCode.F8:
                    TranslateConfig.IsDumpingSprite = !TranslateConfig.IsDumpingSprite;
                    Logger.Log(LogLevel.Info, $"Dumping sprite {(TranslateConfig.IsDumpingSprite ? "Enabled" : "Disabled")}.");
                    break;

                case KeyCode.F9:
                    Dumper.DumpResource(CurrentScene);
                    break;

                case KeyCode.F10:
                    Dumper.DumpObjects(CurrentScene);
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex);
                throw;
            }
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void dumpMerge(Dumper dumper, byte type, org.neo4j.storageengine.api.ReadableChannel channel, long range, int labelId, TxFilter txFilter, long session, long flush) throws java.io.IOException
        private static void DumpMerge(Dumper dumper, sbyte type, ReadableChannel channel, long range, int labelId, TxFilter txFilter, long session, long flush)
        {
            long existingBits = channel.Long;
            long newBits      = channel.Long;

            if (txFilter == null || txFilter.Contains())
            {
                dumper.Merge(type == TYPE_MERGE_ADD, session, flush, range, labelId, existingBits, newBits);
            }
        }
Esempio n. 8
0
        public void DumpAssembler(Program program, Formatter wr)
        {
            if (wr == null || program.Architecture == null)
            {
                return;
            }
            Dumper dump = new Dumper(program);

            dump.Dump(wr);
        }
Esempio n. 9
0
        public void DumpAssembler(Program program, TextWriter wr)
        {
            if (wr == null || program.Architecture == null)
            {
                return;
            }
            Dumper dump = new Dumper(program.Architecture);

            dump.Dump(program, program.ImageMap, wr);
        }
Esempio n. 10
0
        public void Test_Dump_Null許容型()
        {
            int?v = 1;

            Assert.AreEqual("1 (System.Int32)", Dumper.DumpToString(v));

            int?v2 = null;

            Assert.AreEqual("(null)", Dumper.DumpToString(v2));
        }
Esempio n. 11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static long dumpFile(org.neo4j.io.fs.FileSystemAbstraction fs, java.io.File file, Dumper dumper, TxFilter txFilter, long session) throws java.io.IOException
        private static long DumpFile(FileSystemAbstraction fs, File file, Dumper dumper, TxFilter txFilter, long session)
        {
            try
            {
                using (ReadableChannel channel = new ReadAheadChannel <>(fs.Open(file, OpenMode.READ)))
                {
                    long range   = -1;
                    int  labelId = -1;
                    long flush   = 0;
                    while (true)
                    {
                        sbyte type = channel.Get();
                        switch (type)
                        {
                        case TYPE_RANGE:
                            range   = channel.Long;
                            labelId = channel.Int;
                            if (txFilter != null)
                            {
                                txFilter.Clear();
                            }
                            break;

                        case TYPE_PREPARE_ADD:
                        case TYPE_PREPARE_REMOVE:
                            DumpPrepare(dumper, type, channel, range, labelId, txFilter, session, flush);
                            break;

                        case TYPE_MERGE_ADD:
                        case TYPE_MERGE_REMOVE:
                            DumpMerge(dumper, type, channel, range, labelId, txFilter, session, flush);
                            break;

                        case TYPE_FLUSH:
                            flush++;
                            break;

                        case TYPE_SESSION_END:
                            session++;
                            flush = 0;
                            break;

                        default:
                            Console.WriteLine("Unknown type " + type + " at " + (( ReadAheadChannel )channel).position());
                            break;
                        }
                    }
                }
            }
            catch (ReadPastEndException)
            {
                // This is OK. we're done with this file
            }
            return(session);
        }
Esempio n. 12
0
        public void Cache()
        {
            int cnt = 0;

            foreach (var str in resultCache)
            {
                Writer.WriteLine(cnt + ": " + str);
                cnt++;
            }
            Dumper.Dump(resultCache, Writer);
        }
Esempio n. 13
0
        public MainWindow()
        {
            InitializeComponent();

            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en");
            RulesParser.Init();
            Dumper.Init();
            _isProxyRunning = false;

            AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)HandleKeys);
        }
        private NearRegionResult Search(Point from, int around = 4)
        {
            var root = SearchRoot(from, around, 0, null);

            List <NearRegionPoint> ends = new List <NearRegionPoint>();

            GetEnds(root);
            void GetEnds(NearRegionPoint parent)
            {
                if (parent.Children.Count == 0 && parent.Went.Count > Around)
                {
                    ends.Add(parent);
                }
                else
                {
                    foreach (var p in parent.Children)
                    {
                        GetEnds(p);
                    }
                }
            }

            var backup = Game.Field.Clone(false, true, true);
            var cloned = Game.Field.Clone(false, true, true);

            cloned.AutoDump     = false;
            cloned.AutoEvaluate = false;

            var enemyScore = cloned.EvaluateMap(EnemyEnum);

            foreach (var e in ends)
            {
                Dumper?.Record("Set Cell State");
                cloned.Map.ForEach((p, c) =>
                {
                    c.State1 = backup.GetCell(p).State1;
                    c.State2 = backup.GetCell(p).State2;
                });

                foreach (var w in e.Went)
                {
                    cloned.GetCell(w).SetState(TeamEnum, CellState.Occupied);
                }

                Dumper?.Record("Evaluate Score");

                e.TeamScore  = cloned.EvaluateMap(TeamEnum);
                e.EnemyScore = enemyScore;

                Dumper?.Stop();
            }

            return(new NearRegionResult(root, ends.OrderByDescending(p => p.GetScoringEfficiency().Efficiency).ToList()));
        }
Esempio n. 15
0
        public override bool Execute(string[] args)
        {
            if (ArgsOutOfBounds(args.Length, 2, 2))
            {
                return(false);
            }

            Dumper.DumpObject(args[1], System.Type.GetType(args[0]));

            return(true);
        }
Esempio n. 16
0
        public async Task <Stream> DumpAsync(IEndpointInfo endpointInfo, Models.DumpType mode, CancellationToken token)
        {
            if (endpointInfo == null)
            {
                throw new ArgumentNullException(nameof(endpointInfo));
            }

            string dumpTempFolder = _storageOptions.CurrentValue.DumpTempFolder;

            // Ensure folder exists before issue command.
            if (!Directory.Exists(dumpTempFolder))
            {
                Directory.CreateDirectory(dumpTempFolder);
            }

            string   dumpFilePath = Path.Combine(dumpTempFolder, FormattableString.Invariant($"{Guid.NewGuid()}_{endpointInfo.ProcessId}"));
            DumpType dumpType     = MapDumpType(mode);

            IDisposable operationRegistration = null;

            // Only track operation status for endpoints from a listening server because:
            // 1) Each process only ever has a single instance of an IEndpointInfo
            // 2) Only the listening server will query the dump service for the operation status of an endpoint.
            if (IsListenMode)
            {
                // This is a quick fix to prevent the polling algorithm in the ServerEndpointInfoSource
                // from removing IEndpointInfo instances when they don't respond in a timely manner to
                // a dump operation causing the runtime to temporarily be unresponsive. Long term, this
                // concept should be folded into RequestLimitTracker with registered endpoint information
                // and allowing to query the status of an endpoint for a given artifact.
                operationRegistration = _operationTrackerService.Register(endpointInfo);
            }

            try
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    // Get the process
                    Process process = Process.GetProcessById(endpointInfo.ProcessId);
                    await Dumper.CollectDumpAsync(process, dumpFilePath, dumpType);
                }
                else
                {
                    var client = new DiagnosticsClient(endpointInfo.Endpoint);
                    await client.WriteDumpAsync(dumpType, dumpFilePath, logDumpGeneration : false, token);
                }
            }
            finally
            {
                operationRegistration?.Dispose();
            }

            return(new AutoDeleteFileStream(dumpFilePath));
        }
Esempio n. 17
0
        /// <summary>
        /// Dump any type value to application output (in web applications into debug bar, in desktop applications into console).
        /// </summary>
        /// <param name="obj">Any type value to dump into application output.</param>
        /// <param name="options">Dump options collection (optional) - just create new instance with public fields of that:<para /><br />
        /// For this dump call you can change options:<para /><ul>
        /// <li><b>Depth</b> (int, optional) - how many levels in complex type variables will be iterated throw to dump all it's properties, fields and other values.<para /></li>
        /// <li><b>MaxLength</b> (int, optional) - if any dumped string length is larger than this value, it will be cut into this max. length.<para /></li>
        /// <li><b>Return</b> (bool, optional)- if value will be dumped into application output (as default) or returned as dumped string value.<para /></li>
        /// </ul></param>
        /// <returns>Returns empty string by default or dumped variable string if you specify in second argument <c>DumpOptions.Return</c> to be <c>true</c>.</returns>
        public static string Dump(object obj, DumpOptions?options = null)
        {
            Dispatcher dispatcher = Dispatcher.GetCurrent();

            if (dispatcher.Enabled != true)
            {
                return("");
            }
            if (!options.HasValue)
            {
                options = new DumpOptions {
                    Return    = false,
                    Depth     = 0,
                    MaxLength = 0
                }
            }
            ;
            DumpOptions optionsValue = options.Value;

            if (!optionsValue.Depth.HasValue)
            {
                optionsValue.Depth = 0;
            }
            if (!optionsValue.MaxLength.HasValue)
            {
                optionsValue.MaxLength = 0;
            }
            if (!optionsValue.Return.HasValue)
            {
                optionsValue.Return = false;
            }
            if (!optionsValue.SourceLocation.HasValue)
            {
                optionsValue.SourceLocation = Dispatcher.SourceLocation;
            }
            string result  = "";
            bool   htmlOut = Dispatcher.EnvType == EnvType.Web;

            try {
                result = Dumper.Dump(obj, htmlOut, optionsValue.Depth.Value, optionsValue.MaxLength.Value);
            } catch (Exception e) {
                result = Debug.Dump(e, optionsValue);
            }
            if (optionsValue.SourceLocation.HasValue && optionsValue.SourceLocation.Value)
            {
                result += Desharp.Renderers.FileLink.Render(Completers.StackTrace.CompleteCallerPoint(), htmlOut);
            }
            if (!optionsValue.Return.Value || (optionsValue.Return.HasValue && !optionsValue.Return.Value))
            {
                dispatcher.WriteDumpToOutput(result);
                return("");
            }
            return(result);
        }
Esempio n. 18
0
        public void Test_Dump_例外()
        {
            var err = new ErrorClass();

            Assert.AreEqual(
                @"DebugLibTest.ErrorClass (DebugLibTest.ErrorClass)
{
    Error = 呼び出しのターゲットが例外をスローしました。
}
",
                Dumper.DumpToString(err));
        }
Esempio n. 19
0
 public void Test_Dump_プリミティブ()
 {
     Assert.AreEqual("(null)", Dumper.DumpToString(null));
     Assert.AreEqual("1 (System.Int32)", Dumper.DumpToString(1));
     Assert.AreEqual("10 (System.Int64)", Dumper.DumpToString(10L));
     Assert.AreEqual("79228162514264337593543950335 (System.Decimal)", Dumper.DumpToString(Decimal.MaxValue));
     Assert.AreEqual("0.12 (System.Double)", Dumper.DumpToString(0.12));
     Assert.AreEqual("0.1 (System.Single)", Dumper.DumpToString(0.1f));
     Assert.AreEqual("'A' (System.Char)", Dumper.DumpToString('A'));
     Assert.AreEqual("\"str\" (System.String)", Dumper.DumpToString("str"));
     Assert.AreEqual("\"1\\n2\\r3\" (System.String)", Dumper.DumpToString("1\n2\r3"));
 }
Esempio n. 20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void dumpPrepare(Dumper dumper, byte type, org.neo4j.storageengine.api.ReadableChannel channel, long range, int labelId, TxFilter txFilter, long session, long flush) throws java.io.IOException
        private static void DumpPrepare(Dumper dumper, sbyte type, ReadableChannel channel, long range, int labelId, TxFilter txFilter, long session, long flush)
        {
            long txId   = channel.Long;
            int  offset = channel.Get();
            long nodeId = range * 64 + offset;

            if (txFilter == null || txFilter.Contains(txId))
            {
                // I.e. if the txId this update comes from is within the txFilter
                dumper.Prepare(type == TYPE_PREPARE_ADD, session, flush, txId, nodeId, labelId);
            }
        }
Esempio n. 21
0
        public override void Dump()
        {
            IChelaType type = GetFunctionType();

            Dumper.Printf("%s method(%d) %s %s", GetFlagsString(), vslot, GetName(),
                          type != null ? type.GetFullName() : "void ()");
            Dumper.Printf("{");
            {
                DumpContent();
            }
            Dumper.Printf("}");
        }
 public void DumpPackages(bool orderString = true)
 {
     if (orderString)
     {
         Dumper.WriteLine("The order in which the packages can be completed is:");
     }
     foreach (var kvp in Packages)
     {
         Dumper.WriteLine(
             $"{kvp.Key}: {string.Join(", ", kvp.Value.EligibleSteps.Select(x => x.IdentifyWithWorkRemaining()))}");
     }
 }
Esempio n. 23
0
        public void TestMethod_WriteTextFile_DoNotWrite_FolderIsNull()
        {
            Dumper.IsEnabled = true;
            Dumper.Folder    = null;
            var name = this.TestContext.TestName;

            Dumper.WriteTextFile(name, ".txt", writer =>
            {
                writer.Write("SAMPLE");
                Assert.Fail("Dump file was wrote, even though Folder property is false.");
            });
        } // end sub
Esempio n. 24
0
        public void TestMethod_WriteTextFile_DoNotWrite_ActionIsNull()
        {
            Dumper.IsEnabled = true;
            Dumper.Folder    = new DirectoryInfo(Path.Combine(this.TestContext.TestRunResultsDirectory, "dump"));
            var name = this.TestContext.TestName;

            Dumper.WriteTextFile(name, ".txt", null);

            var f = Dumper.GetDumpFile(name, ".txt");

            Assert.IsFalse(f.Exists, "Dump file was created, even though action is null.");
        } // end sub
Esempio n. 25
0
        private void BtnExport_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new SaveFileDialog()
            {
                Filter = "Excel (.xlsx)|*.xlsx",
            };

            if (dlg.ShowDialog() == true)
            {
                Dumper.SaveAsExcel(Session, dlg.FileName).ContinueWith((t) => { Process.Start(dlg.FileName); });
            }
        }
Esempio n. 26
0
        public void TestMethod_GetDumpFile_FolderIsNotCreated_IsEnabledFalse()
        {
            Dumper.IsEnabled = false;
            Dumper.Folder    = new DirectoryInfo(Path.Combine(this.TestContext.TestRunResultsDirectory, "dump2"));
            Debug.WriteLine($"Dumper.Folder: {Dumper.Folder}");

            var name = this.TestContext.TestName;
            var f    = Dumper.GetDumpFile(name);

            Debug.WriteLine($"GetDumpFile.FullName: {f.FullName}");
            Assert.IsFalse(f.Directory.Exists, "Folder was created, even though IsEnabled property is false.");
        } // end function
Esempio n. 27
0
        public void X86Rw_CallTable()
        {
            DoRewriteFile("Fragments/multiple/calltables.asm");
            using (FileUnitTester fut = new FileUnitTester("Intel/RwCallTable.txt"))
            {
                Dumper dump = new Dumper(prog.Architecture);
                dump.Dump(prog, prog.ImageMap, fut.TextWriter);
                fut.TextWriter.WriteLine();
                prog.CallGraph.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Esempio n. 28
0
        public void X86Rw_CallTable()
        {
            DoRewriteFile("Fragments/multiple/calltables.asm");
            using (FileUnitTester fut = new FileUnitTester("Intel/RwCallTable.txt"))
            {
                Dumper dump = new Dumper(program);
                dump.Dump(new TextFormatter(fut.TextWriter));
                fut.TextWriter.WriteLine();
                program.CallGraph.Write(fut.TextWriter);

                fut.AssertFilesEqual();
            }
        }
Esempio n. 29
0
        public void DumpEnumZero()
        {
            var value = MyEnum.Zero;

            var dumper = new Dumper();

            var dump = dumper.Dump(value);

            Assert.NotNull(dump, "Dump shall return a DumpLevel instance.");
            Assert.AreEqual("MyEnum.Zero", dump.Value, "Dump value shall be 'MyEnum.Zero'.");
            Assert.AreEqual(typeof(MyEnum), dump.Type, "Dump type shall be a MyEnum type.");
            Assert.AreEqual(0, dump.Count(), "Dump children count shall be 0.");
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            using (Context c = new Context())
            {
                Console.WriteLine("setting keyboard filter");
                c.SetFilter(Context.FilterKind.KeyBoard, (ushort) (FilterKeyState.Down | FilterKeyState.Up));

                Console.WriteLine("setting mouse filter");
                c.SetFilter(Context.FilterKind.Mouse, (ushort) FilterMouseState.MOUSE_MOVE);

                Console.WriteLine("waiting on device");
                Device d = c.Wait();

                int rec = 0;
                Console.WriteLine("waiting on receive");

                while(( rec = c.Receive( (d = c.Wait() ),1)) > 0)
                {
                    Console.WriteLine("device: {0}, receive returned: {1}", d.Index, rec);
                    if(rec > 0)
                    {
                        if(d.IsKeyBoard)
                        {
                            var ks = c.GetDataAsKeyStroke();
                            Dumper.Dump(ks, "KeyStroke", Console.Out);

                            var s = c.Send(d, ks);
                            Console.WriteLine("send returned: {0}", s);

                            if(ks.code == 0x01)
                            {
                                Console.WriteLine("keystroke.code == 0x01, breaking");
                                break;
                            }
                        }
                        else if(d.IsMouse)
                        {
                            var ms = c.GetDataAsMouseStroke();
                            Dumper.Dump(ms, "MouseStroke", Console.Out);
                            var s = c.Send(d, ms);
                            Console.WriteLine("send returned: {0}", s);
                        }
                    }
                }
            }

            Console.WriteLine("press enter to continue...");
            Console.ReadLine();

            
        }
Esempio n. 31
0
        public void DumpAssembler(Program program, string filename, Dictionary <ImageSegment, List <ImageMapItem> > segmentItems, Formatter wr)
        {
            if (wr == null || program.Architecture == null)
            {
                return;
            }
            Dumper dump = new Dumper(program)
            {
                ShowAddresses = program.User.ShowAddressesInDisassembly,
                ShowCodeBytes = program.User.ShowBytesInDisassembly
            };

            dump.Dump(segmentItems, wr);
        }
Esempio n. 32
0
        public void DumpEmptyStruct()
        {
            var testStruct = new TestStruct();
            var dumper = new Dumper();

            var dump = dumper.Dump(testStruct);

            Assert.NotNull(dump, "Dump shall return a DumpLevel instance.");
            Assert.AreEqual(null, dump.Value, "Dump value shall be null.");
            Assert.AreEqual(typeof(TestStruct), dump.Type, "Dump type shall be a TestStruct type.");
            Assert.AreEqual(1, dump.Count(), "Dump children count shall be 1.");
            Assert.AreEqual(0, dump.Level, "Dump level count shall be 0.");
            var children = new List<DumpLevel>(dump);
            Assert.AreEqual(1, children.Count, "Dump IEnumerable copy shall be count 1 item.");

            Assert.AreEqual("Property", children[0].Header, "First children header shall be 'Property'.");
            Assert.AreEqual(typeof(string), children[0].Type, "First children type shall be a string.");
            Assert.AreEqual(null, children[0].Value, "First children value shall be null.");
            Assert.AreEqual(1, children[0].Level, "First children level shall be 1.");
        }
Esempio n. 33
0
 public void InitializeTestSuite()
 {
     _dumper = new Dumper();
 }
Esempio n. 34
0
        public void DumpObjectWithValueType2Text()
        {
            var valueTest = new ObjectWithValueTypeTest();
            var dumper = new Dumper();

            var dumpText = dumper.Dump(valueTest).ToText();

            Trace.WriteLine(dumpText);

            var expected = "DumpObjectTests.Dump2TextExtension.ObjectWithValueTypeTest" + Environment.NewLine +
                           "	 - PublicProperty : publicProp" + Environment.NewLine +
                           "	 - PublicProperty2 : <null>";

            Assert.AreEqual(expected, dumpText);
        }
Esempio n. 35
0
        public void DumpObjectWithValueTypeFirstLevel2Text()
        {
            var valueTest = new ObjectWithValueTypeTest();
            var dumper = new Dumper{MaxDumpLevel = 1};

            var dumpText = dumper.Dump(valueTest).ToText();

            Trace.WriteLine(dumpText);

            var expected = "DumpObjectTests.Dump2TextExtension.ObjectWithValueTypeTest" + Environment.NewLine +
                           "	 - PublicProperty : ..." + Environment.NewLine +
                           "	 - PublicProperty2 : ...";

            Assert.AreEqual(expected, dumpText);
        }
Esempio n. 36
0
	public static void Main (string[] args) {
		Dumper d = new Dumper ();

		try {
			d.DumpProperties ();
			d.DumpConverters ();
			d.DumpElementProperties ();
			d.DumpRuntimeObjects ();
		}
		catch (Exception e) {
			Console.WriteLine (e);
		}
	}
Esempio n. 37
0
    /// <summary>
    /// Initializes a new instance of the <see cref="XmlRpcManagerServer"/> class 
    /// and registers it at the specified port on local machine.
    /// </summary>
    /// <param name="port">The port.</param>
    public XmlRpcManagerServer(int port) {
      IServerChannelSinkProvider chain = new XmlRpcServerFormatterSinkProvider();
      IDictionary props = new Hashtable();
      props.Add("port", port);
#if BRUNET_NUNIT
      /*
       * anonymous channel. In tests we don't care about service names and 
       * moreover, don't want system to complaint about serive name duplication
       * when it gets restarted frequently
       */
      props.Add("name", ""); 
#else
      props.Add("name", "xmlrpcmanagers");  //so that this channel won't collide with dht services
#endif
      _channel = new HttpChannel(props, null, chain);
      ChannelServices.RegisterChannel(_channel, false);

      _dumper = new Dumper(this);
      RemotingServices.Marshal(_dumper, "xmserver.rem");
    }