/JTacticalSim.DataContext/DataFileFactory.cs
C# | 49 lines | 43 code | 6 blank | 0 comment | 5 complexity | 403ae34310b7e40b911a2d50f5af2c5a MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml.Linq;
- using System.Configuration;
- using JTacticalSim.API.InfoObjects;
- using JTacticalSim.Data;
- using JTacticalSim.API;
- using JTacticalSim.API.Data;
-
- namespace JTacticalSim.DataContext
- {
- public class DataFileFactory
- {
- private static volatile DataFileFactory _instance = null;
- static readonly object padlock = new object();
-
- public static DataFileFactory Instance
- {
- get
- {
- if (_instance == null)
- {
- lock (padlock)
- if (_instance == null) _instance = new DataFileFactory();
- }
-
- return _instance;
- }
- }
-
- private Type _fileType = Utility.GetDataFileType().GetType();
-
-
- public IDataFileInfo<fileType> GetDataFiles<fileType>(string gameFileDirectory, bool IsScenario)
- {
- switch (Utility.GetDataSourceType())
- {
- case DataSourceType.XML:
- return new XMLDataFileInfo(gameFileDirectory, IsScenario) as IDataFileInfo<fileType>;
- default:
- {
- throw new Exception("No data source type found for current configuration or current data source configuration is not a file type");
- }
- }
- }
- }
- }