Beispiel #1
0
        internal void Save(DBMapping mapping)
        {
            using (MemoryStream mStream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(mStream))
                {
                    foreach (DBValue dbValue in mapping.Properties)
                    {
                        if (dbValue.Property.PropertyType.IsSubclassOf(typeof(DBObject)))
                        {
                            DBObject linkOb = (DBObject)dbValue.Property.GetValue(this);
                            dbValue.WriteValue(linkOb?.Index ?? 0, writer);
                        }
                        else
                        {
                            dbValue.WriteValue(dbValue.Property.GetValue(this), writer);
                        }
                    }
                    RawData = mStream.ToArray();
                }

            OnSaved();
        }
Beispiel #2
0
        internal void Save()
        {
            if (IsTemporary)
            {
                return;
            }

            //Disposing of Streams might be causing GC Collect on thread.

            if (SaveMemoryStream == null)
            {
                SaveMemoryStream = new MemoryStream();
            }

            if (SaveBinaryWriter == null)
            {
                SaveBinaryWriter = new BinaryWriter(SaveMemoryStream);
            }

            SaveMemoryStream.SetLength(0);

            foreach (DBValue dbValue in Collection.Mapping.Properties)
            {
                if (dbValue.Property.PropertyType.IsSubclassOf(typeof(DBObject)))
                {
                    DBObject linkOb = (DBObject)dbValue.Property.GetValue(this);
                    dbValue.WriteValue(linkOb?.Index ?? 0, SaveBinaryWriter);
                }
                else
                {
                    dbValue.WriteValue(dbValue.Property.GetValue(this), SaveBinaryWriter);
                }
            }

            RawData = SaveMemoryStream.ToArray();

            OnSaved();
        }
Beispiel #3
0
 internal override void Delete(DBObject ob)
 {
     Binding.Remove((T)ob);
 }
Beispiel #4
0
 internal abstract void Delete(DBObject ob);