WriteValue() 공개 메소드

public WriteValue ( DateTime value ) : void
value DateTime
리턴 void
예제 #1
1
        static void GetDirectoryItemsWithXmlWriter(string path, XmlWriter writer)
        {
            var dirInfo = new DirectoryInfo(path);

            var files = dirInfo.GetFiles();
            var subdirs = dirInfo.GetDirectories();

            writer.WriteStartElement("dir");
            writer.WriteStartAttribute("name");
            writer.WriteValue(dirInfo.Name);
            writer.WriteEndAttribute();

            foreach (var file in files)
            {
                writer.WriteStartElement("file");
                writer.WriteStartAttribute("name");
                writer.WriteValue(file.Name);
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }

            foreach (var dir in subdirs)
            {
                GetDirectoryItemsWithXmlWriter(dir.FullName, writer);
            }

            writer.WriteEndElement();
        }
        public override void SerializeNetwork(XmlWriter xmlWriter)
        {
            base.SerializeNetwork(xmlWriter);

            var expander = ControlElements[0] as SliderExpanderDouble;
            if (expander == null) return;

            xmlWriter.WriteStartAttribute("SliderMax");
            xmlWriter.WriteValue(expander.SliderMax);
            xmlWriter.WriteEndAttribute();

            xmlWriter.WriteStartAttribute("SliderMin");
            xmlWriter.WriteValue(expander.SliderMin);
            xmlWriter.WriteEndAttribute();

            xmlWriter.WriteStartAttribute("SliderValue");
            xmlWriter.WriteValue(expander.SliderValue);
            xmlWriter.WriteEndAttribute();

            xmlWriter.WriteStartAttribute("SliderStep");
            xmlWriter.WriteValue(expander.SliderStep);
            xmlWriter.WriteEndAttribute();

            xmlWriter.WriteStartAttribute("IsExpanded");
            xmlWriter.WriteValue(expander.IsExpanded);
            xmlWriter.WriteEndAttribute();
        }
예제 #3
0
        private static void WriteDirectoryInfo(string directories, XmlWriter writer)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(directories);

            FileInfo[] files = directoryInfo.GetFiles();
            DirectoryInfo[] subDirectories = directoryInfo.GetDirectories();

            writer.WriteStartElement("Dir");
            writer.WriteStartAttribute("name");
            writer.WriteValue(directoryInfo.Name);
            writer.WriteEndAttribute();

            foreach (var file in files)
            {
                writer.WriteStartElement("File");
                writer.WriteStartAttribute("name");
                writer.WriteValue(file.Name);
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }

            foreach (var dir in subDirectories)
            {
                WriteDirectoryInfo(dir.FullName, writer);
            }

            writer.WriteEndElement();
        }
예제 #4
0
        public void Write()
        {
            XmlWriterSettings xmlSetting = new XmlWriterSettings();
            xmlSetting.CloseOutput = true;
            xmlSetting.Encoding = Encoding.UTF8;
            xmlSetting.Indent = true;
            xmlSetting.NewLineChars = "\r\n";

            wr = XmlWriter.Create(GeneralConfig.AppDataPath + "Questionaries\\" + questionary.Category + ".xml", xmlSetting);
            wr.WriteStartDocument();
            wr.WriteStartElement("Questionary");
            wr.WriteStartAttribute("category");
            wr.WriteValue(questionary.Category);
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("created");
            wr.WriteValue(questionary.Created.ToString());
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("updated");
            wr.WriteValue(questionary.Updated.ToString());
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("template");
            wr.WriteValue(questionary.TemplateId);
            wr.WriteEndAttribute();

            wr.WriteStartElement("Questions");
            WriteQuestions();
            wr.WriteEndElement();

            wr.WriteEndElement();
            wr.WriteEndDocument();
            wr.Close();
        }
예제 #5
0
 public override void WriteXml(XmlWriter writer)
 {
     writer.WriteStartElement("X");
     writer.WriteValue(((Point)Value).X);
     writer.WriteEndElement();
     writer.WriteStartElement("Y");
     writer.WriteValue(((Point)Value).Y);
     writer.WriteEndElement();
 }
예제 #6
0
		public void WriteXMLToAttributes(XmlWriter writer)
		{
			writer.WriteStartAttribute("lat");
			writer.WriteValue(this.lat.ToString(CultureInfo.InvariantCulture));
			writer.WriteEndAttribute();
			writer.WriteStartAttribute("lon");
			writer.WriteValue(this.lon.ToString(CultureInfo.InvariantCulture));
			writer.WriteEndAttribute();
		}
