private static StageElement WriteSelectorView(SelectorView sv) { var sve = new StageElement( ElementName.SelectorView, SerializationMaster.Stage(ElementName.ViewArea, sv.viewArea)); sve.AddTextValue(ElementName.Name, sv.name); sve.AddTextValue(ElementName.Description, sv.description); var qualifierViews = sv.qualifierViews; int qvCount = qualifierViews.Count; for (int i = 0; i < qvCount; i++) { var qv = WriteQualifierView(qualifierViews[i]); sve.Add(qv); } var defQv = WriteQualifierView(sv.defaultQualifierView); sve.Add(defQv); return(sve); }
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)); }
private static StageElement WriteAILinkView(AILinkView lv) { var lve = new StageElement( ElementName.AILinkView, SerializationMaster.Stage(ElementName.ViewArea, lv.viewArea), SerializationMaster.ToStageAttribute(AttributeName.Id, lv.aiId)); lve.AddTextValue(ElementName.Name, lv.name); lve.AddTextValue(ElementName.Description, lv.description); return(lve); }
public StageItem StageValue(string name, object value) { IDictionary dictionaries = value as IDictionary; int count = dictionaries.Count; StageList stageList = new StageList(name); foreach (object key in dictionaries.Keys) { stageList.Add(new StageElement(string.Empty, new StageItem[] { SerializationMaster.Stage("key", key), SerializationMaster.Stage("value", dictionaries[key]) })); } return(stageList); }
public StageItem StageValue(string name, object value) { IList lists = value as IList; int count = lists.Count; StageList stageList = new StageList(name); for (int i = 0; i < count; i++) { StageItem stageItem = SerializationMaster.Stage("Item", lists[i]); stageList.Add(stageItem); } return(stageList); }
internal static string Serialize(IList <TopLevelView> items) { var aiPart = new StageElement(ElementName.AIPart); var uiPart = new StageElement(ElementName.UIPart); var root = new StageElement(ElementName.ViewSnippet, aiPart, uiPart); root.AddTextAttribute(AttributeName.SnippetType, ElementName.ViewSnippet); var referencePos = new Vector2(float.MaxValue, float.MaxValue); for (int i = 0; i < items.Count; i++) { var view = items[i]; var selectorView = view as SelectorView; if (selectorView != null) { var item = selectorView.selector; var aiItem = SerializationMaster.Stage(typeof(Selector).Name, item); aiPart.Add(aiItem); var viewItem = WriteSelectorView(selectorView); uiPart.Add(viewItem); //Even though reid also happens on paste we have to do it here as well, otherwise copying linked selectors will fail. item.RegenerateId(); } var linkView = view as AILinkView; if (linkView != null) { var viewItem = WriteAILinkView(linkView); uiPart.Add(viewItem); } if (view.viewArea.xMin < referencePos.x) { referencePos.x = view.viewArea.xMin; } if (view.viewArea.yMin < referencePos.y) { referencePos.y = view.viewArea.yMin; } } uiPart.AddValue(ElementName.ReferencePosition, referencePos); return(SerializationMaster.Serialize(root)); }
/// <summary> /// Stages the value. /// </summary> /// <param name="name">The name to give the resulting <see cref="StageItem" />.</param> /// <param name="value">The value to stage</param> /// <returns> /// The element containing the staged value. /// </returns> public StageItem StageValue(string name, object value) { var list = value as IList; var count = list.Count; var listElement = new StageList(name); for (int i = 0; i < count; i++) { var item = SerializationMaster.Stage("Item", list[i]); listElement.Add(item); } return(listElement); }
internal static string Serialize(QualifierView qualifier) { var aiPart = new StageElement(ElementName.AIPart); var uiPart = new StageElement(ElementName.UIPart); var root = new StageElement(ElementName.QualifierSnippet, aiPart, uiPart); root.AddTextAttribute(AttributeName.SnippetType, ElementName.QualifierSnippet); var aiItem = SerializationMaster.Stage(ElementName.Qualifier, qualifier.qualifier); aiPart.Add(aiItem); var viewItem = WriteQualifierView(qualifier); uiPart.Add(viewItem); return(SerializationMaster.Serialize(root)); }
internal static string Serialize(ActionView action) { var aiPart = new StageElement(ElementName.AIPart); var uiPart = new StageElement(ElementName.UIPart); var root = new StageElement(ElementName.ActionSnippet, aiPart, uiPart); root.AddTextAttribute(AttributeName.SnippetType, ElementName.ActionSnippet); var aiItem = SerializationMaster.Stage(ElementName.Action, action.action); aiPart.Add(aiItem); var viewItem = WriteActionView(action); uiPart.Add(viewItem); return(SerializationMaster.Serialize(root)); }
/// <summary> /// Stages the value. /// </summary> /// <param name="name">The name to give the resulting <see cref="StageItem" />.</param> /// <param name="value">The value to stage</param> /// <returns> /// The element containing the staged value. /// </returns> public StageItem StageValue(string name, object value) { var dic = value as IDictionary; var count = dic.Count; var listElement = new StageList(name); foreach (var key in dic.Keys) { var item = new StageElement( string.Empty, SerializationMaster.Stage("key", key), SerializationMaster.Stage("value", dic[key])); listElement.Add(item); } return(listElement); }