Exemplo n.º 1
0
        public IFigure CloneFigure(ExternalizableFilter filter)
        {
            var persister = new Externalizer();
            var mem       = persister.Save(this, filter);

            return(persister.Load(mem, null) as IFigure);
        }
Exemplo n.º 2
0
        private static IEditor RestoreEditorOnly(
            TransferContentTreeNode content, Externalizer externalizer, IControllerFactory factory
            )
        {
            /// var type = content.Value.Item1; // restoreには使わない
            var modelMem = content.Value.ModelMemento;
            var figMem   = content.Value.FigureMemento;

            var model = externalizer.Load(modelMem);
            var fig   = externalizer.Load(figMem) as IFigure;

            var ret = CreateEditorWithFigure(model, fig, factory);

            if (content.Value.Initializer != null)
            {
                content.Value.Initializer(ret, content.Value.TransferInitArgs);
            }
            return(ret);
        }
Exemplo n.º 3
0
        public void TestNodeFigurePersist()
        {
            var persister = new Externalizer();
            var node      = new SimpleRect();

            node.Bounds = new Rectangle(0, 0, 100, 100);
            IMemento mem = persister.Save(node);

            var onode = persister.Load(mem) as IConnectable;

            Assert.AreNotEqual(node, onode);
            Assert.AreEqual(new Rectangle(0, 0, 100, 100), onode.Bounds);
        }