예제 #7
0
 public virtual void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteStartElement("LotsOfData");
     writer.WriteStartElement("Boolean");
     writer.WriteValue(true);
     writer.WriteEndElement(); //Boolean
     writer.WriteStartElement("DateTime");
     writer.WriteValue(Now);
     writer.WriteEndElement();                                  //DateTime
     writer.WriteStartElement("DecimalValue");
     writer.WriteValue(CommonUtilities.DecimalValue);           //decimal
     writer.WriteEndElement();                                  //DecimalValue
     writer.WriteStartElement("DoubleValue");
     writer.WriteValue(CommonUtilities.DoubleValue);            // double
     writer.WriteEndElement();                                  //DoubleValue
     writer.WriteStartElement("FloatValue");
     writer.WriteValue(CommonUtilities.FloatValue);             //float
     writer.WriteEndElement();                                  //FloatValue
     writer.WriteStartElement("IntValue");
     writer.WriteValue(CommonUtilities.IntValue);               //int
     writer.WriteEndElement();                                  //IntValue
     writer.WriteStartElement("LongValue");
     writer.WriteValue(CommonUtilities.LongValue);              //long
     writer.WriteEndElement();                                  //LongValue
     writer.WriteStartElement("Object");
     writer.WriteValue(CommonUtilities.TimeSpanValue);          //object
     writer.WriteEndElement();                                  //Object
     writer.WriteStartElement("StringValue");
     writer.WriteValue(CommonUtilities.XmlStringForAttributes); //string
     writer.WriteEndElement();                                  //StringValue
     writer.WriteEndElement();                                  //LotsOfData
 }
예제 #8
0
 public void WriteXml(XmlWriter writer)
 {
    if (_value is DateTime)
    {
       writer.WriteValue(XmlConvert.ToString((DateTime)_value, DateSerializationFormat));  
    }
    else
    {            
       writer.WriteValue(XmlConvert.ToString((TimeSpan)_value));  
    }         
 }
예제 #9
0
        private void AddEntry(XmlWriter writer, Package package, string baseUrl)
        {
            writer.WriteStartElement("entry");

            writer.WriteElementString("id", package.ID);

            writer.WriteStartElement("title");
            writer.WriteAttributeString("type", "text");
            writer.WriteValue(package.Name);
            writer.WriteEndElement(); // title

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "alternate");
            writer.WriteAttributeString("href", baseUrl + "/extensions/" + package.ID + "/extension.vsix");
            writer.WriteEndElement(); // link

            writer.WriteStartElement("summary");
            writer.WriteAttributeString("type", "text");
            writer.WriteValue(package.Description);
            writer.WriteEndElement(); // summary

            writer.WriteElementString("published", package.DatePublished.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            writer.WriteElementString("updated", package.DatePublished.ToString("yyyy-MM-ddTHH:mm:ssZ"));

            writer.WriteStartElement("author");
            writer.WriteElementString("name", package.Author);
            writer.WriteEndElement(); // author

            writer.WriteStartElement("content");
            writer.WriteAttributeString("type", "application/octet-stream");
            writer.WriteAttributeString("src", baseUrl + "/extensions/" + package.ID + "/extension.vsix");
            writer.WriteEndElement(); // content

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "icon");
            writer.WriteAttributeString("href", baseUrl + "/extensions/" + package.ID + "/" + package.Icon);
            writer.WriteEndElement(); // icon

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "previewimage");
            writer.WriteAttributeString("href", baseUrl + "/extensions/" + package.ID + "/" + package.Preview);
            writer.WriteEndElement(); // preview

            writer.WriteRaw("\r\n<Vsix xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://schemas.microsoft.com/developer/vsx-syndication-schema/2010\">\r\n");

            writer.WriteElementString("Id", package.ID);
            writer.WriteElementString("Version", package.Version);

            writer.WriteStartElement("References");
            writer.WriteEndElement();

            writer.WriteRaw("</Vsix>");// Vsix
            writer.WriteEndElement(); // entry
        }
예제 #10
0
 static void WriteKey(XmlWriter handle, string keyName, string keyValue)
 {
     handle.WriteStartElement("Key");
     handle.WriteStartAttribute("Name");
     handle.WriteValue(keyName);
     handle.WriteEndAttribute();
     handle.WriteStartAttribute("Value");
     handle.WriteValue(keyValue);
     handle.WriteEndAttribute();
     handle.WriteEndElement();
 }
        private static void writeColumnMapping(XmlWriter writer, ColumnMapping columnMapping)
        {
            writer.WriteStartElement("ColumnMapping");

            writer.WriteStartAttribute("type");
            writer.WriteValue(columnMapping.GetType().Name);
            writer.WriteEndAttribute();

            writer.WriteStartAttribute("columnUse");
            writer.WriteValue(columnMapping.ColumnUse.ToString());
            writer.WriteEndAttribute();

            writer.WriteStartAttribute("destinationColumnReference");
            writer.WriteValue(columnMapping.DestinationColumn.Name);
            writer.WriteEndAttribute();

            if (columnMapping is ExcelColumnMapping)
            {
                var excelColumnMapping = (ExcelColumnMapping)columnMapping;

                writer.WriteStartAttribute("sourceHeader");
                writer.WriteValue(excelColumnMapping.SourceHeader);
                writer.WriteEndAttribute();

            }
            else if (columnMapping is TableColumnMapping)
            {
                var tableColumnMapping = (TableColumnMapping)columnMapping;

                writer.WriteStartAttribute("sourceTableMappingIndex");
                writer.WriteValue(tableColumnMapping.SourceTableMapping.Index);
                writer.WriteEndAttribute();

                writer.WriteStartAttribute("sourceColumnReference");
                writer.WriteValue(tableColumnMapping.SourceColumn.Name);
                writer.WriteEndAttribute();
            }
            else if (columnMapping is LiteralColumnMapping)
            {
                var literalColumnMapping = (LiteralColumnMapping)columnMapping;

                writer.WriteStartAttribute("literal");
                writer.WriteValue(literalColumnMapping.Literal);
                writer.WriteEndAttribute();

                writer.WriteStartAttribute("literalType");
                writer.WriteValue(literalColumnMapping.LiteralType.ToString());
                writer.WriteEndAttribute();
            }

            writer.WriteEndElement();
            writer.WriteRaw("\n");
        }
