/// <summary> /// Serializes a QueryRelated to an XML stream for StartRow and RelatedOids (LinkedTo). /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="queryRelated">QueryRelated.</param> /// <returns>XML stream with the QueryRelated.</returns> public static XmlWriter Serialize(XmlWriter writer, QueryRelated queryRelated) { #region Serialize <StartRow> if (queryRelated.Oid != null) { writer.WriteStartElement(DTD.Request.QueryRequest.QueryRelated.TagStartRow); XMLAdaptorOIDSerializer.Serialize(writer, queryRelated.Oid); writer.WriteEndElement(); } #endregion Serialize <StartRow> #region Serialize <LinkedTo> if (queryRelated.LinkedTo != null) { writer.WriteStartElement(DTD.Request.QueryRequest.QueryRelated.TagLinkedTo); foreach (string lRole in queryRelated.LinkedTo.Keys) { writer.WriteStartElement(DTD.Request.QueryRequest.QueryRelated.LinkedTo.TagLinkItem); writer.WriteAttributeString(DTD.Request.QueryRequest.QueryRelated.LinkedTo.TagRole, lRole); XMLAdaptorOIDSerializer.Serialize(writer, queryRelated.LinkedTo[lRole]); writer.WriteEndElement(); } writer.WriteEndElement(); } #endregion Serialize <LinkedTo> return(writer); }
/// <summary> /// Serializes an Agent to an XML stream. /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="agent">Agent.</param> /// <returns>XML stream with the agent.</returns> internal static XmlWriter Serialize(XmlWriter writer, Oids.Oid agent) { if (agent != null && agent.IsValid()) { writer.WriteStartElement(DTD.Request.TagAgent); XMLAdaptorOIDSerializer.Serialize(writer, agent); writer.WriteEndElement(); } return(writer); }
/// <summary> /// Serializes an ChangeDetectionItem to an XML file. /// </summary> /// <param name="writer">XMLWriter where the ChangeDetectionItem is stored.</param> /// <param name="ChangeDetectionItem">ChangeDetectionItem to serialize.</param> /// <returns>Returns the XMLWriter with the ChangeDetectionItem.</returns> public static XmlWriter Serialize(XmlWriter writer, ChangeDetectionItem item) { writer.WriteStartElement(DTD.Request.ServiceRequest.ChangeDetectionItems.TagChangeDetectionItem); writer.WriteAttributeString(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagName, item.Name); ModelType modelType = Convert.StringTypeToMODELType(item.Type); if (modelType == ModelType.Oid) { writer.WriteAttributeString(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagType, item.ClassName); } else { writer.WriteAttributeString(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagType, item.Type); } if (item.Value != null) { if (item.Value is Oids.AlternateKey) { XMLAlternateKeySerializer.Serialize(writer, (Oids.AlternateKey)item.Value); } else if (item.Value is Oids.Oid) { XMLAdaptorOIDSerializer.Serialize(writer, item.Value as Oids.Oid); } else // <Literal> { string lvalue = Convert.TypeToXml(item.Type, item.Value); //<-- Convert TypeToXML()!!!! if (lvalue.Length > 0) { string lvalueTrim = lvalue.Trim(); if (lvalueTrim.Length > 0) { writer.WriteStartElement(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagLiteral); writer.WriteValue(lvalue); writer.WriteEndElement(); } else // if is string White spaces it value is <NULL> { writer.WriteElementString(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagNull, string.Empty); } } else // Is <NULL> { writer.WriteElementString(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagNull, string.Empty); } } } else // Is <NULL> { writer.WriteElementString(DTD.Request.ServiceRequest.ChangeDetectionItems.ChangeDetectionItem.TagNull, string.Empty); } writer.WriteEndElement(); return(writer); }
/// <summary> /// Serializes a filter variable to an XML file. /// </summary> /// <param name="writer">XMLWriter where the argument is stored.</param> /// <param name="argument">Argument to serialize.</param> /// <returns>Returns the XMLWriter with the argument.</returns> public static XmlWriter Serialize(XmlWriter writer, Argument argument) { writer.WriteStartElement(DTD.Request.QueryRequest.QueryFilter.FilterVariables.TagFilterVariable); writer.WriteAttributeString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagName, argument.Name); ModelType modelType = Convert.StringTypeToMODELType(argument.Type); if (modelType == ModelType.Oid) { writer.WriteAttributeString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagType, argument.ClassName); } else { writer.WriteAttributeString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagType, argument.Type); } if (argument.Value == null) { writer.WriteElementString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagNull, string.Empty); } else { if (argument.Value is Oids.AlternateKey) { XMLAlternateKeySerializer.Serialize(writer, (Oids.AlternateKey)argument.Value); } else if (argument.Value is Oids.Oid) { XMLAdaptorOIDSerializer.Serialize(writer, argument.Value as Oids.Oid); } else // <Literal> { string lvalue = Convert.TypeToXml(argument.Type, argument.Value); //<-- Convert TypeToXML()!!!! if (lvalue.Length > 0) { // Check White spaces. string lvalueTrim = lvalue.Trim(); if (lvalueTrim.Length > 0) { writer.WriteStartElement(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagLiteral); writer.WriteValue(lvalue); writer.WriteEndElement(); } else // if is White spaces is <NULL> { writer.WriteElementString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagNull, string.Empty); } } else // Is <NULL> { writer.WriteElementString(DTD.Request.QueryRequest.QueryFilter.FilterVariables.FilterVariable.TagNull, string.Empty); } } } writer.WriteEndElement(); return(writer); }
public static XmlWriter Serialize(XmlWriter writer, ServiceResponse serviceResponse) { writer.WriteStartElement(DTD.Response.TagServiceResponse); writer.WriteElementString(DTD.Error.TagError, string.Empty); XMLAdaptorOIDSerializer.Serialize(writer, serviceResponse.Oid); XMLArgumentsSerializer.Serialize(writer, serviceResponse.Arguments); writer.WriteEndElement(); return(writer); }
/// <summary> /// Serializes QueryInstance to an XML stream. /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="queryInstance">QueryInstance.</param> /// <returns>XML stream with the QueryInstance.</returns> public static XmlWriter Serialize(XmlWriter writer, QueryInstance queryInstance) { writer.WriteStartElement(DTD.Request.QueryRequest.TagQueryInstance); if (queryInstance.Oid is Oids.AlternateKey) { XMLAlternateKeySerializer.Serialize(writer, queryInstance.GetAlternateKey()); } else { XMLAdaptorOIDSerializer.Serialize(writer, queryInstance.Oid); } writer.WriteEndElement(); return(writer); }
/// <summary> /// Serializes a navigational filtering argument info into an XML file. /// </summary> /// <param name="writer">XMLWriter where the argument is stored.</param> /// <param name="argument">Argument to serialize.</param> /// <returns>Returns the XMLWriter with the argument.</returns> public static XmlWriter Serialize(XmlWriter writer, ArgumentInfo argument) { writer.WriteStartElement(DTD.Request.ServiceRequest.Arguments.TagArgument); writer.WriteAttributeString(DTD.Request.ServiceRequest.Arguments.Argument.TagName, argument.Name); if (argument.Type == ModelType.Oid) { writer.WriteAttributeString(DTD.Request.ServiceRequest.Arguments.Argument.TagType, argument.ClassName); } else { writer.WriteAttributeString(DTD.Request.ServiceRequest.Arguments.Argument.TagType, Convert.MODELTypeToStringType(argument.Type)); } if (argument.Value != null) { if (argument.Value is Oids.AlternateKey) { XMLAlternateKeySerializer.Serialize(writer, (Oids.AlternateKey)argument.Value); } else if (argument.Value is Oids.Oid) { XMLAdaptorOIDSerializer.Serialize(writer, argument.Value as Oids.Oid); } else { string lvalue = Convert.TypeToXml(argument.Type, argument.Value); //<-- Convert TypeToXML()!!!! if (lvalue.Length > 0) { writer.WriteStartElement(DTD.Request.ServiceRequest.Arguments.Argument.TagLiteral); writer.WriteValue(lvalue); writer.WriteEndElement(); } else // Is <NULL> { writer.WriteElementString(DTD.Request.ServiceRequest.Arguments.Argument.TagNull, string.Empty); } } } else // Is <NULL> { writer.WriteElementString(DTD.Request.ServiceRequest.Arguments.Argument.TagNull, string.Empty); } writer.WriteEndElement(); return(writer); }
/// <summary> /// Serializes a NavigationalFiltering to an XML stream. /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="navigationalFiltering">NavigationalFiltering.</param> /// <returns>XML stream with the NavigationalFiltering.</returns> public static XmlWriter Serialize(XmlWriter writer, NavigationalFiltering navigationalFiltering) { #region <NavFilt> writer.WriteStartElement(DTD.Request.QueryRequest.TagNavFilt); if (navigationalFiltering.IsNavigationalArgument) { #region <NavFilt.Argument> writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltArgument); writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagClass, navigationalFiltering.Argument.ClassName); writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagService, navigationalFiltering.Argument.ServiceName); writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagArgument, navigationalFiltering.Argument.ArgumentName); #region <Arguments> XMLNavigationalFilteringArgumentsListSerializer.Serialize(writer, navigationalFiltering.Argument.Arguments); #endregion <Arguments> writer.WriteEndElement(); #endregion <NavFilt.Argument> } else if (navigationalFiltering.IsNavigationalFilterVariable) { #region <NavFilt.Variable> writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltVariable); writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagClass, navigationalFiltering.FilterVariable.ClassName); writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagFilter, navigationalFiltering.FilterVariable.FilterName); writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagVariable, navigationalFiltering.FilterVariable.ArgumentName); #region <Filter.Variables> XMLNavigationalFilteringVariablesListSerializer.Serialize(writer, navigationalFiltering.FilterVariable.Arguments); #endregion <Filter.Variables> writer.WriteEndElement(); #endregion <NavFilt.Variable> } else if (navigationalFiltering.IsNavigationalSelectObject) { #region <NavFilt.SelectedObject> writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltSelectedObject); #region <NavFilt.SelectedObject NavFilterID Attribute> if (navigationalFiltering.SelectedObject.NavigationalFilterID.Length > 0) { writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.TagNavFilterID, navigationalFiltering.SelectedObject.NavigationalFilterID); } #endregion <NavFilt.SelectedObject NavFilterID Attribute> #region OID XMLAdaptorOIDSerializer.Serialize(writer, navigationalFiltering.SelectedObject.SelectedObjectOID); #endregion OID writer.WriteEndElement(); #endregion <NavFilt.SelectedObject> } else if (navigationalFiltering.IsNavigationalServiceIU) { #region <NavFilt.ServiceIU> writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltServiceIU); #region <NavFilt.ServiceIU NavFilterID Attribute> if (navigationalFiltering.ServiceIU.NavigationalFilterID.Length > 0) { writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.TagNavFilterID, navigationalFiltering.ServiceIU.NavigationalFilterID); } #endregion <NavFilt.ServiceIU NavFilterID Attribute> #region <Arguments> XMLNavigationalFilteringArgumentsListSerializer.Serialize(writer, navigationalFiltering.ServiceIU.Arguments); #endregion <Arguments> writer.WriteEndElement(); #endregion <NavFilt.ServiceIU> } writer.WriteEndElement(); return(writer); #endregion <NavFilt> }