public void ObjectPanelManager_CreateObjectSingleOnly() { var manager = CreateObjectPanelManager(); const string NAME = "Panel2 Title"; var vc1 = new VariableContainer <bool>("", "", true, false); var panelA = manager.CreateObjectWinFormsPanel(manager.ListPanelTypes().FirstOrDefault(p => p.Name == NAME), vc1); Assert.IsNotNull(panelA); Assert.IsTrue(panelA.GetType() == typeof(Panel2)); Assert.AreEqual(1, manager.ListCreatedPanelsWinForms().Count()); // Not expecting to be able to create one more var vc2 = new VariableContainer <bool>("", "", true, false); var panelB = manager.CreateObjectWinFormsPanel(manager.ListPanelTypes().FirstOrDefault(p => p.Name == NAME), vc2); Assert.IsNull(panelB); Assert.AreEqual(1, manager.ListCreatedPanelsWinForms().Count()); // Dispose, to be able to create new. panelA.Dispose(); Assert.AreEqual(0, manager.ListCreatedPanelsWinForms().Count()); panelB = manager.CreateObjectWinFormsPanel(manager.ListPanelTypes().FirstOrDefault(p => p.Name == NAME), vc2); Assert.IsNotNull(panelB); Assert.IsTrue(panelB.GetType() == typeof(Panel2)); Assert.AreEqual(1, manager.ListCreatedPanelsWinForms().Count()); // Now dispose the panels panelA.Dispose(); Assert.AreEqual(1, manager.ListCreatedPanelsWinForms().Count()); panelB.Dispose(); Assert.AreEqual(0, manager.ListCreatedPanelsWinForms().Count()); }
/// <summary> /// Adds the variables. /// </summary> /// <param name="configContainer">The configuration container.</param> /// <param name="bForceRefresh">if set to <c>true</c> [b force refresh].</param> public void AddVariables(IConfigContainer configContainer, bool bForceRefresh = true) { _variablesLock.EnterWriteLock(); try { var container = FindContainer(configContainer); if (container == null) { var variables = ConstructValues(configContainer); container = new VariableContainer() { ReferenceCount = 0, Variables = variables }; _variables.Add(configContainer, container); configContainer.OnConfigChange += DoOnConfigContainerChange; } container.ReferenceCount++; if (bForceRefresh) { ConfigManager.Refresh(); } } finally { _variablesLock.ExitWriteLock(); } }
public static ItemOffer Deserialize(VariableContainer container) { return(new ItemOffer( DeserializeMany(container.Get <SerializableList>("sell")), DeserializeMany(container.Get <SerializableList>("buy")) )); }
public static FileVariable Create(IScriptFile file, AccessModifier access, string @namespace, string name, TypeReference type, bool readOnly, int line, int column, int codeHash, VariableContainerAction resetter, VariableContainerAction creator, VariableContainerAction initializer) { var vcOwnerAccess = VariableContainer.Create(@namespace, name, type, readOnly); vcOwnerAccess.FileLine = line; vcOwnerAccess.FileColumn = column; vcOwnerAccess.CodeHash = codeHash; vcOwnerAccess.Tag = new Dictionary <Type, Object>(); if (resetter != null) { vcOwnerAccess.DataResetter = resetter; } if (creator != null) { vcOwnerAccess.DataCreator = creator; } if (initializer != null) { vcOwnerAccess.DataInitializer = initializer; } return(new FileVariable(file, access, line, null, @namespace, name, vcOwnerAccess, vcOwnerAccess.Container.UniqueID)); }
// Use this for initialization void Start() { // Position the window and set the story element to un triggered state windowR = new Rect(0, 0, Screen.width, 1000); triggered = false; active = true; followingPromptId = "s1"; option1id = "s1"; option2id = "s1"; fontSize = 30; currentTask = ""; currentCondition = ""; cont = GameObject.Find("Table").GetComponent <VariableContainer>(); behav = GameObject.Find("Ball").GetComponent <BallBehaviour>(); string loadFrom = Application.dataPath + @"/Resources/Story.XML"; // ÅAth for loading the STORY xml XmlDocument doc = new XmlDocument(); // XML DOCUMENT OBJECT string content = System.IO.File.ReadAllText(loadFrom); // Read the contents of the XML file doc.LoadXml(content); // Load the xml list = doc.GetElementsByTagName("prompt"); // Allthe promtp elements read. // COntainers for changing options ant text Text = ""; options = new List <string>(); optionId = new List <string>(); task = new List <string>(); condition = new List <string>(); }
internal void Reset() { _roomVariables = new Dictionary <string, VariableContainer>(); _itemVariables = new Dictionary <string, VariableContainer>(); _questVariables = new Dictionary <string, Dictionary <Guid, VariableContainer> >(); UserVariables = new VariableContainer(); }
public void should_prioritise_custom_variable_over_other_variables() { // given const string name = "variables-are-super-awesome"; const string environment = "my-env"; _sharedVariablesProvider.ListSharedVariables_Value = new IVariable[] { new Variable("another-thing", "NOT ME", "something else"), new Variable(name, "NOT ME", "something else"), new Variable(name, "NOT ME", "another one"), new Variable(name, "NOT ME", environment), new Variable(name, string.Empty, environment), new Variable("HELLO", "NOT ME", "CARS"), }; var variableContainer = new VariableContainer(environment, _reservedVariableProvider, _sharedVariablesProvider); var expectedVariable = new Variable(name, "expected value", environment); variableContainer.Add(expectedVariable); // when List <IVariable> variables = variableContainer.ToList(); IVariable result = variables.First(x => x.Name == name && x.Environment.Name == environment); // then Assert.That(result, Is.EqualTo(expectedVariable)); }
public void should_not_store_or_return_variables_for_other_environments() { // given const string name = "variables-are-super-awesome"; _sharedVariablesProvider.ListSharedVariables_Value = new IVariable[] { new Variable(name, "not this value", string.Empty), new Variable(name, "nearly expected value", "what environment?"), new Variable(name, "nearly expected value", "another environment"), }; var variableContainer = new VariableContainer("env", _reservedVariableProvider, _sharedVariablesProvider); var anotherVariable = new Variable(name, "expected value", "doobee"); variableContainer.Add(anotherVariable); // when List <IVariable> variables = variableContainer.ToList(); // then Assert.That(variables.Any(x => x == anotherVariable), Is.False); Assert.That(variables.Any(x => x == _sharedVariablesProvider.ListSharedVariables_Value[0]), Is.True); Assert.That(variables.Any(x => x == _sharedVariablesProvider.ListSharedVariables_Value[1]), Is.False); Assert.That(variables.Any(x => x == _sharedVariablesProvider.ListSharedVariables_Value[2]), Is.False); }
public void should_return_a_scoped_shared_variable_over_default_value() { // given const string name = "variables-are-super-awesome"; const string environment = "my-env"; var expectedVariable = new Variable(name, "nearly expected value", environment); _sharedVariablesProvider.ListSharedVariables_Value = new IVariable[] { new Variable(name, "not this value", string.Empty), expectedVariable }; var variableContainer = new VariableContainer(environment, _reservedVariableProvider, _sharedVariablesProvider); variableContainer.Add(new Variable(name, "not me either", string.Empty)); // when List <IVariable> variables = variableContainer.ToList(); IVariable result = variables.First(x => x.Name == name && x.Environment.Name == environment); // then Assert.That(result, Is.EqualTo(expectedVariable)); }
public void Dispose() { var container = new VariableContainer(); Stats.Serialize(container); _roomVariables.Set("monster_stats", container); }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("sell", SerializeMany(SellOffers)); result.Set("buy", SerializeMany(BuyOffers)); return(result); }
public void GetNotexistingTest() { var container = new VariableContainer(); Assert.Empty(container.Keys()); Assert.Null(container.Get("key")); }
internal void Initialize() { VariableContainer.Reset(); IsCasting = false; IsFirstFrame = true; OnInitialize(); }
internal VariableContainer GetItemVariables(string identifier) { if (!_itemVariables.ContainsKey(identifier)) { _itemVariables[identifier] = new VariableContainer(); } return(_itemVariables[identifier]); }
public BuySellState Deserialize(VariableContainer container) { return(new BuySellState { Selling = container.Get <Serializable.Bool>("Selling"), SelectedItemId = container.Get <Serializable.String>("SelectedItemId"), SelectedItemPrice = container.Get <Serializable.Decimal>("SelectedItemPrice"), SelectedItemCount = (int?)container.Get <Serializable.Int>("SelectedItemCount") }); }
public static Offer Deserialize(VariableContainer container) { return(new Offer( (UserId)container.Get("UserId"), container.Get <Serializable.Decimal>("Price"), container.Get <Serializable.Int>("Count"), DateTimeOffset.FromUnixTimeSeconds(container.Get <Serializable.Long>("Created")), container.Get <Serializable.String>("ItemId") )); }
public void Save() { var vars = new VariableContainer(); vars.Set("gold", new Serializable.Decimal(Gold)); vars.Set("health", new Serializable.Decimal(Health)); vars.Set("totalDamage", new Serializable.Decimal(TotalDamage)); vars.Set("attackers", Attacker.Save(Attackers)); GlobalVariables.Variables.Set(_key, vars); }
public StatsContext(Random random, VariableContainer roomVariables) { _roomVariables = roomVariables; var container = roomVariables.Get <VariableContainer>("monster_stats"); Stats = container != null ? ResultStats.Deserialize(container) : Generator.GenerateStats(random); }
/// <summary> /// Create snapshot of Virtual Reference memory model /// </summary> public Snapshot() { _globals = new VariableContainer(VariableKind.Global, this); _locals = new VariableContainer(VariableKind.Local, this, _globals); _localControls = new VariableContainer(VariableKind.LocalControl, this, _globalControls); _globalControls = new VariableContainer(VariableKind.GlobalControl, this); _meta = new VariableContainer(VariableKind.Meta, this); _data = new DataContainer(this); _infoData = new DataContainer(this); }
public VariableManager( Dictionary <string, VariableContainer> roomVariables, Dictionary <string, VariableContainer> itemVariables, VariableContainer persistentVariables, VariableContainer userVariables) { _roomVariables = roomVariables; _itemVariables = itemVariables; PersistentVariables = persistentVariables; UserVariables = userVariables; }
public VariableContainer Serialize() { var result = new VariableContainer(); foreach (var offer in this) { result.Set(offer.Key, offer.Value.Serialize()); } return(result); }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("UserId", UserId); result.Set("Price", new Serializable.Decimal(Price)); result.Set("Count", new Serializable.Int(Count)); result.Set("Created", new Serializable.Decimal(Created.ToUnixTimeSeconds())); result.Set("ItemId", new Serializable.String(ItemId)); return(result); }
public MainWindow() : base("MD", 640, 480) { this.WindowState = WindowState.Maximized; // Client area VariableContainer clientarea = new VariableContainer(); // Menu items MenuItem[] menuitems = new MenuItem[] { MenuItem.Create("File", new MenuItem[] { MenuItem.Create("Import", delegate { using(var fd = new WinForms.OpenFileDialog()) { fd.Filter = "MP3 Files |*.mp3"; if (fd.ShowDialog() == WinForms.DialogResult.OK) { string file = fd.FileName; AudioContext ac = new AudioContext(); MemoryAudioSource mas = new MP3AudioFeed(file).Copy(4096, 4096 * 100); SpectrogramView sp = new SpectrogramView(mas); clientarea.Client = sp; AudioOutput ao = new AudioOutput(mas.Play); ao.Play(); } else { return; } } }), MenuItem.Create("Exit", delegate { this.Close(); }) }) }; // Menu and splitter Menu menu = new Menu(menuitems); SplitContainer sc = new SplitContainer(Axis.Vertical, menu.WithBorder(0.0, 0.0, 0.0, 1.0), clientarea); sc.NearSize = 30.0; // Main layer container LayerContainer lc = new LayerContainer(sc); this.Control = lc; }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("SelectedItemId", new Serializable.String(SelectedItemId)); result.Set("SelectedPriceGroup", new Serializable.Int(SelectedPriceGroup)); result.Set("SelectedItemPrice", new Serializable.Int(SelectedItemPrice)); result.Set("MaxQuantityAvailable", new Serializable.Int(MaxQuantityAvailable)); result.Set("QuantitySelected", new Serializable.Int(QuantitySelected)); result.Set("Selling", new Serializable.Bool(Selling)); return(result); }
public static VariableContainer Serialize <T>(IState <T> state) where T : IState <T> { var container = new VariableContainer(); container.Set("stateId", new Serializable.String(state.StateId)); var innerState = state.Serialize(); container.Set("state", innerState); return(container); }
public AddOfferState Deserialize(VariableContainer container) { return(new AddOfferState { SelectedItemId = container.Get <Serializable.String>("SelectedItemId"), SelectedPriceGroup = container.Get <Serializable.Int>("SelectedPriceGroup"), SelectedItemPrice = container.Get <Serializable.Int>("SelectedItemPrice"), MaxQuantityAvailable = container.Get <Serializable.Int>("MaxQuantityAvailable"), QuantitySelected = container.Get <Serializable.Int>("QuantitySelected"), Selling = container.Get <Serializable.Bool>("Selling") }); }
public static Offers Deserialize(VariableContainer items) { var result = new Offers(); foreach (var key in items.Keys()) { var offer = items.Get <VariableContainer>(key); result[key] = ItemOffer.Deserialize(offer); } return(result); }
public VariableContainer Serialize() { var result = new VariableContainer(); result.Set("Selling", new Serializable.Bool(Selling)); result.Set("SelectedItemId", new Serializable.String(SelectedItemId)); result.Set("SelectedItemPrice", new Serializable.Decimal(SelectedItemPrice)); if (SelectedItemCount != null) { result.Set("SelectedItemCount", new Serializable.Int((int)SelectedItemCount)); } return(result); }
public void PlainTest() { var container = new VariableContainer(); Assert.Empty(container.Keys()); container.Set("test_variable", new Serializable.Int(1)); Assert.Single(container.Keys(), "test_variable"); var value = container.Get <Serializable.Int>("test_variable"); Assert.Equal(1, (int)value); }
private void Save(Variables variables) { var vars = new VariableContainer(); vars.Set("gold", new Serializable.Decimal(variables.Gold)); vars.Set("health", new Serializable.Decimal(variables.Health)); vars.Set("totalDamage", new Serializable.Decimal(variables.TotalDamage)); vars.Set("attackers", Attacker.Save(variables.Attackers)); lock (GlobalVariables.Variables) { GlobalVariables.Variables.Set(GlobalVariablesKey, vars); } }
public static SerializableList Save(IEnumerable <Attacker> attackers) { var result = new SerializableList(); foreach (var attacker in attackers) { var container = new VariableContainer(); container.Set("damageDealed", new Serializable.Decimal(attacker.DamageDealed)); container.Set("userId", attacker.UserId); result.Add(container); } return(result); }