예제 #12
0
        /// <summary>
        /// Helper function to store the MockException in xml
        /// </summary>
        /// <param name="writer"></param>
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            Type exceptionType = this.exception.GetType();

            if (exceptionType == typeof(SqlException))
            {
                // For SqlExceptions, serialize in text form, for easy viewing/editing
                writer.WriteStartElement(SqlExceptionTypeKey);
                if (exception.Data.Contains("HelpLink.ProdVer"))
                {
                    writer.WriteStartElement("serverVersion");
                    writer.WriteValue(exception.Data["HelpLink.ProdVer"]);
                    writer.WriteEndElement();
                }
                foreach (SqlError error in ((SqlException)exception).Errors)
                {
                    writer.WriteStartElement("SqlError");
                    foreach (KeyValuePair <string, string> pair in new KeyValuePair <string, string>[] {
                        new KeyValuePair <string, string>("infoNumber", error.Number.ToString()),
                        new KeyValuePair <string, string>("errorState", error.State.ToString()),
                        new KeyValuePair <string, string>("errorClass", error.Class.ToString()),
                        new KeyValuePair <string, string>("server", error.Server),
                        new KeyValuePair <string, string>("errorMessage", error.Message),
                        new KeyValuePair <string, string>("procedure", error.Procedure),
                        new KeyValuePair <string, string>("lineNumber", error.LineNumber.ToString())
                    })
                    {
                        writer.WriteStartElement(pair.Key);
                        writer.WriteValue(pair.Value);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else if (exceptionType.IsSerializable)
            {
                // For any other serializable exceptions, use the BinaryFormatter to generate serialize it in binary form, and save it in Xml as Base64.
                MemoryStream    stream    = new MemoryStream();
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(stream, this.exception);
                string serializedException = System.Convert.ToBase64String(stream.ToArray());
                writer.WriteStartElement(BinaryExceptionTypeKey);
                writer.WriteValue(serializedException);
                writer.WriteEndElement();
            }
            else
            {
                // Non-Serializable exceptions, nothing can be done at this time
                throw new XmlException(string.Format("Unknown mock exception type '{0}' for serialization.", exceptionType.ToString()));
            }
        }
        public void WriteExcelColumnDefinition(int columnWidth)
        {
            if (_writer == null)
            {
                throw new InvalidOperationException("Cannot write after closing.");
            }

            _writer.WriteStartElement("Column", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteStartAttribute("Width", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteValue(columnWidth);
            _writer.WriteEndAttribute();
            _writer.WriteEndElement();
        }
예제 #14
0
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement(TransliterationSettingsElementName);

            writer.WriteStartElement(ModeElementName);
            writer.WriteValue(Mode.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement(FileNameElementName);
            writer.WriteValue(FileName);
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
예제 #15
0
 private static void XmlWriteTeamTag(XmlWriter writer, string type, string code, string name)
 {
     writer.WriteStartElement(type + "-country");
     writer.WriteAttributeString("code", code);
     writer.WriteValue(name);
     writer.WriteEndElement();
 }
예제 #16
0
        private void WriteLayout(XmlWriter writer)
        {
            writer.WriteStartElement("Layout");

            for (int i = 0; i < map.TileLayers.Count; i++)
            {
                writer.WriteStartElement("Layer");

                writer.WriteStartAttribute("ID");
                writer.WriteValue(i);
                writer.WriteEndAttribute();

                WriteRows(writer, map.TileLayers[i]);

                writer.WriteEndElement();
            }

            writer.WriteStartElement("CustomLayer");

            WriteRows(writer, map.CustomLayer);

            writer.WriteEndElement();

            writer.WriteEndElement();
        }
예제 #17
0
        public void WriteTo(XmlWriter writer, bool includeWhitespace)
        {
            if (includeWhitespace)
                writer.WriteWhitespace(Environment.NewLine);

            writer.WriteStartElement(ElementName);

            if (AttributesCustom != null && AttributesCustom.Length > 0)
            {
                foreach (XAttributeCustom attribute in AttributesCustom)
                    attribute.WriteTo(writer, includeWhitespace); //Call custom render
            }

            bool hadChildNodes = false;

            if (HasElements)
            {
                foreach (XElementWithAttrib child in Nodes())
                {
                    child.WriteTo(writer, includeWhitespace);
                }

                hadChildNodes = true;
            }
            else
                //This element has just a text value
                writer.WriteValue(Value);

            if (hadChildNodes)
                //Write a new line before the End element
                writer.WriteWhitespace(Environment.NewLine);

            writer.WriteFullEndElement();
        }
        public override void SerializeToXML(XmlWriter writer)
        {
            writer.WriteStartElement("Loop");

            foreach (ParamInputModel param in Activity.InputParam)
            {
                string paramValue = param.Value != null ? param.Value.ToString() : param.ValueStr == null ? param.ValueStr : null;

                if (paramValue != null)
                {
                    writer.WriteStartElement(param.IsInputParam ? "InboundParam" : "OutboundParam");
                    writer.WriteAttributeString("name", param.Name);
                    writer.WriteAttributeString("type", param.DataType);
                    writer.WriteStartElement("Value");
                    writer.WriteValue(paramValue); //todo
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
            }


            writer.WriteAttributeString("cycles", "0");
            writer.WriteAttributeString("increment", "1");

            foreach (StandardFlowModel activity in NestedModels)
            {
                activity.SerializeToXML(writer);
            }

            writer.WriteEndElement();
        }
        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();
        }
        /// <summary> 
        /// Write the settings provided to stream 
        /// </summary> 
        /// <param name="inputStream"></param> 
        /// <returns></returns> 
        public static void SerializeAnalyticsSettings(XmlWriter xmlWriter, AnalyticsSettings settings)
        {
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement(SettingsSerializerHelper.RootPropertiesElementName);

            //LOGGING STARTS HERE
            xmlWriter.WriteStartElement(SettingsSerializerHelper.LoggingElementName);

            xmlWriter.WriteStartElement(SettingsSerializerHelper.VersionElementName);
            xmlWriter.WriteValue(settings.LogVersion);
            xmlWriter.WriteEndElement();

            bool isReadEnabled = (settings.LogType & LoggingLevel.Read) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeReadElementName);
            xmlWriter.WriteValue(isReadEnabled);
            xmlWriter.WriteEndElement();

            bool isWriteEnabled = (settings.LogType & LoggingLevel.Write) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeWriteElementName);
            xmlWriter.WriteValue(isWriteEnabled);
            xmlWriter.WriteEndElement();

            bool isDeleteEnabled = (settings.LogType & LoggingLevel.Delete) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeDeleteElementName);
            xmlWriter.WriteValue(isDeleteEnabled);
            xmlWriter.WriteEndElement();

            SerializeRetentionPolicy(xmlWriter, settings.IsLogRetentionPolicyEnabled, settings.LogRetentionInDays);
            xmlWriter.WriteEndElement(); // logging element

            //METRICS STARTS HERE
            xmlWriter.WriteStartElement(SettingsSerializerHelper.MetricsElementName);

            xmlWriter.WriteStartElement(SettingsSerializerHelper.VersionElementName);
            xmlWriter.WriteValue(settings.MetricsVersion);
            xmlWriter.WriteEndElement();

            bool isServiceSummaryEnabled = (settings.MetricsType & MetricsType.ServiceSummary) != MetricsType.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.MetricsEnabledElementName);
            xmlWriter.WriteValue(isServiceSummaryEnabled);
            xmlWriter.WriteEndElement();

            if (isServiceSummaryEnabled)
            {
                bool isApiSummaryEnabled = (settings.MetricsType & MetricsType.ApiSummary) != MetricsType.None;
                xmlWriter.WriteStartElement(SettingsSerializerHelper.IncludeApiSummaryElementName);
                xmlWriter.WriteValue(isApiSummaryEnabled);
                xmlWriter.WriteEndElement();
            }

            SerializeRetentionPolicy(
                xmlWriter,
                settings.IsMetricsRetentionPolicyEnabled,
                settings.MetricsRetentionInDays);
            xmlWriter.WriteEndElement();
            // metrics
            xmlWriter.WriteEndElement();
            // root element
            xmlWriter.WriteEndDocument();
        }
        /// <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>
        /// <exception cref="System.NotImplementedException"></exception>
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteElementString("SessionId", SessionId);

            writer.WriteStartElement("IsRunning");
            writer.WriteValue(IsRunning);
            writer.WriteEndElement();

            if (!String.IsNullOrEmpty(ExecutionStatus))
            {
                writer.WriteStartElement("ExecutionStatus");
                writer.WriteRaw(ExecutionStatus);
                writer.WriteEndElement();
            }

            if (!String.IsNullOrEmpty(Log))
            {
                writer.WriteStartElement("Log");
                writer.WriteRaw(Log);
                writer.WriteEndElement();
            }

            if (!String.IsNullOrEmpty(Error))
                writer.WriteElementString("Error", Error);
        }
 public void Write(SceneCommandInfo info, XmlWriter writer)
 {
     var call = (SceneCallCommandInfo)info;
     writer.WriteStartElement("Call");
     writer.WriteValue(call.Name);
     writer.WriteEndElement();
 }
