コード例 #1
0
        public SerUnit SaveUnit(string name, IFreeze root)
        {
            SerUnit su = new SerUnit();

            su.name = name;
            su.root = root;

            if (units.ContainsKey(name))
            {
                throw new InvalidOperationException("unit " + name + " exists");
            }

            bool   success = false;
            string file    = Path.Combine(Backend.obj_dir, Backend.prefix +
                                          name.Replace("::", ".") + ".ser");

            FreezeBuffer fb = new FreezeBuffer(this, su);

            units[name] = su;

            try {
                fb.String(signature);
                fb.Int(version);
                fb.ObjRef(root);

                byte[] data = fb.GetData();
                su.hash = NewHash().ComputeHash(data);
                File.WriteAllBytes(file, data);
                success = true;
            } finally {
                if (!success)
                {
                    UnloadUnit(name);
                }
            }

            return(su);
        }
コード例 #2
0
 void IFreeze.Freeze(FreezeBuffer fb)
 {
     fb.Byte((byte)SerializationCode.ReflectObj);
     fb.String(GetType().AssemblyQualifiedName);
     fb.Refs(GetData());
 }
コード例 #3
0
 public override void Freeze(Niecza.Serialization.FreezeBuffer fb)
 {
     throw new NotImplementedException();
 }