Exemplo n.º 1
0
        public void ToAml(XmlWriter writer, AmlWriterSettings settings)
        {
            var ex = _content as ServerException;

            if (ex != null)
            {
                ex.ToAml(writer, settings);
            }
            else
            {
                writer.WriteStartElement("SOAP-ENV", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
                writer.WriteStartElement("SOAP-ENV", "Body", "http://schemas.xmlsoap.org/soap/envelope/");
                writer.WriteStartElement("Result");
                var items = _content as IEnumerable <IReadOnlyItem>;
                if (items != null)
                {
                    foreach (var item in items)
                    {
                        item.ToAml(writer, settings);
                    }
                }
                else if (_content != null)
                {
                    writer.WriteString(_amlContext.LocalizationContext.Format(_content));
                }
                writer.WriteEndElement();
                if (_message.Exists)
                {
                    _message.ToAml(writer, settings);
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }
Exemplo n.º 2
0
 public void ToAml(XmlWriter writer, AmlWriterSettings settings)
 {
     writer.WriteStartElement(_name);
     foreach (var child in _children)
     {
         child.ToAml(writer, settings);
     }
     writer.WriteEndElement();
 }
Exemplo n.º 3
0
 public void ToAml(XmlWriter writer, AmlWriterSettings settings)
 {
     writer.WriteStartElement("id");
     foreach (var attr in Attributes())
     {
         writer.WriteAttributeString(attr.Name, attr.Value);
     }
     writer.WriteString(this.Value);
     writer.WriteEndElement();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Write the node to the specified <see cref="XmlWriter" /> as AML
 /// </summary>
 /// <param name="writer"><see cref="XmlWriter" /> to write the node to</param>
 /// <param name="settings">Settings controlling how the node is written</param>
 public void ToAml(XmlWriter writer, AmlWriterSettings settings)
 {
     writer.WriteStartElement("SOAP-ENV", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
     writer.WriteStartElement("SOAP-ENV", "Body", "http://schemas.xmlsoap.org/soap/envelope/");
     writer.WriteStartElement("SOAP-ENV", "Fault", "http://schemas.xmlsoap.org/soap/envelope/");
     writer.WriteAttributeString("xmlns", "af", null, "http://www.aras.com/InnovatorFault");
     foreach (var elem in _fault.Elements())
     {
         elem.ToAml(writer, settings);
     }
     writer.WriteEndElement();
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Write the node to the specified <see cref="XmlWriter"/>
        /// </summary>
        /// <param name="writer"><see cref="XmlWriter"/> to write the node to</param>
        /// <param name="settings">Settings controlling how the node is written</param>
        public void ToAml(XmlWriter writer, AmlWriterSettings settings)
        {
            var name  = this.Name;
            var i     = name.IndexOf(':');
            var attrs = LinkedListOps.Enumerate(_lastAttr).OfType <IReadOnlyAttribute>().ToArray();

            if (attrs.Any(a => a.Name == "xml:lang" && a.Value != AmlContext.LocalizationContext.LanguageCode))
            {
                writer.WriteStartElement("i18n", name, "http://www.aras.com/I18N");
            }
            else if (i > 0)
            {
                var prefix = name.Substring(0, i);
                name = name.Substring(i + 1);
                var ns = "";
                switch (prefix)
                {
                case "SOAP-ENV":
                    ns = "http://schemas.xmlsoap.org/soap/envelope/";
                    break;

                case "af":
                    ns = "http://www.aras.com/InnovatorFault";
                    break;

                default:
                    throw new NotSupportedException();
                }
                writer.WriteStartElement(prefix, name, ns);
            }
            else
            {
                writer.WriteStartElement(name);
            }

            foreach (var attr in attrs)
            {
                i = attr.Name.IndexOf(':');
                if (i > 0)
                {
                    var prefix = attr.Name.Substring(0, i);
                    if (prefix == "xmlns")
                    {
                        continue;
                    }
                    name = attr.Name.Substring(i + 1);
                    var ns = "";
                    switch (prefix)
                    {
                    case "xml":
                        ns = "http://www.w3.org/XML/1998/namespace";
                        break;

                    default:
                        throw new NotSupportedException();
                    }
                    writer.WriteAttributeString(prefix, name, ns, attr.Value);
                }
                else
                {
                    writer.WriteAttributeString(attr.Name, attr.Value);
                }
            }
            var elem = _content as ILinkedElement;

            if (elem == null)
            {
                if (PreferCData)
                {
                    writer.WriteCData(this.Value);
                }
                else
                {
                    writer.WriteString(this.Value);
                }
            }
            else
            {
                var elems = Elements().ToArray();
                var item  = elems.OfType <IReadOnlyItem>().FirstOrDefault();
                if (this is IReadOnlyProperty &&
                    !settings.ExpandPropertyItems &&
                    item != null &&
                    !item.Attribute("action").Exists)
                {
                    writer.WriteAttributeString("type", item.TypeName());
                    var keyedName = item.KeyedName().Value ?? item.Property("id").KeyedName().Value;
                    if (!string.IsNullOrEmpty(keyedName))
                    {
                        writer.WriteAttributeString("keyed_name", keyedName);
                    }
                    writer.WriteString(item.Id());
                }
                else
                {
                    foreach (var e in elems)
                    {
                        e.ToAml(writer, settings);
                    }
                }
            }
            writer.WriteEndElement();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Write the node to the specified <see cref="XmlWriter"/>
        /// </summary>
        /// <param name="writer"><see cref="XmlWriter"/> to write the node to</param>
        /// <param name="settings">Settings controlling how the node is written</param>
        public void ToAml(XmlWriter writer, AmlWriterSettings settings)
        {
            var name   = Name;
            var prefix = Prefix;
            var i      = name.IndexOf(':');
            var attrs  = LinkedListOps.Enumerate(_lastAttr).OfType <IReadOnlyAttribute>().ToArray();

            if (string.IsNullOrEmpty(prefix) && i > 0)
            {
                prefix = name.Substring(0, i);
                name   = name.Substring(i + 1);
            }
            if (string.IsNullOrEmpty(prefix))
            {
                writer.WriteStartElement(name);
            }
            else
            {
                var ns = AmlReader.NamespaceFromPrefix(prefix);
                writer.WriteStartElement(prefix, name, ns);
            }

            foreach (var attr in attrs)
            {
                i = attr.Name.IndexOf(':');
                if (i > 0)
                {
                    var attributePrefix = attr.Name.Substring(0, i);
                    if (attributePrefix == "xmlns")
                    {
                        continue;
                    }
                    name = attr.Name.Substring(i + 1);
                    var ns = AmlReader.NamespaceFromPrefix(attributePrefix);
                    writer.WriteAttributeString(attributePrefix, name, ns, attr.Value);
                }
                else
                {
                    writer.WriteAttributeString(attr.Name, attr.Value);
                }
            }
            if (!(_content is ILinkedElement))
            {
                if (PreferCData)
                {
                    writer.WriteCData(this.Value);
                }
                else
                {
                    writer.WriteString(this.Value);
                }
            }
            else
            {
                var elems = Elements().ToArray();
                var item  = elems.OfType <IReadOnlyItem>().FirstOrDefault();
                if (this is IReadOnlyProperty &&
                    !settings.ExpandPropertyItems &&
                    item?.Attribute("action").Exists == false)
                {
                    writer.WriteAttributeString("type", item.TypeName());
                    var keyedName = item.KeyedName().Value ?? item.Property("id").KeyedName().Value;
                    if (!string.IsNullOrEmpty(keyedName))
                    {
                        writer.WriteAttributeString("keyed_name", keyedName);
                    }
                    writer.WriteString(item.Id());
                }
                else
                {
                    foreach (var e in elems)
                    {
                        e.ToAml(writer, settings);
                    }
                }
            }
            writer.WriteEndElement();
        }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public void ToAml(XmlWriter writer, AmlWriterSettings settings)
 {
     _item.ToAml(writer, settings);
 }