public void DBSerializerConstructorTest() { DbSerializer serializer = new DbSerializer(); Assert.IsNotNull(serializer); Assert.IsNotNull(serializer.Context); }
private void MainForm_Load(object sender, EventArgs e) { string version = FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion; Text = string.Format("风月传说 v{0}", version); try { ConfigData.LoadData(); SystemMenuManager.Load(tabPageGame.Width, tabPageGame.Height); MainTipManager.Init(tabPageGame.Height); PanelManager.Init(tabPageGame.Width, tabPageGame.Height); DbSerializer.Init(); } catch (Exception ex) { NLog.Warn(ex); Close(); } tabPageLogin.BackgroundImage = PicLoader.Read("System", "logback.jpg"); passport = WorldInfoManager.LastAccountName; labelAccount.Text = string.Format("账户 {0}", passport); ChangePage(0); myCursor.ChangeCursor("default"); workThread = new Thread(TimeGo); workThread.IsBackground = true; workThread.Start(); }
public static void Save() { var dts = DbSerializer.CustomTypeToBytes(UserProfile.Profile, typeof(Profile)); C2SSender.Save(UserProfile.ProfileName, dts); WorldInfoManager.Save(); }
public static void SaveToDB() { WorldInfoManager.Save(); FileStream fs = new FileStream(string.Format("./Save/{0}.db", ProfileName), FileMode.OpenOrCreate); var dts = DbSerializer.CustomTypeToBytes(Profile, typeof(Profile)); fs.Write(dts, 0, dts.Length); fs.Close(); }
private static void WriteIntoTheStorage(ILog log, CentralinoConfiguration centralinoConfiguration, CentralinoLines allLines) { log.Info($"Starting to write all lines on storage {centralinoConfiguration.DbConfiguration.ConnectionString}"); (IEnumerable <Seq <Error> > errors, IEnumerable <ICentralinoLine> lines) = allLines.Lines.Partition(); DbSerializer dbSerializer = DbSerializer.From(centralinoConfiguration); dbSerializer.WriteAll(lines); foreach (Seq <Error> error in errors) { log.Warn(ErrorToString(error)); } log.Info($"End of writing to the storage {centralinoConfiguration.DbConfiguration.ConnectionString}"); }
public static bool LoadFromDB(string passport) { if (File.Exists(string.Format("./Save/{0}.db", passport))) { Profile = new Profile(); FileStream fs = new FileStream(string.Format("./Save/{0}.db", passport), FileMode.Open); byte[] dts = new byte[fs.Length]; fs.Read(dts, 0, dts.Length); object tmp; DbSerializer.BytesToCustomType(dts, out tmp, typeof(Profile)); Profile = (Profile)tmp; fs.Close(); return(true); } return(false); }
public void OnPacketLogin(PacketS2CLoginResult s2CLogin) { if (s2CLogin.SaveData.Length == 0) { UserProfile.Profile = new Profile(); UserProfile.Profile.Pid = s2CLogin.PlayerId; } else { object tmp; DbSerializer.BytesToCustomType(s2CLogin.SaveData, out tmp, typeof(Profile)); UserProfile.Profile = (Profile)tmp; TalePlayer.C2SSender.UpdatePlayerInfo(UserProfile.Profile.Name, UserProfile.Profile.InfoBasic.Head); } MainForm.Instance.LoginResult(); }
public static void ClassInitializeMethod(TestContext context) { string dbRelativePath = @"Database\TpaModelDatabase.mdf"; string testingWorkingFolder = Environment.CurrentDirectory; string dbPath = Path.Combine(testingWorkingFolder, dbRelativePath); AppDomain.CurrentDomain.SetData("DataDirectory", dbPath); var instance = SqlProviderServices.Instance; FileInfo databaseFile = new FileInfo(dbPath); Assert.IsTrue(databaseFile.Exists, $"{Environment.CurrentDirectory}"); _connectionString = $@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename={dbPath};Integrated Security = True;Connect Timeout = 30;"; Reflector ae = new Reflector(@"Database\TPA.ApplicationArchitecture.dll"); _assemblyModel = ae.AssemblyModel.ToModel(); ISerialization serialization = new DbSerializer(); serialization.Save(_assemblyModel, _connectionString); }