Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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);
            }
        }
Ejemplo n.º 6
0
        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)));
        }
Ejemplo n.º 7
0
        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)));
        }
Ejemplo n.º 8
0
        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 _));
        }
Ejemplo n.º 9
0
        public void IDictionary_Add_OnNonExistingKeyAndNonNullValue_AddsKeyAndValue()
        {
            IDictionary <string, string> dict = new DataDictionary <string, string>(InitialData);

            dict.Add(InitialNonExistingKey, InitialNonExistingValue);
            Assert.AreEqual(InitialNonExistingValue, dict[InitialNonExistingKey]);
        }
Ejemplo n.º 10
0
        public void IDictionary_Add_OnNullKey_ThrowsArgumentNullException()
        {
            IDictionary <string, string> dict = new DataDictionary <string, string>();

            Assert.Throws <ArgumentNullException>(
                () => dict.Add(null, SomeValue));
        }
Ejemplo n.º 11
0
    //////////////////////////////////////////////////////////////////////////
    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);
        }
    }
Ejemplo n.º 12
0
        protected override DataDictionary GetValues()
        {
            DataDictionary result = (DataDictionary)_init.Clone();

            result.Add("produced", _produced);
            return(result);
        }
Ejemplo n.º 13
0
        /// <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);
            }
        }
Ejemplo n.º 14
0
        protected override DataDictionary GetValues()
        {
            DataDictionary result = base.GetValues();

            result.Add("active", _active ? 1.0f : 0.0f);
            return(result);
        }
Ejemplo n.º 15
0
        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;
                }
            }
        }
Ejemplo n.º 16
0
 protected JsonData(SerializationInfo info, StreamingContext context)
     : this()
 {
     foreach (var entry in info)
     {
         DataDictionary.Add(entry.Name, entry.Value);
     }
 }
Ejemplo n.º 17
0
 /// <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);
 }
Ejemplo n.º 18
0
 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);
     }
 }
Ejemplo n.º 19
0
        public void SetBodyData(object priceDetectiveModel)
        {
            _priceDetectiveModel = priceDetectiveModel as PriceDetectiveEmailModel;

            if (_priceDetectiveModel != null)
            {
                DataDictionary.Add("items", _priceDetectiveModel.Items);
            }
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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")));
            }
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        private void addNewRootNamespace()
        {
            if (NewRootNamespace == string.Empty || NewRootNamespace == null)
            {
                return;
            }
            DataDictionaryNamespace newSpace = new DataDictionaryNamespace();

            newSpace.Name = NewRootNamespace;
            DataDictionary.Add(newSpace);
            NewRootNamespace = string.Empty;
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
 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;
     }
 }