예제 #23
0
파일: entitybase.cs 프로젝트: gmbeard/mndal
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     Array.ForEach(
         Fields,
         delegate(EntityDbField item) {
         writer.WriteStartElement(XmlConvert.EncodeLocalName(item.DbName));
         writer.WriteAttributeString("length", item.DbLength.ToString());
         writer.WriteAttributeString("dbType", item.DbType.ToString());
         object val = GetValueForDbField(item);
         if (null != val)
         {
             try {
                 writer.WriteValue(GetValueForDbField(item));
             }
             catch {
                 writer.WriteString(
                     typeof(XmlConvert).InvokeMember(
                         "ToString",
                         BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod,
                         null,
                         null,
                         new Object[] { GetValueForDbField(item) }).ToString());
             }
         }
         writer.WriteEndElement();
     });
 }
예제 #24
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteStartElement("ID");
     writer.WriteValue(ID);
     writer.WriteEndElement();
     Fields.WriteXml(writer);
 }
예제 #25
0
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("RoutingItem");
			XmlSerialization.WriteXml(Properties, writer);
			writer.WriteValue(Content);
            writer.WriteEndElement();
        }
예제 #26
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            XmlSerializer keySerializer   = new XmlSerializer(typeof(TKey));
            XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

            foreach (TKey key in this.Keys)
            {
                writer.WriteStartElement(key.ToString());
                TValue value = this[key];
                //valueSerializer.Serialize(writer, value);
                writer.WriteValue(value);
                writer.WriteEndElement();

                /*
                 * writer.WriteStartElement("item");
                 * writer.WriteStartElement("key");
                 * keySerializer.Serialize(writer, key);
                 *
                 * writer.WriteEndElement();
                 * writer.WriteStartElement("value");
                 * TValue value = this[key];
                 * valueSerializer.Serialize(writer, value);
                 * writer.WriteEndElement();
                 *
                 * writer.WriteEndElement();*/
            }
        }
 private static void HandleSerializable(XmlWriter writer, Type propertyType, object value)
 {
     if (propertyType.IsGenericType &&
         propertyType.GetGenericTypeDefinition() == typeof (Nullable<>))
     {
         var underlyingType = Nullable.GetUnderlyingType(propertyType);
         HandleSerializable(writer, underlyingType, value);
     }
     else if (propertyType == typeof (DateTime))
     {
         var valueString = ((DateTime)value).ToString("yyyy-MM-dd");
         writer.WriteValue(SecurityElement.Escape(valueString));
     }
     else if (propertyType.IsEnum)
     {
         var valueString = value.ToString();
         var field = propertyType.GetField(valueString);
         var enumAttributes = Attribute.GetCustomAttributes(field, typeof (XmlEnumAttribute), true);
         if (enumAttributes.Length != 0)
         {
             var enumAttribute = (XmlEnumAttribute) enumAttributes[0];
             var enumName = enumAttribute != null ? enumAttribute.Name : valueString;
             writer.WriteValue(SecurityElement.Escape(enumName));
         }
         else
         {
             writer.WriteValue(SecurityElement.Escape(valueString));
         }
     }
     else
     {
         writer.WriteValue(value);
     }
 }
