public override global::System.Data.DataSet Clone() { MediaDataSet cln = ((MediaDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { MediaDataSet ds = new MediaDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public MediaInfoKeeper(String p_version, String p_fileFolder) { version = p_version; ds = new MediaDataSet(); folder = p_fileFolder; if ((folder.Length > 0) && (!(folder.EndsWith(Path.DirectorySeparatorChar.ToString())))) { folder += Path.DirectorySeparatorChar; } if (Parameters.IgnoreWhenLocked) { SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { MediaDataSet ds = new MediaDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
private void UpdateRatings(MediaDataSet.TracksRow track, MediaDataSet.AlbumsRow album, MediaDataSet.ArtistsRow artist, MediaDataSet.GenresRow genre, RatingDelta delta) { track.Rating = UpdateRating(track.Rating, delta.Track); album.Rating = UpdateRating(album.Rating, delta.Album); artist.Rating = UpdateRating(artist.Rating, delta.Artist); genre.Rating = UpdateRating(genre.Rating, delta.Genre); }
/// <summary> /// Load media data from XML file /// </summary> public void Load() { try { ds.ReadXml(folder + Consts.Files.RatingFile); } catch (Exception e) { Log.Write(e); ds = new MediaDataSet(); } if (ds.System.Count != 1) { Log.Write(String.Format("System table contains wrong number of rows - [{0}] instead of one, replacing it with defaults", ds.System.Count)); // we could convert from previous versions.... // actually this could mean, that we have too old data set... ds.System.Clear(); MediaDataSet.SystemRow s = ds.System.NewSystemRow(); s.ApplicationVersion = version; s.DataSetVersion = Consts.DataSetVersion; ds.System.AddSystemRow(s); ds.AcceptChanges(); } // now we should have single entry if (ds.System[0].DataSetVersion < Consts.DataSetVersion) { // TODO: consider conversion from old versions Log.Write(String.Format("DataSet has version [{0}] instead of [{1}], upgrading DataSet...", ds.System[0].DataSetVersion, Consts.DataSetVersion)); ds.System[0].DataSetVersion = Consts.DataSetVersion; } else if (ds.System[0].DataSetVersion != Consts.DataSetVersion) { Log.Write(String.Format("DataSet has version [{0}] instead of [{1}], possible data loss!", ds.System[0].DataSetVersion, Consts.DataSetVersion)); ds.System[0].DataSetVersion = Consts.DataSetVersion; } if (!(ds.System[0].ApplicationVersion.Equals(version))) { ds.System[0].ApplicationVersion = version; Log.Write(String.Format("Application version is [{0}] instead of [{1}]", ds.System[0].ApplicationVersion, version)); } }
//constructor public MediaDataAccessObject() { _mediaDataSet = new MediaDataSet(); _mediaTabTableAdapter = new TabMediaTableAdapter(); }