コード例 #1
0
 /// <summary>
 /// Writes a RouteSet to a .frt file.
 /// </summary>
 /// <param name="routeset">RouteSet to write.</param>
 /// <param name="outputPath">Path of the file to write.</param>
 public static void WriteRouteSet(RouteSet routeset, string outputPath)
 {
     using (var writer = new BinaryWriter(new FileStream(outputPath, FileMode.Create), getEncoding()))
     {
         Action <int> writeEmptyBytes = numberOfBytes => WriteEmptyBytes(writer, numberOfBytes);
         var          writeFunctions  = new WriteFunctions(writer.Write, writer.Write, writer.Write, writer.Write, writer.Write, writeEmptyBytes);
         Write(writeFunctions, routeset);
     }
 }
コード例 #2
0
 public void Write(Stream stream, object value)
 {
     if (value != null && WriteFunctions != null)
     {
         foreach (Type?type in WriteFunctions.Keys)
         {
             if (type.IsInstanceOfType(value))
             {
                 WriteFunctions[type](stream, value);
                 return;
             }
         }
     }
     if (value != null)
     {
         if (value is ImageSource)
         {
             bitmapSourceWriter.Write(stream, value);
         }
         else
         {
             if (value is DependencyObject)
             {
                 XmlWriter?xmlWriter = XmlWriter.Create(stream, new XmlWriterSettings
                 {
                     Indent = true
                 });
                 XamlWriter.Save(value, xmlWriter);
             }
             else
             {
                 if (value is XmlDocument)
                 {
                     (value as XmlDocument)?.Save(stream);
                 }
                 else
                 {
                     jsonWriter.Write(stream, value);
                 }
             }
         }
     }
 }