コード例 #1
0
ファイル: EggBot.cs プロジェクト: GdubSto420/SysBot.NET
 public EggBot(PokeBotConfig cfg, PokeTradeHub <PK8> Hub) : base(cfg)
 {
     hub                 = Hub;
     Counts              = Hub.Counts;
     DumpSetting         = Hub.Config.Folder;
     ContinueGettingEggs = Hub.Config.Egg.ContinueAfterMatch;
     Ping                = !Hub.Config.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.PingOnMatch}>\n" : "";
 }
コード例 #2
0
        private void DumpModule(IntPtr moduleHandle, ImageLayout imageLayout, string filePath)
        {
            bool result;

            using (IDumper dumper = DumperFactory.GetDumper(_process.Id, _dumperType.Value))
                result = dumper.DumpModule(moduleHandle, imageLayout, filePath);
            MessageBoxStub.Show(result ? $"{_resources.GetString("StrDumpModuleSuccessfully")}{Environment.NewLine}{filePath}" : _resources.GetString("StrFailToDumpModule"), result ? MessageBoxIcon.Information : MessageBoxIcon.Error);
        }
コード例 #3
0
        public override IDumper CreateAndLoad(string typeFullName, Dump data)
        {
            Type       loadedType = base.GetTypeFromFullname(typeFullName);
            MethodInfo method     = loadedType.GetMethod("CreateFromDump", new Type[] { typeof(SafeSharedObjects), typeof(Dump) });
            IDumper    instance   = (IDumper)method.Invoke(null, new object[] { sharedObjects, data });

            return(instance);
        }
コード例 #4
0
ファイル: FossilBot.cs プロジェクト: pichu22/SysBot.NET
 public FossilBot(PokeBotConfig cfg, PokeTradeHub <PK8> Hub) : base(cfg)
 {
     Counts        = Hub.Counts;
     DumpSetting   = Hub.Config.Folder;
     Settings      = Hub.Config.Fossil;
     FossilSpecies = Settings.Species;
     CaptureVideo  = Hub.Config.CaptureVideoClip;
 }
コード例 #5
0
ファイル: RaidBot.cs プロジェクト: antonioHigueron/SysBot.NET
 public RaidBot(PokeBotConfig cfg, PokeTradeHub <PK8> hub) : base(cfg)
 {
     Hub      = hub;
     Settings = Hub.Config.Raid;
     Dump     = Hub.Config.Folder;
     Counts   = Hub.Counts;
     ldn      = Settings.UseLdnMitm;
 }
コード例 #6
0
ファイル: EncounterBot.cs プロジェクト: jareed85/SysBot.NET
 public EncounterBot(PokeBotConfig cfg, PokeTradeHub <PK8> hub) : base(cfg)
 {
     Hub         = hub;
     Counts      = Hub.Counts;
     DumpSetting = Hub.Config.Folder;
     DesiredIVs  = StopConditionSettings.InitializeTargetIVs(Hub);
     Ping        = !Hub.Config.StopConditions.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.StopConditions.PingOnMatch}>\n" : "";
 }
コード例 #7
0
        public virtual IDumper CreateAndLoad(string typeFullName, Dump data)
        {
            IDumper instance = CreateInstance(typeFullName);

            instance.LoadDump(data);

            return(instance);
        }
コード例 #8
0
 private void DumpProcess(uint processId, string directoryPath)
 {
     if (!Directory.Exists(directoryPath))
     {
         Directory.CreateDirectory(directoryPath);
     }
     using (IDumper dumper = DumperFactory.GetDumper(processId, _dumperType.Value))
         MessageBoxStub.Show($"{dumper.DumpProcess(directoryPath).ToString()} {_resources.GetString("StrDumpFilesSuccess")}{Environment.NewLine}{directoryPath}", MessageBoxIcon.Information);
 }
