示例#1
0
        public bool Save(string path)
        {
            bool success = serializableObject.Save(path);

            if (success)
            {
                this.HasChanges = false;
            }
            return(success);
        }
示例#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();
        }
示例#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);
     }
 }
示例#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()));
        }
示例#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);
            }
        }
示例#6
0
 public static void Export(Project project, string file)
 {
     file = Path.ChangeExtension(file, Constants.PROJECT_EXT);
     SerializableObject.Save(project, file);
 }
示例#7
0
 public void Save(string filePath)
 {
     SerializableObject.Save(this, filePath);
 }
示例#8
0
 public static void Export(Project project, string file)
 {
     file = Path.ChangeExtension(file, "lpr");
     SerializableObject.Save(project, file);
 }