Beispiel #1
0
        public override object Execute(List <string> args)
        {
            if (args.Count != 2)
            {
                return(false);
            }

            var type   = args[0];
            var outDir = args[1];

            TagLayoutWriter writer;

            switch (type.ToLower())
            {
            case "c#":
            case "cs":
            case "csharp":
                writer = new CSharpLayoutWriter();
                break;

            case "c++":
            case "cpp":
            case "cplusplus":
                writer = new CppLayoutWriter();
                break;

            default:
                return(false);
            }

            Directory.CreateDirectory(outDir);

            var count = 0;

            using (var stream = CacheContext.OpenTagCacheRead())
            {
                foreach (var groupTag in CacheContext.TagCache.Index.NonNull().Select(t => t.Group.Tag).Distinct())
                {
                    TagLayoutGuess    layout  = null;
                    CachedTagInstance lastTag = null;

                    foreach (var tag in CacheContext.TagCache.Index.FindAllInGroup(groupTag))
                    {
                        Console.Write("Analyzing ");
                        TagPrinter.PrintTagShort(tag);

                        lastTag = tag;

                        var analyzer  = new TagAnalyzer(CacheContext.TagCache);
                        var data      = CacheContext.TagCache.ExtractTag(stream, tag);
                        var tagLayout = analyzer.Analyze(data);

                        if (layout != null)
                        {
                            layout.Merge(tagLayout);
                        }
                        else
                        {
                            layout = tagLayout;
                        }
                    }

                    if (layout != null && lastTag != null)
                    {
                        Console.WriteLine("Writing {0} layout", groupTag);

                        var name      = CacheContext.GetString(lastTag.Group.Name);
                        var tagLayout = LayoutGuessFinalizer.MakeLayout(layout, name, groupTag);
                        var path      = Path.Combine(outDir, writer.GetSuggestedFileName(tagLayout));

                        writer.WriteLayout(tagLayout, path);

                        count++;
                    }
                }
            }

            Console.WriteLine("Successfully generated {0} layouts!", count);

            return(true);
        }
Beispiel #2
0
        public override bool Execute(List <string> args)
        {
            if (args.Count != 3)
            {
                return(false);
            }
            var             entry  = args[0];
            var             type   = args[1];
            var             outDir = args[2];
            TagLayoutWriter writer;

            switch (type)
            {
            case "csharp":
                writer = new CSharpLayoutWriter();
                break;

            case "cpp":
                writer = new CppLayoutWriter();
                break;

            default:
                return(false);
            }
            Directory.CreateDirectory(outDir);
            var count = 0;

            using (var stream = _info.OpenCacheRead())
            {
                //foreach (var groupTag in _cache.Tags.NonNull().Select(t => t.Group.Tag).Distinct())
                var groupTag = ArgumentParser.ParseTagIndex(_info, entry).Group.Tag;
                {
                    TagLayoutGuess layout  = null;
                    TagInstance    lastTag = null;
                    foreach (var tag in _cache.Tags.FindAllInGroup(groupTag))
                    {
                        Console.Write("Analyzing ");
                        TagPrinter.PrintTagShort(tag);

                        lastTag = tag;
                        var analyzer  = new TagAnalyzer(_cache);
                        var data      = _cache.ExtractTag(stream, tag);
                        var tagLayout = analyzer.Analyze(data);
                        if (layout != null)
                        {
                            layout.Merge(tagLayout);
                        }
                        else
                        {
                            layout = tagLayout;
                        }
                    }
                    if (layout != null && lastTag != null)
                    {
                        Console.WriteLine("Writing {0} layout", groupTag);
                        var name      = _info.StringIDs.GetString(lastTag.Group.Name);
                        var tagLayout = LayoutGuessFinalizer.MakeLayout(layout, name, groupTag);
                        var path      = Path.Combine(outDir, writer.GetSuggestedFileName(tagLayout));
                        writer.WriteLayout(tagLayout, path);
                        count++;
                    }
                }
            }
            Console.WriteLine("Successfully generated {0} layouts!", count);
            return(true);
        }