Example #1
0
        public static bool SaveToStream(BinaryWriter outputWriter, Entity entity)
        {
            EntityStorage storage = new EntityStorage(string.Empty, entity);

            if (!storage.Write(outputWriter))
            {
                Debug.Assert(false, "Cannot write an entity file!");
                return(false);
            }

            return(true);
        }
Example #2
0
        public static bool SaveToFile(string filePath, Entity entity)
        {
            EntityStorage storage = new EntityStorage(filePath, entity);

            using (FileStream outputStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
            {
                using (BinaryWriter outputWriter = new BinaryWriter(outputStream, storage.Encoding))
                {
                    if (!storage.Write(outputWriter))
                    {
                        Debug.Assert(false, "Cannot write an entity file!");
                        return(false);
                    }
                }
            }

            return(true);
        }