本文整理汇总了C#中System.IO.StreamWriter.WriteEndElement方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriter.WriteEndElement方法的具体用法?C# StreamWriter.WriteEndElement怎么用?C# StreamWriter.WriteEndElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamWriter
的用法示例。
在下文中一共展示了StreamWriter.WriteEndElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/// <summary>
/// This program is used at compile-time by the NSIS Install Scripts.
/// It copies the file properties of an assembly and writes that info a
/// header file that the scripts use to make the installer match the program
///
/// I got it from <http://stackoverflow.com/questions/3039024/nsis-put-exe-version-into-name-of-installer#3040323>
/// </summary>
static void Main(string[] args)
{
try {
string inputFile = args[0];
string outputFile = args[1];
System.Diagnostics.FileVersionInfo fileInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(inputFile);
using (TextWriter writer = new StreamWriter(outputFile, false, Encoding.Default)) {
writer.WriteLine("!define VERSION \"" + fileInfo.FileVersion + "\"");
writer.WriteLine("!define DESCRIPTION \"" + fileInfo.FileDescription + "\"");
writer.WriteLine("!define COPYRIGHT \"" + fileInfo.LegalCopyright + "\"");
writer.Close();
}
string xmlFile = "version.xml";
XmlWriterSettings xws = new XmlWriterSettings();
xws.CloseOutput = true;
xws.ConformanceLevel = ConformanceLevel.Document;
xws.Indent = true;
xws.WriteEndDocumentOnClose = true;
using (XmlWriter writer = XmlWriter.Create(xmlFile)) {
writer.WriteStartDocument();
writer.WriteStartElement("RedBrick");
writer.WriteStartElement("version");
writer.WriteString(fileInfo.FileVersion);
writer.WriteEndElement();
writer.WriteStartElement("url");
writer.WriteString(@"file://\\AMSTORE-SVR-02\shared\shared\general\RedBrick\InstallRedBrick.exe");
writer.WriteEndElement();
string update_message = string.Empty;
using (TextReader tr = new StreamReader(Properties.Settings.Default.MessagePath)) {
update_message = tr.ReadToEnd();
}
writer.WriteStartElement("message");
writer.WriteString(update_message);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
} catch (Exception e) {
Console.WriteLine(e.Message + "\n\n");
Console.WriteLine("Usage: GetAssemblyInfoForNSIS.exe MyApp.exe MyAppVersionInfo.nsh\n");
}
}
示例2: RunTwitterApplication
//.........这里部分代码省略.........
List<Hook> HooksforExcel = Hooks.ToList<Hook>();
//ExcelFileWriter<Hook> myExcel = new ExcelWrite();
//myExcel.WriteDateToExcel(@"C:\TEMP\myExcel.xls", HooksforExcel, "A1", "D1");
// Landmark is detected by trackers
// Landmark is pushed to method for extracting content from DB
// This can happen either here or in openframeworks
// Once content is extracted it must be sequenced on the basis of :
// Time to play each item : Once one item is played for a certain preset amount of time extract the next from DB
// Time calculation in openframeworks:
// Update loop and draw loop
// The sensing modules exist on this side. So Hooks are selected here and published onto the interface between OF and Encounter#
// Hooks are read by OF and sequenced according to time parameters in OF
//Two kinds of time parameters in OF:
// Amount of time video must be played for
// Amount of time a hook should be shown for
// How does timing fit into the update and draw cycles?
// Use a timer, counting seconds until a value is reached
// Validation for time count can be executed at every loop update
// Update should contain a timing module where all the timing logic can be placed
// Objects required in OF
// OF has to handle video placement, playback and sequencing
// OF has to handle Hook placement, sequencing and timing
// OF has to handle visual blocks with animated elements
Console.WriteLine("Stream detection live now:");
stream_for_landmark.MatchingTweetReceived += (sender, arg) =>
{
// Storing the tweet
string tweet = arg.Tweet.ToString();
// Searching through tweet to find relevant landmark
Landmark detectedlandmark = Find_tweeted_landmark(Landmarks, tweet);
// Getting the hook categories that the landmark satisfies
string[] relevantHookCategories = detectedlandmark.Categories;
// Writing detected landmark to text file interface between here and OF
using (StreamWriter writer = new StreamWriter(rootdirectory + @"Project Encounter\Package\Config_Interfaces\TriggeredLandmark.txt", false))
{
writer.Write(detectedlandmark.Name);
}
// Selecting hooks that belong to the relevant categories corresponding to the landmark
List<Hook> RelevantHooks = new List<Hook>();
foreach (string category in relevantHookCategories)
{
RelevantHooks.AddRange((from item in Hooks
where item.category == category
select item).ToArray());
}
// Storing current sensor values
DayorNight = landingzone.DayOrNight();
Weather = Sensors.WeatherSense.SunnyOrCloudy();
// Further filtering hooks based on sensor values
List<Hook> RelevantHooksSensorFilters = new List<Hook>();
RelevantHooksSensorFilters.AddRange(from hook in RelevantHooks
where hook.timeofday.Contains(DayorNight) && hook.weather.Contains(Weather)
select hook);
// Writing the selected hooks to an XML to be read in by OF
using (XmlWriter writer = XmlWriter.Create(rootdirectory + @"Project Encounter\of_v0.8.4_vs_release\apps\myApps\OpenEncounters\bin\dataHooks.xml"))
{
writer.WriteStartDocument();
writer.WriteStartElement("Filtered_hooks");
foreach (Hook item in RelevantHooksSensorFilters)
{
writer.WriteStartElement("Hook");
writer.WriteElementString("text", item.text);
writer.WriteElementString("category", item.category);
writer.WriteElementString("weather", item.weather);
writer.WriteElementString("timeofday", item.timeofday);
writer.WriteElementString("font", item.font);
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndDocument();
}
Console.WriteLine(tweet);
Console.WriteLine();
Console.Write("Landmark Triggered:"); Console.Write(detectedlandmark.Name);
Console.WriteLine();
//System.Threading.Thread.Sleep(
//(int)System.TimeSpan.FromSeconds(30).TotalMilliseconds);
};
// Starting twitter stream detection
stream_for_landmark.StartStreamMatchingAllConditions();
}