예제 #28
0
        private void WriteElement(XNode node, XmlWriter writer)
        {
            writer.WriteStartElement(node.Name);

            foreach (var attr in node.Attributes)
            {
                if (attr.Match == MatchType.Change || attr.Match == MatchType.NoMatch)
                    writer.WriteAttributeString(attr.Name, attr.XmlNode.Value);
            }

            foreach (var text in node.Texts)
            {
                if (text.Match == MatchType.Change || text.Match == MatchType.NoMatch)
                    writer.WriteValue(text.XmlNode.Value);
            }

            foreach (var element in node.Elements)
            {
                if (element.Match == MatchType.Change)
                    WriteElement(element, writer);

                if (element.Match == MatchType.NoMatch)
                    writer.WriteRaw(element.XmlNode.OuterXml);
            }

            writer.WriteEndElement();
        }
예제 #29
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.WriteStartElement(Name);

            foreach (var xAttribute in Attributes)
            {
                xAttribute.WriteXml(writer);
            }

            if (Value != null)
            {
                writer.WriteValue(Value);
            }

            foreach (var xElement in Elements)
            {
                xElement.WriteXml(writer);
            }

            foreach (var xContainer in Containers)
            {
                xContainer.WriteXml(writer);
            }

            writer.WriteEndElement();
        }
 internal override void Save (XmlWriter writer)
 {
         writer.WriteStartElement (XmlName);
         if (!string.IsNullOrWhiteSpace (Value))
                 writer.WriteValue (Value);
         writer.WriteEndElement ();
 }
        public void WriteElement(IAixmConverter converter, int flow, JObject feature, XmlWriter writer)
        {
            var id = feature["properties"]["id"];

            if (flow == 0)
            {
                if (id != null)
                {
                    if (id is JObject)
                    {
                        writer.WriteStartElement("gml", "identifier", null);
                        var obj = id as JObject;
                        foreach(var prop in obj.Properties().Where(p=>p.Name.StartsWith("@")))
                        { 
                            writer.WriteAttributeString(prop.Name.Substring(1), prop.Value.ToString());
                        }
                        writer.WriteValue(id["#text"].ToString());
                        writer.WriteEndElement();


                    }else{
                        writer.WriteElementString("gml", "identifier", null, id.ToString());
                    }
                }   
            }
            else
            {
               

            }
        }
