internal static string Serialize(AICanvas canvas) { var root = new StageElement( ElementName.Canvas, SerializationMaster.Stage(ElementName.Offset, canvas.offset), SerializationMaster.ToStageValue(ElementName.Zoom, canvas.zoom)); var views = canvas.views; int svCount = views.Count; for (int i = 0; i < svCount; i++) { var view = views[i]; StageElement viewElement; if (view is SelectorView) { viewElement = WriteSelectorView((SelectorView)view); } else if (view is AILinkView) { viewElement = WriteAILinkView((AILinkView)view); } else { throw new NotImplementedException("The view type has not been implemented for serialization."); } root.Add(viewElement); } return(SerializationMaster.Serialize(root)); }