示例#1
0
        static async Task MainAsync(string[] args)
        {
            var sj = new SimpleJob();

            IReceive folder = new ReceiverFolderHierarchical(@"D:\test", "*.txt");
            //await folder.LoadData();
            var t = new TransformerFileToLines();

            t.TrimEmptyLines = false;
            //t.valuesRead = folder.valuesRead;
            //await t.Run();

            var addBak = new TransformerFieldAddString("FullName", "FullName", ".bak");

            addBak.valuesRead = t.valuesTransformed;
            //await addBak.Run();


            //var regex = new TransformRowRegex(@"^(?x<ip>123).*?$","text");
            var regex = new TransformRowRegexReplaceGuid(@"^.*x(?<ip>\w+)123.*?$", "text");

            regex.ReplaceAllNextOccurences = true;
            //regex.valuesRead = addBak.valuesTransformed;
            //await regex.Run();
            var file = new SenderByRowToFile("FullName", "lineNr", "text", ".txt");

            file.FileMode = System.IO.FileMode.Append;
            //file.valuesToBeSent = regex.valuesTransformed;
            //await file.Send();

            sj
            .AddReceiver(folder)
            .AddTransformer(t)
            //.AddTransformer(addBak)
            .AddTransformer(regex)
            .AddSender(file);

            File.WriteAllText("def.txt", sj.SerializeMe());
            await sj.Execute();
        }
示例#2
0
        static string JobDllBlockly()
        {
            string   dir              = Environment.CurrentDirectory;
            IReceive folderWithDll    = new ReceiverFolderHierarchical("#static:Directory.GetCurrentDirectory()#", "*.dll");
            var      filterFiles      = new FilterForFilesHierarchical();
            var      recContentFile   = new ReceiverFromDllRelational();
            var      loadDllFromFiles = new TransformerApplyReceiver(recContentFile, "DllFileName", "FullName");
            //retain just types
            var filterTypes = new FilterRetainRelationalName(FilterType.Equal, "Types");
            //load types that are not generic or abstract
            //var justTypes = new FilterComparableEqual(typeof(string), "Types", "NameRelation");
            var notAbstract  = new FilterComparableEqual(typeof(bool), false, "IsAbstract");
            var notGeneric   = new FilterComparableEqual(typeof(bool), false, "IsGeneric");
            var notInterface = new FilterComparableEqual(typeof(bool), false, "IsInterface");
            //var noInterface = new FilterExcludeRelation("Interfaces");
            //var rel2plain = new TransformerRelationalToPlain();
            var haveProps = new FilterComparableGreat(typeof(int), 0, "PropertiesNr");
            //var justRelations = new FilterRetainItemsWithKey("NameRelation", FilterType.Equal);

            var    fileRazor  = Path.Combine(dir, "blockly.cshtml");
            string filename   = "#static:Directory.GetCurrentDirectory()#\\blockly.html";
            ISend  senderHTML = new SyncSenderMultiple(
                new Sender_Text(filename, "<html><body>")
            {
                FileMode = FileMode.Create
            },
                new Sender_HTMLRazor("Views/" + Path.GetFileName(fileRazor), filename),
                //new Sender_HTMLRelationViz("Name", filename),
                new Sender_Text(filename, "</body></html>")
                )
            ;
            var senderRow     = new SenderByRowToFile("Name", "txt", "Block Definition", "txt");
            var clear         = new TransformClearValues();
            var trReceiveHtml = new ReceiverHTMLTable(@"blockly.html", Encoding.UTF8);
            var decodeHtml    = new TransformerHtmlDecode();
            //var addJS = new TransformModifyField("Name", "{0}.js");
            var senderBlockTag          = new SenderByRowToFile("Name", "_def.txt", "Block definition", "txt");
            var senderBlockDefinitionJs = new SenderByRowToFile("Name", "_block.js", "Block JS", "js");
            var senderBlockCodeJs       = new SenderByRowToFile("Name", "_code.js", "Block CodeGenerator", "js");

            var job = new SimpleJobConditionalTransformers();

            job
            .AddReceiver(folderWithDll)
            .AddFilter(filterFiles)
            .AddTransformer(loadDllFromFiles)
            .AddFilter(filterTypes)
            .AddFilter(notAbstract)
            .AddFilter(notGeneric)
            .AddFilter(notInterface)
            .AddFilter(haveProps)
            //.AddTransformer(noInterface)
            //.AddTransformer(rel2plain)
            .AddSender(senderHTML)
            .AddTransformer(clear)
            .Add(clear, trReceiveHtml)
            .Add(trReceiveHtml, decodeHtml)
            .Add(decodeHtml, senderBlockTag)
            .Add(decodeHtml, senderBlockDefinitionJs)
            .Add(decodeHtml, senderBlockCodeJs)

            ;

            return(job.SerializeMe());
        }