예제 #32
0
 public static void WriteTypeAttributes(XmlWriter xmlWriter, object objectWithType)
 {
     string FullyQualifiedName = objectWithType.GetType().AssemblyQualifiedName;
     Regex RemoveExtraCrapSearch = new Regex(", (Version|Culture|PublicKeyToken)=[^,\\]]+");
     string LessQualifiedName = RemoveExtraCrapSearch.Replace(FullyQualifiedName, "");
     xmlWriter.WriteStartAttribute("Type");
     xmlWriter.WriteValue(LessQualifiedName);
 }
예제 #33
0
 public void WriteXML(XmlWriter writer)
 {
     writer.WriteStartElement("Rule");
     writer.WriteStartElement("DoWhatNow");
     writer.WriteValue((int) this.DoWhatNow);
     writer.WriteEndElement();
     writer.WriteStartElement("First");
     writer.WriteValue(this.First);
     writer.WriteEndElement();
     writer.WriteStartElement("Second");
     writer.WriteValue(this.Second);
     writer.WriteEndElement();
     writer.WriteStartElement("Text");
     writer.WriteValue(this.UserSuppliedText);
     writer.WriteEndElement();
     writer.WriteEndElement(); // ShowRule
 }
예제 #34
0
        public void ToXmlWriter(ref System.Xml.XmlWriter xw)
        {
            xw.WriteStartElement("ShippableItem");

            xw.WriteStartElement("IsNonShipping"); xw.WriteValue(this.IsNonShipping); xw.WriteEndElement();
            xw.WriteStartElement("ShipSeparately"); xw.WriteValue(this.ShipSeparately); xw.WriteEndElement();
            Xml.WriteDecimal("ExtraShipFee", this.ExtraShipFee, ref xw);
            Xml.WriteDecimal("Weight", this.Weight, ref xw);
            Xml.WriteDecimal("Length", this.Length, ref xw);
            Xml.WriteDecimal("Width", this.Width, ref xw);
            Xml.WriteDecimal("Height", this.Height, ref xw);
            Xml.WriteLong("ShippingScheduleId", this.ShippingScheduleId, ref xw);
            Xml.WriteInt("ShippingSource", (int)this.ShippingSource, ref xw);
            xw.WriteElementString("ShippingSourceId", this.ShippingSourceId);

            xw.WriteEndElement();
        }
예제 #35
0
        public override void SerializeNetwork(XmlWriter xmlWriter)
        {
            base.SerializeNetwork(xmlWriter);

            xmlWriter.WriteStartAttribute("InputPortsCount");
            xmlWriter.WriteValue(InputPorts.Count);
            xmlWriter.WriteEndAttribute();
        }
예제 #36
0
        public virtual void OnSave(XmlWriter writer)
        {
            Vector3 pos = Transformation.GetPosition();
            Vector3 rot = Transformation.GetRotation();
            Vector3 scale = Transformation.GetScale();
            writer.WriteStartAttribute("position");
            writer.WriteValue(ParseUtils.WriteVector3(pos));
            writer.WriteEndAttribute();

            writer.WriteStartAttribute("rotation");
            writer.WriteValue(ParseUtils.WriteVector3(rot));
            writer.WriteEndAttribute();

            writer.WriteStartAttribute("scale");
            writer.WriteValue(ParseUtils.WriteVector3(scale));
            writer.WriteEndAttribute();
        }
 public override void WriteXml(XmlWriter writer)
 {
     writer.WriteStartElement("Message");
     writer.WriteValue(_replyMessage);
     writer.WriteEndElement();
     writer.WriteStartElement("Data");
     base.WriteXml(writer);
     writer.WriteEndElement();
 }
