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));
        }