示例#1
0
 /// <summary>
 /// Serializes an AlternateKey object to an XML stream.
 /// </summary>
 /// <param name="writer">XML stream to write.</param>
 /// <param name="alternateKey">AlternateKey object.</param>
 /// <returns>XML stream with the AlternateKey object.</returns>
 public static XmlWriter Serialize(XmlWriter writer, Oids.Oid alternateKey)
 {
     writer.WriteStartElement(DTD.TagAlternateKey);
     writer.WriteAttributeString(DTD.AlternateKey.TagName, alternateKey.ClassName);
     // Process element childs.
     foreach (KeyValuePair <ModelType, object> i in alternateKey.GetFields())
     {
         writer.WriteStartElement(DTD.AlternateKey.TagAlternateKeyField);
         writer.WriteAttributeString(DTD.AlternateKey.TagType, Convert.MODELTypeToStringType(i.Key));
         // Set value for this node.
         try
         {
             writer.WriteString(Convert.TypeToXml(i.Key, i.Value));
         }
         catch (Exception ex)
         {
             StringBuilder lMessage = new StringBuilder("Fail Alternate Key Serialize [");
             lMessage.Append(alternateKey.ClassName);
             lMessage.Append(" - ");
             lMessage.Append(alternateKey.AlternateKeyName);
             lMessage.Append(']');
             throw new ApplicationException(lMessage.ToString(), ex);
         }
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     return(writer);
 }
示例#2
0
 /// <summary>
 /// Serializes an Oid object to an XML stream.
 /// </summary>
 /// <param name="writer">XML stream to write.</param>
 /// <param name="oid">Oid.</param>
 /// <returns>XML stream with the Oid object.</returns>
 public static XmlWriter Serialize(XmlWriter writer, Oids.Oid oid)
 {
     writer.WriteStartElement(DTD.TagOID);
     writer.WriteAttributeString(DTD.OID.TagClass, oid.ClassName);
     foreach (KeyValuePair <ModelType, object> i in oid.GetFields())
     {
         writer.WriteStartElement(DTD.OID.TagOIDField);
         writer.WriteAttributeString(DTD.OID.TagType, Convert.MODELTypeToStringType(i.Key));
         try
         {
             writer.WriteString(Convert.TypeToXml(i.Key, i.Value));
         }
         catch (Exception ex)
         {
             StringBuilder lMessage = new StringBuilder("Fail OID Serialize [");
             lMessage.Append(oid.ClassName);
             lMessage.Append(']');
             throw new ApplicationException(lMessage.ToString(), ex);
         }
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     return(writer);
 }