Ejemplo n.º 1
0
        public bool Save(string path)
        {
            bool success = serializableObject.Save(path);

            if (success)
            {
                this.HasChanges = false;
            }
            return(success);
        }
Ejemplo n.º 2
0
        void SaveObject(string table, string id, object obj, bool update)
        {
            byte[]           data;
            string           sql  = "";
            SqliteConnection conn = new SqliteConnection("URI=file:" + dbFile);

            conn.Open();

            using (var cmd = conn.CreateCommand())
            {
                using (MemoryStream stream = new MemoryStream()) {
                    SerializableObject.Save(obj, stream);
                    data = stream.ToArray();
                }
                if (update)
                {
                    sql = String.Format("UPDATE {0} SET Data=@data WHERE id='{1}'", table, id);
                }
                else
                {
                    sql = String.Format("INSERT INTO {0} ([ID], [Data]) VALUES('{1}', @data)", table, id);
                }
                cmd.CommandText = sql;
                cmd.Parameters.Add("@data", DbType.Binary, data.Length).Value = data;
                cmd.ExecuteNonQuery();
            }
            conn.Close();
        }
Ejemplo n.º 3
0
 public static void Save()
 {
     try {
         SerializableObject.Save(state, Config.ConfigFile, SerializableObject.SerializationType.Xml);
     } catch (Exception ex) {
         Log.Error("Errro saving config");
         Log.Exception(ex);
     }
 }
Ejemplo n.º 4
0
        public void AddProject(Project project)
        {
            string path = Path.Combine(project_path, project.UUID.ToString());

            project.Description.LastModified = DateTime.Now;
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            SerializableObject.Save(project, path);
            SerializableObject.Save(project.Description, Path.Combine(desc_path, project.UUID.ToString()));
        }
Ejemplo n.º 5
0
        public void TestCase()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "default.ltt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName)) {
                TeamTemplate template = SerializableObject.Load <TeamTemplate> (stream, SerializationType.Binary);
                var          cstream  = new MemoryStream();
                SerializableObject.Save(template, cstream, SerializationType.Json);
                cstream.Seek(0, SeekOrigin.Begin);
                var jsonString = new StreamReader(cstream).ReadToEnd();
                Console.WriteLine(jsonString);
            }
        }
Ejemplo n.º 6
0
 public static void Export(Project project, string file)
 {
     file = Path.ChangeExtension(file, Constants.PROJECT_EXT);
     SerializableObject.Save(project, file);
 }
Ejemplo n.º 7
0
 public void Save(string filePath)
 {
     SerializableObject.Save(this, filePath);
 }
Ejemplo n.º 8
0
 public static void Export(Project project, string file)
 {
     file = Path.ChangeExtension(file, "lpr");
     SerializableObject.Save(project, file);
 }