WriteAttributeString() публичный Метод

public WriteAttributeString ( string localName, string value ) : void
localName string
value string
Результат void
Пример #1
1
 public static void writeVertex(XmlWriter writer, Vector2D vert)
 {
     writer.WriteStartElement("vertex");
     writer.WriteAttributeString("x", vert.x.ToString());
     writer.WriteAttributeString("y", vert.y.ToString());
     writer.WriteEndElement();
 }
Пример #2
1
 // Methods
 internal virtual void WriteTo( XmlWriter xmlWriter )
 {
     xmlWriter.WriteStartElement( XmlDiff.Prefix, "descriptor", XmlDiff.NamespaceUri );
     xmlWriter.WriteAttributeString( "opid", _operationID.ToString() );
     xmlWriter.WriteAttributeString( "type", Type );
     xmlWriter.WriteEndElement();
 }
Пример #3
0
        public override void GenerateXmlAttributes(XmlWriter writer) {
            base.GenerateXmlAttributes(writer);

            if(Label.IsNotWhiteSpace())
                writer.WriteAttributeString("label", Label);
            if(Align.HasValue)
                writer.WriteAttributeString("Align", Align.ToString());
            if(VAlign.HasValue)
                writer.WriteAttributeString("VAlign", VAlign.ToString());

            if(_fontAttr != null)
                _fontAttr.GenerateXmlAttributes(writer);

            if(LetterSpacing.HasValue)
                writer.WriteAttributeString("LetterSpacing", LetterSpacing.ToString());
            if(LeftMargin.HasValue)
                writer.WriteAttributeString("LeftMargin", LeftMargin.ToString());
            if(BgColor.HasValue)
                writer.WriteAttributeString("BgColor", BgColor.Value.ToHexString());
            if(BorderColor.HasValue)
                writer.WriteAttributeString("BorderColor", BorderColor.Value.ToHexString());
            if(Wrap.HasValue)
                writer.WriteAttributeString("Wrap", Wrap.GetHashCode().ToString());
            if(WrapWidth.HasValue)
                writer.WriteAttributeString("WrapWidth", WrapWidth.ToString());
            if(WrapHeight.HasValue)
                writer.WriteAttributeString("WrapHeight", WrapHeight.ToString());
        }
