Esempio n. 1
0
        public static void Serialize(this FileInfo file, Action <GenericWriter> handler, bool truncate)
        {
            if (file == null || handler == null)
            {
                return;
            }

            if (truncate)
            {
                file = file.EnsureFile(true);
            }

            Interlocked.Increment(ref _PendingWriters);

            VitaNexCore.TryCatch(
                () =>
            {
                using (FileStream stream = GetStream(file))
                {
                    GenericWriter writer = GetBinaryWriter(stream);
                    handler(writer);
                    writer.Close();
                }
            },
                VitaNexCore.ToConsole);

            Interlocked.Decrement(ref _PendingWriters);
        }
Esempio n. 2
0
 public void Serialize(GenericWriter gw)
 {
     gw.Write((int)0);
     gw.Write((int)this.Count);
     foreach (Account a in this)
     {
         a.Serialize(gw);
     }
     gw.Close();
 }
Esempio n. 3
0
 public virtual void Serialize(GenericWriter gw)
 {
     gw.Write((int)0);
     gw.Write((int)List.Count);
     foreach (Trajet t in this)
     {
         t.Serialize(gw);
     }
     gw.Close();
     Dirty = false;
 }
Esempio n. 4
0
        public static void WriteBlock <T>(this GenericWriter writer, Action <GenericWriter, T> onSerialize, T obj)
        {
            using (var ms = new MemoryStream())
            {
                GenericWriter w = ms.GetBinaryWriter();

                VitaNexCore.TryCatch(() => onSerialize(w, obj), VitaNexCore.ToConsole);

                w.Close();

                WriteLongBytes(writer, ms.ToArray());
            }
        }
Esempio n. 5
0
 public virtual void Serialize(GenericWriter gw)
 {
     gw.Write((int)0);
     foreach (GameObject m in this)
     {
         if (m.SpawnerLink == null)
         {
             gw.Write(1);
             m.Serialize(gw);
         }
     }
     gw.Write(0);
     gw.Close();
     dirty = false;
 }
Esempio n. 6
0
        public virtual void Serialize(GenericWriter gw)
        {
            gw.Write((int)0);
            foreach (BaseSpawner m in this)
            {
                gw.Write(1);
                if (m is MobileSpawner)
                {
                    gw.Write(0);
                }
                else
                {
                    gw.Write(1);
                }
                m.Serialize(gw);
            }
            gw.Write(0);
            gw.Write((int)World.regSpawners.Count);
            //Console.WriteLine("{0} spawn path", World.regSpawners.Count );
            IDictionaryEnumerator regcountEnumerator = World.regSpawners.GetEnumerator();

            while (regcountEnumerator.MoveNext())
            {
                if (regcountEnumerator.Value == null)
                {
                    continue;
                }
                gw.Write((int)regcountEnumerator.Key);
                gw.Write((int)(regcountEnumerator.Value as ArrayList).Count);
                foreach (int t in (regcountEnumerator.Value as ArrayList))
                {
                    gw.Write(t);
                }
            }
            gw.Close();
            dirty = false;
        }