public void Execute(CommandBase cmd)
        {
            Validate(cmd);
            CurrentCommand = cmd;

            TraceLine($"{ CommandUtils.GetCommandYamlName(cmd.GetType()) } { cmd.GetParametersInfo() }");
            Migrator.Current.Tracer.Indent();

            cmd.ExecuteInternal(this);

            Migrator.Current.Tracer.IndentBack();
        }
示例#2
0
        public static MapConfig ReadFromString(string yamlString, IEnumerable <Type> customCommands)
        {
            var commandMapping = new Dictionary <string, Type>()
            {
                { CommandUtils.GetCommandYamlName(typeof(ReplaceCommandSet)), typeof(ReplaceCommandSet) },
                { CommandUtils.GetCommandYamlName(typeof(SetFlowCommand)), typeof(SetFlowCommand) },
                { CommandUtils.GetCommandYamlName(typeof(LookupCommand)), typeof(LookupCommand) },
                { CommandUtils.GetCommandYamlName(typeof(TypeConvertCommand)), typeof(TypeConvertCommand) },
                { CommandUtils.GetCommandYamlName(typeof(SetCommand)), typeof(SetCommand) },
                { CommandUtils.GetCommandYamlName(typeof(ConcatCommand)), typeof(ConcatCommand) },
                { CommandUtils.GetCommandYamlName(typeof(GetValueCommand)), typeof(GetValueCommand) },
                { CommandUtils.GetCommandYamlName(typeof(GetNotEmptyValueCommand)), typeof(GetNotEmptyValueCommand) },
                { CommandUtils.GetCommandYamlName(typeof(IfCommand)), typeof(IfCommand) },
                { CommandUtils.GetCommandYamlName(typeof(TraceCommand)), typeof(TraceCommand) },
                { CommandUtils.GetCommandYamlName(typeof(CommandSet <CommandBase>)), typeof(CommandSet <CommandBase>) },
                { CommandUtils.GetCommandYamlName(typeof(GetTargetCommand)), typeof(GetTargetCommand) },
                { CommandUtils.GetCommandYamlName(typeof(MessageCommand)), typeof(MessageCommand) },

                { "csv", typeof(CsvDataSource) },
                { "composite-source", typeof(CompositeDataSource) },
                { "excel", typeof(ExcelDataSource) },
                { "sql", typeof(SqlDataSource) },
            };

            var builder = new DeserializerBuilder();

            customCommands
            .Select(type => new KeyValuePair <string, Type>(type.Name, type))
            .Union(commandMapping)
            .ToList()
            .ForEach(type => builder = builder.WithTagMapping("!" + type.Key, type.Value));

            var deserializer = builder.Build();

            var mapConfig = deserializer.Deserialize <MapConfig>(yamlString);

            mapConfig.Initialize();

            return(mapConfig);
        }