/* CONSTRUCTOR */ void Awake() { if (_instance == null) { _instance = this; GameObject.DontDestroyOnLoad(gameObject); } else { GameObject.Destroy(gameObject); } }
/// <inheritdoc /> public override void Init(ITorchBase torch) { base.Init(torch); string path = Path.Combine(StoragePath, "Essentials.cfg"); Log.Info($"Attempting to load config from {path}"); _config = Persistent <EssentialsConfig> .Load(path); _sessionManager = Torch.Managers.GetManager <TorchSessionManager>(); if (_sessionManager != null) { _sessionManager.SessionStateChanged += SessionChanged; } else { Log.Warn("No session manager. MOTD won't work"); } homeDataPath = Path.Combine(StoragePath, "players.json"); if (!File.Exists(homeDataPath)) { File.Create(homeDataPath); } rankDataPath = Path.Combine(StoragePath, "ranks.json"); if (!File.Exists(rankDataPath)) { File.Create(rankDataPath); } Instance = this; _pm = torch.Managers.GetManager <PatchManager>(); _context = _pm.AcquireContext(); SessionDownloadPatch.Patch(_context); if (Config.CutGameTags) { GameTagsPatch.Patch(_context); } }
/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { Layout.Clear(); fontSizes = GUIArrayField <int, FontSizeArrayRow> .Create( new LocEdString("Font sizes"), importOptions.FontSizes, Layout); fontSizes.OnChanged += x => importOptions.FontSizes = x; fontSizes.IsExpanded = Persistent.GetBool("fontSizes_Expanded"); fontSizes.OnExpand += x => Persistent.SetBool("fontSizes_Expanded", x); charRanges = GUIArrayField <CharRange, CharRangeArrayRow> .Create( new LocEdString("Character ranges"), importOptions.CharIndexRanges, Layout); charRanges.OnChanged += x => importOptions.CharIndexRanges = x; charRanges.IsExpanded = Persistent.GetBool("charRanges_Expanded"); charRanges.OnExpand += x => Persistent.SetBool("charRanges_Expanded", x); renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode")); renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x; boldField = new GUIToggleField(new LocEdString("Bold")); boldField.OnChanged += x => importOptions.Bold = x; italicField = new GUIToggleField(new LocEdString("Italic")); italicField.OnChanged += x => importOptions.Italic = x; dpiField = new GUIIntField(new LocEdString("DPI")); dpiField.OnChanged += x => importOptions.Dpi = x; Layout.AddElement(renderModeField); Layout.AddElement(boldField); Layout.AddElement(italicField); Layout.AddElement(dpiField); Layout.AddSpace(10); reimportButton = new GUIReimportButton(InspectedResourcePath, Layout, () => { ProjectLibrary.Reimport(InspectedResourcePath, importOptions, true); }); UpdateGUIValues(); }
public static void OnStartup() { try { Persistent.Load(); Access.Initialize(); Textures.Initialize(); IntegrationManager.Initialize(); CompatibilityManager.Initialize(); } catch (System.Exception exception) { var info = new ExceptionInfo(exception); Error("RimHUD was unable to initialize properly due to the following exception:\n" + info.Text); State.Activated = false; Harmony.UnpatchAll(); } }
protected virtual bool CRUDActionDone(ICRUDForm form, CRUDAction action, Persistent persistentObject) { SetBusy(); bool result = ValidateCRUD(action, persistentObject, form.ErrorMessages); if (result) { if (PersistOnCRUDDone) { result = PersistCRUD(action, persistentObject, form.ErrorMessages); } if (result) { RefreshGridAfterCRUD(action); } } ClearBusy(); return(result); }
/// <inheritdoc/> public override T GetValue(Persistent obj) { var field = Field; int fieldIndex = field.MappingInfo.Offset; var tuple = obj.Tuple; TupleFieldState state; var value = tuple.GetValue(fieldIndex, out state); if (!state.HasValue()) { return((T)@default); } if (type.IsEnum) { return((T)Enum.ToObject(type, value)); } return((T)Enum.ToObject(Nullable.GetUnderlyingType(type), value)); }
// Use this for initialization private void Awake() { persistentMgr = GetComponent <Persistent>(); buttonLogin = GameObject.Find("ButtonLogin").GetComponent <Button>(); buttonMonoStereo = GameObject.Find("ButtonMonoStereo").GetComponent <Button>(); buttonCreds = GameObject.Find("ButtonCredentials").GetComponent <Button>(); imageBackground = GameObject.Find("Credentials").GetComponent <UnityEngine.UI.Image>(); inputEmail = GameObject.Find("Email").GetComponent <InputField>(); inputFirst = GameObject.Find("First").GetComponent <InputField>(); inputLast = GameObject.Find("Last").GetComponent <InputField>(); textFps = GameObject.Find("TextFps").GetComponent <Text>(); buttonLogin.onClick.AddListener(ButtonLoginClicked); buttonMonoStereo.onClick.AddListener(ButtonMonoStereoClicked); buttonCreds.onClick.AddListener(ButtonCredsClicked); CheckIfEditor(); imageBackground.gameObject.SetActive(false); CheckIfNeeded(); InvokeRepeating("UpdateFps", 1, 1); }
public override void Init(ITorchBase torch) { base.Init(torch); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); UpdateMePlugin.Log.Warn("Loading UpdateMe config."); bool initializeConfig = !File.Exists(Path.Combine(base.StoragePath, "UpdateMe.cfg")); this._config = Persistent <UpdateMePluginConfig> .Load(Path.Combine(base.StoragePath, "UpdateMe.cfg"), true); if (initializeConfig) { this._config.Data.Enabled = true; this._config.Data.LogEnabled = true; this._config.Data.RestartForNewTorchVersion = true; this._config.Data.MessageForNewTorchVersion = "A new Torch version has been found!"; this._config.Data.RestartForNewDSVersion = true; this._config.Data.MessageForNewDSVersion = "A new Space Engineers DS version has been found!"; this._config.Data.RestartInMinutes = 2; this._config.Data.CheckFrequencyInMinutes = 5; } this._config.Save(); this._config.Data.SetLoaded(this); UpdateMePlugin.Log.Debug("UpdateMe config loaded."); /* * try * { * GameVersion = new MyVersion(MyPerGameSettings.BasicGameInfo.GameVersion.Value); * } * catch (Exception ex) * { * Util.Log(string.Concat("UpdateMe catched an exception! - MyVersion", ex, ex.StackTrace)); * } */ myTimer = new Timer(); myTimer.Enabled = false; UpdateMePlugin.Instance = this; }
/// <inheritdoc /> public override void Init(ITorchBase torch) { base.Init(torch); string path = Path.Combine(StoragePath, "Essentials.cfg"); Log.Info($"Attempting to load config from {path}"); _config = Persistent <EssentialsConfig> .Load(path); _sessionManager = Torch.Managers.GetManager <TorchSessionManager>(); if (_sessionManager != null) { _sessionManager.SessionStateChanged += SessionChanged; } else { Log.Warn("No session manager. MOTD won't work"); } Instance = this; }
private void SetupConfig() { var configFile = Path.Combine(StoragePath, "HeadHunterConfig.cfg"); try { _config = Persistent <HeadHunterConfig> .Load(configFile); } catch (Exception e) { Log.Warn(e); } if (_config?.Data == null) { //Log.Info("Create Default Config, because none was found!"); _config = new Persistent <HeadHunterConfig>(configFile, new HeadHunterConfig()); _config.Save(); } }
// Use this for initialization of base class public void InitTest() { goWorld = GameObject.Find("World" + GetType()); Debug.Log("world " + goWorld.name + "\n"); goImageMarker = GameObject.Find("ImageMarker"); audioMgr = GetComponent <Audio>(); cam = GameObject.Find("ARCamera"); goHandle = GameObject.Find("Handle"); quizzyMgr = GetComponent <Quizzy>(); lobbyMgr = GetComponent <Lobby>(); postMgr = GetComponent <Post>(); trackMgr = GetComponent <Track>(); assetMgr = GetComponent <Asset>(); messageMgr = GetComponent <Message>(); udpMgr = GetComponent <Udp>(); persistentMgr = GetComponent <Persistent>(); replayMgr = GetComponent <Replay>(); buttonsMgr = GetComponent <Buttons>(); goWorld.SetActive(false); }
public virtual void Journal_should_serialize_Persistent_with_string_manifest() { var probe = CreateTestProbe(); var persistentEvent = new Persistent(new TestJournal.MyPayload2("b", 5), 1L, Pid, null, false, null, WriterGuid); var messages = new List <AtomicWrite> { new AtomicWrite(persistentEvent) }; Journal.Tell(new WriteMessages(messages, probe.Ref, ActorInstanceId)); probe.ExpectMsg <WriteMessagesSuccessful>(); probe.ExpectMsg <WriteMessageSuccess>(m => m.ActorInstanceId == ActorInstanceId && m.Persistent.PersistenceId == Pid); Journal.Tell(new ReplayMessages(0, long.MaxValue, long.MaxValue, Pid, probe.Ref)); probe.ExpectMsg <ReplayedMessage>(s => s.Persistent.PersistenceId == persistentEvent.PersistenceId && s.Persistent.SequenceNr == persistentEvent.SequenceNr && s.Persistent.Payload.AsInstanceOf <TestJournal.MyPayload2>().Data.Equals(".b.")); probe.ExpectMsg <RecoverySuccess>(); }
public override void Init(ITorchBase torch) { base.Init(torch); try { Settings = Persistent <Settings> .Load(Path.Combine(StoragePath, "Concealment.cfg")); } catch (Exception e) { Log.Warn(e); } if (Settings?.Data == null) { Settings = new Persistent <Settings>(Path.Combine(StoragePath, "Concealment.cfg"), new Settings()); } Settings.Data.PropertyChanged += Data_PropertyChanged; _concealedAabbTree = new MyDynamicAABBTreeD(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION); RegisterEntityStorage("Concealment", Id); torch.Managers.GetManager <ITorchSessionManager>()?.AddFactory(CreateManager); }
private IPersistentRepresentation GetPersistentRepresentation(PersistentMessage message) { IActorRef sender = ActorRefs.NoSender; if (message.Sender != null) { sender = system.Provider.ResolveActorRef(message.Sender); } var repr = new Persistent( GetPayload(message.Payload), message.SequenceNr, message.PersistenceId, message.Manifest, message.Deleted, sender, message.WriterGuid); return(message.Timestamp > 0L ? repr.WithTimestamp(message.Timestamp) : repr); }
private void Save() { var xe = new XElement(LayoutPreset.RootElementName); xe.Add(new XAttribute(LayoutPreset.VersionAttributeName, Mod.Version)); if (_includeDocked) { xe.Add(HudLayout.Docked.ToXml(HudLayout.DockedElementName, _includeHeight ? Theme.InspectPaneHeight.Value : -1, _includeWidth ? Theme.InspectPaneTabWidth.Value : -1, _includeTabs ? Theme.InspectPaneMinTabs.Value : -1)); } if (_includeFloating) { xe.Add(HudLayout.Floating.ToXml(HudLayout.FloatingElementName, _includeHeight ? Theme.HudHeight.Value : -1, _includeWidth ? Theme.HudWidth.Value : -1)); } Persistent.SaveLayoutPreset(_name, xe); LayoutPreset.RefreshUserPresets(); Dialog_Alert.Open(Lang.Get("Alert.Saved", _name)); Close(); }
protected override void DrawContent(Rect rect) { var grid = rect.GetVGrid(Padding, -1f, ButtonHeight); _tabs.Draw(grid[1]); var button = GUIPlus.DrawButtonRow(grid[2], ButtonWidth, Padding, Lang.Get("Dialog_Config.SetToDefault"), Lang.Get("Dialog_Config.OpenFolder"), Lang.Get("Button.Close")); if (button == 1) { ConfirmSetToDefault(); } else if (button == 2) { Persistent.OpenConfigFolder(); } else if (button == 3) { Close(); } }
/// <inheritdoc /> public override void Init(ITorchBase torch) { base.Init(torch); var configFile = Path.Combine(StoragePath, "ShipFixer.cfg"); try { _config = Persistent<ShipFixerConfig>.Load(configFile); } catch (Exception e) { Log.Warn(e); } if (_config?.Data == null) { Log.Info("Create Default Config, because none was found!"); _config = new Persistent<ShipFixerConfig>(configFile, new ShipFixerConfig()); Save(); } }
protected override void Awake() { Application.targetFrameRate = 60; TouchProxy.Init(); Options = new Options(); Options.Load(); Persistent = new Persistent(); Persistent.Load(); ImageManager = new ImageManager(); ImageManager.Init(); ImageManager.LoadImages(); PlayerProgress = new PlayerProgress(); Purchaser = new Purchaser(); Purchaser.PurchaseFinished += Purchaser_PurchaseFinished; Purchaser.InitializePurchasing(); }
private void SetupConfig() { var configFile = Path.Combine(StoragePath, "EventTeams.cfg"); try { _config = Persistent <EventTeamsConfig> .Load(configFile); } catch (Exception e) { Log.Warn(e); } if (_config?.Data == null) { Log.Info("Create Default config because none was found"); _config = new Persistent <EventTeamsConfig>(configFile, new EventTeamsConfig()); _config.Save(); } }
public override void Init(ITorchBase torch) { string path = Path.Combine(StoragePath, "hive_uplink.cfg"); _log.Info($"Attempting to load config from {path}"); _config = Persistent <HiveConfig> .Load(path); if (_config.Data.HiveId == null && _config.Data.SectorId == null) { _log.Fatal($"Setup config and restart the server to enable hive uplink"); return; } var manager = new HiveUplinkManager(torch, _config.Data); torch.Managers.AddManager(manager); var factionManager = new HiveFactionManager(torch); torch.Managers.AddManager(factionManager); }
private void OnExpanded(object sender, RoutedEventArgs e) { this.Timer.Stop(); object obj = ((TreeViewItem)e.OriginalSource).Header; if (obj != null && obj is Persistent) { Persistent value = (Persistent)obj; if (value != null && !value.IsDefault) { if (!value.isCompleted) { Load(value); } if (Expanded != null) { Expanded(value); } } } }
protected void RelSelFilter(DataCombo dc, Type relType, Persistent parent, String filterValue) { if (relType == businessLogic.PersistentType) { if (crudController != null) { crudController.Dispose(); } if (businessLogic is IFiltrable) { ((IFiltrable)businessLogic).SetFilterObject(parent); } this.dc = dc; crudController = new CRUDController(businessLogic, gridTitle, crudFormTitle, crudFormType, this); CRUDControllerManager.Instance.GetCRUDChildControllerManager().SetChildControllers(crudController); crudController.ShowGrid(filterValue); } }
private void SetupConfig() { var configFile = Path.Combine(StoragePath, "KothPluginConfig.cfg"); try { _config = Persistent <KothPluginConfig> .Load(configFile); } catch (Exception e) { Log.Warn(e); } if (_config?.Data != null) { return; } Log.Info("Creating Default Config"); _config = new Persistent <KothPluginConfig>(configFile, new KothPluginConfig()); _config.Save(); }
/// <inheritdoc /> public override void Init(ITorchBase torch) { base.Init(torch); ScriptsPath = Path.Combine(StoragePath, "Scripts"); _config = Persistent <ScriptManagerConfig> .Load(Path.Combine(StoragePath, "ScriptManager.cfg")); ScriptEntry.loadingComplete = true; Log.Info("Config has been loaded."); Instance = this; _sessionManager = Torch.Managers.GetManager <TorchSessionManager>(); if (_sessionManager != null) { _sessionManager.SessionStateChanged += OnSessionStateChanged; } var patchMgr = torch.Managers.GetManager <PatchManager>(); var patchContext = patchMgr.AcquireContext(); PatchSession(patchContext); PatchPB(patchContext); //apply hooks patchMgr.Commit(); //Your init code here, the game is not initialized at this point. Task.Run(delegate { foreach (var script in _config.Data.Whitelist) { string code = ""; code = script.Code; script.MD5Hash = Util.GetMD5Hash(code); } }); MessageHandler.Init(); }
/// <inheritdoc/> public override void SetValue(Persistent obj, T value) { var field = Field; ArgumentValidator.EnsureArgumentNotNull(value, "value"); var valueType = value.GetType(); if (field.ValueType != valueType) { throw new InvalidOperationException(String.Format( Strings.ExResultTypeIncorrect, valueType.Name, field.ValueType.Name)); } var structure = (Structure)(object)value; var adapter = (IFieldValueAdapter)value; if (adapter.Owner != null) { adapter.Owner.EnsureIsFetched(adapter.Field); } structure.Tuple.CopyTo(obj.Tuple, 0, field.MappingInfo.Offset, field.MappingInfo.Length); }
private IEnumerator PlayCoroutine() { GameTime gameTime = GameObject.Find("GameTime").GetComponent <GameTime>(); gameTime.ZeroTime(); Persistent.Get <EventSystem>().enabled = false; GetComponent <AudioSource>().Play(); Camera.main.backgroundColor = Color.red; yield return(StartCoroutine(CoroutineUtility.WaitForUnscaledTime(1.0f))); GameObject.Find("InputPlane").GetComponent <InputPlane>().ResetFingers(); gameTime.TimeScaleDirection = TimeScaleDirection; Camera.main.backgroundColor = Color.black; while (gameTime.CurrentTime > 0f) { yield return(null); } Persistent.Get <EventSystem>().enabled = true; }
/// <summary> /// Store in a object data from persistent object. /// </summary> /// <param name="persistentData">The persistent data object.</param> public override void SetData(Persistent persistentData) { if (this.GetType() == typeof(Character)) { var talkablePersistent = (CharacterPersistent)persistentData; uniqueId = talkablePersistent.id; ((Character)this).influence = talkablePersistent.influence; contexts = Data.SetArrayData <Context>(contexts, talkablePersistent.contexts); } else if (this.GetType() == typeof(Interactable)) { var talkablePersistent = (InteractablePersistent)persistentData; uniqueId = talkablePersistent.id; contexts = Data.SetArrayData <Context>(contexts, talkablePersistent.contexts); } else { var talkablePersistent = (TalkablePersistent)persistentData; uniqueId = talkablePersistent.id; contexts = Data.SetArrayData <Context>(contexts, talkablePersistent.contexts); } }
/// <summary> /// Initialize chidren's parent /// </summary> /// <param name="item"></param> public virtual void RefreshParent(Persistent parent) { if (parent is PeriodName) { PeriodName period = (PeriodName)parent; foreach (PeriodInterval interval in period.intervalListChangeHandler.Items) { interval.periodName = period; RefreshParent(interval); } } else if (parent is PeriodInterval) { PeriodInterval interval = (PeriodInterval)parent; foreach (PeriodInterval child in interval.childrenListChangeHandler.Items) { child.parent = interval; child.periodName = interval.periodName; RefreshParent(child); } } }
/// <inheritdoc /> public override void Init(ITorchBase torch) { base.Init(torch); string path = Path.Combine(StoragePath, "TebexTorchAPI.cfg"); Tebex.logInfo($"Attempting to load config from {path}"); _config = Persistent <TebexConfig> .Load(path); _sessionManager = Torch.Managers.GetManager <TorchSessionManager>(); if (_sessionManager != null) { _sessionManager.SessionStateChanged += SessionChanged; } System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => { return(true); }; Torch.GameStateChanged += GameStateChanged; this.information = new WebstoreInfo(); Instance = this; }
private void SetupConfig() { var configFile = Path.Combine(StoragePath, "Wormhole.cfg"); try { _config = Persistent <Config> .Load(configFile); } catch (Exception e) { Log.Warn(e); } if (_config?.Data == null) { Log.Info("Create Default Config, because none was found!"); _config = new Persistent <Config>(configFile, new Config()); _config.Save(); } //Utilities.WormholeGateConfigUpdate(); }
public static void Init() { var configurationRepository = new Mock <IConfigurationRepository>(); configurationRepository.Setup(x => x.GetCurrentDay()).Returns(5); var currencyRepository = new Mock <ICurrencyRepository>(); currencyRepository .SetupGet(x => x.Gold) .Returns(new Currency() { ID = (int)CurrencyTypeEnum.Gold, Name = "Gold", ShortName = "Gold", Symbol = "Gold" }); GameHelper.Init(configurationRepository.Object, currencyRepository.Object, Mock.Of <ICitizenService>()); LinkCreator.Current = new StringLinkCreator(); Persistent.Init(new TestRegionPersistentRepository(), new TestCurrencyPersistentRepository(), new TestCountryPersistentRepository()); }
public void MessageSerializer_when_given_a_Persistent_manifest_should_handle_custom_Persistent_message_serialization() { var persistent = new Persistent(new MyPayload("b"), 13, "p1", "", writerGuid: Guid.NewGuid().ToString()); var serializer = _serialization.FindSerializerFor(persistent); var bytes = serializer.ToBinary(persistent); var deserialized = serializer.FromBinary(bytes, typeof(Persistent)); deserialized.ShouldBe(persistent.WithPayload(new MyPayload(".b."))); }
internal void SetState(object obj, Persistent.ObjectState state) { lock(this) { Entry e = Put(obj); e.state = state; if ((state & Persistent.ObjectState.DIRTY) != 0) { e.pin = obj; } else { e.pin = null; } } }
public void TestUndoRedo() { var a = new Persistent<string>("what?"); var undoRedo = new UndoRedo<Persistent<string>>(a); undoRedo.NewAction("Say something"); a.Value = "hello"; undoRedo.Undo(); Assert.True(a.Value == "what?"); undoRedo.Redo(); Assert.True(a.Value == "hello"); }
private void App_OnStartup(object sender, StartupEventArgs e) { try { Current.Dispatcher.UnhandledException += (o, args) => { ErrorManager.ShowError("Something unexpected happened in the launcher, please report this error.", args.Exception, true); args.Handled = true; }; uniqueLaunchGateway = new WurmAssistantLauncherGateway(doNotAutoEnter: true); uniqueLaunchGateway.Enter(1000); LauncherPipeCom = new PipeCom(uniqueLaunchGateway.UniqueId, "Default"); LauncherPipeCom.LoginAsEndpointAlpha(); LauncherTaskbarIcon = (TaskbarIcon)FindResource("LauncherTaskbarIcon"); AppContext.BuildContext(); Logger = new SimpleLogger(); Logger.SetLogSaveDir(PathEx.CombineWithCodeBase("LauncherLogs")); Logger.SetConsoleHandlingMode(SimpleLogger.ConsoleHandlingOption.SendConsoleToLoggerOutputDIAG); SpellbookLogger.Logged += (o, args) => { switch (args.Severity) { case LogSeverity.Debug: Logger.LogDebug(args.Message, args.Source, args.Exception); break; case LogSeverity.Info: Logger.LogInfo(args.Message, args.Source, args.Exception); break; case LogSeverity.Error: Logger.LogError(args.Message, args.Source, args.Exception); break; } }; var logger = new PersistentLogger(); var storage = new PlainFilePersistentStorage(logger, AppContext.LauncherSettingsDir); var serializer = new JsonPersistentSerializer(logger); PersistentFactory = new PersistentFactory(storage, serializer, logger); var initialSetup = new InitialSetupManager(); initialSetup.Execute(); Settings = PersistentFactory.Create<LauncherSettings>("LauncherSettings"); StartupUri = new Uri(@"Views\MainWindow.xaml", UriKind.Relative); } catch (GatewayClosedException) { // try activate existing instance of launcher using (var pipecom = new PipeCom(uniqueLaunchGateway.UniqueId, "Default")) { pipecom.LoginAsAlphaClient(); pipecom.TrySend("ShowWindow", null); } Shutdown(); } catch (Exception exception) { MessageBox.Show("Unexpected error while starting the Launcher, please report this bug! Error: " + exception.Message); Logger.LogError("error on app init", this, exception); Shutdown(); } }
public void TestStore() { var a = new Persistent<string>("one"); a.Store(); a.Value = "two"; a.Undo(); Assert.True(a.Value == "one"); a.Redo(); Assert.True(a.Value == "two"); }
public void MessageSerializer_should_serialize_manifest_provided_by_EventAdapter() { var p1 = new Persistent(new MyPayload("a"), sender: TestActor).WithManifest("manifest"); var serializer = _serialization.FindSerializerFor(p1); var bytes = serializer.ToBinary(p1); var back = (Persistent)serializer.FromBinary(bytes, typeof (Persistent)); back.Manifest.ShouldBe(p1.Manifest); }
public void TestList3() { var a = new Persistent<string>("one"); var b = new Persistent<string>("two"); var persistent = new PersistentList<Persistent<string>>(); persistent.Add(a); persistent.Add(b); persistent.Store(); a.Value = "1"; b.Value = "2"; persistent.Store(); persistent[0] = b; persistent[1] = a; persistent.Store(); persistent.Undo(); Assert.True(persistent[0] == b); Assert.True(persistent[1] == a); persistent.Undo(); Assert.True(persistent[0] == a); Assert.True(persistent[1] == b); }
// Use this for initialization void Start() { if (something == null) { something = this; DontDestroyOnLoad(something); } else { DestroyImmediate(this); return; } }
public void MessageSerializer_when_given_payload_serializer_with_string_manifest_should_handle_serialization() { var persistent = new Persistent(new MyPayload2("a", 17), 13, "p1", "", writerGuid: Guid.NewGuid().ToString()); var serializer = _serialization.FindSerializerFor(persistent); var bytes = serializer.ToBinary(persistent); var deserialized = serializer.FromBinary(bytes, null); deserialized.ShouldBe(persistent.WithPayload(new MyPayload2(".a.", 17))); }
public void MessageSerializer_should_custom_serialize_AtomicWrite_messages_during_remoting() { var p1 = new Persistent(new MyPayload("a"), sender: TestActor); var p2 = new Persistent(new MyPayload("b"), sender: TestActor); _localActor.Tell(new AtomicWrite(ImmutableList.Create(new IPersistentRepresentation[] {p1, p2}))); ExpectMsg("p.a."); ExpectMsg("p.b."); }
public void TestLoaded() { var a = new LoadedTestObject(); Assert.True(a.Loaded); var persistent = new Persistent<LoadedTestObject>(a); var b = new LoadedTestObject(); persistent.Store(); Assert.True(a.Loaded); persistent.Value = b; persistent.Store(); Assert.False(a.Loaded); Assert.True(b.Loaded); var c = new LoadedTestObject(); persistent.Value = c; persistent.Store(); // previous:c, current:c Assert.False(a.Loaded); Assert.False(b.Loaded); persistent.Undo(); // previous:b, current:c, next:c persistent.Undo(); // previous:a, current:b, next:c Assert.True(persistent.Value == b); Assert.False(a.Loaded); Assert.True(b.Loaded); Assert.False(c.Loaded); persistent.Undo(); // current:a, next:b Assert.True(a.Loaded); Assert.False(b.Loaded); Assert.False(c.Loaded); persistent.Redo(); // previous:a, current:b, next:c persistent.Redo(); // previous:b, current:c, next:c Assert.False(a.Loaded); Assert.False(b.Loaded); Assert.True(c.Loaded); persistent.Redo(); // previous:c, current:c Assert.False(a.Loaded); Assert.False(b.Loaded); Assert.True(c.Loaded); }