コード例 #9
0
 private object InvokeDelegate(IDumper list, string suffixName, params object[] parameters)
 {
     var lengthObj = list.GetSuffix(suffixName);
     Assert.IsNotNull(lengthObj);
     var lengthDelegate = lengthObj as Delegate;
     Assert.IsNotNull(lengthDelegate);
     var length = lengthDelegate.DynamicInvoke(parameters);
     return length;
 }
コード例 #10
0
 public DumpContext(IDumper dumper, DumpInfo dumpInfo, Set <INode> matchedNodes, Set <INode> multiMatchedNodes,
                    Set <IEdge> matchedEdges, Set <IEdge> multiMatchedEdges)
 {
     Dumper            = dumper;
     DumpInfo          = dumpInfo;
     MatchedNodes      = matchedNodes;
     MultiMatchedNodes = multiMatchedNodes;
     MatchedEdges      = matchedEdges;
     MultiMatchedEdges = multiMatchedEdges;
 }
コード例 #11
0
        private object InvokeDelegate(IDumper stack, string suffixName, params object[] parameters)
        {
            var lengthObj = stack.GetSuffix(suffixName);

            Assert.IsNotNull(lengthObj);
            var lengthDelegate = lengthObj as Delegate;

            Assert.IsNotNull(lengthDelegate);
            var length = lengthDelegate.DynamicInvoke(parameters);

            return(length);
        }
コード例 #12
0
 public RaidBot(PokeBotConfig cfg, PokeTradeHub <PK8> hub) : base(cfg)
 {
     Hub               = hub;
     Settings          = hub.Config.Raid;
     Dump              = hub.Config.Folder;
     Counts            = hub.Counts;
     ldn               = Settings.UseLdnMitm;
     RaidLog           = Settings.RaidLog;
     FriendCode        = Settings.FriendCode;
     Roll              = Settings.AutoRoll;
     FRBoth            = Settings.FriendCombined;
     FRAdd             = Settings.FriendAdd;
     FriendRemoveCount = Settings.FriendPurge;
 }
コード例 #13
0
        public Dump Dump(IDumper dumper, bool includeType = true)
        {
            var dump = dumper.Dump();

            List <object> keys = new List <object>(dump.Keys);

            foreach (object key in keys)
            {
                dump[key] = DumpValue(dump[key], includeType);
            }

            if (includeType)
            {
                dump.Add(TYPE_KEY, dumper.GetType().Namespace + "." + dumper.GetType().Name);
            }

            return(dump);
        }
コード例 #14
0
        public EncounterBot(PokeBotConfig cfg, PokeTradeHub <PK8> Hub) : base(cfg)
        {
            hub           = Hub;
            Counts        = Hub.Counts;
            DumpSetting   = Hub.Config.Folder;
            DesiredNature = Hub.Config.Encounter.DesiredNature;

            /* Populate DesiredIVs array.  Bot matches 0 and 31 IVs.
             * Any other nonzero IV is treated as a minimum accepted value.
             * If they put "x", this is a wild card so we can leave -1. */
            string[] splitIVs = Hub.Config.Encounter.DesiredIVs.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // Only accept up to 6 values in case people can't count.
            for (int i = 0; i < 6 && i < splitIVs.Length; i++)
            {
                if (splitIVs[i] == "x" || splitIVs[i] == "X")
                {
                    continue;
                }
                DesiredIVs[i] = Convert.ToInt32(splitIVs[i]);
            }
        }
コード例 #15
0
ファイル: SerializationMgr.cs プロジェクト: pand5461/KOS-1
        public override IDumper CreateAndLoad(string typeFullName, Dump data)
        {
            IDumper instance = base.CreateInstance(typeFullName);

            if (instance is IHasSharedObjects)
            {
                IHasSharedObjects withSharedObjects = instance as IHasSharedObjects;
                withSharedObjects.Shared = sharedObjects;
            }
            else if (instance is IHasSafeSharedObjects)
            {
                IHasSafeSharedObjects withSharedObjects = instance as IHasSafeSharedObjects;
                withSharedObjects.Shared = sharedObjects;
            }

            if (instance != null)
            {
                instance.LoadDump(data);
            }

            return(instance);
        }