Пример #4
0
        /// <summary>
        /// Add authors.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        private static void AddAuthors(XmlWriter writer)
        {
            writer.WriteStartElement("authors");

            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                writer.WriteStartElement("author");

                writer.WriteAttributeString("id", user.UserName);
                writer.WriteAttributeString(
                    "date-created", user.CreationDate.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
                writer.WriteAttributeString(
                    "date-modified", user.CreationDate.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
                writer.WriteAttributeString("approved", "true");
                writer.WriteAttributeString("email", user.Email);

                writer.WriteStartElement("title");
                writer.WriteAttributeString("type", "text");
                writer.WriteCData(user.UserName);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Пример #5
0
        public void Generate(XmlWriter writer)
        {
            writer.WriteStartElement(@"category");
            writer.WriteAttributeString(@"name", this.Name);

            if (this.InstanceString != null)
                writer.WriteAttributeString(@"instance", this.InstanceString);

            if (this.PublishTimeString != null)
                writer.WriteAttributeString(@"publishTime", this.PublishTimeString);

            if (this.ContainerString != null)
                writer.WriteAttributeString(@"container", this.ContainerString);

            if (this.VersionString != null)
                writer.WriteAttributeString(@"version", this.VersionString);

            if (this.ExpireTypeString != null)
                writer.WriteAttributeString(@"expireType", this.ExpireTypeString);

            //if (this.EndpointId != null)
            //    writer.WriteAttributeString(@"endpointId", this.EndpointId);

            if (this.ExpiresString != null)
                writer.WriteAttributeString(@"expires", this.ExpiresString);

            if (value != null)
                value.Generate(writer);

            writer.WriteEndElement();
        }
Пример #6
0
        public void WriteResponseMessage ( XmlWriter writer, string innerXml, NuxleusAsyncResult asyncResult ) {

            using (writer) {
                writer.WriteStartDocument();
                if (m_responseType == ResponseType.REDIRECT) {
                    writer.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='/service/transform/openid-redirect.xsl'");
                }
                writer.WriteStartElement("auth");
                writer.WriteAttributeString("xml:base", "http://dev.amp.fm/");
                writer.WriteAttributeString("status", m_status);
                if (m_responseType == ResponseType.REDIRECT) {
                    writer.WriteElementString("url", "http://dev.amp.fm/");
                }
                if (m_responseType == ResponseType.QUERY_RESPONSE && innerXml != null) {
                    writer.WriteStartElement("response");
                    writer.WriteRaw(innerXml);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            asyncResult.CompleteCall();

        }
        public void Write(IEffectPartInfo info, XmlWriter writer)
        {
            var weapon = (WeaponEffectPartInfo)info;

            writer.WriteStartElement("Weapon");

            switch (weapon.Action)
            {
                case WeaponAction.Shoot:
                case WeaponAction.RotateForward:
                case WeaponAction.RotateBackward:
                    writer.WriteValue(weapon.Action.ToString());
                    break;

                case WeaponAction.Ammo:
                    writer.WriteAttributeString("val", weapon.Ammo.ToString());
                    break;

                case WeaponAction.Change:
                    writer.WriteAttributeString("name", weapon.ChangeName);
                    break;
            }

            writer.WriteEndElement();
        }
Пример #8
0
 void WriteAttributes(XmlWriter writer)
 {
     writer.WriteAttributeString("Name", Name);
     writer.WriteAttributeString("Description", Description);
     writer.WriteAttributeString("Triggered", XmlConvert.ToString(Triggered));
     writer.WriteAttributeString("Rating", Rating);
 }
        public static void WriteXml(XmlWriter writer, string key, Property value)
        {
            writer.WriteStartElement("PropertyEntry");

            writer.WriteAttributeString("Key", key);

            var type = value.GetType();
            try
            {
                var ser = GetSerializer(type);
                writer.WriteAttributeString("Type", type.AssemblyQualifiedName);
                ser.Serialize(writer, value);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Serialization failed: " + ex.Message);
                Console.WriteLine("Property Key: " + key);
                Console.WriteLine("Property Value: " + value);
                Console.WriteLine("Property Type Name: " + type.Name);
                Console.WriteLine("Property Type Qualified Name: " + type.AssemblyQualifiedName);
                Console.WriteLine("Stacktrace: " + ex.StackTrace);
            }

            writer.WriteEndElement();
        }
		protected override void WriteValue(XmlWriter writer, object value)
		{
			IDictionary dictionary = (IDictionary) value;
			foreach (object key in dictionary.Keys)
			{
				object target = dictionary[key];

				// any way to refactor code block?
				ReflectorTypeAttribute typeAttribute = ReflectorTypeAttribute.GetAttribute(target);
				if (typeAttribute == null)
				{
					writer.WriteStartElement(elementName);
					writer.WriteAttributeString(attribute.Key, key.ToString());
					writer.WriteString(target.ToString());
					writer.WriteEndElement();
				}
				else
				{
					writer.WriteStartElement(typeAttribute.Name);
					writer.WriteAttributeString(attribute.Key, key.ToString());

					XmlTypeSerialiser serialiser = (XmlTypeSerialiser) typeAttribute.CreateSerialiser(target.GetType());
					serialiser.WriteMembers(writer, target);

					writer.WriteEndElement();
				}
			}
		}
Пример #11
0
        // Originally this class used the XML attributes to serialize itself
        // via an XmlSerializer, but that turns out not the work (see the comments
        // in EventWriter). So instead we have localized all the XML related code
        // in this one method. It turns out to be simpler to understand, too.
        public void ToXml(XmlWriter writer)
        {
            Contract.Requires(writer != null);

            writer.WriteStartElement("event");
            if (Stanza != null) writer.WriteAttributeString("stanza", Stanza);
            if (Unbroken) writer.WriteAttributeString("unbroken", "1");

            if (Data != null) WriteTextElement(writer, "data", Data);
            if (Source != null) WriteTextElement(writer, "source", Source);
            if (SourceType != null) WriteTextElement(writer, "sourcetype", SourceType);
            if (Index != null) WriteTextElement(writer, "index", Index);
            if (Host != null) WriteTextElement(writer, "host", Host);

            if (Time.HasValue)
            {
                double timestamp = (double)(Time.Value.Ticks - ticksSinceEpoch) / TimeSpan.TicksPerSecond;
                writer.WriteStartElement("time");
                writer.WriteString(timestamp.ToString());
                writer.WriteEndElement();
            }

            if (Done)
            {
                writer.WriteStartElement("done");
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Пример #12
0
		void WriteTo (XmlWriter writer)
		{
			writer.WriteStartElement (Node);
			if (NodeName != null)
				writer.WriteAttributeString (nameAttribute, NodeName);
			if (Expanded)
				writer.WriteAttributeString (expandedAttribute, bool.TrueString);
			if (Selected)
				writer.WriteAttributeString (selectedAttribute, bool.TrueString);

			if (Options != null) {
				foreach (var opt in Options) {
					writer.WriteStartElement ("Option");
					writer.WriteAttributeString ("id", opt.Key.ToString());
					writer.WriteAttributeString ("value", opt.Value.ToString ());
					writer.WriteEndElement (); // Option
				}
			}
			
			if (ChildrenState != null) { 
				foreach (NodeState ces in ChildrenState) {
					ces.WriteTo (writer);
				}
			}
			
			writer.WriteEndElement (); // NodeState
		}
        public static void WriteMapping(XmlWriter writer, ISymbolMapping mapping)
        {
            writer.WriteStartElement(mapping.GetType().Name);
            writer.WriteAttributeString("Name", mapping.Name);

            var replaceMapping = mapping as ReplaceMapping;
            if (replaceMapping != null)
            {
                foreach (var replacement in replaceMapping.Replacements.OrderBy(kv => kv.Key))
                {
                    writer.WriteStartElement("Replacement");
                    writer.WriteAttributeString("Replace", replacement.Key);
                    writer.WriteAttributeString("With", replacement.Value);
                    writer.WriteEndElement();
                }
                var scriptedMapping = replaceMapping as ScriptedMapping;
                if (scriptedMapping != null)
                {
                    writer.WriteStartElement("ScriptBody");
                    writer.WriteString(scriptedMapping.ScriptBody);
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
        }
Пример #14
0
		internal override void WriteXml(XmlWriter writer)
		{
			if (base.IsSlot)
			{
                writer.WriteStartElement("Property", NodeQuery.XmlNamespace);
				writer.WriteAttributeString("name", base.PropertySlot.Name);
				writer.WriteEndElement();
			}
			else if (!IsValue)
			{
                writer.WriteStartElement("Property", NodeQuery.XmlNamespace);
				writer.WriteAttributeString("name", base.NodeAttribute.ToString());
				writer.WriteEndElement();
			}
			else
			{
				if (_value == null)
                    writer.WriteElementString("NullValue", NodeQuery.XmlNamespace, null);
				else if (_value is string)
					writer.WriteString((string)_value);
				else if (_value is int)
					writer.WriteString(XmlConvert.ToString((int)_value));
				else if (_value is decimal)
					writer.WriteString(XmlConvert.ToString((decimal)_value));
				if (_value is DateTime)
					writer.WriteString(XmlConvert.ToString((DateTime)_value, XmlDateTimeSerializationMode.Unspecified));
			}

		}
Пример #15
0
 public void Serialize(XmlWriter xml)
 {
     xml.WriteStartElement("T-Results");
     xml.WriteAttributeString("ID", results.AnalysisID.ToString());
     xml.WriteAttributeString("Finished", results.Finished.ToString());
     if (results != null && results.AnalysisID > 0 && results.Finished)
     {
         writeResultCases(xml);
         writeJointDisplacements(xml);
         writeJointReactions(xml);
         writeJointVelocities(xml);
         writeJointAccelerations(xml);
         writeJointMasses(xml);
         writeElementJointForces(xml);
         writeBaseReactions(xml);
         writeModalPeriods(xml);
         writeModalLoadParticipation(xml);
         writeModalParticipationMass(xml);
         writeModalParticipationFactors(xml);
         writeResponseSpectrumModalInfo(xml);
         writeDesignSteelSummary(xml);
         writeDesignSteelPMM(xml);
         writeDesignSteelShear(xml);
         writeDesignConcreteColumn(xml);
         writeDesignConcreteBeam(xml);
     }
     xml.WriteEndElement();
 }
Пример #16
0
 private static void WriteSummary(XmlWriter writer, string date, string sum)
 {
     writer.WriteStartElement("summary");
     writer.WriteAttributeString("date", date);
     writer.WriteAttributeString("total-sum", sum);
     writer.WriteEndElement();
 }
Пример #17
0
		private static void WriteShapes(XmlWriter writer, GraphAbstract g)
		{
			writer.WriteStartElement("g");
			for(int k=0; k<g.Shapes.Count; k++) //<rect x="1140" y="30" width="100" height="20" style="fill: url(#two_hues); stroke: black;"/>
			{
				writer.WriteStartElement("rect");
				writer.WriteAttributeString("x", g.Shapes[k].X.ToString());
				writer.WriteAttributeString("y", g.Shapes[k].Y.ToString());
				writer.WriteAttributeString("width", g.Shapes[k].Width.ToString());
				writer.WriteAttributeString("height", g.Shapes[k].Height.ToString());
				writer.WriteAttributeString("rx", "2");//rounded rectangle				

				//writer.WriteAttributeString("style", "fill: url(#two_hues); stroke: black;");
				writer.WriteAttributeString("fill",  string.Concat("#", (g.Shapes[k].ShapeColor.ToArgb() & 0x00FFFFFF).ToString("X6")) );
				writer.WriteEndElement();
				
				//<text text-anchor="middle" x="{$x+50}" y="{$y+15}">
				writer.WriteStartElement("text");
				writer.WriteAttributeString("x", Convert.ToString(g.Shapes[k].X + 10));
				writer.WriteAttributeString("y", Convert.ToString(g.Shapes[k].Y + 15));
				writer.WriteAttributeString("text-anchor", "start");			
				writer.WriteAttributeString("font-size", "9");
				writer.WriteString(g.Shapes[k].Text);
				writer.WriteEndElement();
				
			}
			writer.WriteEndElement();
		}
Пример #18
0
 protected override void OnWriteXml(XmlWriter writer)
 {
     writer.WriteAttributeString("Font", Font != null ? Font.Name : "");
     writer.WriteAttributeString("Text", Text);
     writer.WriteAttributeString("Foreground", Foreground.ToString());
     writer.WriteAttributeString("Position", Position.ToString());
 }
        /// <summary>
        /// Writes the 'atom:category' element with the specified attributes.
        /// </summary>
        /// <param name="writer">The Xml writer to write to.</param>
        /// <param name="term">The value for the 'term' attribute (required).</param>
        /// <param name="scheme">The value for the 'scheme' attribute (optional).</param>
        /// <param name="label">The value for the 'label' attribute (optional).</param>
        internal static void WriteCategory(XmlWriter writer, string term, string scheme, string label)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(writer != null, "writer != null");

            writer.WriteStartElement(
                AtomConstants.AtomNamespacePrefix,
                AtomConstants.AtomCategoryElementName,
                AtomConstants.AtomNamespace);

            if (term == null)
            {
                throw new ODataException(Strings.ODataAtomWriterMetadataUtils_CategoryMustSpecifyTerm);
            }

            writer.WriteAttributeString(
                AtomConstants.AtomCategoryTermAttributeName,
                term);

            if (scheme != null)
            {
                writer.WriteAttributeString(AtomConstants.AtomCategorySchemeAttributeName, scheme);
            }

            if (label != null)
            {
                writer.WriteAttributeString(AtomConstants.AtomCategoryLabelAttributeName, label);
            }

            writer.WriteEndElement();
        }
Пример #20
0
 private static void WriteQueuedRequestSnapshot(XmlWriter xmlWriter, QueuedRequestSnapshot queuedRequest)
 {
     xmlWriter.WriteStartElement("Request");
     xmlWriter.WriteAttributeString("projectName", queuedRequest.ProjectName);
     xmlWriter.WriteAttributeString("activity", queuedRequest.Activity.ToString());
     xmlWriter.WriteEndElement();
 }
Пример #21
0
		public override void ToXml(XmlWriter xwriter)
		{
			xwriter.WriteStartElement("ShelvingEqualizer");
			xwriter.WriteAttributeString("center", this.CenterFrequency.ToString());
			xwriter.WriteAttributeString("gain"  , this.Gain           .ToString());
			xwriter.WriteEndElement();
		}
Пример #22
0
 public void WriteXml(XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("change");
     xmlWriter.WriteAttributeString("kind", Kind.ToString());
     xmlWriter.WriteAttributeString("version", Version);
     xmlWriter.WriteEndElement();
 }
Пример #23
0
 internal override void ToXml(XmlWriter writer, string element)
 {
     writer.WriteStartElement(element);
     writer.WriteAttributeString("xsi:type", "ChangesetVersionSpec");
     writer.WriteAttributeString("cs", Convert.ToString(changesetId));
     writer.WriteEndElement();
 }
Пример #24
0
		public void WriteTo(XmlWriter writer)
		{
			writer.WriteStartElement("Setting");
			writer.WriteAttributeString("Name", this.Name);
			writer.WriteAttributeString("Type", this.SerializedSettingType);
			writer.WriteAttributeString("Scope", this.Scope.ToString());
			
			if (!string.IsNullOrEmpty(description)) {
				writer.WriteAttributeString("Description", description);
			}
			if (generateDefaultValueInCode != GenerateDefaultValueInCodeDefault) {
				writer.WriteAttributeString("GenerateDefaultValueInCode", XmlConvert.ToString(generateDefaultValueInCode));
			}
			if (!string.IsNullOrEmpty(provider)) {
				writer.WriteAttributeString("Provider", provider);
			}
			if (scope == SettingScope.User) {
				writer.WriteAttributeString("Roaming", XmlConvert.ToString(roaming));
			}
			
			writer.WriteStartElement("Value");
			writer.WriteAttributeString("Profile", "(Default)");
			writer.WriteValue(SerializedValue);
			writer.WriteEndElement();
			
			writer.WriteEndElement(); // Setting
		}
Пример #25
0
        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            var csRoot = project.RootDirectory.GetChildDirectory("cs");
            if (csRoot != null)
            {
                var serviceReferencesRoot = csRoot.GetChildDirectory("Service References");
                if (serviceReferencesRoot != null)
                {
                    writer.WriteStartElement("ItemGroup");

                    writer.WriteStartElement("WCFMetadata");
                    writer.WriteAttributeString("Include", "Service References" + Path.DirectorySeparatorChar);
                    writer.WriteEndElement();

                    foreach (var child in serviceReferencesRoot.ChildDirectories)
                    {
                        writer.WriteStartElement("WCFMetadataStorage");
                        writer.WriteAttributeString("Include", "Service References\\" + child + Path.DirectorySeparatorChar);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                }
            }
        }
Пример #26
0
        public static void Write(XmlWriter writer, Ticket pt)
        {
            var declarations = NamespaceDeclarations(pt);

            writer.WriteStartDocument();
            var prefix = declarations.LookupPrefix(Psf.PrintTicket.NamespaceName);
            writer.WriteStartElement(prefix, Psf.PrintTicket.LocalName, Psf.PrintTicket.NamespaceName);
            writer.WriteAttributeString("version", "1");

            foreach (var decl in declarations)
            {
                writer.WriteAttributeString("xmlns", decl.Prefix, null, decl.Uri.NamespaceName);
            }

            foreach (var f in pt.Features())
            {
                Write(writer, f);
            }

            foreach (var p in pt.Properties())
            {
                Write(writer, p);
            }

            foreach (var p in pt.Parameters())
            {
                Write(writer, p);
            }

            writer.WriteEndElement();
            writer.Flush();
        }
Пример #27
0
		public void Write(XmlWriter writer)
		{
			writer.WriteStartElement("task");
			writer.WriteAttributeString("taskName", TaskName);
			writer.WriteAttributeString("visible", IsVisible ? "true" : "false");
			writer.WriteEndElement();
		}
Пример #28
0
        private void InsertNode(XmlWriter writer, Item item) {
            if (item.IsNamespaced) {
                writer.WriteStartElement(item.LocalName, item.Namespace);
            } else {
                writer.WriteStartElement(item.LocalName);
            }

            foreach (Item.AttributeNode attr in item.Attributes) {
                if (attr.IsNamespaced) {
                    writer.WriteStartAttribute(attr.LocalName, attr.Namespace);
                    writer.WriteAttributeString(attr.LocalName, attr.Namespace, attr.Value);
                } else {
                    writer.WriteStartAttribute(attr.LocalName);
                    writer.WriteAttributeString(attr.LocalName, attr.Value);
                }
                writer.WriteEndAttribute();
            }

            if (item.HasContent) {
                if (item.IsNamespaced) {
                    writer.WriteElementString(item.LocalName, item.Namespace, item.LocalValue.ToString());
                } else {
                    writer.WriteElementString(item.LocalName, item.LocalValue.ToString());
                }
            }

            if (item.HasChildren) {
                foreach (Item child in item.Children) {
                    InsertNode(writer, child);
                }
            }
            writer.WriteEndElement();
        }
Пример #29
0
        private static void TraverseDirectory(XmlWriter writer, string path, StringBuilder textToShowinConsole)
        {
            bool inDirectories = true;
            string[] folderDirectories = Directory.GetDirectories(path);

            if (0 == folderDirectories.Length)
            {
                folderDirectories = Directory.GetFiles(path);
                inDirectories = false;
            }

            for (int i = 0; i < folderDirectories.Length; i++)
            {
                textToShowinConsole.AppendLine(folderDirectories[i]);
                if (inDirectories)
                {
                    writer.WriteStartElement("dir");
                    writer.WriteAttributeString("path", folderDirectories[i]);
                    TraverseDirectory(writer, folderDirectories[i], textToShowinConsole);
                    writer.WriteEndElement();
                }
                else
                {
                    writer.WriteStartElement("file");
                    writer.WriteAttributeString("filename", Path.GetFileName(folderDirectories[i]));
                    writer.WriteEndElement();
                }
            }
        }
Пример #30
0
 public void WriteXml(XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("param");
     xmlWriter.WriteAttributeString("name", Name);
     xmlWriter.WriteAttributeString("type", Type);
     xmlWriter.WriteEndElement();
 }
Пример #31
0
        protected override void DoWrite(Node node)
        {
            switch (node.Type)
            {
            case NodeType.DocumentStart:
            case NodeType.DocumentEnd:
                // nada a fazer
                break;

            case NodeType.ObjectStart:
            {
                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    var name    = (node.Value ?? "Element").ToString();
                    var tagName = ValueConventions.CreateName(name, Settings, TextCase.PascalCase);

                    writer.WriteStartElement(tagName);
                }

                stack.Push(NodeType.Object);
                break;
            }

            case NodeType.ObjectEnd:
            {
                stack.Pop();

                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    writer.WriteEndElement();
                }
                break;
            }

            case NodeType.CollectionStart:
            {
                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    var name    = (node.Value ?? "Array").ToString();
                    var tagName = ValueConventions.CreateName(name, Settings, TextCase.PascalCase);
                    writer.WriteStartElement(tagName);
                }

                var attName = ValueConventions.CreateName("IsArray", Settings, TextCase.PascalCase);
                writer.WriteAttributeString(attName, "true");

                stack.Push(NodeType.Collection);
                break;
            }

            case NodeType.CollectionEnd:
            {
                stack.Pop();

                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    writer.WriteEndElement();
                }

                break;
            }

            case NodeType.PropertyStart:
            {
                var name    = (node.Value ?? "Property").ToString();
                var tagName = ValueConventions.CreateName(name, Settings, TextCase.PascalCase);
                writer.WriteStartElement(tagName);

                stack.Push(NodeType.Property);
                break;
            }

            case NodeType.PropertyEnd:
            {
                writer.WriteEndElement();
                stack.Pop();
                break;
            }

            case NodeType.Value:
            {
                if (node.Value == null)
                {
                    writer.WriteValue(null);
                }
                else if (node.Value is XContainer)
                {
                    var xml   = (XContainer)node.Value;
                    var cdata = xml.ToString(SaveOptions.DisableFormatting);
                    writer.WriteCData(cdata);
                }
                else
                {
                    var text = ValueConventions.CreateText(node.Value, Settings);
                    writer.WriteValue(text);
                }
                break;
            }

            default:
                throw new SerializationException("Token não esperado: " + node);
            }

            if (Settings.AutoFlush)
            {
                DoFlush();
            }
        }
Пример #32
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("X", X.ToString());
     writer.WriteAttributeString("Y", Y.ToString());
     writer.WriteAttributeString("Type", ((int)Type).ToString());
 }
 private void WriteExcelStyleElement(CellStyle style)
 {
     _writer.WriteStartElement("Style", "urn:schemas-microsoft-com:office:spreadsheet");
     _writer.WriteAttributeString("ID", "urn:schemas-microsoft-com:office:spreadsheet", style.ToString());
     _writer.WriteEndElement();
 }
Пример #34
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        /// <remarks>For some reason this type is not defined in the ISO Data types XSD</remarks>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Format the base
            ANYFormatter anyFormatter = new ANYFormatter();

            anyFormatter.Graph(s, o, result);

            // If null flavor is not
            if ((o as IAny).NullFlavor != null)
            {
                return;
            }

            // Get the property information
            Type   pivlType                  = o.GetType();
            object valueValue                = pivlType.GetProperty("Value").GetValue(o, null),
                   operatorValue             = pivlType.GetProperty("Operator").GetValue(o, null),
                   alignmentValue            = pivlType.GetProperty("Alignment").GetValue(o, null),
                   phaseValue                = pivlType.GetProperty("Phase").GetValue(o, null),
                   periodValue               = pivlType.GetProperty("Period").GetValue(o, null),
                   institutionSpecifiedValue = pivlType.GetProperty("InstitutionSpecified").GetValue(o, null),
                   countValue                = pivlType.GetProperty("Count").GetValue(o, null),
                   frequencyValue            = pivlType.GetProperty("Frequency").GetValue(o, null),
                   originalTextValue         = pivlType.GetProperty("OriginalText").GetValue(o, null);

            // Attributes
            if (institutionSpecifiedValue != null)
            {
                s.WriteAttributeString("isFlexible", institutionSpecifiedValue.ToString().ToLower());
            }
            if (alignmentValue != null)
            {
                s.WriteAttributeString("alignment", Util.ToWireFormat(alignmentValue));
            }
            if (countValue != null)
            {
                s.WriteAttributeString("count", Util.ToWireFormat(countValue));
            }
            if (operatorValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Operator", "PIVL", s.ToString()));
            }
            if (valueValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Value", "PIVL", s.ToString()));
            }

            // Original text
            if (originalTextValue != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalTextValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
            }

            // Phase
            if (phaseValue != null)
            {
                s.WriteStartElement("phase", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, phaseValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
            }

            // Frequency or period
            if (frequencyValue != null)
            {
                s.WriteStartElement("frequency", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, frequencyValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
            }
            else if (periodValue != null)
            {
                s.WriteStartElement("period", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, periodValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
                if (frequencyValue != null)
                {
                    result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "'Period' and 'Frequency' specified, this is not permitted, either 'Period' xor 'Frequency' may be represented. Will only represent 'Period' property", s.ToString(), null));
                }
            }
        }
Пример #35
0
        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 execute_Utilities = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPParameter inputFeatureDatasetParameter = paramvalues.get_Element(in_featureDatasetParameterNumber) as IGPParameter;
                IGPValue inputFeatureDatasetGPValue = execute_Utilities.UnpackGPValue(inputFeatureDatasetParameter);
                IGPValue outputOSMFileGPValue = execute_Utilities.UnpackGPValue(paramvalues.get_Element(out_osmFileLocationParameterNumber));

                // get the name of the feature dataset
                int fdDemlimiterPosition = inputFeatureDatasetGPValue.GetAsText().LastIndexOf("\\");

                string nameOfFeatureDataset = inputFeatureDatasetGPValue.GetAsText().Substring(fdDemlimiterPosition + 1);


                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                System.Xml.XmlWriter xmlWriter = null;

                try
                {
                    xmlWriter = XmlWriter.Create(outputOSMFileGPValue.GetAsText(), settings);
                }
                catch (Exception ex)
                {
                    message.AddError(120021, ex.Message);
                    return;
                }

                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("osm"); // start the osm root node
                xmlWriter.WriteAttributeString("version", "0.6"); // add the version attribute
                xmlWriter.WriteAttributeString("generator", "ArcGIS Editor for OpenStreetMap"); // add the generator attribute

                // write all the nodes
                // use a feature search cursor to loop through all the known points and write them out as osm node

                IFeatureClassContainer osmFeatureClasses = execute_Utilities.OpenDataset(inputFeatureDatasetGPValue) as IFeatureClassContainer;

                if (osmFeatureClasses == null)
                {
                    message.AddError(120022, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), inputFeatureDatasetParameter.Name));
                    return;
                }

                IFeatureClass osmPointFeatureClass = osmFeatureClasses.get_ClassByName(nameOfFeatureDataset + "_osm_pt");

                if (osmPointFeatureClass == null)
                {
                    message.AddError(120023, string.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_no_pointfeatureclass"), nameOfFeatureDataset + "_osm_pt"));
                    return;
                }

                // check the extension of the point feature class to determine its version
                int internalOSMExtensionVersion = osmPointFeatureClass.OSMExtensionVersion();

                IFeatureCursor searchCursor = null;

                System.Xml.Serialization.XmlSerializerNamespaces xmlnsEmpty = new System.Xml.Serialization.XmlSerializerNamespaces();
                xmlnsEmpty.Add("", "");

                message.AddMessage(resourceManager.GetString("GPTools_OSMGPExport2OSM_exporting_pts_msg"));
                int pointCounter = 0;

                string nodesExportedMessage = String.Empty;

                // collect the indices for the point feature class once
                int pointOSMIDFieldIndex = osmPointFeatureClass.Fields.FindField("OSMID");
                int pointChangesetFieldIndex = osmPointFeatureClass.Fields.FindField("osmchangeset");
                int pointVersionFieldIndex = osmPointFeatureClass.Fields.FindField("osmversion");
                int pointUIDFieldIndex = osmPointFeatureClass.Fields.FindField("osmuid");
                int pointUserFieldIndex = osmPointFeatureClass.Fields.FindField("osmuser");
                int pointTimeStampFieldIndex = osmPointFeatureClass.Fields.FindField("osmtimestamp");
                int pointVisibleFieldIndex = osmPointFeatureClass.Fields.FindField("osmvisible");
                int pointTagsFieldIndex = osmPointFeatureClass.Fields.FindField("osmTags");

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    searchCursor = osmPointFeatureClass.Search(null, false);
                    comReleaser.ManageLifetime(searchCursor);

                    System.Xml.Serialization.XmlSerializer pointSerializer = new System.Xml.Serialization.XmlSerializer(typeof(node));

                    IFeature currentFeature = searchCursor.NextFeature();

                    IWorkspace pointWorkspace = ((IDataset)osmPointFeatureClass).Workspace;

                    while (currentFeature != null)
                    {
                        if (TrackCancel.Continue() == true)
                        {
                            // convert the found point feature into a osm node representation to store into the OSM XML file
                            node osmNode = ConvertPointFeatureToOSMNode(currentFeature, pointWorkspace, pointTagsFieldIndex, pointOSMIDFieldIndex, pointChangesetFieldIndex, pointVersionFieldIndex, pointUIDFieldIndex, pointUserFieldIndex, pointTimeStampFieldIndex, pointVisibleFieldIndex, internalOSMExtensionVersion);

                            pointSerializer.Serialize(xmlWriter, osmNode, xmlnsEmpty);

                            // increase the point counter to later status report
                            pointCounter++;

                            currentFeature = searchCursor.NextFeature();
                        }
                        else
                        {
                            // properly close the document
                            xmlWriter.WriteEndElement(); // closing the osm root element
                            xmlWriter.WriteEndDocument(); // finishing the document

                            xmlWriter.Close(); // closing the document

                            // report the number of elements loader so far
                            nodesExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_pts_exported_msg"), pointCounter);
                            message.AddMessage(nodesExportedMessage);

                            return;
                        }
                    }
                }

                nodesExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_pts_exported_msg"), pointCounter);
                message.AddMessage(nodesExportedMessage);

                // next loop through the line and polygon feature classes to export those features as ways
                // in case we encounter a multi-part geometry, store it in a relation collection that will be serialized when exporting the relations table
                IFeatureClass osmLineFeatureClass = osmFeatureClasses.get_ClassByName(nameOfFeatureDataset + "_osm_ln");

                if (osmLineFeatureClass == null)
                {
                    message.AddError(120023, string.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_no_linefeatureclass"), nameOfFeatureDataset + "_osm_ln"));
                    return;
                }

                message.AddMessage(resourceManager.GetString("GPTools_OSMGPExport2OSM_exporting_ways_msg"));

                // as we are looping through the line and polygon feature classes let's collect the multi-part features separately 
                // as they are considered relations in the OSM world
                List<relation> multiPartElements = new List<relation>();

                System.Xml.Serialization.XmlSerializer waySerializer = new System.Xml.Serialization.XmlSerializer(typeof(way));
                int lineCounter = 0;
                int relationCounter = 0;
                string waysExportedMessage = String.Empty;

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    searchCursor = osmLineFeatureClass.Search(null, false);
                    comReleaser.ManageLifetime(searchCursor);

                    IFeature currentFeature = searchCursor.NextFeature();

                    // collect the indices for the point feature class once
                    int lineOSMIDFieldIndex = osmLineFeatureClass.Fields.FindField("OSMID");
                    int lineChangesetFieldIndex = osmLineFeatureClass.Fields.FindField("osmchangeset");
                    int lineVersionFieldIndex = osmLineFeatureClass.Fields.FindField("osmversion");
                    int lineUIDFieldIndex = osmLineFeatureClass.Fields.FindField("osmuid");
                    int lineUserFieldIndex = osmLineFeatureClass.Fields.FindField("osmuser");
                    int lineTimeStampFieldIndex = osmLineFeatureClass.Fields.FindField("osmtimestamp");
                    int lineVisibleFieldIndex = osmLineFeatureClass.Fields.FindField("osmvisible");
                    int lineTagsFieldIndex = osmLineFeatureClass.Fields.FindField("osmTags");
                    int lineMembersFieldIndex = osmLineFeatureClass.Fields.FindField("osmMembers");

                    IWorkspace lineWorkspace = ((IDataset)osmLineFeatureClass).Workspace;

                    while (currentFeature != null)
                    {
                        if (TrackCancel.Continue() == false)
                        {
                            // properly close the document
                            xmlWriter.WriteEndElement(); // closing the osm root element
                            xmlWriter.WriteEndDocument(); // finishing the document

                            xmlWriter.Close(); // closing the document

                            // report the number of elements loaded so far
                            waysExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_ways_exported_msg"), lineCounter);
                            message.AddMessage(waysExportedMessage);

                            return;
                        }

                        //test if the feature geometry has multiple parts
                        IGeometryCollection geometryCollection = currentFeature.Shape as IGeometryCollection;

                        if (geometryCollection != null)
                        {
                            if (geometryCollection.GeometryCount == 1)
                            {
                                // convert the found polyline feature into a osm way representation to store into the OSM XML file
                                way osmWay = ConvertFeatureToOSMWay(currentFeature, lineWorkspace, osmPointFeatureClass, pointOSMIDFieldIndex, lineTagsFieldIndex, lineOSMIDFieldIndex, lineChangesetFieldIndex, lineVersionFieldIndex, lineUIDFieldIndex, lineUserFieldIndex, lineTimeStampFieldIndex, lineVisibleFieldIndex, internalOSMExtensionVersion);
                                waySerializer.Serialize(xmlWriter, osmWay, xmlnsEmpty);

                                // increase the line counter for later status report
                                lineCounter++;
                            }
                            else
                            {
                                relation osmRelation = ConvertRowToOSMRelation((IRow)currentFeature, lineWorkspace, lineTagsFieldIndex, lineOSMIDFieldIndex, lineChangesetFieldIndex, lineVersionFieldIndex, lineUIDFieldIndex, lineUserFieldIndex, lineTimeStampFieldIndex, lineVisibleFieldIndex, lineMembersFieldIndex, internalOSMExtensionVersion);
                                multiPartElements.Add(osmRelation);

                                // increase the line counter for later status report
                                relationCounter++;
                            }
                        }

                        currentFeature = searchCursor.NextFeature();
                    }
                }


                IFeatureClass osmPolygonFeatureClass = osmFeatureClasses.get_ClassByName(nameOfFeatureDataset + "_osm_ply");
                IFeatureWorkspace commonWorkspace = ((IDataset)osmPolygonFeatureClass).Workspace as IFeatureWorkspace;

                if (osmPolygonFeatureClass == null)
                {
                    message.AddError(120024, string.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_no_polygonfeatureclass"), nameOfFeatureDataset + "_osm_ply"));
                    return;
                }

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    searchCursor = osmPolygonFeatureClass.Search(null, false);
                    comReleaser.ManageLifetime(searchCursor);

                    IFeature currentFeature = searchCursor.NextFeature();

                    // collect the indices for the point feature class once
                    int polygonOSMIDFieldIndex = osmPolygonFeatureClass.Fields.FindField("OSMID");
                    int polygonChangesetFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmchangeset");
                    int polygonVersionFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmversion");
                    int polygonUIDFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmuid");
                    int polygonUserFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmuser");
                    int polygonTimeStampFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmtimestamp");
                    int polygonVisibleFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmvisible");
                    int polygonTagsFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmTags");
                    int polygonMembersFieldIndex = osmPolygonFeatureClass.Fields.FindField("osmMembers");

                    IWorkspace polygonWorkspace = ((IDataset)osmPolygonFeatureClass).Workspace;

                    while (currentFeature != null)
                    {
                        if (TrackCancel.Continue() == false)
                        {
                            // properly close the document
                            xmlWriter.WriteEndElement(); // closing the osm root element
                            xmlWriter.WriteEndDocument(); // finishing the document

                            xmlWriter.Close(); // closing the document

                            // report the number of elements loaded so far
                            waysExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_ways_exported_msg"), lineCounter);
                            message.AddMessage(waysExportedMessage);

                            message.AddAbort(resourceManager.GetString("GPTools_toolabort"));
                            return;
                        }

                        //test if the feature geometry has multiple parts
                        IGeometryCollection geometryCollection = currentFeature.Shape as IGeometryCollection;

                        if (geometryCollection != null)
                        {
                            if (geometryCollection.GeometryCount == 1)
                            {
                                // convert the found polyline feature into a osm way representation to store into the OSM XML file
                                way osmWay = ConvertFeatureToOSMWay(currentFeature, polygonWorkspace, osmPointFeatureClass, pointOSMIDFieldIndex, polygonTagsFieldIndex, polygonOSMIDFieldIndex, polygonChangesetFieldIndex, polygonVersionFieldIndex, polygonUIDFieldIndex, polygonUserFieldIndex, polygonTimeStampFieldIndex, polygonVisibleFieldIndex, internalOSMExtensionVersion);
                                waySerializer.Serialize(xmlWriter, osmWay, xmlnsEmpty);

                                // increase the line counter for later status report
                                lineCounter++;
                            }
                            else
                            {
                                relation osmRelation = ConvertRowToOSMRelation((IRow)currentFeature, polygonWorkspace, polygonTagsFieldIndex, polygonOSMIDFieldIndex, polygonChangesetFieldIndex, polygonVersionFieldIndex, polygonUIDFieldIndex, polygonUserFieldIndex, polygonTimeStampFieldIndex, polygonVisibleFieldIndex, polygonMembersFieldIndex, internalOSMExtensionVersion);
                                multiPartElements.Add(osmRelation);

                                // increase the line counter for later status report
                                relationCounter++;
                            }
                        }

                        currentFeature = searchCursor.NextFeature();
                    }
                }

                waysExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_ways_exported_msg"), lineCounter);
                message.AddMessage(waysExportedMessage);


                // now let's go through the relation table 
                message.AddMessage(resourceManager.GetString("GPTools_OSMGPExport2OSM_exporting_relations_msg"));
                ITable relationTable = commonWorkspace.OpenTable(nameOfFeatureDataset + "_osm_relation");

                if (relationTable == null)
                {
                    message.AddError(120025, String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_no_relationTable"), nameOfFeatureDataset + "_osm_relation"));
                    return;
                }


                System.Xml.Serialization.XmlSerializer relationSerializer = new System.Xml.Serialization.XmlSerializer(typeof(relation));
                string relationsExportedMessage = String.Empty;

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    ICursor rowCursor = relationTable.Search(null, false);
                    comReleaser.ManageLifetime(rowCursor);

                    IRow currentRow = rowCursor.NextRow();

                    // collect the indices for the relation table once
                    int relationOSMIDFieldIndex = relationTable.Fields.FindField("OSMID");
                    int relationChangesetFieldIndex = relationTable.Fields.FindField("osmchangeset");
                    int relationVersionFieldIndex = relationTable.Fields.FindField("osmversion");
                    int relationUIDFieldIndex = relationTable.Fields.FindField("osmuid");
                    int relationUserFieldIndex = relationTable.Fields.FindField("osmuser");
                    int relationTimeStampFieldIndex = relationTable.Fields.FindField("osmtimestamp");
                    int relationVisibleFieldIndex = relationTable.Fields.FindField("osmvisible");
                    int relationTagsFieldIndex = relationTable.Fields.FindField("osmTags");
                    int relationMembersFieldIndex = relationTable.Fields.FindField("osmMembers");

                    IWorkspace polygonWorkspace = ((IDataset)osmPolygonFeatureClass).Workspace;


                    while (currentRow != null)
                    {
                        if (TrackCancel.Continue() == false)
                        {
                            // properly close the document
                            xmlWriter.WriteEndElement(); // closing the osm root element
                            xmlWriter.WriteEndDocument(); // finishing the document

                            xmlWriter.Close(); // closing the document

                            // report the number of elements loaded so far
                            relationsExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_relations_exported_msg"), relationCounter);
                            message.AddMessage(relationsExportedMessage);

                            message.AddAbort(resourceManager.GetString("GPTools_toolabort"));
                            return;
                        }

                        relation osmRelation = ConvertRowToOSMRelation(currentRow, (IWorkspace)commonWorkspace, relationTagsFieldIndex, relationOSMIDFieldIndex, relationChangesetFieldIndex, relationVersionFieldIndex, relationUIDFieldIndex, relationUserFieldIndex, relationTimeStampFieldIndex, relationVisibleFieldIndex, relationMembersFieldIndex, internalOSMExtensionVersion);
                        relationSerializer.Serialize(xmlWriter, osmRelation, xmlnsEmpty);

                        // increase the line counter for later status report
                        relationCounter++;

                        currentRow = rowCursor.NextRow();
                    }
                }

                // lastly let's serialize the collected multipart-geometries back into relation elements
                foreach (relation currentRelation in multiPartElements)
                {
                    if (TrackCancel.Continue() == false)
                    {
                        // properly close the document
                        xmlWriter.WriteEndElement(); // closing the osm root element
                        xmlWriter.WriteEndDocument(); // finishing the document

                        xmlWriter.Close(); // closing the document

                        // report the number of elements loaded so far
                        relationsExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_relations_exported_msg"), relationCounter);
                        message.AddMessage(relationsExportedMessage);

                        return;
                    }

                    relationSerializer.Serialize(xmlWriter, currentRelation, xmlnsEmpty);
                    relationCounter++;
                }

                relationsExportedMessage = String.Format(resourceManager.GetString("GPTools_OSMGPExport2OSM_relations_exported_msg"), relationCounter);
                message.AddMessage(relationsExportedMessage);


                xmlWriter.WriteEndElement(); // closing the osm root element
                xmlWriter.WriteEndDocument(); // finishing the document

                xmlWriter.Close(); // closing the document
            }
            catch (Exception ex)
            {
                message.AddError(11111, ex.StackTrace);
                message.AddError(120026, ex.Message);
            }
        }
