cecs_343/demo/patterns-demo/creational/factory/implementation/DataStoreFactory.cs
/// <summary>
/// Creation of a new Data Store instance
/// </summary>
/// <param name="type">String literal of the type</param>
/// <returns>A new instance of a Data Store</returns>
Creation of a new Data Store instance
Creation of a new Data Store instance
public IDataStore Create(string type)
        {
            switch(type?.ToUpper())
            {
                case DataStoreTypes.NoSql:
                    return new NoSqlDataStore();  
                case DataStoreTypes.File:
                    return new FileDataStore();
                case DataStoreTypes.Default:
                case null:
                case "":
                default:
                    return new SqlDataStore();
            }
        }
public IDataStore Create ( string type ) { switch ( type ? . ToUpper ( ) ) { case DataStoreTypes . NoSql : return new NoSqlDataStore ( ) ; case DataStoreTypes . File : return new FileDataStore ( ) ; case DataStoreTypes . Default : case null : case " " : default : return new SqlDataStore ( ) ; } }
Creation of a new Data Store instance
Creation of a new Data Store instance
// Note 1: Use of the new keyword is isolated to this method only // Note 2: A string data type was used for type, but it could have been  // an Enumeration object as well // Case statement fall-through to account for default scenarios
A new instance of a Data Store
A new instance of a Data Store
type
string
String literal of the type
String literal of the type