예제 #38
0
        void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("Id", ns);
            writer.WriteValue(m_linkItem.Id);
            writer.WriteEndElement();

            writer.WriteElementString("Title", ns, m_linkItem.Title);
            writer.WriteElementString("Description", ns, m_linkItem.Description);

            writer.WriteStartElement("DateStart", ns);
            writer.WriteValue(m_linkItem.DateStart);
            writer.WriteEndElement();

            writer.WriteStartElement("DateEnd", ns);
            writer.WriteValue(m_linkItem.DateEnd);
            writer.WriteEndElement();

            writer.WriteElementString("Url", ns, m_linkItem.Url);
        }
예제 #39
0
        }     // End Sub ReadXml

        void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
        {
            // [XmlAttribute(AttributeName = "type")]
            // [XmlElement(ElementName = "name", Namespace = "http://www.itunes.com/dtds/podcast-1.0.dtd")]

            // writer.WriteAttributeString("Name", "bla");

            if (this.m_value != System.DateTime.MinValue)
            {
                //writer.WriteElementString("Birthday", this.m_value.ToString("r"));
                writer.WriteValue(this.m_value.ToString("r", System.Globalization.CultureInfo.InvariantCulture));
            }
        } // End Sub WriteXml
예제 #40
0
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
            Thread.Sleep(500);
            Byte[] bytes = File.ReadAllBytes(e.FullPath);

            file1 = Convert.ToBase64String(bytes);
            string        date_year    = DateTime.Now.ToString("yyyy");
            string        date_month   = DateTime.Now.ToString("MM");
            string        date_day     = DateTime.Now.ToString("dd");
            string        current_date = date_year + date_month + date_day + "-";
            StringBuilder sb           = new StringBuilder();

            System.Xml.XmlWriter xw = XmlWriter.Create(sb);

            xw.WriteStartElement("date");
            xw.WriteAttributeString("xml_date", "yyyy-mm-dd", null, current_date);
            xw.WriteStartElement("log");

            xw.WriteValue(file1);
            xw.WriteEndElement();


            xw.WriteEndElement();



            xw.Close();

            try
            {
                // wrstream.WriteLine(file1);
                wrstream.WriteLine(sb.ToString());
                wrstream.Flush();
            }
            catch (Exception ecp)
            {
                ecp.GetBaseException();
            }
            try
            {
                //ns.Flush();
                wrstream.Flush();
                //wrstream.Close(); //если я закрываю поток происходит передача данных и клиент теряет связь
                //Я бы не говорил что это очень плохо
            }
            catch (Exception ex2)
            {
                ex2.GetBaseException();
            }
        }
예제 #41
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            XmlSerializer valueSerializer = new XmlSerializer(typeof(string));

            foreach (string key in this.Keys)
            {
                string xmlKey = XmlConvert.EncodeName(key);
                writer.WriteStartElement(xmlKey);
                if (this[key] != null)
                {
                    writer.WriteValue(this[key]);
                }
                writer.WriteEndElement();
            }
        }
예제 #42
0
        public void SerializeToXml(ref System.Xml.XmlWriter xw)
        {
            xw.WriteStartElement("part");

            xw.WriteElementString("id", this.Id);
            xw.WriteElementString("typecode", "columncontainer");
            xw.WriteStartElement("spacerabove"); xw.WriteValue(this.SpacerAbove); xw.WriteEndElement();

            xw.WriteStartElement("columns");
            foreach (IColumn c in this.Columns)
            {
                c.SerializeToXml(ref xw);
            }
            xw.WriteEndElement();

            xw.WriteEndElement();
        }
예제 #43
0
        /// <summary>
        /// Converts an object into its XML representation.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"></see> stream to which the object is serialized.</param>
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            //XmlSerializer xmlser = new XmlSerializer(typeof(MetaObject));

            foreach (MetaObject moList in this)
            {
                writer.WriteStartElement("list");
                foreach (MetaField mf in moList.GetMetaType().Fields)
                {
                    if (mf.InPrimaryKey)
                    {
                        continue;
                    }

                    object value = moList.Properties[mf.Name].Value;

                    // OZ [2008-04-09] Fix Problem with Files
                    FileInfo fileInfo = value as FileInfo;
                    if (mf.GetMetaType().McDataType == McDataType.File && fileInfo != null)
                    {
                        value = fileInfo.Name;
                    }

                    // OZ [2008-04-09] Fix Problem with GUid
                    if (mf.GetMetaType().McDataType == McDataType.Guid && value is Guid)
                    {
                        value = ((Guid)value).ToString();
                    }

                    // OZ [2008-10-30] Fix Problem with PrimaryKeyId
                    if (value is PrimaryKeyId)
                    {
                        value = ((PrimaryKeyId)value).ToString();
                    }

                    writer.WriteStartElement(mf.Name);
                    if (value != null)
                    {
                        writer.WriteValue(value);
                    }
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                //xmlser.Serialize(writer, moList);
            }
        }