コード例 #16
0
        public EncounterBot(PokeBotConfig cfg, EncounterSettings encounter, IDumper dump, BotCompleteCounts count) : base(cfg)
        {
            Counts        = count;
            DumpSetting   = dump;
            StopOnSpecies = encounter.StopOnSpecies;
            Mode          = encounter.EncounteringType;
            DesiredNature = encounter.DesiredNature;

            /* Populate DesiredIVs array.  Bot matches 0 and 31 IVs.
             * Any other nonzero IV is treated as a minimum accepted value.
             * If they put "x", this is a wild card so we can leave -1. */
            string[] splitIVs = encounter.DesiredIVs.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // Only accept up to 6 values in case people can't count.
            for (int i = 0; i < 6 && i < splitIVs.Length; i++)
            {
                if (splitIVs[i] == "x" || splitIVs[i] == "X")
                {
                    continue;
                }
                DesiredIVs[i] = Convert.ToInt32(splitIVs[i]);
            }
        }
コード例 #17
0
ファイル: Dumper.cs プロジェクト: xyannis/NecroBot
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
     _dumper = dumper;
     _subPath = subPath;
 }
コード例 #18
0
ファイル: PokeTradeBot.cs プロジェクト: rigrassm/SporkBot.NET
 public PokeTradeBot(PokeTradeHub <PK8> hub, PokeBotConfig cfg) : base(cfg)
 {
     Hub             = hub;
     DumpSetting     = hub.Config.Folder;
     GiveawaySetting = hub.Config.Giveaway;
 }
コード例 #19
0
ファイル: PokeTradeBot.cs プロジェクト: jan2705/ForkBot.NET
 public PokeTradeBot(PokeTradeHub <PK8> hub, PokeBotState cfg) : base(cfg)
 {
     Hub         = hub;
     DumpSetting = hub.Config.Folder;
 }
コード例 #20
0
 /// <summary>
 /// Dumps the graph with a given graph dumper.
 /// </summary>
 /// <param name="graph">The graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
 public static void Dump(IGraph graph, IDumper dumper, DumpInfo dumpInfo)
 {
     DumpMatch(graph, dumper, dumpInfo, null, 0);
 }
コード例 #21
0
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
                              int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
                     textColor, color, style, thickness);
 }
コード例 #22
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
     int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
         textColor, color, style, thickness);
 }
コード例 #23
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Dumps the named graph with a given graph dumper and default dump style.
 /// </summary>
 /// <param name="namedGraph">The named graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 public static void Dump(INamedGraph namedGraph, IDumper dumper)
 {
     DumpMatch(namedGraph, dumper, new DumpInfo(namedGraph.GetElementName), null, 0);
 }
コード例 #24
0
ファイル: FormatterTest.cs プロジェクト: KSP-KOS/KOS
 private string Serialize(IDumper o)
 {
     return new SafeSerializationMgr(null).Serialize(o, FormatWriter);
 }
コード例 #25
0
ファイル: SafeSerializationMgr.cs プロジェクト: KSP-KOS/KOS
 public string ToString(IDumper dumper)
 {
     return Serialize(dumper, TerminalFormatter.Instance, false);
 }
コード例 #26
0
ファイル: SafeSerializationMgr.cs プロジェクト: KSP-KOS/KOS
 public string Serialize(IDumper serialized, IFormatWriter formatter, bool includeType = true)
 {
     return formatter.Write(Dump(serialized, includeType));
 }
コード例 #27
0
ファイル: SafeSerializationMgr.cs プロジェクト: KSP-KOS/KOS
        public Dump Dump(IDumper dumper, bool includeType = true)
        {
            var dump = dumper.Dump();

            List<object> keys = new List<object>(dump.Keys);

            foreach (object key in keys)
            {
                dump[key] = DumpValue(dump[key], includeType);
            }

            if (includeType)
            {
                dump.Add(TYPE_KEY, dumper.GetType().Namespace + "." + dumper.GetType().Name);
            }

            return dump;
        }