Пример #36
0
 public virtual void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("Id", this.Id);
 }
Пример #37
0
        public void SaveTextItem(System.Xml.XmlWriter Writer, StaticTextFormatter item, string name)
        {
            Writer.WriteStartElement(name);
            Writer.WriteAttributeString("colour", item.ForeColour.ToArgb().ToString());
            Writer.WriteAttributeString("fontFamily", item.Font.FontFamily.Name);
            Writer.WriteAttributeString("fontSize", item.Font.Size.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Writer.WriteAttributeString("fontStyle", item.Font.Style.ToString());
            Writer.WriteAttributeString("alignment", item.Alignment.ToString());
            Writer.WriteAttributeString("margin", item.Margin.ToString());

            Writer.WriteStartElement("textOutline");
            Writer.WriteAttributeString("opacity", item.TextOutline.Opacity.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Writer.WriteAttributeString("colour", item.TextOutline.Color.ToArgb().ToString());
            Writer.WriteAttributeString("thickness", item.TextOutline.Thickness.ToString());
            Writer.WriteEndElement();

            Writer.WriteStartElement("dropShadow");
            Writer.WriteAttributeString("opacity", item.DropShadow.Opacity.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Writer.WriteAttributeString("colour", item.DropShadow.Color.ToArgb().ToString());
            Writer.WriteAttributeString("angle", item.DropShadow.Direction.ToString());
            Writer.WriteAttributeString("altitude", item.DropShadow.Altitude.ToString());
            Writer.WriteEndElement();

            Writer.WriteEndElement();
        }
Пример #38
0
 public void ToXml(System.Xml.XmlWriter w)
 {
     w.WriteStartElement("Ocean");
     w.WriteAttributeString("DisplayOcean", displayOcean.ToString());
     w.WriteAttributeString("UseParams", useParams.ToString());
     w.WriteAttributeString("WaveHeight", waveHeight.ToString());
     w.WriteAttributeString("SeaLevel", seaLevel.ToString());
     w.WriteAttributeString("BumpScale", bumpScale.ToString());
     w.WriteAttributeString("BumpSpeedX", bumpSpeedX.ToString());
     w.WriteAttributeString("BumpSpeedZ", bumpSpeedZ.ToString());
     w.WriteAttributeString("TextureScaleX", textureScaleX.ToString());
     w.WriteAttributeString("TextureScaleZ", textureScaleZ.ToString());
     w.WriteStartElement("DeepColor");
     w.WriteAttributeString("R", deepColor.r.ToString());
     w.WriteAttributeString("G", deepColor.g.ToString());
     w.WriteAttributeString("B", deepColor.b.ToString());
     w.WriteEndElement(); // DeepColor
     w.WriteStartElement("ShallowColor");
     w.WriteAttributeString("R", shallowColor.r.ToString());
     w.WriteAttributeString("G", shallowColor.g.ToString());
     w.WriteAttributeString("B", shallowColor.b.ToString());
     w.WriteEndElement(); // ShallowColor
     w.WriteEndElement(); // Ocean
 }
Пример #39
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("id", id.ToString());
     writer.WriteAttributeString("ref_nr", ref_nr.ToString());
     writer.WriteAttributeString("virksomhed", virksomhed);
     writer.WriteAttributeString("emne", emne);
     writer.WriteAttributeString("dokument_type", dokument_type);
     writer.WriteAttributeString("år", år.ToString());
     writer.WriteAttributeString("ekstern_kilde", ekstern_kilde);
     writer.WriteAttributeString("beskrivelse", beskrivelse);
     writer.WriteAttributeString("oprettes_af", oprettes_af);
     writer.WriteAttributeString("oprettet_dato", oprettet_dato.ToString());
     writer.WriteAttributeString("kilde_sti", kilde_sti);
 }
Пример #40
0
        public void WriteXml(System.Xml.XmlWriter writer, FeedType feedType)
        {
            writer.WriteStartElement("entry", Namespaces.atomNamespace);
            // id
            writer.WriteElementString("id", Namespaces.atomNamespace, this.Id);
            // title
            writer.WriteElementString("title", Namespaces.atomNamespace, this.Title);

            // uuid
            if (this.IsUuidSet)
            {
                writer.WriteElementString("uuid", Namespaces.syncNamespace, this.Uuid.ToString());
            }

            foreach (SyncFeedEntryLink link in this.SyncLinks)
            {
                writer.WriteStartElement("link", Namespaces.atomNamespace);
                if (!String.IsNullOrEmpty(link.LinkRel))
                {
                    writer.WriteAttributeString("rel", link.LinkRel);
                }
                if (!String.IsNullOrEmpty(link.LinkType))
                {
                    writer.WriteAttributeString("type", link.LinkType);
                }
                if (!String.IsNullOrEmpty(link.Href))
                {
                    writer.WriteAttributeString("href", link.Href);
                }
                if (!String.IsNullOrEmpty(link.Title))
                {
                    writer.WriteAttributeString("title", link.Title);
                }
                if (!String.IsNullOrEmpty(link.PayloadPath))
                {
                    writer.WriteAttributeString(Namespaces.sdataPrefix, "payloadPath", Namespaces.sdataNamespace, link.PayloadPath);
                }
                if (!String.IsNullOrEmpty(link.Uuid))
                {
                    writer.WriteAttributeString(Namespaces.syncPrefix, "uuid", Namespaces.syncNamespace, link.Uuid);
                }
                writer.WriteEndElement();
            }

            switch (feedType)
            {
            case FeedType.Resource:
                break;

            case FeedType.SyncSource:
                //<!-- Per-Resource Synchronization State -->
                System.Xml.Serialization.XmlSerializer syncStateSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SyncState));
                syncStateSerializer.Serialize(writer, this.SyncState);
                if (!String.IsNullOrEmpty(this.HttpMethod))
                {
                    writer.WriteElementString("httpMethod", Namespaces.sdataHttpNamespace, this.HttpMethod);
                }
                break;

            case FeedType.SyncTarget:
                writer.WriteElementString("httpStatus", Namespaces.sdataHttpNamespace, Convert.ToInt32(this.HttpStatusCode).ToString());
                writer.WriteElementString("httpMessage", Namespaces.sdataHttpNamespace, this.HttpMessage);
                writer.WriteElementString("location", Namespaces.sdataHttpNamespace, this.HttpLocation);
                writer.WriteElementString("httpMethod", Namespaces.sdataHttpNamespace, this.HttpMethod);

                break;

            case FeedType.Linked:
            case FeedType.LinkedSingle:
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(LinkedElement));
                serializer.Serialize(writer, this.Linked);

                break;
            }
            // Content ??
            // links  ??

            if (null != this.HttpETag)
            {
                writer.WriteElementString("etag", Namespaces.sdataHttpNamespace, this.HttpETag);
            }

            //<!-- XML payload -->
            if (this.Payload != null)
            {
                System.Xml.Serialization.XmlSerializer serializer;
                //if (this.Payload is TradingAccountPayload)
                serializer = new System.Xml.Serialization.XmlSerializer(this.Payload.GetType());
                //else
                //serializer = new System.Xml.Serialization.XmlSerializer(typeof(PayloadBase));
                serializer.Serialize(writer, this.Payload);
            }
            writer.WriteEndElement();
        }
