private VideoFile(SerializationInfo info, DeserializeInfo di) : this(di.Server, di.Info, di.Type) { actors = info.GetValue("a", typeof(string[])) as string[]; description = info.GetString("de"); director = info.GetString("di"); genre = info.GetString("g"); title = info.GetString("t"); try { width = info.GetInt32("w"); height = info.GetInt32("h"); } catch (Exception) { } var ts = info.GetInt64("du"); if (ts > 0) { duration = new TimeSpan(ts); } try { bookmark = info.GetInt64("b"); } catch (Exception) { bookmark = 0; } try { subTitle = info.GetValue("st", typeof(Subtitle)) as Subtitle; } catch (Exception) { subTitle = null; } initialized = true; }
private AudioFile(SerializationInfo info, DeserializeInfo di) : this(di.Server, di.Info, di.Type) { album = info.GetString("al"); artist = info.GetString("ar"); genre = info.GetString("g"); performer = info.GetString("p"); title = info.GetString("ti"); try { track = info.GetInt32("tr"); } catch (Exception) { // no op } var ts = info.GetInt64("d"); if (ts > 0) { duration = new TimeSpan(ts); } initialized = true; }
private VideoFile(SerializationInfo info, DeserializeInfo di) : this(di.Server, di.Info, di.Type) { actors = info.GetValue("a", typeof(string[])) as string[]; description = info.GetString("de"); director = info.GetString("di"); genre = info.GetString("g"); try { lastpos = info.GetInt64("lp"); /* * if (lastpos > 0) * { * Error("LASTPOS FOR " + this.Path + " : " + (float)lastpos/(float)base.InfoSize*100.0); * } */ } catch (Exception) { lastpos = 0; } //title = info.GetString("t"); try { width = info.GetInt32("w"); height = info.GetInt32("h"); } catch (Exception) { } var ts = info.GetInt64("du"); if (ts > 0) { duration = new TimeSpan(ts); } try { bookmark = info.GetInt64("b"); } catch (Exception) { bookmark = 0; } try { //subTitle = info.GetValue("st", typeof(Subtitle)) as Subtitle; subTitle = new Subtitle(new System.IO.FileInfo(this.Path)); } catch (Exception) { subTitle = null; } try { this.tvshowid = info.GetInt32("tvid"); FetchTV(); } catch (Exception) { } Server.UpdateFileCache(this); initialized = true; }
private ImageFile(SerializationInfo info, DeserializeInfo di) : this(di.Server, di.Info, di.Type) { creator = info.GetString("cr"); description = info.GetString("d"); title = info.GetString("t"); width = info.GetInt32("w"); height = info.GetInt32("h"); initialized = true; }
/* ------------------ BaseFile serialize ------------------ * using (var s = new MemoryStream()) { * var ctx = new StreamingContext( * StreamingContextStates.Persistence, * null * ); * var formatter = new BinaryFormatter(null, ctx) { * TypeFormat = FormatterTypeStyle.TypesWhenNeeded, * AssemblyFormat = FormatterAssemblyStyle.Simple * }; * formatter.Serialize(s, file); * } */ /* * using (var s = new MemoryStream(data)) { * var ctx = new StreamingContext( * StreamingContextStates.Persistence, * new DeserializeInfo(null, info, DlnaMime.ImageJPEG) * ); * var formatter = new BinaryFormatter(null, ctx) { * TypeFormat = FormatterTypeStyle.TypesWhenNeeded, * AssemblyFormat = FormatterAssemblyStyle.Simple * }; * var rv = formatter.Deserialize(s) as Cover; * return rv; * } */ /* ------------------ Cover deserialize ------------------ * using (var s = new MemoryStream(data)) { * var ctx = new StreamingContext( * StreamingContextStates.Persistence, * new DeserializeInfo(null, info, DlnaMime.ImageJPEG) * ); * var formatter = new BinaryFormatter(null, ctx) { * TypeFormat = FormatterTypeStyle.TypesWhenNeeded, * AssemblyFormat = FormatterAssemblyStyle.Simple * }; * var rv = formatter.Deserialize(s) as Cover; * return rv; * } */ /* ------------------ BaseFile deserialize ------------------ * using (var s = new MemoryStream(data)) { * var ctx = new StreamingContext( * StreamingContextStates.Persistence, * new DeserializeInfo(server, info, type)); * var formatter = new BinaryFormatter(null, ctx) { * TypeFormat = FormatterTypeStyle.TypesWhenNeeded, * AssemblyFormat = FormatterAssemblyStyle.Simple * }; * var rv = formatter.Deserialize(s) as BaseFile; * rv.Item = info; * return rv; * } */ private static T Decode <T>(byte[] data, DeserializeInfo dinfo) where T : class { if (data == null) { return((T)null); } using (var s = new MemoryStream(data)) { var ctx = new StreamingContext(StreamingContextStates.Persistence, dinfo); var formatter = new BinaryFormatter(null, ctx) { TypeFormat = FormatterTypeStyle.TypesWhenNeeded, AssemblyFormat = FormatterAssemblyStyle.Simple }; return(formatter.Deserialize(s) as T); } }
private VideoFile(SerializationInfo info, DeserializeInfo di): this(di.Server, di.Info, di.Type) { this.actors = info.GetValue("a", typeof(string[])) as string[]; this.description = info.GetString("de"); this.director = info.GetString("di"); this.genre = info.GetString("g"); try { this.lastpos = info.GetInt64("lp"); } catch (Exception) { this.lastpos = 0; } try { this.width = info.GetInt32("w"); this.height = info.GetInt32("h"); } catch (Exception) { // ignored } var ts = info.GetInt64("du"); if (ts > 0) this.duration = new TimeSpan(ts); try { this.bookmark = info.GetInt64("b"); } catch (Exception) { this.bookmark = 0; } try { this.subTitle = new Subtitle(new FileInfo(this.Path)); } catch (Exception) { this.subTitle = null; } try { this.tvshowid = info.GetInt32("tvid"); this.FetchTV(); } catch (Exception) { // ignored } this.Server.UpdateFileCache(this); this._isMetaDataInitialized = true; }