예제 #1
0
 public void Write
 (
     System.Xml.XmlWriter xmlWriter,
     XCRI.Interfaces.XCRICAP11.IImage image
 )
 {
     if (image == null)
     {
         throw new ArgumentNullException("image");
     }
     if ((image.CompatibleWith & XCRIProfiles.XCRI_v1_1) == 0)
     {
         return;
     }
     this._WriteStartElement(xmlWriter, "image", Configuration.Namespaces.XCRICAP11NamespaceUri);
     this._WriteXsiTypeAttribute(xmlWriter, image.XsiTypeValue, image.XsiTypeValueNamespace);
     this._WriteXmlLanguageAttribute(xmlWriter, image.XmlLanguage);
     if (image.Source != null)
     {
         if (String.IsNullOrEmpty(xmlWriter.LookupPrefix(Configuration.Namespaces.XCRICAP11NamespaceUri)))
         {
             xmlWriter.WriteAttributeString("src", image.Source.ToString());
         }
         else
         {
             xmlWriter.WriteAttributeString("src", Configuration.Namespaces.XCRICAP11NamespaceUri, image.Source.ToString());
         }
     }
     if (String.IsNullOrEmpty(image.Title) == false)
     {
         if (String.IsNullOrEmpty(xmlWriter.LookupPrefix(Configuration.Namespaces.XCRICAP11NamespaceUri)))
         {
             xmlWriter.WriteAttributeString("title", image.Title);
         }
         else
         {
             xmlWriter.WriteAttributeString("title", Configuration.Namespaces.XCRICAP11NamespaceUri, image.Title);
         }
     }
     if (String.IsNullOrEmpty(image.Alt) == false)
     {
         if (String.IsNullOrEmpty(xmlWriter.LookupPrefix(Configuration.Namespaces.XCRICAP11NamespaceUri)))
         {
             xmlWriter.WriteAttributeString("alt", image.Alt);
         }
         else
         {
             xmlWriter.WriteAttributeString("alt", Configuration.Namespaces.XCRICAP11NamespaceUri, image.Alt);
         }
     }
     this._WriteEndElement(xmlWriter);
 }