コード例 #28
0
ファイル: Dumper.cs プロジェクト: CalebD44/NecroBot
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 /// <param name="subPath"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
 }
コード例 #29
0
ファイル: ScriptDumper.cs プロジェクト: scemino/nscumm
        public void DumpScript(byte[] data, IDumper dumper)
        {
            try
            {
                var scriptInterpreter = ScriptParser.Create(Game);
                var compilationUnit = scriptInterpreter.Parse(data);
                var replacers = new IAstReplacer[]
                {
                    //new ReplacePushAndPop(),
                    new ResolveVariables(scriptInterpreter.KnownVariables),
                    //new ResolveAllTypesOfVariables(Game.Version),
                    // OK forget about this, I have to use structuring...
                    //new ReplaceJumpToIf(),
                    //new ReplaceJumpToWhile(),
                    //new ReplaceJumpToGoTo()
                };
                Array.ForEach(replacers, r => compilationUnit = r.Replace(compilationUnit));

                dumper.Write(compilationUnit.Accept(new DumpAstVisitor()));
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e);
                Console.ResetColor();
            }
        }
コード例 #30
0
ファイル: Dumper.cs プロジェクト: nachtwacht/NecroBot
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 /// <param name="subPath"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
 }
コード例 #31
0
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
                              GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
                     color, borderColor, shape);
 }
コード例 #32
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
     GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
         color, borderColor, shape);
 }
