Ejemplo n.º 1
0
        public void ColideKeys()
        {
            var mp = new MPT
            {
                ["oi"] = "batata",
                ["oi"] = "batatatinha"
            };

            Assert.True(mp.ContainsKey("oi"));
            Assert.Equal("batatatinha", mp["oi"]);

            mp["orelha"] = "batatatinha";
            Assert.Equal("batatatinha", mp["orelha"]);

            mp["orfão"] = "criança";
            Assert.Equal("criança", mp["orfão"]);

            mp["orfanato"] = "crianças";
            Assert.Equal("crianças", mp["orfanato"]);

            Assert.True(mp.Remove("orfanato"));
            Assert.Equal("criança", mp["orfão"]);
            Assert.False(mp.ContainsKey("orfanato"));

            mp["orfã"] = "menina";
            Assert.Equal("menina", mp["orfã"]);
        }
Ejemplo n.º 2
0
            public MPW(MPT type, object value)
            {
                Type  = type;
                Value = value;

                if (Type == MPT.ListEntityRecords)
                {
                    List <EntityRecord> records = Value as List <EntityRecord>;
                    if (records != null)
                    {
                        for (int i = 0; i < records.Count; i++)
                        {
                            var recMPW = new MPW(MPT.EntityRecord, records[i]);
                            Properties[$"[{i}]"] = recMPW;
                        }
                    }
                }
                else if (Type == MPT.EntityRecord)
                {
                    EntityRecord record = Value as EntityRecord;
                    if (record != null)
                    {
                        foreach (var propName in record.Properties.Keys)
                        {
                            var propValue = record[propName];
                            //the case when set record from page post
                            if (propName.StartsWith("$") && propName.Contains(".") && propValue is List <Guid> )
                            {
                                string[]            split   = propName.Split('.');
                                List <EntityRecord> records = new List <EntityRecord>();
                                foreach (Guid id in (List <Guid>)propValue)
                                {
                                    EntityRecord rec = new EntityRecord();
                                    rec["id"] = id;
                                    records.Add(rec);
                                }
                                Properties[split[0]] = new MPW(MPT.ListEntityRecords, records);
                            }
                            else
                            {
                                if (propValue is List <EntityRecord> )
                                {
                                    Properties[propName] = new MPW(MPT.ListEntityRecords, propValue);
                                }
                                else if (propValue is EntityRecord)
                                {
                                    Properties[propName] = new MPW(MPT.EntityRecord, propValue);
                                }
                                else
                                {
                                    Properties[propName] = new MPW(MPT.Object, propValue);
                                }
                            }
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        public void DistinctRoot()
        {
            var mp = new MPT();

            Assert.False(mp == null);
            mp[new byte[] { 0x0, 0x0, 0x1 }] = new byte[] { 0x0, 0x0, 0x1 };
            Assert.Equal(new byte[] { 0x0, 0x0, 0x1 }, mp[new byte[] { 0x0, 0x0, 0x1 }]);

            mp[new byte[] { 0x11, 0x0, 0x2 }] = new byte[] { 0x11, 0x0, 0x2 };
            Assert.Equal(new byte[] { 0x11, 0x0, 0x2 }, mp[new byte[] { 0x11, 0x0, 0x2 }]);
        }
Ejemplo n.º 4
0
            public MPW(MPT type, object value)
            {
                Type  = type;
                Value = value;

                if (Type == MPT.ListEntityRecords)
                {
                    List <EntityRecord> records = Value as List <EntityRecord>;
                    if (records != null)
                    {
                        for (int i = 0; i < records.Count; i++)
                        {
                            var recMPW = new MPW(MPT.EntityRecord, records[i]);
                            Properties.Add($"[{i}]", recMPW);
                        }
                    }
                }
                else if (Type == MPT.EntityRecord)
                {
                    EntityRecord record = Value as EntityRecord;
                    if (record != null)
                    {
                        foreach (var propName in record.Properties.Keys)
                        {
                            var propValue = record[propName];
                            if (propValue is List <EntityRecord> )
                            {
                                Properties.Add(propName, new MPW(MPT.ListEntityRecords, propValue));
                            }
                            else if (propValue is EntityRecord)
                            {
                                Properties.Add(propName, new MPW(MPT.EntityRecord, propValue));
                            }
                            else
                            {
                                Properties.Add(propName, new MPW(MPT.Object, propValue));
                            }
                        }
                    }
                }
            }
Ejemplo n.º 5
0
	public int NGetAvgForMpt(MPT mpt)
	{
		if (m_mpmptcMeals[(int)mpt] == 0)
			return 0;

		return m_mpmptnMealSum[(int)mpt] / m_mpmptcMeals[(int)mpt];
	}