예제 #2
0
 /// <summary>
 /// Salva os dados da instancia no escritor informado.
 /// </summary>
 /// <param name="writer"></param>
 protected override void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("xmlns", "i", null, Namespaces.SchemaInstance);
     writer.WriteStartElement("Conditionals", Namespaces.Query);
     foreach (ConditionalTerm i in _conditionals)
     {
         writer.WriteStartElement(i.QualifiedName.Name, i.QualifiedName.Namespace);
         var qname = i.QualifiedName;
         if (qname.Name != "ConditionalTerm")
         {
             var prefix = writer.LookupPrefix(qname.Namespace);
             if (string.IsNullOrEmpty(prefix))
             {
                 writer.WriteAttributeString("xmlns", qname.Namespace);
             }
         }
         ((System.Xml.Serialization.IXmlSerializable)i).WriteXml(writer);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     writer.WriteStartElement("LogicalOperators", Namespaces.Query);
     foreach (var i in _logicalOperators)
     {
         writer.WriteElementString("LogicalOperator", Namespaces.Query, i.ToString());
     }
     writer.WriteEndElement();
     writer.WriteStartElement("Parameters", Namespaces.Query);
     foreach (System.Xml.Serialization.IXmlSerializable i in this.ParameterContainer)
     {
         writer.WriteStartElement("QueryParameter", Namespaces.Query);
         i.WriteXml(writer);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
예제 #3
0
 public void Write
 (
     System.Xml.XmlWriter xmlWriter,
     ResourceStatus resourceStatus
 )
 {
     if (resourceStatus == ResourceStatus.Unknown)
     {
         return;
     }
     if (String.IsNullOrEmpty(xmlWriter.LookupPrefix(Configuration.Namespaces.XCRICAP11NamespaceUri)))
     {
         xmlWriter.WriteAttributeString
         (
             "recstatus",
             ((int)resourceStatus).ToString()
         );
     }
     else
     {
         xmlWriter.WriteAttributeString
         (
             "recstatus",
             Configuration.Namespaces.XCRICAP11NamespaceUri,
             ((int)resourceStatus).ToString()
         );
     }
 }
예제 #4
0
 public void Write
 (
     System.Xml.XmlWriter xmlWriter,
     XCRI.Interfaces.XCRICAP11.ICatalog catalog
 )
 {
     if (catalog == null)
     {
         throw new ArgumentNullException("catalog");
     }
     if ((catalog.CompatibleWith & XCRIProfiles.XCRI_v1_1) == 0)
     {
         return;
     }
     this._WriteStartElement(xmlWriter, "catalog", Configuration.Namespaces.XCRICAP11NamespaceUri);
     if (catalog.Generated.HasValue == false)
     {
         if (String.IsNullOrEmpty(xmlWriter.LookupPrefix(Configuration.Namespaces.XCRICAP11NamespaceUri)))
         {
             xmlWriter.WriteAttributeString("generated", (new DateTimeOffset(DateTime.Now)).ToISO8601(true));
         }
         else
         {
             xmlWriter.WriteAttributeString("generated", Configuration.Namespaces.XCRICAP11NamespaceUri, (new DateTimeOffset(DateTime.Now)).ToISO8601(true));
         }
     }
     else
     if (String.IsNullOrEmpty(xmlWriter.LookupPrefix(Configuration.Namespaces.XCRICAP11NamespaceUri)))
     {
         xmlWriter.WriteAttributeString("generated", catalog.Generated.Value.ToISO8601(true));
     }
     else
     {
         xmlWriter.WriteAttributeString("generated", Configuration.Namespaces.XCRICAP11NamespaceUri, catalog.Generated.Value.ToISO8601(true));
     }
     this.WriteXCRI11GenericItem(xmlWriter, (XCRI.Interfaces.XCRICAP11.IGeneric)catalog);
     foreach (XCRI.Interfaces.XCRICAP11.IProvider provider in catalog.Providers)
     {
         if (provider != null)
         {
             this.Write(xmlWriter, provider);
         }
     }
     this._WriteEndElement(xmlWriter);
 }
예제 #5
0
        /// <summary>
        /// Insere o tipo do termo condicional
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="term"></param>
        internal protected static void InsertConditionalTermType(System.Xml.XmlWriter writer, ConditionalTerm term)
        {
            var qname  = term.QualifiedName;
            var prefix = writer.LookupPrefix(qname.Namespace);

            if (string.IsNullOrEmpty(prefix))
            {
                writer.WriteAttributeString("xmlns", qname.Namespace);
            }
            writer.WriteAttributeString("type", Namespaces.SchemaInstance, string.Format("{0}{1}{2}", prefix, string.IsNullOrEmpty(prefix) ? "" : ":", qname.Name));
        }
예제 #6
0
        string Lookup(string parameter)
        {
            var lookup = _writer.LookupPrefix(parameter ?? string.Empty);

            if (parameter != null && lookup == string.Empty && !ContainsKey(string.Empty))
            {
                Add(string.Empty, parameter);
            }

            var result = parameter == this.Get(string.Empty) ? string.Empty : lookup;

            return(result);
        }
예제 #7
0
 protected virtual void _WriteAttribute
 (
     System.Xml.XmlWriter xmlWriter,
     string attributeName,
     string attributeNamespace,
     string attributeValue,
     string attributeValueNamespace
 )
 {
     if (String.IsNullOrEmpty(attributeValue))
     {
         return;
     }
     if (attributeName.Contains(":"))
     {
         xmlWriter.WriteStartAttribute
         (
             attributeName.Substring(0, attributeName.IndexOf(":")),
             attributeName.Substring(attributeName.IndexOf(":") + 1),
             String.Empty
         );
     }
     else
     {
         xmlWriter.WriteStartAttribute
         (
             attributeName,
             attributeNamespace
         );
     }
     if (String.IsNullOrEmpty(attributeValueNamespace))
     {
         xmlWriter.WriteString(attributeValue);
     }
     else
     {
         xmlWriter.WriteString(String.Format
                               (
                                   "{0}:{1}",
                                   xmlWriter.LookupPrefix(attributeValueNamespace),
                                   attributeValue
                               ));
     }
     xmlWriter.WriteEndAttribute();
 }
예제 #8
0
 /// <summary>
 /// Serializa os dados no XML.
 /// </summary>
 /// <param name="writer"></param>
 protected override void WriteXml(System.Xml.XmlWriter writer)
 {
     foreach (ConditionalTerm i in _values.Where(f => f != null))
     {
         writer.WriteStartElement(i.QualifiedName.Name, i.QualifiedName.Namespace);
         var qname = i.QualifiedName;
         if (qname.Name != "ConditionalTerm")
         {
             var prefix = writer.LookupPrefix(qname.Namespace);
             if (string.IsNullOrEmpty(prefix))
             {
                 writer.WriteAttributeString("xmlns", qname.Namespace);
             }
         }
         ((System.Xml.Serialization.IXmlSerializable)i).WriteXml(writer);
         writer.WriteEndElement();
     }
 }