コード例 #33
0
        /// <summary>
        /// Dumps the given matches.
        /// </summary>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatchOnly(IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which,
                                         ref Set <INode> matchedNodes, ref Set <INode> multiMatchedNodes, ref Set <IEdge> matchedEdges, ref Set <IEdge> multiMatchedEdges)
        {
            matchedNodes = new Set <INode>();
            matchedEdges = new Set <IEdge>();

            if ((int)which >= 0 && (int)which < matches.Count)
            {
                // Show exactly one match

                IMatch match = matches.GetMatch((int)which);
                matchedNodes.Add(match.Nodes);
                matchedEdges.Add(match.Edges);
            }
            else
            {
                GrColor     vnodeColor       = dumpInfo.GetNodeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor     vedgeColor       = dumpInfo.GetEdgeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor     vnodeBorderColor = dumpInfo.GetNodeDumpTypeBorderColor(GrElemDumpType.VirtualMatch);
                GrColor     vnodeTextColor   = dumpInfo.GetNodeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrColor     vedgeTextColor   = dumpInfo.GetEdgeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrNodeShape vnodeShape       = dumpInfo.GetNodeDumpTypeShape(GrElemDumpType.VirtualMatch);
                GrLineStyle vedgeLineStyle   = dumpInfo.GetEdgeDumpTypeLineStyle(GrElemDumpType.VirtualMatch);
                int         vedgeThickness   = dumpInfo.GetEdgeDumpTypeThickness(GrElemDumpType.VirtualMatch);

                multiMatchedNodes = new Set <INode>();
                multiMatchedEdges = new Set <IEdge>();

                // TODO: May edges to nodes be dumped before those nodes exist??
                // TODO: Should indices in strings start at 0 or 1? (original: 0)

                // Dump all matches with virtual nodes
                int i = 0;
                foreach (IMatch match in matches)
                {
                    VirtualNode virtNode = new VirtualNode(-i - 1);
                    dumper.DumpNode(virtNode, String.Format("{0}. match of {1}", i + 1, matches.Producer.Name),
                                    null, vnodeTextColor, vnodeColor, vnodeBorderColor, vnodeShape);
                    int j = 1;
                    foreach (INode node in match.Nodes)
                    {
                        dumper.DumpEdge(virtNode, node, String.Format("node {0}", ++j), null,
                                        vedgeTextColor, vedgeColor, vedgeLineStyle, vedgeThickness);

                        if (matchedNodes.Contains(node))
                        {
                            multiMatchedNodes.Add(node);
                        }
                        else
                        {
                            matchedNodes.Add(node);
                        }
                    }

                    // Collect matched edges
                    foreach (IEdge edge in match.Edges)
                    {
                        if (matchedEdges.Contains(edge))
                        {
                            multiMatchedEdges.Add(edge);
                        }
                        else
                        {
                            matchedEdges.Add(edge);
                        }
                    }
                    ++i;
                }

                if (which == DumpMatchSpecial.OnlyMatches)
                {
                    // Dump the matches only
                    // First dump the matched nodes

                    foreach (INode node in matchedNodes)
                    {
                        GrElemDumpType dumpType;
                        if (multiMatchedNodes.Contains(node))
                        {
                            dumpType = GrElemDumpType.MultiMatched;
                        }
                        else
                        {
                            dumpType = GrElemDumpType.SingleMatched;
                        }

                        DumpNode(node, dumpInfo.GetNodeDumpTypeTextColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeBorderColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeShape(dumpType),
                                 dumper, dumpInfo);
                    }

                    // Now add the matched edges (possibly including "Not matched" nodes)

                    foreach (IEdge edge in matchedEdges)
                    {
                        if (!matchedNodes.Contains(edge.Source))
                        {
                            DumpNode(edge.Source,
                                     dumpInfo.GetNodeTypeTextColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeBorderColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeShape(edge.Source.Type),
                                     dumper, dumpInfo);
                        }

                        if (!matchedNodes.Contains(edge.Target))
                        {
                            DumpNode(edge.Target,
                                     dumpInfo.GetNodeTypeTextColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeBorderColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeShape(edge.Target.Type),
                                     dumper, dumpInfo);
                        }

                        GrElemDumpType dumpType;
                        if (multiMatchedEdges.Contains(edge))
                        {
                            dumpType = GrElemDumpType.MultiMatched;
                        }
                        else
                        {
                            dumpType = GrElemDumpType.SingleMatched;
                        }

                        DumpEdge(edge, dumpInfo.GetEdgeDumpTypeTextColor(dumpType),
                                 dumpInfo.GetEdgeDumpTypeColor(dumpType),
                                 dumpInfo.GetEdgeDumpTypeLineStyle(dumpType),
                                 dumpInfo.GetEdgeDumpTypeThickness(dumpType),
                                 dumper, dumpInfo);
                    }
                    return;
                }
            }
        }
コード例 #34
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Dumps the graph with a given graph dumper.
 /// </summary>
 /// <param name="graph">The graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
 public static void Dump(IGraph graph, IDumper dumper, DumpInfo dumpInfo)
 {
     DumpMatch(graph, dumper, dumpInfo, null, 0);
 }
コード例 #35
0
 /// <summary>
 /// Dumps the named graph with a given graph dumper and default dump style.
 /// </summary>
 /// <param name="namedGraph">The named graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 public static void Dump(INamedGraph namedGraph, IDumper dumper)
 {
     DumpMatch(namedGraph, dumper, new DumpInfo(namedGraph.GetElementName), null, 0);
 }
