//use this to set up a new class of data /*the structure is * classInstance= (class type)SetUpAndLoadDataFile<class type>( * class.fileName, * class.fileHash, * classInstance); */ //you would call this function in another class before useing the file public static object SetUpAndLoadDataFile <DataType>(string fileName, string filehash, object dataInput) { string Path = DataManaginigMethods.createFilePathname(fileName); if (File.Exists(Path)) { DataType Data = (DataType) loadData <DataType>(Path, filehash); return(Data); } else { DataManaginigMethods.SaveSomeData(dataInput, fileName, filehash); DataType Data = (DataType) loadData <DataType>(Path, filehash); return(Data); } }
public static void saveData() { DataManaginigMethods.SaveSomeData(m_myclass, "filename", "hash"); }
// public static MyClass m_myclass = new MyClass(); public static void LoadTheData() { m_my_class = (MyClass)DataManaginigMethods.SetUpAndLoadDataFile <MyClass>("filename", "hash", m_myclass); }