public override void ReadExternal(IMemento memento, ExternalizeContext context) { base.ReadExternal(memento, context); if (memento.Contains("Outgoings")) { foreach (var ex in memento.ReadExternalizables("Outgoings")) { var edge = ex as IConnection; if (edge != null) { _Outgoings.Add(edge); } } } if (memento.Contains("Incomings")) { foreach (var ex in memento.ReadExternalizables("Incomings")) { var edge = ex as IConnection; if (edge != null) { _Incomings.Add(edge); } } } }
public virtual void ReadExternal(IMemento memento, ExternalizeContext context) { _isVisible = memento.ReadBool("IsVisible"); _layout = memento.ReadExternalizable("Layout") as ILayout; if (_layout != null) { _layout.Owner = this; } if (memento.Contains("LayoutConstraints")) { var constraints = memento.ReadSerializable("LayoutConstraints") as Dictionary <IMemento, object>; if (constraints.Count > 0) { foreach (var pair in constraints) { var child = context.GetExternalizable("Children", pair.Key) as IFigure; LayoutConstraints[child] = pair.Value; } } } if (memento.Contains("PersistentData")) { var data = memento.ReadSerializable("PersistentData") as Dictionary <string, object>; if (data.Count > 0) { foreach (var pair in data) { PersistentData[pair.Key] = pair.Value; } } } if (memento.Contains("Children")) { var children = memento.ReadExternalizables("Children"); foreach (var child in children) { var childFig = child as IFigure; if (childFig != null) { Children.Add(childFig); } } } }
public void ReadExternal(IMemento memento, ExternalizeContext context) { _inLoading = true; var modelSerializer = context.ExtendedData[EditorConsts.ModelSerializerKey] as IModelSerializer; var site = context.ExtendedData[EditorConsts.EditorSiteKey] as IEditorSite; if (modelSerializer == null || site == null) { throw new ArgumentException("context.ExtendedData is invalid"); } var model = modelSerializer.Load(memento.ReadSerializable("ModelHint")); var fig = memento.ReadExternalizable("Figure") as IFigure; var ctrl = site.ControllerFactory.CreateController(model); /// Controllerは作り直す Model = model; _Figure = fig; _Controller = ctrl; using (Figure.DirtManager.BeginDirty()) { ctrl.ConfigureEditor(this); if (memento.Contains("Children")) { foreach (var child in memento.ReadExternalizables("Children")) { var childEditor = child as Editor; if (childEditor != null) { AddChildEditor(childEditor); } } } RelocateAllHandles(); RelocateFocus(); //Refresh(); //Enable(); } _inLoading = false; }