コード例 #36
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
        /// <summary>
        /// Dumps one or more matches with a given graph dumper.
        /// </summary>
        /// <param name="graph">The graph to be dumped.</param>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatch(IGraph graph, IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which)
        {
            Set<INode> matchedNodes = null;
            Set<INode> multiMatchedNodes = null;
            Set<IEdge> matchedEdges = null;
            Set<IEdge> multiMatchedEdges = null;

            if(matches != null)
            {
                DumpMatchOnly(dumper, dumpInfo, matches, which,
                    ref matchedNodes, ref multiMatchedNodes, ref matchedEdges, ref multiMatchedEdges);
            }

            // Dump the graph, but color the matches if any exist

            DumpContext dc = new DumpContext(dumper, dumpInfo,
                matchedNodes, multiMatchedNodes, matchedEdges, multiMatchedEdges);

            foreach(NodeType nodeType in graph.Model.NodeModel.Types)
            {
                if(dumpInfo.IsExcludedNodeType(nodeType)) continue;
                dc.Nodes.Add(graph.GetExactNodes(nodeType));
            }

            dc.InitialNodes = new Set<INode>(dc.Nodes);
            Set<INode> nodes = new Set<INode>(dc.Nodes);
            DumpGroups(graph, nodes, dc);
        }
コード例 #37
0
ファイル: EggBot.cs プロジェクト: jkufa/SysBot.NET
 public EggBot(PokeTradeHub <PK8> hub, PokeBotConfig cfg) : base(cfg)
 {
     Counts      = hub.Counts;
     DumpSetting = hub.Config;
 }
コード例 #38
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
        /// <summary>
        /// Dumps the given matches.
        /// </summary>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatchOnly(IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which,
            ref Set<INode> matchedNodes, ref Set<INode> multiMatchedNodes, ref Set<IEdge> matchedEdges, ref Set<IEdge> multiMatchedEdges)
        {
            matchedNodes = new Set<INode>();
            matchedEdges = new Set<IEdge>();

            if((int)which >= 0 && (int)which < matches.Count)
            {
                // Show exactly one match

                IMatch match = matches.GetMatch((int)which);
                matchedNodes.Add(match.Nodes);
                matchedEdges.Add(match.Edges);
            }
            else
            {
                GrColor vnodeColor = dumpInfo.GetNodeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor vedgeColor = dumpInfo.GetEdgeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor vnodeBorderColor = dumpInfo.GetNodeDumpTypeBorderColor(GrElemDumpType.VirtualMatch);
                GrColor vnodeTextColor = dumpInfo.GetNodeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrColor vedgeTextColor = dumpInfo.GetEdgeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrNodeShape vnodeShape = dumpInfo.GetNodeDumpTypeShape(GrElemDumpType.VirtualMatch);
                GrLineStyle vedgeLineStyle = dumpInfo.GetEdgeDumpTypeLineStyle(GrElemDumpType.VirtualMatch);
                int vedgeThickness = dumpInfo.GetEdgeDumpTypeThickness(GrElemDumpType.VirtualMatch);

                multiMatchedNodes = new Set<INode>();
                multiMatchedEdges = new Set<IEdge>();

                // TODO: May edges to nodes be dumped before those nodes exist??
                // TODO: Should indices in strings start at 0 or 1? (original: 0)

                // Dump all matches with virtual nodes
                int i = 0;
                foreach(IMatch match in matches)
                {
                    VirtualNode virtNode = new VirtualNode(-i - 1);
                    dumper.DumpNode(virtNode, String.Format("{0}. match of {1}", i + 1, matches.Producer.Name),
                        null, vnodeTextColor, vnodeColor, vnodeBorderColor, vnodeShape);
                    int j = 1;
                    foreach(INode node in match.Nodes)
                    {
                        dumper.DumpEdge(virtNode, node, String.Format("node {0}", j++), null,
                            vedgeTextColor, vedgeColor, vedgeLineStyle, vedgeThickness);

                        if(matchedNodes.Contains(node)) multiMatchedNodes.Add(node);
                        else matchedNodes.Add(node);
                    }

                    // Collect matched edges
                    foreach(IEdge edge in match.Edges)
                    {
                        if(matchedEdges.Contains(edge)) multiMatchedEdges.Add(edge);
                        else matchedEdges.Add(edge);
                    }
                    i++;
                }

                if(which == DumpMatchSpecial.OnlyMatches)
                {
                    // Dump the matches only
                    // First dump the matched nodes

                    foreach(INode node in matchedNodes)
                    {
                        GrElemDumpType dumpType;
                        if(multiMatchedNodes.Contains(node))
                            dumpType = GrElemDumpType.MultiMatched;
                        else
                            dumpType = GrElemDumpType.SingleMatched;

                        DumpNode(node, dumpInfo.GetNodeDumpTypeTextColor(dumpType),
                            dumpInfo.GetNodeDumpTypeColor(dumpType),
                            dumpInfo.GetNodeDumpTypeBorderColor(dumpType),
                            dumpInfo.GetNodeDumpTypeShape(dumpType),
                            dumper, dumpInfo);
                    }

                    // Now add the matched edges (possibly including "Not matched" nodes)

                    foreach(IEdge edge in matchedEdges)
                    {
                        if(!matchedNodes.Contains(edge.Source))
                            DumpNode(edge.Source,
                                dumpInfo.GetNodeTypeTextColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeBorderColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeShape(edge.Source.Type),
                                dumper, dumpInfo);

                        if(!matchedNodes.Contains(edge.Target))
                            DumpNode(edge.Target,
                                dumpInfo.GetNodeTypeTextColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeBorderColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeShape(edge.Target.Type),
                                dumper, dumpInfo);

                        GrElemDumpType dumpType;
                        if(multiMatchedEdges.Contains(edge))
                            dumpType = GrElemDumpType.MultiMatched;
                        else
                            dumpType = GrElemDumpType.SingleMatched;

                        DumpEdge(edge, dumpInfo.GetEdgeDumpTypeTextColor(dumpType),
                            dumpInfo.GetEdgeDumpTypeColor(dumpType),
                            dumpInfo.GetEdgeDumpTypeLineStyle(dumpType),
                            dumpInfo.GetEdgeDumpTypeThickness(dumpType),
                            dumper, dumpInfo);
                    }
                    return;
                }
            }
        }
