static void Main() { // Create an object instance of NameCollisions. NameCollisions test = new NameCollisions(); // Call the appropriate method by casting // the object to the appropriate interface. ((IFileWriter)test).SaveData(); ((IDbWriter)test).SaveData(); Console.WriteLine(); // Or we can create interface references and // call the methods with these references. Notice // the use of the "as" keyword here. This is a // good practice. IFileWriter iFile = test as IFileWriter; if (iFile != null) iFile.SaveData(); IDbWriter iDB = test as IDbWriter; if (iDB != null) iDB.SaveData(); Console.Write ("\n\nPress <ENTER> to end: "); Console.ReadLine(); }
static void Main() { // Create an object instance of NameCollisions and // call the SaveData() method. NameCollisions test = new NameCollisions(); if (test is IFileWriter) test.SaveData(); if (test is IDbWriter) test.SaveData(); Console.Write ("\n\nPress <ENTER> to end: "); Console.ReadLine(); }
public void Rename(string newName) { if (!NameCollisions.Contains(newName)) { _namesList.Add(newName); _namesList.Remove(_fileHandler.FilePath); var act = new RenameAction(_fileHandler.Rename, newName, _fileHandler.FilePath); ToRename.Add(act); _actions.Enqueue(act); } else { //NameCollisions.Add(); } }