Пример #41
0
 private void WriteIntegerContent(XmlTextWriter writer, PsoIntUnsigned value)
 {
     writer.WriteAttributeString("value", value.Value.ToString("X8"));
 }
Пример #42
0
        protected virtual void WriteXmlBase(System.Xml.XmlWriter writer)
        {
            string openEhrPrefix = RmXmlSerializer.UseOpenEhrPrefix(writer);
            string xsiPrefix     = RmXmlSerializer.UseXsiPrefix(writer);

            // %HYYKA%
            // HKF: Not valid against schema when attribute has prefix and namespace
            //writer.WriteAttributeString(openEhrPrefix, "archetype_node_id",
            //    XmlSerializer.OpenEhrNamespace, this.ArchetypeNodeId);
            writer.WriteAttributeString("archetype_node_id", this.ArchetypeNodeId);

            writer.WriteStartElement(openEhrPrefix, "name", RmXmlSerializer.OpenEhrNamespace);
            string nameType = openEhrPrefix;

            if (!string.IsNullOrEmpty(nameType))
            {
                nameType += ":";
            }
            if (this.Name.GetType() == typeof(DvCodedText))
            {
                writer.WriteAttributeString(xsiPrefix, "type", RmXmlSerializer.XsiNamespace,
                                            nameType + "DV_CODED_TEXT");
            }
            this.Name.WriteXml(writer);
            writer.WriteEndElement();

            if (this.Uid != null)
            {
                writer.WriteStartElement(openEhrPrefix, "uid", RmXmlSerializer.OpenEhrNamespace);
                string uidType = openEhrPrefix;
                if (!string.IsNullOrEmpty(uidType))
                {
                    uidType += ":";
                }

                if (this.Uid.GetType() == typeof(ObjectVersionId))
                {
                    writer.WriteAttributeString(xsiPrefix, "type",
                                                RmXmlSerializer.XsiNamespace, uidType + "OBJECT_VERSION_ID");
                }
                else
                {
                    writer.WriteAttributeString(xsiPrefix, "type", RmXmlSerializer.XsiNamespace, uidType + "HIER_OBJECT_ID");
                }

                this.Uid.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (this.Links != null && this.Links.Count > 0)
            {
                foreach (Link aLink in this.Links)
                {
                    writer.WriteStartElement(openEhrPrefix, "links", RmXmlSerializer.OpenEhrNamespace);
                    aLink.WriteXml(writer);
                    writer.WriteEndElement();
                }
            }

            if (this.ArchetypeDetails != null)
            {
                writer.WriteStartElement(openEhrPrefix, "archetype_details", RmXmlSerializer.OpenEhrNamespace);
                this.ArchetypeDetails.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (this.FeederAudit != null)
            {
                writer.WriteStartElement(openEhrPrefix, "feeder_audit", RmXmlSerializer.OpenEhrNamespace);
                this.FeederAudit.WriteXml(writer);
                writer.WriteEndElement();
            }
        }
Пример #43
0
 public static void WriteStartFlowDocument(this System.Xml.XmlWriter x)
 {
     x.WriteStartElement("FlowDocument");
     x.WriteAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
     x.WriteAttributeString("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml");
 }
Пример #44
0
        /// <summary>
        /// Exports the specified XML writer.
        /// </summary>
        /// <param name="xmlWriter">The XML writer.</param>
        /// <param name="includeWindowsUsersAndGroups">if set to <c>true</c> [include windows users and groups].</param>
        /// <param name="includeDBUsers">if set to <c>true</c> [include DB users].</param>
        /// <param name="includeAuthorizations">if set to <c>true</c> [include authorizations].</param>
        /// <param name="ownerOfExport">The owner of export.</param>
        public void Export(System.Xml.XmlWriter xmlWriter, bool includeWindowsUsersAndGroups, bool includeDBUsers, bool includeAuthorizations, object ownerOfExport)
        {
            System.Windows.Forms.Application.DoEvents();
            xmlWriter.WriteStartElement("Store");
            xmlWriter.WriteAttributeString("Name", this.name);
            xmlWriter.WriteAttributeString("Description", this.description);
            //Attributes
            xmlWriter.WriteStartElement("Attributes");
            foreach (IAzManAttribute <IAzManStore> attribute in this.GetAttributes())
            {
                ((IAzManExport)attribute).Export(xmlWriter, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, ownerOfExport);
            }
            xmlWriter.WriteEndElement();
            //Permissions
            xmlWriter.WriteStartElement("Permissions");
            //Managers
            xmlWriter.WriteStartElement("Managers");
            foreach (KeyValuePair <string, bool> kvp in this.GetManagers())
            {
                if (kvp.Value == true)
                {
                    xmlWriter.WriteStartElement("Manager");
                    xmlWriter.WriteAttributeString("SqlUserOrRole", kvp.Key);
                    xmlWriter.WriteEndElement();
                }
            }
            xmlWriter.WriteEndElement();
            //Users
            xmlWriter.WriteStartElement("Users");
            foreach (KeyValuePair <string, bool> kvp in this.GetUsers())
            {
                if (kvp.Value == true)
                {
                    xmlWriter.WriteStartElement("User");
                    xmlWriter.WriteAttributeString("SqlUserOrRole", kvp.Key);
                    xmlWriter.WriteEndElement();
                }
            }
            xmlWriter.WriteEndElement();
            //Readers
            xmlWriter.WriteStartElement("Readers");
            foreach (KeyValuePair <string, bool> kvp in this.GetReaders())
            {
                if (kvp.Value == true)
                {
                    xmlWriter.WriteStartElement("Reader");
                    xmlWriter.WriteAttributeString("SqlUserOrRole", kvp.Key);
                    xmlWriter.WriteEndElement();
                }
            }
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
            //Store Groups
            xmlWriter.WriteStartElement("StoreGroups");
            foreach (IAzManStoreGroup storeGroup in this.GetStoreGroups())
            {
                storeGroup.Export(xmlWriter, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, ownerOfExport);
            }
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("Applications");
            //Applications
            foreach (IAzManApplication application in this.GetApplications())
            {
                application.Export(xmlWriter, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, ownerOfExport);
            }
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();
        }
Пример #45
0
        /// <summary>
        /// Save the attribute values of this class to XML.
        /// </summary>
        /// <param name="writer"></param>
        protected override void SaveAttributes(System.Xml.XmlWriter writer)
        {
            base.SaveAttributes(writer);

            writer.WriteAttributeString("Stereotype", string.Format("{0}", this.Stereotype));
        }
 public void ToXml(System.Xml.XmlWriter w)
 {
     w.WriteStartElement("DirectionalLight");
     w.WriteAttributeString("Azimuth", this.azimuth.ToString());
     w.WriteAttributeString("Zenith", this.zenith.ToString());
     w.WriteStartElement("Direction");
     w.WriteAttributeString("x", this.lightDirection.x.ToString());
     w.WriteAttributeString("y", this.lightDirection.y.ToString());
     w.WriteAttributeString("z", this.lightDirection.z.ToString());
     w.WriteEndElement(); // End Direction
     w.WriteStartElement("Diffuse");
     w.WriteAttributeString("R", this.diffuse.r.ToString());
     w.WriteAttributeString("G", this.diffuse.g.ToString());
     w.WriteAttributeString("B", this.diffuse.b.ToString());
     w.WriteEndElement(); // End diffuse
     w.WriteStartElement("Specular");
     w.WriteAttributeString("R", this.specular.r.ToString());
     w.WriteAttributeString("G", this.specular.g.ToString());
     w.WriteAttributeString("B", this.specular.b.ToString());
     w.WriteEndElement(); // End Specular
     w.WriteEndElement(); // End GlobalAmbientLight
 }
Пример #47
0
        private void WriteFloatContent(XmlTextWriter writer, PsoFloat value)
        {
            var s1 = string.Format(CultureInfo.InvariantCulture, "{0:0.0###########}", value.Value);

            writer.WriteAttributeString("value", s1);
        }
        public void ToXml(System.Xml.XmlWriter w)
        {
            w.WriteStartElement("TerrainDisplay");
            w.WriteAttributeString("Type", "AlphaSplat");
            w.WriteAttributeString("UseParams", useParams.ToString());
            w.WriteAttributeString("TextureTileSize", textureTileSize.ToString());
            w.WriteAttributeString("Alpha0MosaicName", alpha0MosaicName);
            w.WriteAttributeString("Alpha1MosaicName", alpha1MosaicName);
            w.WriteAttributeString("Layer1TextureName", l1TextureName);
            w.WriteAttributeString("Layer2TextureName", l2TextureName);
            w.WriteAttributeString("Layer3TextureName", l3TextureName);
            w.WriteAttributeString("Layer4TextureName", l4TextureName);
            w.WriteAttributeString("Layer5TextureName", l5TextureName);
            w.WriteAttributeString("Layer6TextureName", l6TextureName);
            w.WriteAttributeString("Layer7TextureName", l7TextureName);
            w.WriteAttributeString("Layer8TextureName", l8TextureName);
            w.WriteAttributeString("DetailTextureName", detailTextureName);

            w.WriteEndElement();
        }
Пример #49
0
 private void Write5Content(XmlTextWriter writer, PsoType5 value)
 {
     writer.WriteAttributeString("value", value.Value.ToString());
 }
Пример #50
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Format base attributes
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            if ((o as ANY).NullFlavor != null)
            {
                return;                                // no need to continue formatting
            }
            // Get the values the formatter needs to represent in XML
            Type   ivlType           = o.GetType();
            object operatorValue     = ivlType.GetProperty("Operator").GetValue(o, null),
                   lowValue          = ivlType.GetProperty("Low").GetValue(o, null),
                   highValue         = ivlType.GetProperty("High").GetValue(o, null),
                   widthValue        = ivlType.GetProperty("Width").GetValue(o, null),
                   originalTextValue = ivlType.GetProperty("OriginalText").GetValue(o, null),
                   lowClosedValue    = ivlType.GetProperty("LowClosed").GetValue(o, null),
                   highClosedValue   = ivlType.GetProperty("HighClosed").GetValue(o, null),
                   valueValue        = ivlType.GetProperty("Value").GetValue(o, null);

            // Low / high closed
            if (lowClosedValue != null)
            {
                s.WriteAttributeString("lowClosed", Util.ToWireFormat(lowClosedValue));
            }
            if (highClosedValue != null)
            {
                s.WriteAttributeString("highClosed", Util.ToWireFormat(highClosedValue));
            }
            if (operatorValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Operator", "IVL", s.ToString()));
            }

            // Original text
            if (originalTextValue != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalTextValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            bool invalidCombo = false;

            // Valid combinations
            if (lowValue != null)
            {
                s.WriteStartElement("low", "urn:hl7-org:v3");

                // Low value XSI?
                if (lowValue.GetType() != GenericArguments[0])
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(lowValue.GetType()));
                }

                var hostResult = this.Host.Graph(s, lowValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                if (highValue != null)
                {
                    s.WriteStartElement("high", "urn:hl7-org:v3");

                    if (highValue.GetType() != GenericArguments[0])
                    {
                        s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(highValue.GetType()));
                    }

                    hostResult  = this.Host.Graph(s, highValue as IGraphable);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
                invalidCombo |= valueValue != null || widthValue != null;
            }
            else if (highValue != null)
            {
                s.WriteStartElement("high", "urn:hl7-org:v3");

                // High value XSI
                if (highValue.GetType() != GenericArguments[0])
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(highValue.GetType()));
                }

                var hostResult = this.Host.Graph(s, highValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                invalidCombo |= valueValue != null || widthValue != null;
            }
            if (widthValue != null && ((lowValue == null) ^ (highValue == null) || lowValue == null && highValue == null))
            {
                s.WriteStartElement("width", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, widthValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                if (valueValue != null)
                {
                    s.WriteStartElement("any", "urn:hl7-org:v3");

                    // Value value xsi type
                    if (valueValue.GetType() != GenericArguments[0])
                    {
                        s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(valueValue.GetType()));
                    }

                    hostResult  = this.Host.Graph(s, valueValue as IGraphable);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
                invalidCombo |= lowValue != null || highValue != null;
            }
            else if (valueValue != null)
            {
                s.WriteStartElement("any", "urn:hl7-org:v3");

                // Value value xsi type
                if (valueValue.GetType() != GenericArguments[0])
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(valueValue.GetType()));
                }

                var hostResult = this.Host.Graph(s, valueValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                invalidCombo |= lowValue != null || highValue != null;
            }
            else
            {
                invalidCombo = true;
            }

            // Invalid combination, warn
            if (invalidCombo)
            {
                result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "This IVL is not conformant to the ISO21090 data types specification. Only 'Value' and/or 'Width', or 'Low' and/or 'High' are permitted. All data has been serialized but may not be interpreted by a remote system", s.ToString(), null));
            }
        }
