Esempio n. 1
0
        public CompositionDiagramElement Clone(CompositionDiagramElement element)
        {
            var settings = _compositionRegistry.Serialize(element);
            var clone    = _compositionRegistry.Deserialize(settings);

            return(clone);
        }
Esempio n. 2
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);
        }