Esempio n. 1
0
        private static IPersistenceObject ImportElement(IZetboxContext ctx, Dictionary <Guid, IPersistenceObject> objects, IPackageProvider s)
        {
            Guid exportGuid = s.Reader.GetAttribute("ExportGuid").TryParseGuidValue();

            if (exportGuid != Guid.Empty)
            {
                string ifTypeName = string.Format("{0}.{1}", s.Reader.NamespaceURI, s.Reader.LocalName);
                ifTypeName = MigrateTypeNameMapping(ifTypeName);
                InterfaceType ifType = ctx.GetInterfaceType(ifTypeName);
                if (ifType.Type == null)
                {
                    Log.WarnOnce(string.Format("Type {0} not found", ifTypeName));
                    return(null);
                }

                IPersistenceObject obj = FindObject(ctx, objects, exportGuid, ifType);

                using (var children = s.Reader.ReadSubtree())
                {
                    while (children.Read())
                    {
                        if (children.NodeType == XmlNodeType.Element)
                        {
                            ((IExportableInternal)obj).MergeImport(s.Reader);
                        }
                    }
                }

                if (obj is Blob && s.SupportsBlobs)
                {
                    var blob = (Blob)obj;
                    using (var stream = s.GetBlob(blob.ExportGuid))
                    {
                        blob.StoragePath = ctx.Internals().StoreBlobStream(stream, blob.ExportGuid, blob.CreatedOn, blob.OriginalName);
                    }
                }

                return(obj);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        private static IPersistenceObject ImportElement(IZetboxContext ctx, Dictionary<Guid, IPersistenceObject> objects, IPackageProvider s)
        {
            Guid exportGuid = s.Reader.GetAttribute("ExportGuid").TryParseGuidValue();
            if (exportGuid != Guid.Empty)
            {
                string ifTypeName = string.Format("{0}.{1}", s.Reader.NamespaceURI, s.Reader.LocalName);
                ifTypeName = MigrateTypeNameMapping(ifTypeName);
                InterfaceType ifType = ctx.GetInterfaceType(ifTypeName);
                if (ifType.Type == null)
                {
                    Log.WarnOnce(string.Format("Type {0} not found", ifTypeName));
                    return null;
                }

                IPersistenceObject obj = FindObject(ctx, objects, exportGuid, ifType);

                using (var children = s.Reader.ReadSubtree())
                {
                    while (children.Read())
                    {
                        if (children.NodeType == XmlNodeType.Element)
                        {
                            ((IExportableInternal)obj).MergeImport(s.Reader);
                        }
                    }
                }

                if (obj is Blob && s.SupportsBlobs)
                {
                    var blob = (Blob)obj;
                    using (var stream = s.GetBlob(blob.ExportGuid))
                    {
                        blob.StoragePath = ctx.Internals().StoreBlobStream(stream, blob.ExportGuid, blob.CreatedOn, blob.OriginalName);
                    }
                }

                return obj;
            }
            else
            {
                return null;
            }
        }