public static Source GetSource(Contexts.Sources.Source source) { var contextType = source.GetType(); if (contextType == typeof(Contexts.Sources.Database)) return new Database(); else if(contextType == typeof(Contexts.Sources.FlatFile)) return new FlatFile(); else throw new ArgumentException(); }