protected override DataDictionary GetValues() { DataDictionary result = base.GetValues(); result.Add("recycling", (float)_recycling); result.Add("time_in_use", (float)_timeInUse); result.Add("recycled", (float)_recycled); return(result); }
public void Contains_MultipleItemsInCollectionLastKeyAndValuesMatch_ReturnsTrue() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); var pair = new KeyValuePair <string, string> ("foobar", "baz"); nvc.Add("foobar", "blah"); nvc.Add("foobar", "baz"); rdd.AddCollection(nvc); bool has_item = rdd.Contains(pair); Assert.IsTrue(has_item); }
public void Contains_MultipleItemsWithPartialEndMatchesInCollection_ReturnsFalse() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); var pair = new KeyValuePair <string, string> ("foobar", "baz"); nvc.Add("foobar", "abaz"); nvc.Add("foobar", "abaz"); nvc.Add("foobar", "abaz"); rdd.AddCollection(nvc); bool has_item = rdd.Contains(pair); Assert.IsFalse(has_item); }
private void AddData(DataDictionary dict, SysTable table, RowCollection rows) { if (!dict.ContainsKey(table.qualified_name)) { dict.Add(table.qualified_name, rows); } }
/// <summary> /// The load routine for the static data file collection /// </summary> /// <param name="PopulateNodeTrees"></param> /// <returns></returns> public bool Load(int populateDepth = 0) { // Loads the static data and builds the trees representing the data files if (!DataDirectoryInfo.Exists) { return(false); } else { foreach (FileInfo dataFile in DataDirectoryInfo.GetFiles(targetFileExtension)) { // Create a new Json_File_UI and populate the path. Json_File_UI tempJsonFile = new Json_File_UI(this, dataFile, populateDepth); // Add the file to the Data Dictionary DataDictionary.Add(dataFile.Name, tempJsonFile); //if (tempJsonFile.IsLoaded) // && !LoadError) { if (tempJsonFile.RootNode == null) { throw new NullReferenceException ("Json_FileCollection.Load: tempJsonFile.RootNode was null."); } else { RootNode.Nodes.Insert(0, tempJsonFile.RootNode); } } } return(true); } }
public void ICollection_Add_OnExistingKey_ThrowsArgumentException() { ICollection <KeyValuePair <string, string> > dict = new DataDictionary <string, string>(InitialData); Assert.Throws <ArgumentException>( () => dict.Add(new KeyValuePair <string, string>(InitialExistingKey, DifferentValueForInitialExistingKey))); }
public void ICollection_Add_OnNullKey_ThrowsArgumentNullException() { ICollection <KeyValuePair <string, string> > dict = new DataDictionary <string, string>(); Assert.Throws <ArgumentNullException>( () => dict.Add(new KeyValuePair <string, string>(null, SomeValue))); }
public void IDictionary_Add_OnNonExistingKeyAndNullValue_DoesNotAdd() { IDictionary <string, string> dict = new DataDictionary <string, string>(InitialData); dict.Add(InitialNonExistingKey, null); Assert.IsFalse(dict.TryGetValue(InitialNonExistingKey, out _)); }
public void IDictionary_Add_OnNonExistingKeyAndNonNullValue_AddsKeyAndValue() { IDictionary <string, string> dict = new DataDictionary <string, string>(InitialData); dict.Add(InitialNonExistingKey, InitialNonExistingValue); Assert.AreEqual(InitialNonExistingValue, dict[InitialNonExistingKey]); }
public void IDictionary_Add_OnNullKey_ThrowsArgumentNullException() { IDictionary <string, string> dict = new DataDictionary <string, string>(); Assert.Throws <ArgumentNullException>( () => dict.Add(null, SomeValue)); }
////////////////////////////////////////////////////////////////////////// public void OnBeforeSerialize() { if (m_Data == null || m_DataBase == null) { return; } m_Data.Clear(); foreach (var n in m_DataBase) { var type = DataType.Null; if (n.Value.m_Data != null) { var dataType = n.Value.m_Data.GetType(); if (dataType == typeof(int)) { type = DataType.Int; } else if (dataType == typeof(float)) { type = DataType.Float; } else if (dataType == typeof(bool)) { type = DataType.Boolean; } else if (dataType == typeof(string)) { type = DataType.String; } else if (dataType == typeof(Vector2)) { type = DataType.Vector2; } else if (dataType == typeof(Vector3)) { type = DataType.Vector3; } else if (dataType == typeof(Vector2Int)) { type = DataType.Vector2Int; } else if (dataType == typeof(Vector3Int)) { type = DataType.Vector3Int; } else { type = DataType.Object; } } var dataElement = new DataElement() { m_DataType = type, m_Data = n.Value.m_Data }; m_Data.Add(n.Key, dataElement); } }
protected override DataDictionary GetValues() { DataDictionary result = (DataDictionary)_init.Clone(); result.Add("produced", _produced); return(result); }
/// <summary> /// The load routine for the static data file collection /// </summary> /// <param name="PopulateNodeTrees"></param> /// <returns></returns> public new bool Load(int PopulateNodeTreeDepth = 0) { // Loads the static data and builds the trees representing the data files if (!DataDirectoryInfo.Exists) { return(false); } else { foreach (FileInfo dataFile in DataDirectoryInfo.GetFiles(targetFileExtension)) // .Reverse()) { Debug.Print("File evaluated {0}", dataFile.Name); // Create a new HEStationonBlueprintFile and populate the path. StationBlueprint_File tempBlueprintFile = new StationBlueprint_File(this, dataFile); // Add the file to the Data Dictionary DataDictionary.Add(dataFile.Name, tempBlueprintFile); if (tempBlueprintFile.IsLoaded && !LoadError) { // if (PopulateNodeTreeDepth > 0) tempBlueprintFile.DataViewRootNode.CreateChildNodesFromjData(PopulateNodeTreeDepth); if (tempBlueprintFile.RootNode == null) { throw new NullReferenceException(); } else { RootNode.Nodes.Insert(0, tempBlueprintFile.RootNode); } } } return(true); } }
protected override DataDictionary GetValues() { DataDictionary result = base.GetValues(); result.Add("active", _active ? 1.0f : 0.0f); return(result); }
public void SetBodyData(object xtbData) { xtbOutput = xtbData as XtbOutput; if (xtbOutput != null) { try { DataDictionary.Add("balance", xtbOutput.Balance?.ToString(CultureInfo.InvariantCulture)); DataDictionary.Add("gain", xtbOutput.Gain?.ToString(CultureInfo.InvariantCulture)); } catch (Exception e) { if (xtbOutput == null) { Log.Error("Can't create HTML body. Xtb data is empty."); } else { Log.Error($"Can't create HTML body out of this data: Balance={this.xtbOutput.Balance} Gain={this.xtbOutput.Gain}"); } Log.Error("XtbHtmlGenerator error.", e); return; } } }
protected JsonData(SerializationInfo info, StreamingContext context) : this() { foreach (var entry in info) { DataDictionary.Add(entry.Name, entry.Value); } }
/// <summary> /// Fills the data dictionary. /// </summary> protected virtual void FillDataDictionary() { DataDictionary.Add("Teams", TeamsCount); DataDictionary.Add("Renders", RendersCount); DataDictionary.Add("Playlists", PlaylistsCount); DataDictionary.Add("Projects", CreatedProjects); DataDictionary.Add("Time", GeneralTimer.ElapsedSeconds); }
public void SetBodyData(object data) { this.flatOutput = data as FlatOutput; if (this.flatOutput != null) { DataDictionary.Add("private_flats", flatOutput.PrivateFlatsByCategory); DataDictionary.Add("all_flats", flatOutput.AllFlatsByCategory); } }
public void SetBodyData(object priceDetectiveModel) { _priceDetectiveModel = priceDetectiveModel as PriceDetectiveEmailModel; if (_priceDetectiveModel != null) { DataDictionary.Add("items", _priceDetectiveModel.Items); } }
public void Count_SingleItemInCollection_ReturnsOne() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); nvc.Add("foobar", "baz"); rdd.AddCollection(nvc); Assert.AreEqual(1, rdd.Count); }
public void SetBodyData(object binanceVM) { this.binanceModel = binanceVM as BinanceVM; if (binanceModel != null) { DataDictionary.Add("symbol_value", binanceModel.SymbolsValues.Where(x => x.ConvertedPrice > 10)); DataDictionary.Add("total_value", binanceModel.TotalValue.ToString("C2", CultureInfo.CreateSpecificCulture("en-US"))); } }
public bool Push <T>(string key, T loader) { if (mTables.ContainsKey(key)) { return(false); } mTables.Add(key, loader); return(true); }
protected void onNewEntryDataDictionaryRequest(object details) { DataDictionary nedd = new DataDictionary(); if (!String.IsNullOrEmpty(partialCall)) { nedd.Add("Callsign", partialCall); } MessageSink.MessageBus.GetEvent <DataDictionaryResponse>().Publish(nedd); }
public void Count_ItemInCollectionAndItemAdded_ReturnsTwo() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); nvc.Add("foobar", "baz"); rdd.AddCollection(nvc); rdd.Add("foobar", "baz"); Assert.AreEqual(2, rdd.Count); }
public void Clear_ItemInCollection_SetsCountZero() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); nvc.Add("foobar", "baz"); rdd.AddCollection(nvc); rdd.Clear(); Assert.AreEqual(0, rdd.Count); }
private void addNewRootNamespace() { if (NewRootNamespace == string.Empty || NewRootNamespace == null) { return; } DataDictionaryNamespace newSpace = new DataDictionaryNamespace(); newSpace.Name = NewRootNamespace; DataDictionary.Add(newSpace); NewRootNamespace = string.Empty; }
public void ContainsKey_ItemInCollection_ReturnsTrue() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); nvc.Add("foobar", "baz"); rdd.AddCollection(nvc); bool has_item = rdd.ContainsKey("foobar"); Assert.IsTrue(has_item); }
public DataDictionary ToData() { var dictionary = new DataDictionary(); foreach (var item in this) { dictionary.Add(item.Key, item.Value); } // TODO: We should be converting strings to jobject. return(dictionary); }
public void Clear_ItemInCollection_RemovesItem() { var nvc = new DataDictionary(); var rdd = new RequestDataDictionary(); nvc.Add("foobar", "baz"); rdd.AddCollection(nvc); rdd.Clear(); bool has_item = rdd.ContainsKey("foobar"); Assert.IsFalse(has_item); }
public void Save(T data) { if (!DataDictionary.Data.ContainsKey(((IData)data).TagName)) { DataDictionary.Add(((IData)data).TagName, data); JsonData.SaveJson(Constants.CountriesFileName, DataDictionary, Application.dataPath); int maxId = PopupDataList.Select(x => x.Id).Max(); PopupDataList.Add(new PopupData { Id = maxId, Name = ((IData)data).Name, TagName = ((IData)data).TagName }); SelectedItemId = maxId; IsNew = false; } }