public ISequenceResolver Instantiate(ColumnType type, ISequenceResolverArgs args) { switch (type) { case ColumnType.Text: return(Instantiate <string>(args)); case ColumnType.Numeric: return(Instantiate <decimal>(args)); case ColumnType.DateTime: return(Instantiate <DateTime>(args)); case ColumnType.Boolean: return(Instantiate <bool>(args)); default: throw new ArgumentOutOfRangeException(); } }
public ISequenceResolver <T> Instantiate <T>(ISequenceResolverArgs args) { if (args is ListSequenceResolverArgs) { return(new ListSequenceResolver <T>((ListSequenceResolverArgs)args)); } if (args is ILoopSequenceResolverArgs) { var strategy = MapStrategy <T>(args as ILoopSequenceResolverArgs); return(new LoopSequenceResolver <T>(strategy)); } return(new ListSequenceResolver <T>((ListSequenceResolverArgs)args)); throw new ArgumentOutOfRangeException($"Type '{args.GetType().Name}' is not expected when building a Scalar"); }
public void Build() { if (!isSetup) { throw new InvalidOperationException(); } if (obj is SentinelLoopXml) { var loop = obj as SentinelLoopXml; switch (columnType) { case ColumnType.Numeric: args = BuildSentinelLoopResolverArgs <decimal, decimal>(loop.Seed, loop.Terminal, loop.Step, loop.IntervalMode); break; case ColumnType.DateTime: args = BuildSentinelLoopResolverArgs <DateTime, IDuration>(loop.Seed, loop.Terminal, loop.Step, loop.IntervalMode); break; default: throw new ArgumentOutOfRangeException(); } } else if (obj is List <string> ) { var helper = new ScalarHelper(serviceLocator, globalVariables); var resolvers = new List <IScalarResolver>(); foreach (var value in obj as List <string> ) { resolvers.Add(helper.InstantiateResolver <string>(value)); } args = new ListSequenceResolverArgs(resolvers); } if (args == null) { throw new ArgumentException(); } }