ciao.
innanzitutto mi scuso se è un post voluminoso.
Ho creato le classi a partire da uno schema .xsd con xsd.exe.
A questo punto le classi sono state create in due namespaces: ifc_org e IFCModel.
Ho due classi uos , come era nello schema.
questa è la classe IFCModel.uos
e questa è la ifc_org.uoscodice:[XmlRoot(ElementName="uos",Namespace=Declarations.SchemaVersion,IsNullable=false),Serializable] [XmlType(TypeName="uos",Namespace=Declarations.SchemaVersion)] [XmlInclude(typeof(IFCModel.IfcApprovalRelationship))] [XmlInclude(typeof(IFCModel.IfcDocumentInformation))] [XmlInclude(typeof(IFCModel.IfcRelaxation))] [XmlInclude(typeof(IFCModel.IfcDimensionalExponents))] [XmlInclude(typeof(IFCModel.IfcPresentationStyle))] [XmlInclude(typeof(IFCModel.IfcProfileDef))] [XmlInclude(typeof(IFCModel.IfcClassificationItem))] [XmlInclude(typeof(IFCModel.IfcBoundaryCondition))] [XmlInclude(typeof(IFCModel.IfcTable))] [XmlInclude(typeof(IFCModel.IfcPresentationLayerAssignment))] [XmlInclude(typeof(IFCModel.IfcClassificationItemRelationship))] [XmlInclude(typeof(IFCModel.IfcTextStyleForDefinedFont))] [XmlInclude(typeof(IFCModel.IfcPreDefinedItem))] [XmlInclude(typeof(IFCModel.IfcPropertyEnumeration))] [XmlInclude(typeof(IFCModel.IfcRepresentationMap))] [XmlInclude(typeof(IFCModel.IfcTextStyleWithBoxCharacteristics))] [XmlInclude(typeof(IFCModel.IfcTimeSeries))] [XmlInclude(typeof(IFCModel.IfcMaterialLayer))] [XmlInclude(typeof(IFCModel.IfcRepresentationContext))] [XmlInclude(typeof(IFCModel.IfcPhysicalQuantity))] [XmlInclude(typeof(IFCModel.IfcPropertyConstraintRelationship))] [XmlInclude(typeof(IFCModel.IfcOwnerHistory))] [XmlInclude(typeof(IFCModel.IfcTextureVertex))] [XmlInclude(typeof(IFCModel.IfcDerivedUnitElement))] [XmlInclude(typeof(IFCModel.IfcDocumentElectronicFormat))] [XmlInclude(typeof(IFCModel.IfcAddress))] [XmlInclude(typeof(IFCModel.IfcClassification))] [XmlInclude(typeof(IFCModel.IfcMonetaryUnit))] [XmlInclude(typeof(IFCModel.IfcMaterialLayerSet))] [XmlInclude(typeof(IFCModel.IfcLightDistributionData))] [XmlInclude(typeof(IFCModel.IfcClassificationNotationFacet))] [XmlInclude(typeof(IFCModel.IfcApprovalActorRelationship))] [XmlInclude(typeof(IFCModel.IfcObjectPlacement))] [XmlInclude(typeof(IFCModel.IfcConstraintAggregationRelationship))] [XmlInclude(typeof(IFCModel.IfcReinforcementBarProperties))] [XmlInclude(typeof(IFCModel.IfcAppliedValueRelationship))] [XmlInclude(typeof(IFCModel.IfcPropertyDependencyRelationship))] [XmlInclude(typeof(IFCModel.IfcSectionReinforcementProperties))] [XmlInclude(typeof(IFCModel.IfcProperty))] [XmlInclude(typeof(IFCModel.IfcSurfaceStyleShading))] [XmlInclude(typeof(IFCModel.IfcMaterialClassificationRelationship))] [XmlInclude(typeof(IFCModel.IfcCoordinatedUniversalTimeOffset))] [XmlInclude(typeof(IFCModel.IfcApprovalPropertyRelationship))] [XmlInclude(typeof(IFCModel.IfcConnectionGeometry))] [XmlInclude(typeof(IFCModel.IfcCurrencyRelationship))] [XmlInclude(typeof(IFCModel.IfcCurveStyleFontPattern))] [XmlInclude(typeof(IFCModel.IfcMaterialList))] [XmlInclude(typeof(IFCModel.IfcAppliedValue))] [XmlInclude(typeof(IFCModel.IfcRoot))] [XmlInclude(typeof(IFCModel.IfcApproval))] [XmlInclude(typeof(IFCModel.IfcUnitAssignment))] [XmlInclude(typeof(IFCModel.IfcIrregularTimeSeriesValue))] [XmlInclude(typeof(IFCModel.IfcDraughtingCalloutRelationship))] [XmlInclude(typeof(IFCModel.IfcTimeSeriesValue))] [XmlInclude(typeof(IFCModel.IfcStructuralConnectionCondition))] [XmlInclude(typeof(IFCModel.IfcClassificationNotation))] [XmlInclude(typeof(IFCModel.IfcSectionProperties))] [XmlInclude(typeof(IFCModel.IfcSurfaceTexture))] [XmlInclude(typeof(IFCModel.IfcOrganizationRelationship))] [XmlInclude(typeof(IFCModel.IfcLocalTime))] [XmlInclude(typeof(IFCModel.IfcLightIntensityDistribution))] [XmlInclude(typeof(IFCModel.IfcMeasureWithUnit))] [XmlInclude(typeof(IFCModel.IfcShapeAspect))] [XmlInclude(typeof(IFCModel.IfcTableRow))] [XmlInclude(typeof(IFCModel.IfcVirtualGridIntersection))] [XmlInclude(typeof(IFCModel.IfcTimeSeriesReferenceRelationship))] [XmlInclude(typeof(IFCModel.IfcColourSpecification))] [XmlInclude(typeof(IFCModel.IfcApplication))] [XmlInclude(typeof(IFCModel.IfcOrganization))] [XmlInclude(typeof(IFCModel.IfcReferencesValueDocument))] [XmlInclude(typeof(IFCModel.IfcTextStyleTextModel))] [XmlInclude(typeof(IFCModel.IfcCalendarDate))] [XmlInclude(typeof(IFCModel.IfcMaterialProperties))] [XmlInclude(typeof(IFCModel.IfcSurfaceStyleLighting))] [XmlInclude(typeof(IFCModel.IfcPersonAndOrganization))] [XmlInclude(typeof(IFCModel.IfcSurfaceStyleWithTextures))] [XmlInclude(typeof(IFCModel.IfcPerson))] [XmlInclude(typeof(IFCModel.IfcTextureCoordinate))] [XmlInclude(typeof(IFCModel.IfcCurveStyleFont))] [XmlInclude(typeof(IFCModel.IfcConstraintClassificationRelationship))] [XmlInclude(typeof(IFCModel.IfcConstraint))] [XmlInclude(typeof(IFCModel.IfcStructuralLoad))] [XmlInclude(typeof(IFCModel.IfcActorRole))] [XmlInclude(typeof(IFCModel.IfcCurveStyleFontAndScaling))] [XmlInclude(typeof(IFCModel.IfcDocumentInformationRelationship))] [XmlInclude(typeof(IFCModel.IfcPresentationStyleAssignment))] [XmlInclude(typeof(IFCModel.IfcProfileProperties))] [XmlInclude(typeof(IFCModel.IfcDerivedUnit))] [XmlInclude(typeof(IFCModel.IfcNamedUnit))] [XmlInclude(typeof(IFCModel.IfcRepresentationItem))] [XmlInclude(typeof(IFCModel.IfcSurfaceStyleRefraction))] [XmlInclude(typeof(IFCModel.IfcGridAxis))] [XmlInclude(typeof(IFCModel.IfcLibraryInformation))] [XmlInclude(typeof(IFCModel.IfcMaterialLayerSetUsage))] [XmlInclude(typeof(IFCModel.IfcConstraintRelationship))] [XmlInclude(typeof(IFCModel.IfcVertexBasedTextureMap))] [XmlInclude(typeof(IFCModel.IfcRepresentation))] [XmlInclude(typeof(IFCModel.IfcDateAndTime))] [XmlInclude(typeof(IFCModel.IfcMaterial))] [XmlInclude(typeof(IFCModel.IfcExternalReference))] [XmlInclude(typeof(IFCModel.IfcProductRepresentation))] public class uos : ifc_org.uos { [System.Runtime.InteropServices.DispIdAttribute(-4)] public IEnumerator GetEnumerator() { return EntityCollection.GetEnumerator(); } public ifc_org.Entity Add(ifc_org.Entity obj) { return EntityCollection.Add(obj); } [XmlIgnore] public ifc_org.Entity this[int index] { get { return (ifc_org.Entity) EntityCollection[index]; } } [XmlIgnore] public int Count { get { return EntityCollection.Count; } } public void Clear() { EntityCollection.Clear(); } public ifc_org.Entity Remove(int index) { ifc_org.Entity obj = EntityCollection[index]; EntityCollection.Remove(obj); return obj; } public void Remove(object obj) { EntityCollection.Remove(obj); } [XmlElement(Type=typeof(ifc_org.Entity),ElementName="Entity",IsNullable=false,Form=XmlSchemaForm.Qualified,Namespace="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common")] [EditorBrowsable(EditorBrowsableState.Advanced)] public EntityCollection __EntityCollection; [XmlIgnore] public EntityCollection EntityCollection { get { if (__EntityCollection == null) __EntityCollection = new EntityCollection(); return __EntityCollection; } set {__EntityCollection = value;} } public uos() : base() { } new public void MakeSchemaCompliant() { base.MakeSchemaCompliant(); foreach (ifc_org.Entity _c in EntityCollection) _c.MakeSchemaCompliant(); } new public static event DepthFirstTraversalDelegate DepthFirstTraversalEvent; new public void DepthFirstTraversal(object parent, object context) { if (DepthFirstTraversalEvent != null) DepthFirstTraversalEvent(this, parent, context); base.DepthFirstTraversal(parent, context); if (__EntityCollection != null) foreach (ifc_org.Entity _d in __EntityCollection) _d.DepthFirstTraversal(this, context); } }
adesso ho tentato di deserializzare cosi:codice:[XmlRoot(ElementName="uos",Namespace=Declarations.SchemaVersion,IsNullable=false),Serializable] [XmlType(TypeName="uos",Namespace=Declarations.SchemaVersion)] public class uos { [XmlAttribute(AttributeName="id",Form=XmlSchemaForm.Unqualified,DataType="ID",Namespace=Declarations.SchemaVersion)] [EditorBrowsable(EditorBrowsableState.Advanced)] public string __id; [XmlIgnore] public string id { get { return __id; } set { __id = value; } } [XmlAttribute(AttributeName="express",Form=XmlSchemaForm.Unqualified,Namespace=Declarations.SchemaVersion)] [EditorBrowsable(EditorBrowsableState.Advanced)] public string __express; [XmlIgnore] public string express { get { return __express; } set { __express = value; } } [XmlAttribute(AttributeName="configuration",Form=XmlSchemaForm.Unqualified,Namespace=Declarations.SchemaVersion)] [EditorBrowsable(EditorBrowsableState.Advanced)] public string __configuration; [XmlIgnore] public string configuration { get { return __configuration; } set { __configuration = value; } } [XmlAttribute(AttributeName="schemaLocation",Form=XmlSchemaForm.Unqualified,Namespace=Declarations.SchemaVersion)] [EditorBrowsable(EditorBrowsableState.Advanced)] public string __schemaLocation; [XmlIgnore] public string schemaLocation { get { return __schemaLocation; } set { __schemaLocation = value; } } [XmlAttribute(AttributeName="edo",Form=XmlSchemaForm.Unqualified,DataType="anyURI",Namespace=Declarations.SchemaVersion)] [EditorBrowsable(EditorBrowsableState.Advanced)] public string __edo; [XmlIgnore] public string edo { get { return __edo; } set { __edo = value; } } [XmlAttribute(AttributeName="description",Form=XmlSchemaForm.Unqualified,DataType="string",Namespace=Declarations.SchemaVersion)] [EditorBrowsable(EditorBrowsableState.Advanced)] public string __description; [XmlIgnore] public string description { get { return __description; } set { __description = value; } } public uos() { id = string.Empty; } public void MakeSchemaCompliant() { } public static event DepthFirstTraversalDelegate DepthFirstTraversalEvent; public void DepthFirstTraversal(object parent, object context) { if (DepthFirstTraversalEvent != null) DepthFirstTraversalEvent(this, parent, context); } }
ora, quando eseguo la deseralizzazione sulla rootcodice:XmlSerializer serializer = new XmlSerializer(typeof(ifc_org.iso_10303_28)); TextReader reader = new StreamReader("c:\\ifcdir\\new\\miniExample.xml"); ifc_org.iso_10303_28 root = (ifc_org.iso_10303_28)serializer.Deserialize(reader);
tutti gli elementi vengono letti correnttamente(nelle classi ifc_org), tranne quelli nella classe IFCModel.uos
anche se ho una oggetto IFCModel.uos nell'oggetto root ,ma tutti i suoi elementi sono vuoti ,è come
se la deserializzazione non li avesse toccati.
come posso debuggare il perchè di questa mancata deserializzazione?
grazie.

Rispondi quotando