public void Save(CompositionDiagramElement element, bool isComposition) { if (element == null) { throw new ArgumentNullException(nameof(element)); } if (!isComposition) { if (!_strategies.Contains(element)) { _strategies.Add(element); } } else { DiagramElements.Add(element); } var path = isComposition ? _compositionsPath : _strategiesPath; var settings = _compositionRegistry.Serialize(element); var file = Path.Combine(path, element.GetFileName()); _serializer.Serialize(settings, file); }
public void Remove(CompositionDiagramElement element, bool isComposition) { if (element == null) { throw new ArgumentNullException("element"); } if (isComposition) { _compositionRegistry.TryRemove(element); _compositions.Remove(element); } else { _strategies.Remove(element); } var path = isComposition ? _compositionsPath : _strategiesPath; var file = Path.Combine(path, element.GetFileName()); if (File.Exists(file)) { File.Delete(file); } }
public CompositionDiagramElement Discard(CompositionDiagramElement element, bool isComposition) { if (element == null) { throw new ArgumentNullException("element"); } var path = isComposition ? _compositionsPath : _strategiesPath; var file = Path.Combine(path, element.GetFileName()); var settings = _serializer.Deserialize(file); var discardedElement = _compositionRegistry.Deserialize(settings); if (isComposition) { // TODO discard in CompositionRegistry DiagramElements.Remove(element); DiagramElements.Add(discardedElement); var index = _compositions.IndexOf(element); _compositions[index] = discardedElement; } else { var index = _strategies.IndexOf(element); _strategies[index] = discardedElement; } return(discardedElement); }
public void Discard(CompositionDiagramElement element, bool isComposition) { if (element == null) { throw new ArgumentNullException(nameof(element)); } var path = isComposition ? _compositionsPath : _strategiesPath; var file = Path.Combine(path, element.GetFileName()); var settings = _serializer.Deserialize(file); _compositionRegistry.Load(element, settings); }
public void Save(CompositionDiagramElement element, bool isComposition) { if (element == null) throw new ArgumentNullException("element"); if (!isComposition) { if (!_strategies.Contains(element)) _strategies.Add(element); } else { DiagramElements.Add(element); if (!_compositions.Contains(element)) _compositions.Add(element); } var path = isComposition ? _compositionsPath : _strategiesPath; var settings = _compositionRegistry.Serialize(element); var file = Path.Combine(path, element.GetFileName()); _serializer.Serialize(settings, file); }
public void Save(CompositionDiagramElement element, bool isComposition) { if (element == null) throw new ArgumentNullException(nameof(element)); if (!isComposition) { if (!_strategies.Contains(element)) _strategies.Add(element); } else DiagramElements.Add(element); var path = isComposition ? _compositionsPath : _strategiesPath; var settings = _compositionRegistry.Serialize(element); var file = Path.Combine(path, element.GetFileName()); CultureInfo.InvariantCulture.DoInCulture(() => _serializer.Serialize(settings, file)); }
public void Discard(CompositionDiagramElement element, bool isComposition) { if (element == null) throw new ArgumentNullException(nameof(element)); var path = isComposition ? _compositionsPath : _strategiesPath; var file = Path.Combine(path, element.GetFileName()); var settings = CultureInfo.InvariantCulture.DoInCulture(() => _serializer.Deserialize(file)); _compositionRegistry.Load(element, settings); }
public void Remove(CompositionDiagramElement element, bool isComposition) { if (element == null) throw new ArgumentNullException(nameof(element)); if (isComposition) { _compositionRegistry.TryRemove(element); } else _strategies.Remove(element); var path = isComposition ? _compositionsPath : _strategiesPath; var file = Path.Combine(path, element.GetFileName()); if (File.Exists(file)) File.Delete(file); }
public CompositionDiagramElement Discard(CompositionDiagramElement element, bool isComposition) { if (element == null) throw new ArgumentNullException("element"); var path = isComposition ? _compositionsPath : _strategiesPath; var file = Path.Combine(path, element.GetFileName()); var settings = _serializer.Deserialize(file); var discardedElement = _compositionRegistry.Deserialize(settings); if (isComposition) { // TODO discard in CompositionRegistry DiagramElements.Remove(element); DiagramElements.Add(discardedElement); var index = _compositions.IndexOf(element); _compositions[index] = discardedElement; } else { var index = _strategies.IndexOf(element); _strategies[index] = discardedElement; } return discardedElement; }