Пример #51
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     WriteXmlInvoked = true;
     writer.WriteAttributeString("StringValue", StringValue);
     writer.WriteAttributeString("BoolValue", BoolValue.ToString());
 }
Пример #52
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("Title", mTitle);
     writer.WriteAttributeString("Path", mPath);
 }
 public override void SerializeContent(System.Xml.XmlWriter writer)
 {
     Guard.ArgumentNotNull(writer, "writer");
     writer.WriteAttributeString(TypeNamePropertyName, this.TypeName);
 }
Пример #54
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("DigitalInputs");
            foreach (EosDigitalInput input in DigitalInputs)
            {
                writer.WriteStartElement("DigitalInput");
                writer.WriteAttributeString("Number", input.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteString(input.Name);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("AnalogInputs");
            foreach (EosAnalogInput input in AnalogInputs)
            {
                writer.WriteStartElement("AnalogInput");
                writer.WriteAttributeString("Number", input.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteString(input.Name);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("LEDOutputs");
            foreach (EosLedOutput output in LedOutputs)
            {
                writer.WriteStartElement("LEDOutput");
                writer.WriteAttributeString("Number", output.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteString(output.Name);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("TextOutputs");
            foreach (EosTextOutput output in TextOutputs)
            {
                writer.WriteStartElement("TextOutput");
                writer.WriteAttributeString("Number", output.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteString(output.Name);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("ServoOutputs");
            foreach (EosServo output in ServoOutputs)
            {
                writer.WriteStartElement("ServoOutput");
                writer.WriteAttributeString("Number", output.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteAttributeString("Name", output.Name);
                output.Calibration.Write(writer);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("StepperOutputs");
            foreach (EosStepper output in StepperOutputs)
            {
                writer.WriteStartElement("StepperOutput");
                writer.WriteAttributeString("Number", output.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteAttributeString("Name", output.Name);
                output.Calibration.Write(writer);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("CoilOutputs");
            foreach (EosCoilOutput output in CoilOutputs)
            {
                writer.WriteStartElement("CoilOutput");
                writer.WriteAttributeString("Number", output.Number.ToString(System.Globalization.CultureInfo.InvariantCulture));
                writer.WriteAttributeString("Name", output.Name);
                output.Calibration.Write(writer);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
Пример #55
0
        private void WriteStructureContentXml(RbfStructure value, XmlTextWriter writer)
        {
            foreach (var child in value.Children)
            {
                if (child is RbfBytes)
                {
                    var bytesChild = (RbfBytes)child;

                    var contentField = (RbfString)null;
                    foreach (var xyz in value.Children)
                    {
                        if (xyz.Name != null && xyz.Name.Equals("content"))
                        {
                            contentField = (RbfString)xyz;
                        }
                    }

                    if (contentField != null)
                    {
                        if (contentField.Value.Equals("char_array"))
                        {
                            var sb = new StringBuilder();
                            sb.AppendLine("");
                            foreach (var k in bytesChild.Value)
                            {
                                sb.AppendLine(k.ToString());
                            }
                            writer.WriteString(sb.ToString());
                        }
                        else if (contentField.Value.Equals("short_array"))
                        {
                            var sb          = new StringBuilder();
                            var valueReader = new DataReader(new MemoryStream(bytesChild.Value));
                            while (valueReader.Position < valueReader.Length)
                            {
                                var y = valueReader.ReadUInt16();
                                sb.AppendLine(y.ToString());
                            }
                            writer.WriteString(sb.ToString());
                        }
                        else
                        {
                            throw new Exception("Unexpected content type");
                        }
                    }
                    else
                    {
                        string stringValue = Encoding.ASCII.GetString(bytesChild.Value);
                        writer.WriteString(stringValue.Substring(0, stringValue.Length - 1));
                    }
                }

                if (child is RbfFloat)
                {
                    writer.WriteStartElement(child.Name);
                    var floatChild = (RbfFloat)child;
                    var s1         = string.Format(CultureInfo.InvariantCulture, "{0:0.0###########}", floatChild.Value);
                    writer.WriteAttributeString("value", s1);
                    writer.WriteEndElement();
                }

                if (child is RbfString)
                {
                    var stringChild = (RbfString)child;
                    if (stringChild.Name.Equals("content"))
                    {
                        writer.WriteAttributeString("content", stringChild.Value);
                    }
                    else if (stringChild.Name.Equals("type"))
                    {
                        writer.WriteAttributeString("type", stringChild.Value);
                    }
                    else
                    {
                        throw new Exception("Unexpected string content");
                    }
                }

                if (child is RbfStructure)
                {
                    writer.WriteStartElement(child.Name);
                    WriteStructureContentXml((RbfStructure)child, writer);
                    writer.WriteEndElement();
                }

                if (child is RbfUint32)
                {
                    var intChild = (RbfUint32)child;
                    writer.WriteStartElement(child.Name);
                    writer.WriteAttributeString("value", "0x" + intChild.Value.ToString("X8"));
                    writer.WriteEndElement();
                }

                if (child is RbfBoolean)
                {
                    var booleanChild = (RbfBoolean)child;
                    writer.WriteStartElement(child.Name);
                    writer.WriteAttributeString("value", booleanChild.Value ? "true" : "false");
                    writer.WriteEndElement();
                }

                if (child is RbfFloat3)
                {
                    writer.WriteStartElement(child.Name);
                    var floatVectorChild = (RbfFloat3)child;
                    var s1 = string.Format(CultureInfo.InvariantCulture, "{0:0.0###########}", floatVectorChild.X);
                    var s2 = string.Format(CultureInfo.InvariantCulture, "{0:0.0###########}", floatVectorChild.Y);
                    var s3 = string.Format(CultureInfo.InvariantCulture, "{0:0.0###########}", floatVectorChild.Z);
                    writer.WriteAttributeString("x", s1);
                    writer.WriteAttributeString("y", s2);
                    writer.WriteAttributeString("z", s3);
                    writer.WriteEndElement();
                }
            }
        }
Пример #56
0
 public bool writeAttributeNs(string prefix, string name, string uri, string content) =>
 CheckedCall(() => _writer.WriteAttributeString(prefix, name, uri, content));
Пример #57
0
 /// <summary>
 /// Escreve os dados do parametro no xml.
 /// </summary>
 /// <param name="writer"></param>
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("name", Name);
     writer.WriteAttributeString("value", Value);
 }
Пример #58
0
        public new void WriteXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.WriteXmlAttributes(writer);

            writer.WriteAttributeString("defaultValue", DEFAULT_VALUE);
        }
Пример #59
0
 /// <summary>
 /// Converts an object into its XML representation.
 /// </summary>
 /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized. </param>
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString(Name, GetStringXmlValue());
 }
 /// <summary>
 /// Converts an object into its XML representation
 /// </summary>
 /// <param name="writer">The System.Xml.XmlWriter stream to which the object is serialized</param>
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("open", this.Open.ToString());
     writer.WriteAttributeString("close", this.Close.ToString());
 }