static void load_preferences() { try { Assembly ass = Assembly.GetEntryAssembly(); string root_dir = FileName.Directory(ass.Location); string filename = root_dir + "Preferences.xml"; if (File.Exists(filename)) { SplashScreen.CurrentAction = "Loading user preferences"; Preferences prefs = Serialisation <Preferences> .Load(filename, SerialisationMode.XML); if (prefs != null) { Session.Preferences = prefs; } } } catch (Exception ex) { LogSystem.Trace(ex); } }
private void AddImportProject_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = Program.ProjectFilter; if (dlg.ShowDialog() == DialogResult.OK) { Project p = Serialisation <Project> .Load(dlg.FileName, SerialisationMode.Binary); if (p != null) { RegionalMapSelectForm map_dlg = new RegionalMapSelectForm(p.RegionalMaps, null, true); if (map_dlg.ShowDialog(this) != DialogResult.OK) { return; } Session.Project.RegionalMaps.AddRange(map_dlg.Maps); Session.Modified = true; update_maps(); } } }
public static Project LoadBackup(string filename) { Project p = null; try { Assembly ass = Assembly.GetEntryAssembly(); string dir = Tools.FileName.Directory(ass.Location) + "Backup\\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string backup_name = dir + Tools.FileName.Name(filename); if (File.Exists(backup_name)) { p = Serialisation <Project> .Load(backup_name, SerialisationMode.Binary); if (p != null) { string str = "There was a problem opening this project; it has been recovered from its most recent backup version."; MessageBox.Show(str, "Masterplan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { LogSystem.Trace(ex); } return(p); }
public static Masterplan.Data.Project LoadBackup(string filename) { Masterplan.Data.Project project = null; try { Assembly entryAssembly = Assembly.GetEntryAssembly(); string str = string.Concat(Utils.FileName.Directory(entryAssembly.Location), "Backup\\"); if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } string str1 = string.Concat(str, Utils.FileName.Name(filename)); if (File.Exists(str1)) { project = Serialisation <Masterplan.Data.Project> .Load(str1, SerialisationMode.Binary); if (project != null) { MessageBox.Show("There was a problem opening this project; it has been recovered from its most recent backup version.", "Masterplan", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } catch (Exception exception) { LogSystem.Trace(exception); } return(project); }
public void EregisterUtilisateur(Utilisateur utilisateur) { var chemin = $"{Directory.GetCurrentDirectory()}\\{"Utilisateur"}"; this.utilisateurs.Add(utilisateur); Serialisation <Utilisateur> .Srialisation(chemin, utilisateurs); }
public void Save <T>(T obj) { var xml = Serialisation.SerializeObject <T>(obj); var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SavedCanvas.xml"); File.WriteAllText(path, xml); }
public static Library LoadLibrary(string filename) { try { if (Program.SplashScreen != null) { Program.SplashScreen.CurrentSubAction = Tools.FileName.Name(filename); Program.SplashScreen.Progress += 1; } Library lib = Serialisation <Library> .Load(filename, SerialisationMode.Binary); if (lib != null) { lib.Name = Tools.FileName.Name(filename); lib.Update(); Session.Libraries.Add(lib); } else { LogSystem.Trace("Could not load " + Tools.FileName.Name(filename)); } return(lib); } catch (Exception ex) { LogSystem.Trace(ex); } return(null); }
private void FileImport_Click(object sender, EventArgs e) { if (MessageBox.Show("Importing an artifact file will clear any changes you have made to the item shown.", "Masterplan", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Cancel) { return; } OpenFileDialog openFileDialog = new OpenFileDialog() { Title = "Import Artifact", Filter = Program.ArtifactFilter }; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Masterplan.Data.Artifact artifact = Serialisation <Masterplan.Data.Artifact> .Load(openFileDialog.FileName, SerialisationMode.Binary); if (artifact != null) { this.fArtifact = artifact; this.update_statblock(); return; } MessageBox.Show("The artifact could not be imported.", "Masterplan", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
private static void HandleDequeue() { if (_StartedThreads >= STAGING_DEQUEUE_THREADS) { return; } _StartedThreads++; while (true) { BasicDeliverEventArgs ea = RabbitMq.RabbitMqManager.Dequeue(RabbitMqManager.RabbitMqQueue.InboundStaging, 1, 100).FirstOrDefault(); if (ea == null) { Thread.Sleep(1000); continue; } MtaQueuedMessage qmsg = Serialisation.Deserialise <MtaQueuedMessage>(ea.Body); MtaMessage msg = new MtaMessage(qmsg.ID, qmsg.VirtualMTAGroupID, qmsg.InternalSendID, qmsg.MailFrom, qmsg.RcptTo, string.Empty); RabbitMqManager.Publish(msg, RabbitMqManager.RabbitMqQueue.Inbound, true); RabbitMqManager.Publish(qmsg, RabbitMqManager.RabbitMqQueue.OutboundWaiting, true); RabbitMqManager.Ack(RabbitMqManager.RabbitMqQueue.InboundStaging, ea.DeliveryTag, false); } }
public void ExtractByteData(Action <byte[]> callback) { Debug.Log("ExtractByteData from " + allEvents.Count + " events"); IEvent[] array = allEvents.ToArray(); byte[] binary = Serialisation.ToBinary(array); callback.Invoke(binary); }
private void FileImport_Click(object sender, EventArgs e) { string msg = "Importing an artifact file will clear any changes you have made to the item shown."; if (MessageBox.Show(msg, "Masterplan", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel) { return; } OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Import Artifact"; dlg.Filter = Program.ArtifactFilter; if (dlg.ShowDialog() == DialogResult.OK) { Artifact a = Serialisation <Artifact> .Load(dlg.FileName, SerialisationMode.Binary); if (a != null) { fArtifact = a; update_statblock(); } else { string error = "The artifact could not be imported."; MessageBox.Show(error, "Masterplan", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void HandleDequeue() { while (!IsStopping) { BasicDeliverEventArgs ea = RabbitMq.RabbitMqManager.Dequeue(RabbitMqManager.RabbitMqQueue.InboundStaging, 1, 100).FirstOrDefault(); if (ea == null) { //await Task.Delay(1000); System.Threading.Thread.Sleep(1000); continue; } MtaQueuedMessage qmsg = Serialisation.Deserialise <MtaQueuedMessage>(ea.Body).Result; MtaMessage msg = new MtaMessage { ID = qmsg.ID, InternalSendID = qmsg.InternalSendID, MailFrom = qmsg.MailFrom, RcptTo = qmsg.RcptTo, VirtualMTAGroupID = qmsg.VirtualMTAGroupID }; RabbitMqManager.Publish(msg, RabbitMqManager.RabbitMqQueue.Inbound, true, qmsg.RabbitMqPriority).Wait(); RabbitMqManager.Publish(qmsg, RabbitMqManager.RabbitMqQueue.OutboundWaiting, true, qmsg.RabbitMqPriority).Wait(); RabbitMqManager.Ack(RabbitMqManager.RabbitMqQueue.InboundStaging, ea.DeliveryTag, false); } }
public static T FromJson <T>(string json) { try { T result = Serialisation.FromJson <T>(json); return(result); } catch (ArgumentException ex) when(json.Contains("ORA-04030")) { throw new CistException("Cist returned \"out of process memory\" exception", CistExceptionStatus.OutOfMemory, ex); } catch (ArgumentException ex) when(json.Contains("ORA-01089")) { throw new CistException("Cist returned \"immediate shutdown in progress - no operations permitted\" exception", CistExceptionStatus.ShutdownInProgress, ex); } catch (ArgumentException ex) when(json.Contains("ORA-01652")) { throw new CistException("Cist returned \"unable to extend temp segment\" exception", CistExceptionStatus.UnableToExtendTempSegment, ex); } catch (ArgumentException ex) when(json.Contains("ORA-08103")) { throw new CistException("Cist returned \"object no longer exists\" exception", CistExceptionStatus.ObjectNoLongerExists, ex); } catch (ArgumentException ex) when(Regex.IsMatch(json, @"ORA-\d+")) { Match match = Regex.Match(json, @"ORA-\d+"); ex.Data.Add("Status", match.Value); throw new CistException($"Cist returned \"Oracle exception: {match.Value}\" exception", CistExceptionStatus.UnknownError, ex); } }
public static Library LoadLibrary(string filename) { Library library; try { if (Program.SplashScreen != null) { Program.SplashScreen.CurrentSubAction = Utils.FileName.Name(filename); ProgressScreen splashScreen = Program.SplashScreen; splashScreen.Progress = splashScreen.Progress + 1; } string str = Program.SimplifySecurityData(Program.SecurityData); Library library1 = Serialisation <Library> .Load(filename, SerialisationMode.Binary); if (library1 == null) { LogSystem.Trace(string.Concat("Could not load ", Utils.FileName.Name(filename))); } else { library1.Name = Utils.FileName.Name(filename); library1.Update(); if (Program.CopyProtection) { if (library1.SecurityData == null || library1.SecurityData == "") { library1.SecurityData = str; if (!Serialisation <Library> .Save(filename, library1, SerialisationMode.Binary)) { LogSystem.Trace(string.Concat("Could not save ", library1.Name)); } } string str1 = Program.SimplifySecurityData(library1.SecurityData); if (str1 != str) { string[] name = new string[] { "Could not load ", library1.Name, ": ", str1, " vs ", str }; LogSystem.Trace(string.Concat(name)); Session.DisabledLibraries.Add(library1.Name); library = null; return(library); } } else if (library1.SecurityData != "") { library1.SecurityData = ""; Serialisation <Library> .Save(filename, library1, SerialisationMode.Binary); } Session.Libraries.Add(library1); } library = library1; } catch (Exception exception) { LogSystem.Trace(exception); return(null); } return(library); }
public T Load <T>() { var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "SavedCanvas.xml"); var xml = File.ReadAllText(path); var obj = (T)Serialisation.DeserializeObject <T>(xml); return(obj); }
public void SendEntityMod(IEntityModifier m) { object[] args = new object[] { Serialisation.ToBinary(m.e), // Assume that the entity is not serialised with the modifier Serialisation.ToBinary(m) }; View.RPC("DoEntityDependentMod", PhotonTargets.All, args); }
private void DoIndependentMod(byte[] binary) { IIndependentModifier m = Serialisation.To <IIndependentModifier>(binary); PingSimulator.Delay(() => { EM.ApplyMod(m, DistributeBetweenPlayersAsyncFilter); }); }
// Token: 0x06000146 RID: 326 RVA: 0x00009D88 File Offset: 0x00007F88 public static T DeserialiseStruct <T>(string xmlString) { if (Serialisation.isVerbose) { Debug.Log("Deserialising using the string method, now passing control to the byte converter."); } return(Serialisation.DeserialiseStruct <T>(new UTF8Encoding().GetBytes(xmlString))); }
public MetaDaemonApi(RpcConfig bitsharesConfig, RpcConfig bitcoinConfig, string bitsharesAccount, string databaseName, string databaseUser, string databasePassword, string listenAddress, string bitcoinFeeAddress, string bitsharesFeeAccount, string adminUsernames, string masterSiteUrl, string masterSiteIp, AsyncPump scheduler) : base(bitsharesConfig, bitcoinConfig, bitsharesAccount, adminUsernames, databaseName, databaseUser, databasePassword) { m_bitshaaresFeeAccount = bitsharesFeeAccount; m_bitcoinFeeAddress = bitcoinFeeAddress; m_masterSiteUrl = masterSiteUrl.TrimEnd('/'); m_scheduler = scheduler; ServicePointManager.ServerCertificateValidationCallback = Validator; Serialisation.Defaults(); // don't ban on exception here because we'll only end up banning the webserver! m_server = new ApiServer <IDummyDaemon>(new string[] { listenAddress }, null, false, eDdosMaxRequests.Ignore, eDdosInSeconds.One); m_api = new SharedApi <IDummyDaemon>(m_dataAccess); m_server.ExceptionEvent += m_api.OnApiException; // only allow the main site to post to us m_server.SetIpLock(masterSiteIp); m_marketHandlers = new Dictionary <string, MarketBase>(); // get all market pegged assets List <BitsharesAsset> allAssets = m_bitshares.BlockchainListAssets("", int.MaxValue); m_allBitsharesAssets = allAssets.ToDictionary(a => a.id); Dictionary <int, BitsharesAsset> peggedAssets = allAssets.Where(a => a.issuer_id <= 0).ToDictionary(a => a.id); // get all active markets containing those assets m_allDexMarkets = m_bitshares.BlockchainListMarkets().Where(m => m.last_error == null && peggedAssets.ContainsKey(m.base_id) && peggedAssets.ContainsKey(m.quote_id)).ToList(); m_allCurrencies = m_dataAccess.GetAllCurrencies(); List <MarketRow> markets = GetAllMarkets(); foreach (MarketRow r in markets) { m_marketHandlers[r.symbol_pair] = CreateHandlerForMarket(r); } m_server.HandlePostRoute(Routes.kSubmitAddress, OnSubmitAddress, eDdosMaxRequests.Ignore, eDdosInSeconds.Ignore, false); m_server.HandleGetRoute(Routes.kGetAllMarkets, OnGetAllMarkets, eDdosMaxRequests.Ignore, eDdosInSeconds.Ignore, false); }
protected static void AddLibrary(string fileName) { Library library; library = Serialisation <Library> .Load(fileName, SerialisationMode.Binary); Assert.IsNotNull(library, "Missing library : " + fileName); Libraries.Add(library); }
public void ResetWithByteData(byte[] data) { IEvent[] array = Serialisation.To <IEvent[]>(data); Debug.Log("ResetWithByteData with " + array.Length + " events"); Reset(); for (int i = 0; i < array.Length; i++) // Ignore interval data for now { RegisterEvent(array[i]); } }
private void CheckIn(byte[] data) { var modules = Agent.AgentModules.ToList(); foreach (var module in modules) { if (module.NotifyTeamServer) { Agent.SendModuleData("Core", "RegisterAgentModule", Serialisation.SerialiseData(module)); } } }
private void DataFromTeamServer(byte[] data) { try { var packet = Serialisation.DeserialiseData <ReversePortForwardPacket>(Convert.FromBase64String(Encoding.UTF8.GetString(data))); InboundPackets.Add(packet); } catch (Exception e) { Agent.SendError(e.Message); } }
public void Update() { if (Contact.Count() != 0) { Serialisation.Serialiser(Contact, chemin); Contact = (List <Model.Contact>)Serialisation.Deserialiser(chemin); } else { File.Delete(chemin); } }
private void DataFromTeamServer(byte[] data) { try { var packet = Serialisation.DeserialiseData <ReversePortForwardPacket>(data); InboundPackets.Add(packet); } catch (Exception e) { Agent.SendError(e.Message); } }
public MainViewModel(INavigationService navigationService) { this.navigationService = navigationService; MessengerInstance.Register <NotificationMessage>(this, ReceiveMessage); Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; string folderPath = localFolder.Path; chemin = Path.Combine(folderPath, @"Contact.bin"); if (File.Exists(chemin) == true) { Contact = (List <Model.Contact>)Serialisation.Deserialiser(chemin); } }
public void ReceiveMessage(NotificationMessage notificationMessage) { string notification = notificationMessage.Notification; if (notification == "ajouterContact") { if (File.Exists(chemin) == true) { Contact = (List <Model.Contact>)Serialisation.Deserialiser(chemin); } } //do your work }
private void Start() { var canInteractLoadBtn = Serialisation.HasCurrentSave(); buttonContainer = transform.Find("ButtonContainer"); startButton = buttonContainer.Find("Start").GetComponent <Button>(); loadButton = buttonContainer.Find("Load").GetComponent <Button>(); options = buttonContainer.Find("Options").GetComponent <Button>(); loadButton.interactable = canInteractLoadBtn; startButton.onClick.AddListener(OnStart); loadButton.onClick.AddListener(OnLoad); }
private static void save_preferences() { try { string str = FileName.Directory(Assembly.GetEntryAssembly().Location); string str1 = string.Concat(str, "Preferences.xml"); Serialisation <Preferences> .Save(str1, Session.Preferences, SerialisationMode.XML); } catch (Exception exception) { LogSystem.Trace(exception); } }
public void CanSerliaiseTable() { var serialiser = new Serialisation(); var generator = new TableGenerator(new GeneratorSettings { CharacterString = Alphabet.English, Size = 1000 }); var table = generator.Generate(); var result = serialiser.Serliaise(table); var key = table.ForwardTable[0].Keys.ToList()[0]; var expectedText = "{\"ForwardTable\":{\"columns\":[{\"rows\":[{\"f\":" + (int)key + ",\"t\":" + (int)table.ForwardTable[0][key].Item1 + ",\"n\":" + table.ForwardTable[0][key].Item2 + "},"; Assert.IsTrue(result.Contains(expectedText)); }