コード例 #39
0
ファイル: EggBot.cs プロジェクト: pichu22/SysBot.NET
 public EggBot(PokeBotConfig cfg, EggSettings egg, IDumper dump, BotCompleteCounts count) : base(cfg)
 {
     Counts              = count;
     DumpSetting         = dump;
     ContinueGettingEggs = egg.ContinueAfterMatch;
 }
コード例 #40
0
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 /// <param name="subPath"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
     _dumper  = dumper;
     _subPath = subPath;
 }
コード例 #41
0
ファイル: Yaml.cs プロジェクト: IngisKahn/Nyaml
 public static void Emit(IEnumerable<Events.Base> events, IDumper dumper)
 {
     foreach (var @event in events)
         dumper.Emit(@event);
 }
コード例 #42
0
 public string ToString(IDumper dumper)
 {
     return(Serialize(dumper, TerminalFormatter.Instance, false));
 }
コード例 #43
0
 public CompositesOperations(IDumper dumper)
 {
     _dumper = dumper;
 }
コード例 #44
0
 public string Serialize(IDumper serialized, IFormatWriter formatter, bool includeType = true)
 {
     return(formatter.Write(Dump(serialized, includeType)));
 }
コード例 #45
0
 public PokeTradeBot(PokeTradeHub <PK8> hub, PokeBotConfig cfg) : base(cfg)
 {
     Hub         = hub;
     DumpSetting = hub.Config;
 }
コード例 #46
0
ファイル: GraphDumper.cs プロジェクト: jblomer/GrGen.NET
 public DumpContext(IDumper dumper, DumpInfo dumpInfo, Set<INode> matchedNodes, Set<INode> multiMatchedNodes,
     Set<IEdge> matchedEdges, Set<IEdge> multiMatchedEdges)
 {
     Dumper = dumper;
     DumpInfo = dumpInfo;
     MatchedNodes = matchedNodes;
     MultiMatchedNodes = multiMatchedNodes;
     MatchedEdges = matchedEdges;
     MultiMatchedEdges = multiMatchedEdges;
 }