ExportQto() public static method

public static ExportQto ( DocQuantitySet docPset ) : IfcDoc.Schema.PSD.QtoSetDef
docPset DocQuantitySet
return IfcDoc.Schema.PSD.QtoSetDef
Exemplo n.º 1
0
        public void Save()
        {
            // build map of enumerations
            Dictionary <string, DocPropertyEnumeration> mapPropEnum = new Dictionary <string, DocPropertyEnumeration>();

            foreach (DocPropertyEnumeration docEnum in this.m_project.PropertyEnumerations)
            {
                if (!mapPropEnum.ContainsKey(docEnum.Name))
                {
                    mapPropEnum.Add(docEnum.Name, docEnum);
                }
            }

            using (Package zip = ZipPackage.Open(this.m_stream, FileMode.Create))
            {
                foreach (DocSection docSection in this.m_project.Sections)
                {
                    foreach (DocSchema docSchema in docSection.Schemas)
                    {
                        if (this.m_type == null || this.m_type == typeof(DocPropertySet))
                        {
                            foreach (DocPropertySet docPset in docSchema.PropertySets)
                            {
                                if (m_included == null || this.m_included.ContainsKey(docPset))
                                {
                                    if (docPset.IsVisible())
                                    {
                                        Uri         uri  = PackUriHelper.CreatePartUri(new Uri(docPset.Name + ".xml", UriKind.Relative));
                                        PackagePart part = zip.CreatePart(uri, "", CompressionOption.Normal);
                                        using (Stream refstream = part.GetStream())
                                        {
                                            refstream.SetLength(0);
                                            PropertySetDef psd = Program.ExportPsd(docPset, mapPropEnum, this.m_project);
                                            using (FormatXML format = new FormatXML(refstream, typeof(PropertySetDef), PropertySetDef.DefaultNamespace, null))
                                            {
                                                format.Instance = psd;
                                                format.Save();
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (this.m_type == null || this.m_type == typeof(DocQuantitySet))
                        {
                            foreach (DocQuantitySet docQset in docSchema.QuantitySets)
                            {
                                if (m_included == null || this.m_included.ContainsKey(docQset))
                                {
                                    Uri         uri  = PackUriHelper.CreatePartUri(new Uri(docQset.Name + ".xml", UriKind.Relative));
                                    PackagePart part = zip.CreatePart(uri, "", CompressionOption.Normal);
                                    using (Stream refstream = part.GetStream())
                                    {
                                        refstream.SetLength(0);
                                        QtoSetDef psd = Program.ExportQto(docQset, this.m_project);
                                        using (FormatXML format = new FormatXML(refstream, typeof(QtoSetDef), PropertySetDef.DefaultNamespace, null))
                                        {
                                            format.Instance = psd;
                                            format.Save();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }