예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
		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);
		}
예제 #6
0
		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));
		}
예제 #7
0
		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);
		}
예제 #8
0
		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);
		}
예제 #9
0
		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;
		}