Esempio n. 1
0
        public static IProcessor InterpretProcessor(Context context, string text)
        {
            try
            {
                var words = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (words.Count() == 0)
                {
                    return(null);
                }

                string command    = words.First().ToLower();
                var    parameters = words.Skip(1);

                switch (command)
                {
                case "markdown":
                    return(new RenderProcessor(new MarkDownRenderer()));

                case "template":
                {
                    var processor = new TemplateProcessor();
                    //pr.Template = influx.Documents.First(); //Document document = Document.CreateInContext(context, template);
                    processor.Influx = Selector.Create(context, parameters);
                    return(processor);
                }

                case "razor":
                    return(new RenderProcessor(new RazorRenderer()));

                case "copy":
                    return(new CopyProcessor());

                case "save":
                {
                    string mask      = parameters.FirstOrDefault();
                    var    processor = new SaveProcessor();
                    processor.Mask = mask;
                    return(processor);
                }

                case "stash":
                {
                    string key = words.Skip(1).First();
                    if (!key.StartsWith(Selector.STASHPREFIX))
                    {
                        throw new Exception("Stash name should always begin with " + Selector.STASHPREFIX);
                    }
                    return(new StashProcessor(key));
                }

                case "attach":
                {
                    IProcessor p = new AttachProcessor();
                    p.Influx = Selector.Create(context, parameters);
                    return(p);
                }

                case "concatenate":
                    return(new ConcatenateProcessor());

                case "make":
                    return(new MakeProcessor());

                case "makeall":
                {
                    string folder = parameters.FirstOrDefault();
                    return(new MakeForAllProcessor(folder));
                }

                case "profiletable":
                    return(new ProfileProcessor());

                case "structure":
                    return(new StructureProcessor());

                case "dict":
                    return(new DictTableProcessor());

                case "valueset":
                    return(new ValueSetProcessor());

                default:
                    throw new Exception("Unknown processing command: " + command);
                }
            }
            catch
            {
                throw new Exception("Invalid processor statement: " + text);
            }
        }
Esempio n. 2
0
        public static IProcessor InterpretProcessor(Context context, string text)
        {
            try
            {
                var words = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (words.Count() == 0) 
                    return null;
                
                string command = words.First().ToLower();
                var parameters = words.Skip(1);

                switch (command)
                {
                    case "markdown":
                        return new RenderProcessor(new MarkDownRenderer());

                    case "template":
                    {
                        var processor = new TemplateProcessor();
                        //pr.Template = influx.Documents.First(); //Document document = Document.CreateInContext(context, template);
                        processor.Influx = Selector.Create(context, parameters);
                        return processor;
                    }

                    case "razor":
                        return new RenderProcessor(new RazorRenderer());

                    case "copy":
                        return new CopyProcessor();

                    case "save":
                    {
                        string mask = parameters.FirstOrDefault();
                        var processor = new SaveProcessor();
                        processor.Mask = mask;
                        return processor;
                    }

                    case "stash":
                    {
                        string key = words.Skip(1).First();
                        if (!key.StartsWith(Selector.STASHPREFIX)) throw new Exception("Stash name should always begin with " + Selector.STASHPREFIX);
                        return new StashProcessor(key);
                    }

                    case "attach":
                    {
                        IProcessor p = new AttachProcessor();
                        p.Influx = Selector.Create(context, parameters);
                        return p;
                    }

                    case "concatenate":
                        return new ConcatenateProcessor();

                    case "make":
                        return new MakeProcessor();

                    case "makeall":
                    {
                        string folder = parameters.FirstOrDefault();
                        return new MakeForAllProcessor(folder);
                    }

                    case "profiletable":
                        return new ProfileProcessor();

                    case "structure":
                        return new StructureProcessor();

                    case "dict":
                        return new DictTableProcessor();

                    case "valueset":
                        return new ValueSetProcessor();

                    default:
                        throw new Exception("Unknown processing command: " + command);
                }
            }
            catch
            {
                throw new Exception("Invalid processor statement: " + text);
            }
        }