Example #1
0
        /// <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);
        }
 /// <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);
        }