private static void DisposeInstance(Configuration configuration) { var instance = configuration.Instance as IDisposable; configuration.Instance = null; if (instance == null) { return; } instance.Dispose(); }
public void Store(Configuration configuration) { var match = _configurations.FirstOrDefault(x => x.Name == configuration.Name); if (match == null) { _configurations.Add(configuration); } else { int index = _configurations.IndexOf(match); _configurations[index] = configuration; DisposeInstance(match); } }