Ejemplo n.º 1
0
        protected override void RequestLoad(DesignService service, DesignBuffer buffer)
        {
            var document = new DilxDocument();

            document.Read(buffer.LoadData());

            Ancestors ancestors;
            IHost     host;
            XDocument ancestor = null;

            if (document.Ancestors.Count >= 1)
            {
                ancestors = document.Ancestors;
                ancestor  = MergeAncestors(ancestors);
                var merge   = XDocument.Load(new StringReader(document.Content));
                var current = new XDocument();
                current.Add(new XElement(ancestor.Root));
                Inheritance.Merge(current, merge);
                host = HostFromDocumentData(current, GetDocumentExpression(buffer));
            }
            else
            {
                host      = HostFromDocumentData(document.Content, GetDocumentExpression(buffer));
                ancestors = null;
            }
            SetDesignHost(host, true);
            UpdateReadOnly(ancestor);
            _ancestors = ancestors;
        }
Ejemplo n.º 2
0
        public override void Open(IHost host)
        {
            CheckHostsDocument(host);
            DocumentDesignBuffer buffer = BufferFromHost(host);

            Service.ValidateBuffer(buffer);
            var document = new DilxDocument();

            document.Read(buffer.LoadData());
            XDocument mergedAncestors = MergeAncestors(document.Ancestors); // do this first in case of errors

            SetDesignHost(host, false);
            Service.SetBuffer(buffer);
            Service.SetModified(false);
            _ancestors = document.Ancestors;
            UpdateReadOnly(mergedAncestors);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext AContext)
        {
            AContext.Response.ContentType = FrontendUtility.CXmlContentType;

            // Read the DILX content
            DilxDocument LDocument = new DilxDocument();

            LDocument.Read(AContext.Request.InputStream);

            // Prepare ancestors
            XmlDocument LMergedAncestors = DilxUtility.MergeAncestors(null, LDocument.Ancestors, AContext);

            // Write DIL
            LMergedAncestors.Save(AContext.Response.OutputStream);

            AContext.Response.End();
        }
Ejemplo n.º 4
0
        public void Process(Stream ASource, Stream ATarget, HttpContext AContext)
        {
            DilxDocument LDocument = new DilxDocument();

            LDocument.Read(ASource);

            // Prepare ancestors
            XmlDocument LMergedAncestors = DilxUtility.MergeAncestors(null, LDocument.Ancestors, AContext);

            // Prepare current
            XmlDocument LCurrent = new XmlDocument();

            LCurrent.Load(LDocument.Content);

            //Perform the diff
            LDocument.Content.SetLength(0);
            Inheritance.Diff(LMergedAncestors, LCurrent).Save(LDocument.Content);
            LDocument.Write(ATarget);
        }
Ejemplo n.º 5
0
        public void Process(Stream ASource, Stream ATarget, HttpContext AContext)
        {
            // Read the document
            DilxDocument LDocument = new DilxDocument();

            LDocument.Read(ASource);

            // Process ancestors
            XmlDocument LCurrent = DilxUtility.MergeAncestors(null, LDocument.Ancestors, AContext);

            // Process content
            if (LCurrent == null)
            {
                StreamUtility.CopyStream(LDocument.Content, ATarget);
            }
            else
            {
                XmlDocument LMerge = new XmlDocument();
                LMerge.Load(LDocument.Content);
                LCurrent = Inheritance.Merge(LCurrent, LMerge);
                LCurrent.Save(ATarget);
            }
        }
Ejemplo n.º 6
0
        protected override void RequestSave(DesignService service, DesignBuffer buffer)
        {
            var document = new DilxDocument();

            if (_ancestors != null)
            {
                document.Ancestors = _ancestors;
            }

            var        content    = new XDocument();
            Serializer serializer = FrontendSession.CreateSerializer();

            serializer.Serialize(content, DesignHost.Children[0]);
            Dataphoria.Warnings.AppendErrors(this, serializer.Errors, true);

            if (_ancestors != null)
            {
                content = Inheritance.Diff(MergeAncestors(document.Ancestors), content);
            }
            document.Content = content.Root.ToString(); // only the document node

            buffer.SaveData(document.Write());
            UpdateHostsDocument(buffer);
        }