Exemplo n.º 1
0
 public virtual void Serialization()
 {
     using (FileStream fs = new FileStream(FilePath, SerializationFileMode))
     {
         SerializationFormatter.Serialize(fs, this);
         Console.WriteLine("Object serialized");
     }
 }
Exemplo n.º 2
0
 public virtual object Deserialization(SecureMessenger o)
 {
     using (FileStream fs = new FileStream(FilePath, SerializationFileMode))
     {
         o = (SecureMessenger)SerializationFormatter.Deserialize(fs);
         Console.WriteLine("Object deserialized");
     }
     return(o);
 }
Exemplo n.º 3
0
        private async Task <T> Load <T>(Uri uri) where T : IBaseUri
        {
            log.Information("Loading {T} from {url}", typeof(T), uri);
            using (var mem = new MemoryStream())
            {
                await Downloader.Download(uri, mem);

                log.Debug("Deserializing");
                mem.Position = 0;
                var t = (T)SerializationFormatter.Deserialize(mem);
                t.BaseUri = new Uri(uri, ".");
                return(t);
            }
        }
			internal readonly FileTools.BinaryWriter2 binaryWriter; // the one of the Formatter when multiplexed.

			internal ChannelInfos(
				SerializationFormatter Formatter,
				Stream stream,
#if DEBUG
 string NameForDebugging,
#endif
 ChannelNumber ChannelNumber
)
			{
				this.stream = stream;

#if DEBUG
				this.NameForDebugging = NameForDebugging;
#endif
				this.ChannelNumber = ChannelNumber;


				this.streamWriterForText =
					Formatter.IsStringFormatter ?
					(Formatter.parameters.TheStreamingMode == StreamingModes.SetOfStreams ?
					new StreamWriter(stream)
					: Formatter.streamWriter)
					: null;

				this.binaryWriter =
					!Formatter.IsStringFormatter ?
					(Formatter.parameters.TheStreamingMode == StreamingModes.SetOfStreams ?
					new FileTools.BinaryWriter2(stream, Encoding.UTF8)
					: Formatter.binaryWriter)
					: null;
			}