예제 #44
0
        /// <summary>
        /// Implements a custom serialization of the key, using the type name as a specifier.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="key"></param>
        protected override void SerializeKey(System.Xml.XmlWriter writer, Type key)
        {
            writer.WriteStartElement(SerializedKeyElementName);
            if (SerializeKeyTypeAsKeyAttribute)
            {
                writer.WriteStartAttribute("type");
                writer.WriteValue("System.String");
                writer.WriteEndAttribute();
            }
            var typeFullName = key.FullName;

            if (!typeFullName.Contains(","))
            {
                typeFullName += ", " + key.Assembly.GetName().Name;
            }
            writer.WriteRaw(XmlUtility.EncodeText(typeFullName));
            writer.WriteEndElement();
        }
예제 #45
0
        public void SerializeToXml(ref System.Xml.XmlWriter xw)
        {
            xw.WriteStartElement("part");

            xw.WriteElementString("id", this.Id);
            xw.WriteElementString("typecode", "column");
            xw.WriteElementString("size", this.Size.ToString());
            xw.WriteStartElement("nogutter"); xw.WriteValue(this.NoGutter); xw.WriteEndElement();

            xw.WriteStartElement("parts");
            foreach (IContentPart p in this.Parts)
            {
                p.SerializeToXml(ref xw);
            }
            xw.WriteEndElement();

            xw.WriteEndElement();
        }
예제 #46
0
 public override void WriteXml(System.Xml.XmlWriter writer)
 {
     base.WriteXml(writer);
     writer.WriteElementString("IsTrigger", XmlConvert.ToString(IsTrigger));
     writer.WriteStartElement("DoNothing");
     writer.WriteValue(DoNothing);
     writer.WriteEndElement();
     writer.WriteStartElement("CustomScale");
     writer.WriteElementString("X", XmlConvert.ToString(CustomScale.X));
     writer.WriteElementString("Y", XmlConvert.ToString(CustomScale.Y));
     writer.WriteElementString("Z", XmlConvert.ToString(CustomScale.Z));
     writer.WriteEndElement();
     writer.WriteStartElement("CustomOffset");
     writer.WriteElementString("X", XmlConvert.ToString(CustomOffset.X));
     writer.WriteElementString("Y", XmlConvert.ToString(CustomOffset.Y));
     writer.WriteElementString("Z", XmlConvert.ToString(CustomOffset.Z));
     writer.WriteEndElement();
 }
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteAttributeString("Default", Default);

            if (Translations != null && Translations.Count > 0)
            {
                // write translations in a nested node
                writer.WriteStartElement("Translations");

                foreach (var tranlation in Translations)
                {
                    writer.WriteStartElement("Translation");
                    writer.WriteAttributeString("LanguageCode", tranlation.Key);
                    writer.WriteValue(tranlation.Value);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }
예제 #48
0
 public void WriteXmlContent(System.Xml.XmlWriter writer, int tabIndex = 0)
 {
     #region ALIACES
     writer.WriteStartElement("aliaces");
     if (ALIACES != null)
     {
         tabIndex++;
         foreach (string aliace in ALIACES)
         {
             if (!string.IsNullOrEmpty(aliace))
             {
                 writer.WriteStartElement("aliace");
                 writer.WriteValue(aliace);
                 writer.WriteEndElement();
             }
         }
         tabIndex++;
     }
     writer.WriteEndElement();
     #endregion
 }
예제 #49
0
        public void ToXmlWriter(ref System.Xml.XmlWriter xw)
        {
            if (xw != null)
            {
                xw.WriteStartElement("ContentColumn");

                xw.WriteElementString("Bvin", this.Bvin);
                xw.WriteElementString("DisplayName", this.DisplayName);

                xw.WriteStartElement("SystemColumn");
                xw.WriteValue(this.SystemColumn);
                xw.WriteEndElement();

                xw.WriteStartElement("Blocks");
                foreach (ContentBlock b in this.Blocks)
                {
                    b.ToXmlWriter(ref xw);
                }
                xw.WriteEndElement();


                xw.WriteEndElement(); // end Column
            }
        }
 public override void WriteValue(object value)
 {
     CheckAsync();
     coreWriter.WriteValue(value);
 }
예제 #51
0
파일: TextOnlyNode.cs 프로젝트: radtek/Omi
 protected override void WriteInner(System.Xml.XmlWriter writer)
 {
     writer.WriteValue(_value ?? string.Empty);
 }
예제 #52
0
 public override void WriteValue(object value)
 {
     writer.WriteValue(value);
 }
예제 #53
0
 public static void WriteElement(this XmlWriter xw, string localName, object value)
 {
     xw.WriteStartElement(localName);
     xw.WriteValue(value);
     xw.WriteEndElement();
 }
예제 #54
0
 public static void WriteAttribute(this XmlWriter xw, string localName, object value)
 {
     xw.WriteStartAttribute(localName);
     xw.WriteValue(value);
     xw.WriteEndAttribute();
 }
예제 #55
0
 void System.Xml.Serialization.IXmlSerializable.WriteXml(Xml.XmlWriter writer)
 {
     writer.WriteValue(this.ToString());
 }
예제 #56
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();
            }
        }