EdmStructuredValue

We found 10 examples in language CSharp for this search. You will see 41 fragments of code.

Other methods


        /// <summary>
        /// Retrieves the value corresponding to the given property name. Returns null if no such value exists.
        /// </summary>
        /// <param name="propertyName">The property that describes the value being found.</param>
        /// <returns>The requested value, or null if no such value exists.</returns>
        public IEdmPropertyValue FindPropertyValue(string propertyName)
        {
            // If there is a dictionary, use it.
            Dictionary<string, IEdmPropertyValue> propertiesDictionary = this.PropertiesDictionary;
            if (propertiesDictionary != null)
            {
                IEdmPropertyValue propertyValue;
                propertiesDictionary.TryGetValue(propertyName, out propertyValue);
                return propertyValue;
            }

            // If there is no dictionary, go through the property values and take the first match.
            foreach (IEdmPropertyValue propertyValue in this.propertyValues)
            {
                if (propertyValue.Name == propertyName)
                {
                    return propertyValue;
                }
            }

            return null;
        }

        private Dictionary<string, IEdmPropertyValue> ComputePropertiesDictionary()
        {
            Dictionary<string, IEdmPropertyValue> propertiesDictionary = new Dictionary<string, IEdmPropertyValue>();

            foreach (IEdmPropertyValue propertyValue in this.propertyValues)
            {
                propertiesDictionary[propertyValue.Name] = propertyValue;
            }

            return propertiesDictionary;
        }


        /// <summary>
        /// Retrieves the value corresponding to the given property name. Returns null if no such value exists.
        /// </summary>
        /// <param name="propertyName">The property that describes the value being found.</param>
        /// <returns>The requested value, or null if no such value exists.</returns>
        public IEdmPropertyValue FindPropertyValue(string propertyName)
        {
            // If there is a dictionary, use it.
            Dictionary<string, IEdmPropertyValue> propertiesDictionary = this.PropertiesDictionary;
            if (propertiesDictionary != null)
            {
                IEdmPropertyValue propertyValue;
                propertiesDictionary.TryGetValue(propertyName, out propertyValue);
                return propertyValue;
            }

            // If there is no dictionary, go through the property values and take the first match.
            foreach (IEdmPropertyValue propertyValue in this.propertyValues)
            {
                if (propertyValue.Name == propertyName)
                {
                    return propertyValue;
                }
            }

            return null;
        }

        private Dictionary<string, IEdmPropertyValue> ComputePropertiesDictionary()
        {
            Dictionary<string, IEdmPropertyValue> propertiesDictionary = new Dictionary<string, IEdmPropertyValue>();

            foreach (IEdmPropertyValue propertyValue in this.propertyValues)
            {
                propertiesDictionary[propertyValue.Name] = propertyValue;
            }

            return propertiesDictionary;
        }


        /// <summary>
        /// Retrieves the value corresponding to the given property name. Returns null if no such value exists.
        /// </summary>
        /// <param name="propertyName">The property that describes the value being found.</param>
        /// <returns>The requested value, or null if no such value exists.</returns>
        public IEdmPropertyValue FindPropertyValue(string propertyName)
        {
            // If there is a dictionary, use it.
            Dictionary<string, IEdmPropertyValue> propertiesDictionary = this.PropertiesDictionary;
            if (propertiesDictionary != null)
            {
                IEdmPropertyValue propertyValue;
                propertiesDictionary.TryGetValue(propertyName, out propertyValue);
                return propertyValue;
            }

            // If there is no dictionary, go through the property values and take the first match.
            foreach (IEdmPropertyValue propertyValue in this.propertyValues)
            {
                if (propertyValue.Name == propertyName)
                {
                    return propertyValue;
                }
            }

            return null;
        }

        private Dictionary<string, IEdmPropertyValue> ComputePropertiesDictionary()
        {
            Dictionary<string, IEdmPropertyValue> propertiesDictionary = new Dictionary<string, IEdmPropertyValue>();

            foreach (IEdmPropertyValue propertyValue in this.propertyValues)
            {
                propertiesDictionary[propertyValue.Name] = propertyValue;
            }

            return propertiesDictionary;
        }


		private Dictionary<string, IEdmPropertyValue> ComputePropertiesDictionary()
		{
			Dictionary<string, IEdmPropertyValue> strs = new Dictionary<string, IEdmPropertyValue>();
			foreach (IEdmPropertyValue propertyValue in this.propertyValues)
			{
				strs[propertyValue.Name] = propertyValue;
			}
			return strs;
		}

		public IEdmPropertyValue FindPropertyValue(string propertyName)
		{
			IEdmPropertyValue edmPropertyValue = null;
			IEdmPropertyValue edmPropertyValue1;
			Dictionary<string, IEdmPropertyValue> propertiesDictionary = this.PropertiesDictionary;
			if (propertiesDictionary == null)
			{
				IEnumerator<IEdmPropertyValue> enumerator = this.propertyValues.GetEnumerator();
				using (enumerator)
				{
					while (enumerator.MoveNext())
					{
						IEdmPropertyValue current = enumerator.Current;
						if (current.Name != propertyName)
						{
							continue;
						}
						edmPropertyValue1 = current;
						return edmPropertyValue1;
					}
					return null;
				}
				return edmPropertyValue1;
			}
			else
			{
				propertiesDictionary.TryGetValue(propertyName, out edmPropertyValue);
				return edmPropertyValue;
			}
		}

        [TestMethod]
        public void ConvertPrimitiveTypes()
        {
            EdmToClrConverter c = new EdmToClrConverter();

            byte[] b = { 1, 2, 3 };
            Assert.AreEqual(b, c.AsClrValue(new EdmBinaryConstant(b), typeof(byte[])), "binary 1");
            Assert.AreEqual(b, c.AsClrValue<byte[]>(new EdmBinaryConstant(b)), "binary2");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(byte[])), "Null is null even when null is bool");

            Assert.AreEqual("qwerty", c.AsClrValue(new EdmStringConstant("qwerty"), typeof(string)), "string 1");
            Assert.AreEqual("qwerty", c.AsClrValue<string>(new EdmStringConstant("qwerty")), "string 2");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(string)), "Null is null even when null is string");

            Assert.AreEqual(true, c.AsClrValue(new EdmBooleanConstant(true), typeof(bool)), "bool 1");
            Assert.AreEqual(true, c.AsClrValue<bool>(new EdmBooleanConstant(true)), "bool 2");

            bool? nullableBool = true;
            Assert.AreEqual(nullableBool, c.AsClrValue(new EdmBooleanConstant(true), typeof(bool?)), "nullable bool");
            Assert.AreEqual(typeof(bool), c.AsClrValue(new EdmBooleanConstant(true), typeof(bool?)).GetType(), "nullable bool correct type");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(bool?)), "Null is null even when null is bool");

            Assert.AreEqual('q', c.AsClrValue(new EdmIntegerConstant('q'), typeof(char)), "char 1");
            Assert.AreEqual('q', c.AsClrValue<char>(new EdmIntegerConstant('q')), "char 2");

            char? nullableChar = 'q';
            Assert.AreEqual(nullableChar, c.AsClrValue(new EdmIntegerConstant('q'), typeof(char?)), "nullable char");
            Assert.AreEqual(typeof(char), c.AsClrValue(new EdmIntegerConstant('q'), typeof(char?)).GetType(), "nullable char is correct type");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(char?)), "Null is null even when null is char");

            Assert.AreEqual((sbyte)(-12), c.AsClrValue(new EdmIntegerConstant(-12), typeof(sbyte)), "sbyte 1");
            Assert.AreEqual((sbyte)(-12), c.AsClrValue<sbyte>(new EdmIntegerConstant(-12)), "sbyte 2");

            sbyte? nullableSByte = -12;
            Assert.AreEqual(nullableSByte, ((sbyte?)c.AsClrValue(new EdmIntegerConstant(-12), typeof(sbyte?))).Value, "nullable sbyte");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(sbyte?)), "Null is null even when null is sbyte");

            Assert.AreEqual((byte)12, c.AsClrValue(new EdmIntegerConstant(12), typeof(byte)), "byte 1");
            Assert.AreEqual((byte)12, c.AsClrValue<byte>(new EdmIntegerConstant(12)), "byte 2");
            try
            {
                c.AsClrValue<byte>(new EdmIntegerConstant(257));
                Assert.Fail("OverflowException expected");
            }
            catch (OverflowException)
            {
            }

            byte? nullableByte = 12;
            Assert.AreEqual(nullableByte, ((byte?)c.AsClrValue(new EdmIntegerConstant(12), typeof(byte?))).Value, "nullable byte");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(byte?)), "Null is null even when null is byte");
            try
            {
                c.AsClrValue(new EdmIntegerConstant(257), typeof(byte?));
                Assert.Fail("OverflowException expected");
            }
            catch (OverflowException)
            {
            }

            Assert.AreEqual((Int16)(-12), c.AsClrValue(new EdmIntegerConstant(-12), typeof(Int16)), "Int16 1");
            Assert.AreEqual((Int16)(-12), c.AsClrValue<Int16>(new EdmIntegerConstant(-12)), "Int16 2");

            Int16? nullableInt16 = -12;
            Assert.AreEqual(nullableInt16, ((Int16?)c.AsClrValue(new EdmIntegerConstant(-12), typeof(Int16?))).Value, "nullable Int16");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(Int16?)), "Null is null even when null is Int16");

            Assert.AreEqual((UInt16)12, c.AsClrValue(new EdmIntegerConstant(12), typeof(UInt16)), "UInt16 1");
            Assert.AreEqual((UInt16)12, c.AsClrValue<UInt16>(new EdmIntegerConstant(12)), "UInt16 2");

            Assert.AreEqual((UInt16)12, ((UInt16?)c.AsClrValue(new EdmIntegerConstant(12), typeof(UInt16?))).Value, "nullable UInt16");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(UInt16?)), "Null is null even when null is UInt16");

            Assert.AreEqual((Int32)(-12), c.AsClrValue(new EdmIntegerConstant(-12), typeof(Int32)), "Int32 1");
            Assert.AreEqual((Int32)(-12), c.AsClrValue<Int32>(new EdmIntegerConstant(-12)), "Int32 2");

            Assert.AreEqual((Int32)(-12), ((Int32?)c.AsClrValue(new EdmIntegerConstant(-12), typeof(Int32?))).Value, "nullable Int32");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(Int32?)), "Null is null even when null is Int32");

            Assert.AreEqual((UInt32)12, c.AsClrValue(new EdmIntegerConstant(12), typeof(UInt32)), "UInt32 1");
            Assert.AreEqual((UInt32)12, c.AsClrValue<UInt32>(new EdmIntegerConstant(12)), "UInt32 2");

            Assert.AreEqual((UInt32)12, ((UInt32?)c.AsClrValue(new EdmIntegerConstant(12), typeof(UInt32?))).Value, "nullable UInt32");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(UInt32?)), "Null is null even when null is UInt32");

            Assert.AreEqual((Int64)(-12), c.AsClrValue(new EdmIntegerConstant(-12), typeof(Int64)), "Int64 1");
            Assert.AreEqual((Int64)(-12), c.AsClrValue<Int64>(new EdmIntegerConstant(-12)), "Int64 2");

            Assert.AreEqual((Int64)(-12), ((Int64?)c.AsClrValue(new EdmIntegerConstant(-12), typeof(Int64?))).Value, "nullable Int64");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(Int64?)), "Null is null even when null is Int64");

            Assert.AreEqual((UInt64)12, c.AsClrValue(new EdmIntegerConstant(12), typeof(UInt64)), "UInt64 1");
            Assert.AreEqual((UInt64)12, c.AsClrValue<UInt64>(new EdmIntegerConstant(12)), "UInt64 2");

            Assert.AreEqual((UInt64)12, ((UInt64?)c.AsClrValue(new EdmIntegerConstant(12), typeof(UInt64?))).Value, "nullable UInt64");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(UInt64?)), "Null is null even when null is UInt64");

            Assert.AreEqual((double)1.2, c.AsClrValue(new EdmFloatingConstant(1.2), typeof(double)), "double 1");
            Assert.AreEqual((double)1.2, c.AsClrValue<double>(new EdmFloatingConstant(1.2)), "double 2");

            Assert.AreEqual((double)1.2, ((double?)c.AsClrValue(new EdmFloatingConstant(1.2), typeof(double?))).Value, "nullable double");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(double?)), "Null is null even when null is double");

            Assert.AreEqual((Single)1.2, c.AsClrValue(new EdmFloatingConstant(1.2), typeof(Single)), "Single 1");
            Assert.AreEqual((Single)1.2, c.AsClrValue<Single>(new EdmFloatingConstant(1.2)), "Single 2");

            Assert.AreEqual((Single)1.2, ((Single?)c.AsClrValue(new EdmFloatingConstant(1.2), typeof(Single?))).Value, "nullable Single");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(Single?)), "Null is null even when null is Single");

            Assert.AreEqual((decimal)1.2, c.AsClrValue(new EdmDecimalConstant(1.2m), typeof(decimal)), "decimal 1");
            Assert.AreEqual((decimal)1.2, c.AsClrValue<decimal>(new EdmDecimalConstant(1.2m)), "decimal 2");

            Assert.AreEqual((decimal)1.2, ((decimal?)c.AsClrValue(new EdmDecimalConstant(1.2m), typeof(decimal?))).Value, "nullable decimal");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(decimal?)), "Null is null even when null is decimal");

            DateTime dt = new DateTime(2011, 10, 18, 14, 48, 16);

            DateTimeOffset dto = new DateTimeOffset(dt, new TimeSpan(-8, 0, 0));
            Assert.AreEqual(dto, c.AsClrValue(new EdmDateTimeOffsetConstant(dto), typeof(DateTimeOffset)), "DateTimeOffset 1");
            Assert.AreEqual(dto, c.AsClrValue<DateTimeOffset>(new EdmDateTimeOffsetConstant(dto)), "DateTimeOffset 2");

            Assert.AreEqual(dto, ((DateTimeOffset?)c.AsClrValue(new EdmDateTimeOffsetConstant(dto), typeof(DateTimeOffset?))).Value, "nullable DateTimeOffset");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(DateTimeOffset?)), "Null is null even when null is DateTimeOffset");

            Date date = new Date(2014, 8, 8);

            Assert.AreEqual(date, c.AsClrValue(new EdmDateConstant(date), typeof(Date)), "Date 1");
            Assert.AreEqual(date, c.AsClrValue<Date>(new EdmDateConstant(date)), "Date 2");
            Assert.AreEqual(date, ((Date?)c.AsClrValue(new EdmDateConstant(date), typeof(Date?))).Value, "nullable Date");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(Date?)), "Null is null even when null is Date");

            TimeOfDay time = new TimeOfDay(12, 5, 30, 900);
            Assert.AreEqual(time, c.AsClrValue(new EdmTimeOfDayConstant(time), typeof(TimeOfDay)), "Time 1");
            Assert.AreEqual(time, c.AsClrValue<TimeOfDay>(new EdmTimeOfDayConstant(time)), "Time 2");
            Assert.AreEqual(time, ((TimeOfDay?)c.AsClrValue(new EdmTimeOfDayConstant(time), typeof(TimeOfDay?))).Value, "nullable Time");
            Assert.IsNull(c.AsClrValue(EdmNullExpression.Instance, typeof(TimeOfDay?)), "Null is null even when null is Time");
        }

        [TestMethod]
        public void ConvertCollections()
        {
            string[] elements = { "ab", "cd", "ef", null };
            EdmCollectionValue c = new EdmCollectionValue(
                EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(true)),
                elements.Select(e => e == null ? (IEdmDelayedValue)EdmNullExpression.Instance : (IEdmDelayedValue)new EdmStringConstant(e)));

            EdmToClrConverter cv = new EdmToClrConverter();

            string[] converted = ((IEnumerable<string>)cv.AsClrValue(c, typeof(IEnumerable<string>))).ToArray();
            Assert.AreEqual(elements.Length, converted.Length, "Length 1");
            for (int i = 0; i < elements.Length; ++i)
            {
                Assert.AreEqual(elements[i], converted[i], "elements[i] 1");
            }

            converted = cv.AsClrValue<IEnumerable<string>>(c).ToArray();
            Assert.AreEqual(elements.Length, converted.Length, "Length 2");
            for (int i = 0; i < elements.Length; ++i)
            {
                Assert.AreEqual(elements[i], converted[i], "elements[i] 2");
            }
        }

        [TestMethod]
        public void ConvertEnums()
        {
            EdmToClrConverter c = new EdmToClrConverter();

            EdmEnumType e32 = new EdmEnumType("", "");
            var r32 = e32.AddMember("Red", new EdmEnumMemberValue(10));
            e32.AddMember("Blue", new EdmEnumMemberValue(20));

            EdmEnumValue evRed = new EdmEnumValue(new EdmEnumTypeReference(e32, false), r32);
            EdmEnumValue ev20 = new EdmEnumValue(new EdmEnumTypeReference(e32, false), new EdmEnumMemberValue(20));
            EdmEnumValue ev30 = new EdmEnumValue(new EdmEnumTypeReference(e32, false), new EdmEnumMemberValue(30));

            Assert.AreEqual(RedBlue.Red, c.AsClrValue<RedBlue>(evRed), "c.AsClrValue<RedBlue>(evRed)");
            Assert.AreEqual(RedBlue.Blue, c.AsClrValue<RedBlue>(ev20), "c.AsClrValue<RedBlue>(ev20)");
            Assert.AreEqual((RedBlue)30, c.AsClrValue<RedBlue>(ev30), "c.AsClrValue<RedBlue>(ev30)");

            Assert.AreEqual(null, c.AsClrValue<RedBlue?>(EdmNullExpression.Instance), "Null Enum is null");

            Assert.AreEqual(RedBlueByte.Red, c.AsClrValue<RedBlueByte>(evRed), "c.AsClrValue<RedBlueByte>(evRed)");
            Assert.AreEqual(RedBlueByte.Blue, c.AsClrValue<RedBlueByte>(ev20), "c.AsClrValue<RedBlueByte>(ev20)");
            Assert.AreEqual((RedBlueByte)30, c.AsClrValue<RedBlueByte>(ev30), "c.AsClrValue<RedBlueByte>(ev30)");

            Assert.AreEqual(RedBlueLong.Red, c.AsClrValue<RedBlueLong>(evRed), "c.AsClrValue<RedBlueLong>(evRed)");
            Assert.AreEqual(RedBlueLong.Blue, c.AsClrValue<RedBlueLong>(ev20), "c.AsClrValue<RedBlueLong>(ev20)");
            Assert.AreEqual((RedBlueLong)30, c.AsClrValue<RedBlueLong>(ev30), "c.AsClrValue<RedBlueLong>(ev30)");

            Assert.AreEqual(RedBlueLong.Red, c.AsClrValue(evRed, typeof(RedBlueLong)), "c.AsClrValue(evRed, typeof(RedBlueLong))");
            Assert.AreEqual(RedBlueLong.Blue, c.AsClrValue(ev20, typeof(RedBlueLong)), "c.AsClrValue(ev20, typeof(RedBlueLong))");
            Assert.AreEqual((RedBlueLong)30, c.AsClrValue(ev30, typeof(RedBlueLong)), "c.AsClrValue(ev30, typeof(RedBlueLong))");
        }

        [TestMethod]
        public void ConvertStructuredTypes()
        {
            IEdmStructuredValue c1_inner = new EdmStructuredValue(null, new IEdmPropertyValue[]
            {
                new EdmPropertyValue("P1", new EdmStringConstant("c1ip1")),
                new EdmPropertyValue("P3", new EdmIntegerConstant(110))
            });

            IEdmStructuredValue c2 = new EdmStructuredValue(null, new IEdmPropertyValue[]
            {
                new EdmPropertyValue("Q1", new EdmStringConstant("c2q1")),
                new EdmPropertyValue("Q2", c1_inner),
                new EdmPropertyValue("Q3", new EdmIntegerConstant(22))
            });

            IEdmStructuredValue c1 = new EdmStructuredValue(null, new IEdmPropertyValue[]
            {
                new EdmPropertyValue("P1", new EdmStringConstant("c1p1")),
                new EdmPropertyValue("P2", c2),
                new EdmPropertyValue("P3", new EdmIntegerConstant(11))
            });

            EdmToClrConverter cv = new EdmToClrConverter();

            C1[] clrC1s = { (C1)cv.AsClrValue(c1, typeof(C1)), cv.AsClrValue<C1>(c1) };

            for (int i = 0; i < clrC1s.Length; ++i)
            {
                C1 clrC1 = clrC1s[i];

                // C1
                Assert.IsNotNull(clrC1, "c1 " + i);
                Assert.AreEqual("c1p1", clrC1.P1, "c1.P1 " + i);
                Assert.AreEqual(11, clrC1.P3, "c1.P3 " + i);

                // C1.P2
                Assert.IsNotNull(clrC1.P2, "c1.P2 " + i);
                Assert.AreEqual("c2q1", clrC1.P2.Q1, "c1.P2.Q1 " + i);
                Assert.AreEqual(22, clrC1.P2.Q3, "c1.P2.Q3 " + i);

                // C1.P2.Q2
                Assert.IsNotNull(clrC1.P2.Q2, "c1.P2.Q2 " + i);
                Assert.AreEqual("c1ip1", clrC1.P2.Q2.P1, "c1.P2.Q2.P1 " + i);
                Assert.AreEqual(110, clrC1.P2.Q2.P3, "c1.P2.Q2.P3 " + i);

                // C1.P2.Q2.P2
                Assert.IsNull(clrC1.P2.Q2.P2, "c1.P2.Q2.P2 " + i);
            }
        }

        [TestMethod]
        public void ConvertGraphWithLoops()
        {
            var c1_inner_loopProperty = new EdmPropertyValue("P2");

            IEdmStructuredValue c1_inner = new EdmStructuredValue(null, new IEdmPropertyValue[]
            {
                new EdmPropertyValue("P1", new EdmStringConstant("c1ip1")),
                c1_inner_loopProperty,
                new EdmPropertyValue("P3", new EdmIntegerConstant(110)),
                new EdmPropertyValue("NoClrCounterpart", new EdmIntegerConstant(110)) // conversion should ignore this and not choke
            });

            IEdmStructuredValue c2 = new EdmStructuredValue(null, new IEdmPropertyValue[]
            {
                new EdmPropertyValue("Q1", new EdmStringConstant("c2q1")),
                new EdmPropertyValue("Q2", c1_inner),
                new EdmPropertyValue("Q3", EdmNullExpression.Instance)
            });

            c1_inner_loopProperty.Value = c2;

            IEdmStructuredValue c1 = new EdmStructuredValue(null, new IEdmPropertyValue[]
            {
                new EdmPropertyValue("P1", new EdmStringConstant("c1p1")),
                new EdmPropertyValue("P2", c2),
                new EdmPropertyValue("P3", new EdmIntegerConstant(11))
            });

            EdmToClrConverter cv = new EdmToClrConverter();

            C1[] clrC1s = { (C1)cv.AsClrValue(c1, typeof(C1)), cv.AsClrValue<C1>(c1) };

            for (int i = 0; i < clrC1s.Length; ++i)
            {
                C1 clrC1 = clrC1s[i];

                // C1
                Assert.IsNotNull(clrC1, "c1 " + i);
                Assert.AreEqual("c1p1", clrC1.P1, "c1.P1 " + i);
                Assert.AreEqual(11, clrC1.P3, "c1.P3 " + i);

                // C1.P2
                Assert.IsNotNull(clrC1.P2, "c1.P2 " + i);
                Assert.AreEqual("c2q1", clrC1.P2.Q1, "c1.P2.Q1 " + i);
                Assert.AreEqual(null, clrC1.P2.Q3, "c1.P2.Q3 " + i);

                // C1.P2.Q2
                Assert.IsNotNull(clrC1.P2.Q2, "c1.P2.Q2 " + i);
                Assert.AreEqual("c1ip1", clrC1.P2.Q2.P1, "c1.P2.Q2.P1 " + i);
                Assert.AreEqual(110, clrC1.P2.Q2.P3, "c1.P2.Q2.P3 " + i);

                // C1.P2.Q2.P2
                Assert.IsTrue(Object.ReferenceEquals(clrC1.P2.Q2.P2, clrC1.P2), "c1.P2.Q2.P2 " + i);
            }
        }
            #region IList<int>
            int IList<int>.IndexOf(int item)
            {
                throw new NotImplementedException();
            }


		// Token: 0x060003D8 RID: 984 RVA: 0x00009AE8 File Offset: 0x00007CE8
		public T AsClrValue<T>(IEdmValue edmValue)
		{
			EdmUtil.CheckArgumentNull<IEdmValue>(edmValue, "edmValue");
			bool convertEnumValues = false;
			return (T)((object)this.AsClrValue(edmValue, typeof(T), convertEnumValues));
		}

		// Token: 0x060003D9 RID: 985 RVA: 0x00009B1C File Offset: 0x00007D1C
		public object AsClrValue(IEdmValue edmValue, Type clrType)
		{
			EdmUtil.CheckArgumentNull<IEdmValue>(edmValue, "edmValue");
			EdmUtil.CheckArgumentNull<Type>(clrType, "clrType");
			bool convertEnumValues = true;
			return this.AsClrValue(edmValue, clrType, convertEnumValues);
		}

		// Token: 0x060003DA RID: 986 RVA: 0x00009B4C File Offset: 0x00007D4C
		public void RegisterConvertedObject(IEdmStructuredValue edmValue, object clrObject)
		{
			this.convertedObjects.Add(edmValue, clrObject);
		}

		// Token: 0x060003DB RID: 987 RVA: 0x00009B5B File Offset: 0x00007D5B
		internal static byte[] AsClrByteArray(IEdmValue edmValue)
		{
			EdmUtil.CheckArgumentNull<IEdmValue>(edmValue, "edmValue");
			if (edmValue is IEdmNullValue)
			{
				return null;
			}
			return ((IEdmBinaryValue)edmValue).Value;
		}

		// Token: 0x060003DC RID: 988 RVA: 0x00009B7E File Offset: 0x00007D7E
		internal static string AsClrString(IEdmValue edmValue)
		{
			EdmUtil.CheckArgumentNull<IEdmValue>(edmValue, "edmValue");
			if (edmValue is IEdmNullValue)
			{
				return null;
			}
			return ((IEdmStringValue)edmValue).Value;
		}

		// Token: 0x060003DD RID: 989 RVA: 0x00009BA1 File Offset: 0x00007DA1
		internal static bool AsClrBoolean(IEdmValue edmValue)
		{
			EdmUtil.CheckArgumentNull<IEdmValue>(edmValue, "edmValue");
			return ((IEdmBooleanValue)edmValue).Value;
		}


        [Fact]
        public void GetEntityMetadataBuilderShouldThrowWhenMetadataDocumentUriIsNull()
        {
            ODataMetadataContext context = new ODataMetadataContext(
                true /*readingResponse*/,
                null,
                new EdmTypeReaderResolver(this.edmModel, null),
                this.edmModel,
                null /*metadataDocumentUri*/,
                null /*requestUri*/);
            IEdmEntitySet set = this.edmModel.EntityContainer.FindEntitySet("Products");
            ODataResource entry = TestUtils.CreateODataEntry(set, new EdmStructuredValue(new EdmEntityTypeReference(set.EntityType(), true), new IEdmPropertyValue[0]), set.EntityType());
            Action action = () => context.GetResourceMetadataBuilderForReader(new TestJsonLightReaderEntryState { Resource = entry, SelectedProperties = new SelectedPropertiesNode(SelectedPropertiesNode.SelectionType.EntireSubtree), NavigationSource = set }, false);
            action.Throws<ODataException>(Strings.ODataJsonLightResourceMetadataContext_MetadataAnnotationMustBeInPayload("odata.context"));
        }

        [Fact]
        public void GetEntityMetadataBuilderShouldNotThrowWhenMetadataDocumentUriIsNonNullAndAbsolute()
        {
            ODataMetadataContext context = new ODataMetadataContext(
                true /*readingResponse*/,
                null,
                new EdmTypeReaderResolver(this.edmModel, null),
                this.edmModel,
                new Uri("http://myservice.svc/$metadata", UriKind.Absolute),
                null /*requestUri*/);
            IEdmEntitySet set = this.edmModel.EntityContainer.FindEntitySet("Products");
            ODataResource entry = TestUtils.CreateODataEntry(set, new EdmStructuredValue(new EdmEntityTypeReference(set.EntityType(), true), new IEdmPropertyValue[0]), set.EntityType());
            Action action = () => context.GetResourceMetadataBuilderForReader(new TestJsonLightReaderEntryState { Resource = entry, SelectedProperties = new SelectedPropertiesNode("*", null, null), NavigationSource = set }, false);
            action.DoesNotThrow();
        }

        [Fact]
        public void CheckForOperationsRequiringContainerQualificationFallBackToWhetherTypeIsOpen()
        {
            var closedType = new EdmEntityType("NS", "Type1");
            var openType = new EdmEntityType("NS", "Type2", null, false, true);

            ODataMetadataContext context = new ODataMetadataContext(
                true /*readingResponse*/,
                null,
                new EdmTypeReaderResolver(this.edmModel, null),
                this.edmModel,
                null /*metadataDocumentUri*/,
                null /*requestUri*/);

            Assert.False(context.OperationsBoundToStructuredTypeMustBeContainerQualified(closedType));
            Assert.True(context.OperationsBoundToStructuredTypeMustBeContainerQualified(openType));
        }


        private void SetupModelsAndValues()
        {
            this.SetupOperations();
            this.SetupVocabularyDefinitionModel();

            this.SetupBaseModel();
            this.SetupValues();
        }

        private void SetupOperations()
        {
            const string builtinFunctionsCsdl =
@"<Schema Namespace=""Functions"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
  <Function Name=""StringConcat""><ReturnType Type=""String""/>
    <Parameter Name=""String1"" Type=""String"" />
    <Parameter Name=""String2"" Type=""String"" />
  </Function>
  <Function Name=""StringConcat""><ReturnType Type=""String""/>
    <Parameter Name=""String1"" Type=""String"" />
    <Parameter Name=""String2"" Type=""String"" />
    <Parameter Name=""String3"" Type=""String"" />
  </Function>
  <Function Name=""True""><ReturnType Type=""Boolean"" /></Function>
  <Function Name=""False""><ReturnType Type=""Boolean"" /></Function>
</Schema>";
            this.operationsModel = this.Parse(builtinFunctionsCsdl);

            this.operationsLookup = new Dictionary<IEdmOperation, Func<IEdmValue[], IEdmValue>>();

            IEdmOperation stringConcat2 = this.operationsModel.FindOperations("Functions.StringConcat").Single(f => f.Parameters.Count() == 2);
            this.operationsLookup[stringConcat2] = (a) => new EdmStringConstant(((IEdmStringValue)a[0]).Value + ((IEdmStringValue)a[1]).Value);

            IEdmOperation stringConcat3 = this.operationsModel.FindOperations("Functions.StringConcat").Single(f => f.Parameters.Count() == 3);
            this.operationsLookup[stringConcat3] = (a) => new EdmStringConstant(((IEdmStringValue)a[0]).Value + ((IEdmStringValue)a[1]).Value + ((IEdmStringValue)a[2]).Value);

            IEdmOperation trueOperation = this.operationsModel.FindOperations("Functions.True").Single();
            this.operationsLookup[trueOperation] = (a) => new EdmBooleanConstant(true);

            IEdmOperation falseOperation = this.operationsModel.FindOperations("Functions.False").Single();
            this.operationsLookup[falseOperation] = (a) => new EdmBooleanConstant(false);
        }

        private void SetupVocabularyDefinitionModel()
        {
            const string vocabularyDefinitionModelCsdl =
@"<Schema Namespace=""bar"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
    <Term Name=""BinaryValue"" Type=""Binary"" />
    <Term Name=""BooleanValue"" Type=""Boolean"" />
    <Term Name=""ByteValue"" Type=""Byte"" />
    <Term Name=""DateTimeOffsetValue"" Type=""DateTimeOffset"" />
    <Term Name=""DateValue"" Type=""Date"" />
    <Term Name=""DecimalValue"" Type=""Decimal"" />
    <Term Name=""DoubleValue"" Type=""Double"" />
    <Term Name=""GuidValue"" Type=""Guid"" />
    <Term Name=""Int16Value"" Type=""Int16"" />
    <Term Name=""Int32Value"" Type=""Int32"" />
    <Term Name=""Int64Value"" Type=""Int64"" />
    <Term Name=""SByteValue"" Type=""SByte"" />
    <Term Name=""SingleValue"" Type=""Single"" />
    <Term Name=""StringValue"" Type=""String"" />
    <Term Name=""TimeOfDayValue"" Type=""TimeOfDay"" />
    <Term Name=""DurationValue"" Type=""Duration"" />
    <Term Name=""GeographyValue"" Type=""Geography"" />
    <Term Name=""GeometryValue"" Type=""Geometry"" />
    <Term Name=""ComplexValue"" Type=""bar.Note"" />
    <Term Name=""EntityValue"" Type=""bar.MoreTransformedPerson"" />    
    
    <EntityType Name=""TransformedPerson"">
        <Property Name=""Age"" Type=""Int32"" Nullable=""false"" />
    </EntityType>
    <EntityType Name=""MoreTransformedPerson"" BaseType=""bar.TransformedPerson"">
        <Property Name=""Description"" Type=""String"" />
    </EntityType>

    <ComplexType Name=""Note"">
        <Property Name=""Summary"" Type=""String"" />
    </ComplexType>
</Schema>";
            this.vocabularyDefinitionModel = this.Parse(vocabularyDefinitionModelCsdl);
        }

        private void SetupBaseModel()
        {
            const string baseModelCsdl = @"
<Schema Namespace=""foo"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
    <EntityType Name=""Person"">
        <Key>
            <PropertyRef Name=""Name"" />
        </Key>
        <Property Name=""Name"" Type=""String"" Nullable=""false"" />
        <Property Name=""Birthday"" Type=""DateTimeOffset"" />
        <Property Name=""CoolnessIndex"" Type=""Int32"" />
        <Property Name=""Living"" Type=""Boolean"" />
        <Property Name=""Famous"" Type=""Boolean"" />
        <Property Name=""ContactInfo"" Type=""foo.ContactInfo"" />
        <NavigationProperty Name=""Address"" Type=""foo.Address"" Nullable=""false"" />
    </EntityType>
    <ComplexType Name=""ContactInfo"">
        <Property Name=""Email"" Type=""String"" />
        <Property Name=""WorkPhone"" Type=""foo.PhoneNumber"" />
        <Property Name=""HomePhone"" Type=""foo.PhoneNumber"" />
    </ComplexType>
    <ComplexType Name=""PhoneNumber"">
        <Property Name=""Area"" Type=""Int32"" />
        <Property Name=""Local"" Type=""Int64"" />
        <Property Name=""Extension"" Type=""Int32"" />
    </ComplexType>
    <ComplexType Name=""ZipCode"">
        <Property Name=""Main"" Type=""String"" />
        <Property Name=""Extension"" Type=""String"" />
    </ComplexType>
    <EntityType Name=""Address"">
        <Key>
            <PropertyRef Name=""Number"" />
            <PropertyRef Name=""Street"" />
            <PropertyRef Name=""City"" />
            <PropertyRef Name=""State"" />
        </Key>
        <Property Name=""Number"" Type=""Int32"" Nullable=""false"" />
        <Property Name=""Street"" Type=""String"" Nullable=""false"" />
        <Property Name=""City"" Type=""String"" Nullable=""false"" />
        <Property Name=""State"" Type=""String"" Nullable=""false"" />
        <Property Name=""Zip"" Type=""foo.ZipCode"" />
    </EntityType>
    <EntityType Name=""Professional"" BaseType=""foo.Person"">
        <Property Name=""Profession"" Type=""String"" />
    </EntityType>
    <EnumType Name=""PersonType"">
        <Member Name=""Extrovert"" />
        <Member Name=""Introvert"" Value=""7"" />
    </EnumType>
    <EntityContainer Name=""fooContainer"">
        <EntitySet Name=""PersonSet"" EntityType=""foo.Person"" />
    </EntityContainer>
</Schema>";
            this.baseModel = this.Parse(baseModelCsdl);
        }

        private void SetupValues()
        {
            IEdmEntityType person = (IEdmEntityType)this.baseModel.FindType("foo.Person");
            IEdmEntityType professional = (IEdmEntityType)this.baseModel.FindType("foo.Professional");
            IEdmEntityType address = (IEdmEntityType)this.baseModel.FindType("foo.Address");

            // ?? no EdmComplexValue
            var zipMain = new EdmPropertyValue("Main", new EdmStringConstant("98052"));
            var zipExtension = new EdmPropertyValue("Extension", new EdmStringConstant("0000"));
            var zipValue = new EdmPropertyValue("Zip", new EdmStructuredValue(null, new EdmPropertyValue[] { zipMain, zipExtension }));

            EdmPropertyValue address1Number = new EdmPropertyValue("Number", new EdmIntegerConstant(null, 1));
            EdmPropertyValue address1Street = new EdmPropertyValue("Street", new EdmStringConstant(null, "Joey Ramone Place"));
            EdmPropertyValue address1City = new EdmPropertyValue("City", new EdmStringConstant(null, "New York"));
            EdmPropertyValue address1State = new EdmPropertyValue("State", new EdmStringConstant(null, "New York"));
            EdmPropertyValue[] address1Properties = new EdmPropertyValue[] { address1Number, address1Street, address1City, address1State, zipValue };
            EdmStructuredValue address1Value = new EdmStructuredValue(new EdmEntityTypeReference(address, true), address1Properties);

            var phoneLocal = new EdmPropertyValue("Local", new EdmIntegerConstant(9991234));
            var phoneValue = new EdmPropertyValue("WorkPhone", new EdmStructuredValue(null, new EdmPropertyValue[] { phoneLocal }));
            var contactInfoValue = new EdmPropertyValue("ContactInfo", new EdmStructuredValue(null, new EdmPropertyValue[] { phoneValue }));

            EdmPropertyValue person1Name = new EdmPropertyValue("Name", new EdmStringConstant(null, "Joey Ramone"));
            EdmPropertyValue person1Birthday = new EdmPropertyValue("Birthday", new EdmDateTimeOffsetConstant(null, new DateTimeOffset(1951, 5, 19, 0, 0, 0, TimeSpan.Zero)));
            EdmPropertyValue person1CoolnessIndex = new EdmPropertyValue("CoolnessIndex", new EdmIntegerConstant(null, Int32.MaxValue));
            EdmPropertyValue person1Living = new EdmPropertyValue("Living", new EdmBooleanConstant(false));
            EdmPropertyValue person1Famous = new EdmPropertyValue("Famous", new EdmBooleanConstant(null, true));
            EdmPropertyValue person1Address = new EdmPropertyValue("Address", address1Value);

            EdmPropertyValue[] person1Properties = new EdmPropertyValue[] { person1Name, person1Birthday, person1CoolnessIndex, person1Living, person1Famous, person1Address, contactInfoValue };
            this.personValue = new EdmStructuredValue(new EdmEntityTypeReference(person, false), person1Properties);

            this.professionalValue = new EdmStructuredValue(new EdmEntityTypeReference(professional, false), person1Properties);
        }

        [TestMethod]
        public void Term_Constant_OnBaseEntityTypes()
        {
            this.SetupModelsAndValues();

            const string applicationCsdl =
@"<Schema Namespace=""Annotations.Application"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
    <Annotations Target=""foo.Person"">
        <Annotation Term=""bar.Int32Value"" Qualifier=""q1.q1"" Int=""100"" />
    </Annotations>
</Schema>";
            IEdmModel applicationModel = this.Parse(applicationCsdl, this.baseModel, this.vocabularyDefinitionModel);
            EdmExpressionEvaluator expressionEvaluator = new EdmExpressionEvaluator(this.operationsLookup);

            IEdmTerm termInt32Value = this.vocabularyDefinitionModel.FindTerm("bar.Int32Value");

            IEdmValue annotationOnPerson = applicationModel.GetTermValue(this.personValue, termInt32Value, expressionEvaluator);
            Assert.AreEqual(100, ((IEdmIntegerValue)annotationOnPerson).Value, "Term annotation value is wrong.");

            annotationOnPerson = applicationModel.GetTermValue(this.personValue, termInt32Value, "q1.q1", expressionEvaluator);
            Assert.AreEqual(100, ((IEdmIntegerValue)annotationOnPerson).Value, "Term annotation value is wrong.");

            IEdmValue annotationInherited = applicationModel.GetTermValue(this.professionalValue, termInt32Value, expressionEvaluator);
            Assert.AreEqual(100, ((IEdmIntegerValue)annotationInherited).Value, "Term annotation value is wrong.");

            annotationInherited = applicationModel.GetTermValue(this.professionalValue, termInt32Value, "q1.q1", expressionEvaluator);
            Assert.AreEqual(100, ((IEdmIntegerValue)annotationInherited).Value, "Term annotation value is wrong.");
        }


		// Token: 0x060003FA RID: 1018 RVA: 0x0000A7C5 File Offset: 0x000089C5
		public IEdmValue Evaluate(IEdmExpression expression)
		{
			EdmUtil.CheckArgumentNull<IEdmExpression>(expression, "expression");
			return this.Eval(expression, null);
		}

		// Token: 0x060003FB RID: 1019 RVA: 0x0000A7DB File Offset: 0x000089DB
		public IEdmValue Evaluate(IEdmExpression expression, IEdmStructuredValue context)
		{
			EdmUtil.CheckArgumentNull<IEdmExpression>(expression, "expression");
			return this.Eval(expression, context);
		}

		// Token: 0x060003FC RID: 1020 RVA: 0x0000A7F1 File Offset: 0x000089F1
		public IEdmValue Evaluate(IEdmExpression expression, IEdmStructuredValue context, IEdmTypeReference targetType)
		{
			EdmUtil.CheckArgumentNull<IEdmExpression>(expression, "expression");
			EdmUtil.CheckArgumentNull<IEdmTypeReference>(targetType, "targetType");
			return EdmExpressionEvaluator.AssertType(targetType, this.Eval(expression, context));
		}

		// Token: 0x060003FD RID: 1021 RVA: 0x0000A819 File Offset: 0x00008A19
		private static bool InRange(long value, long min, long max)
		{
			return value >= min && value <= max;
		}

		// Token: 0x060003FE RID: 1022 RVA: 0x0000A828 File Offset: 0x00008A28
		private static bool FitsInSingle(double value)
		{
			return value >= -3.4028234663852886E+38 && value <= 3.4028234663852886E+38;
		}

		// Token: 0x060003FF RID: 1023 RVA: 0x0000A847 File Offset: 0x00008A47
		private static bool MatchesType(IEdmTypeReference targetType, IEdmValue operand)
		{
			return EdmExpressionEvaluator.MatchesType(targetType, operand, true);
		}


		private static bool AssertOrMatchStructuredType(IEdmStructuredTypeReference structuredTargetType, IEdmStructuredValue structuredValue, bool testPropertyTypes, List<IEdmPropertyValue> newProperties)
		{
			bool flag;
			IEdmTypeReference type = structuredValue.Type;
			if (type == null || type.TypeKind() == EdmTypeKind.Row || structuredTargetType.StructuredDefinition().InheritsFrom(type.AsStructured().StructuredDefinition()))
			{
				HashSetInternal<IEdmPropertyValue> edmPropertyValues = new HashSetInternal<IEdmPropertyValue>();
				IEnumerator<IEdmStructuralProperty> enumerator = structuredTargetType.StructuralProperties().GetEnumerator();
				using (enumerator)
				{
					while (enumerator.MoveNext())
					{
						IEdmProperty current = enumerator.Current;
						IEdmPropertyValue edmPropertyValue = structuredValue.FindPropertyValue(current.Name);
						if (edmPropertyValue != null)
						{
							edmPropertyValues.Add(edmPropertyValue);
							if (!testPropertyTypes)
							{
								continue;
							}
							if (newProperties == null)
							{
								if (EdmExpressionEvaluator.MatchesType(current.Type, edmPropertyValue.Value))
								{
									continue;
								}
								flag = false;
								return flag;
							}
							else
							{
								newProperties.Add(new EdmPropertyValue(edmPropertyValue.Name, EdmExpressionEvaluator.AssertType(current.Type, edmPropertyValue.Value)));
							}
						}
						else
						{
							flag = false;
							return flag;
						}
					}
					if (structuredTargetType.IsEntity())
					{
						IEnumerator<IEdmNavigationProperty> enumerator1 = structuredTargetType.AsEntity().NavigationProperties().GetEnumerator();
						using (enumerator1)
						{
							while (enumerator1.MoveNext())
							{
								IEdmNavigationProperty edmNavigationProperty = enumerator1.Current;
								IEdmPropertyValue edmPropertyValue1 = structuredValue.FindPropertyValue(edmNavigationProperty.Name);
								if (edmPropertyValue1 != null)
								{
									if (!testPropertyTypes || EdmExpressionEvaluator.MatchesType(edmNavigationProperty.Type, edmPropertyValue1.Value, false))
									{
										edmPropertyValues.Add(edmPropertyValue1);
										if (newProperties == null)
										{
											continue;
										}
										newProperties.Add(edmPropertyValue1);
									}
									else
									{
										flag = false;
										return flag;
									}
								}
								else
								{
									flag = false;
									return flag;
								}
							}
						}
					}
					if (newProperties != null)
					{
						IEnumerator<IEdmPropertyValue> enumerator2 = structuredValue.PropertyValues.GetEnumerator();
						using (enumerator2)
						{
							while (enumerator2.MoveNext())
							{
								IEdmPropertyValue current1 = enumerator2.Current;
								if (edmPropertyValues.Contains(current1))
								{
									continue;
								}
								newProperties.Add(current1);
							}
						}
					}
					return true;
				}
				return flag;
			}
			else
			{
				return false;
			}
		}

		private static IEdmValue AssertType(IEdmTypeReference targetType, IEdmValue operand)
		{
			IEdmTypeReference type = operand.Type;
			EdmValueKind valueKind = operand.ValueKind;
			if ((type == null || valueKind == EdmValueKind.Null || !type.Definition.IsOrInheritsFrom(targetType.Definition)) && targetType.TypeKind() != EdmTypeKind.None)
			{
				bool flag = true;
				EdmValueKind edmValueKind = valueKind;
				if (edmValueKind == EdmValueKind.Collection)
				{
					if (!targetType.IsCollection())
					{
						flag = false;
					}
					else
					{
						return new EdmExpressionEvaluator.AssertTypeCollectionValue(targetType.AsCollection(), (IEdmCollectionValue)operand);
					}
				}
				else
				{
					if (edmValueKind == EdmValueKind.Structured)
					{
						if (!targetType.IsStructured())
						{
							flag = false;
						}
						else
						{
							IEdmStructuredTypeReference edmStructuredTypeReference = targetType.AsStructured();
							List<IEdmPropertyValue> edmPropertyValues = new List<IEdmPropertyValue>();
							flag = EdmExpressionEvaluator.AssertOrMatchStructuredType(edmStructuredTypeReference, (IEdmStructuredValue)operand, true, edmPropertyValues);
							if (flag)
							{
								return new EdmStructuredValue(edmStructuredTypeReference, edmPropertyValues);
							}
						}
					}
					else
					{
						flag = EdmExpressionEvaluator.MatchesType(targetType, operand);
					}
				}
				if (flag)
				{
					return operand;
				}
				else
				{
					throw new InvalidOperationException(Strings.Edm_Evaluator_FailedTypeAssertion(targetType.ToTraceString()));
				}
			}
			else
			{
				return operand;
			}
		}

		private IEdmValue Eval(IEdmExpression expression, IEdmStructuredValue context)
		{
			Func<IEdmValue[], IEdmValue> func = null;
			IEdmStructuredTypeReference edmStructuredTypeReference;
			IEdmCollectionTypeReference edmCollectionTypeReference;
			object traceString;
			EdmExpressionKind expressionKind = expression.ExpressionKind;
			switch (expressionKind)
			{
				case EdmExpressionKind.BinaryConstant:
				{
					return (IEdmBinaryConstantExpression)expression;
				}
				case EdmExpressionKind.BooleanConstant:
				{
					return (IEdmBooleanConstantExpression)expression;
				}
				case EdmExpressionKind.DateTimeConstant:
				{
					return (IEdmDateTimeConstantExpression)expression;
				}
				case EdmExpressionKind.DateTimeOffsetConstant:
				{
					return (IEdmDateTimeOffsetConstantExpression)expression;
				}
				case EdmExpressionKind.DecimalConstant:
				{
					return (IEdmDecimalConstantExpression)expression;
				}
				case EdmExpressionKind.FloatingConstant:
				{
					return (IEdmFloatingConstantExpression)expression;
				}
				case EdmExpressionKind.GuidConstant:
				{
					return (IEdmGuidConstantExpression)expression;
				}
				case EdmExpressionKind.IntegerConstant:
				{
					return (IEdmIntegerConstantExpression)expression;
				}
				case EdmExpressionKind.StringConstant:
				{
					return (IEdmStringConstantExpression)expression;
				}
				case EdmExpressionKind.TimeConstant:
				{
					return (IEdmTimeConstantExpression)expression;
				}
				case EdmExpressionKind.Null:
				{
					return (IEdmNullExpression)expression;
				}
				case EdmExpressionKind.Record:
				{
					IEdmRecordExpression edmRecordExpression = (IEdmRecordExpression)expression;
					EdmExpressionEvaluator.DelayedExpressionContext delayedExpressionContext = new EdmExpressionEvaluator.DelayedExpressionContext(this, context);
					List<IEdmPropertyValue> edmPropertyValues = new List<IEdmPropertyValue>();
					foreach (IEdmPropertyConstructor property in edmRecordExpression.Properties)
					{
						edmPropertyValues.Add(new EdmExpressionEvaluator.DelayedRecordProperty(delayedExpressionContext, property));
					}
					if (edmRecordExpression.DeclaredType != null)
					{
						edmStructuredTypeReference = edmRecordExpression.DeclaredType.AsStructured();
					}
					else
					{
						edmStructuredTypeReference = null;
					}
					EdmStructuredValue edmStructuredValue = new EdmStructuredValue(edmStructuredTypeReference, edmPropertyValues);
					return edmStructuredValue;
				}
				case EdmExpressionKind.Collection:
				{
					IEdmCollectionExpression edmCollectionExpression = (IEdmCollectionExpression)expression;
					EdmExpressionEvaluator.DelayedExpressionContext delayedExpressionContext1 = new EdmExpressionEvaluator.DelayedExpressionContext(this, context);
					List<IEdmDelayedValue> edmDelayedValues = new List<IEdmDelayedValue>();
					foreach (IEdmExpression element in edmCollectionExpression.Elements)
					{
						edmDelayedValues.Add(this.MapLabeledExpressionToDelayedValue(element, delayedExpressionContext1, context));
					}
					if (edmCollectionExpression.DeclaredType != null)
					{
						edmCollectionTypeReference = edmCollectionExpression.DeclaredType.AsCollection();
					}
					else
					{
						edmCollectionTypeReference = null;
					}
					EdmCollectionValue edmCollectionValue = new EdmCollectionValue(edmCollectionTypeReference, edmDelayedValues);
					return edmCollectionValue;
				}
				case EdmExpressionKind.Path:
				{
					EdmUtil.CheckArgumentNull<IEdmStructuredValue>(context, "context");
					IEdmPathExpression edmPathExpression = (IEdmPathExpression)expression;
					IEdmValue edmValue = context;
					foreach (string path in edmPathExpression.Path)
					{
						edmValue = this.FindProperty(path, edmValue);
						if (edmValue != null)
						{
							continue;
						}
						throw new InvalidOperationException(Strings.Edm_Evaluator_UnboundPath(path));
					}
					return edmValue;
				}
				case EdmExpressionKind.ParameterReference:
				case EdmExpressionKind.FunctionReference:
				case EdmExpressionKind.PropertyReference:
				case EdmExpressionKind.ValueTermReference:
				case EdmExpressionKind.EntitySetReference:
				case EdmExpressionKind.EnumMemberReference:
				{
					throw new InvalidOperationException(string.Concat("Not yet implemented: evaluation of ", expression.ExpressionKind.ToString(), " expressions."));
				}
				case EdmExpressionKind.If:
				{
					IEdmIfExpression edmIfExpression = (IEdmIfExpression)expression;
					if (!((IEdmBooleanValue)this.Eval(edmIfExpression.TestExpression, context)).Value)
					{
						return this.Eval(edmIfExpression.FalseExpression, context);
					}
					else
					{
						return this.Eval(edmIfExpression.TrueExpression, context);
					}
				}
				case EdmExpressionKind.AssertType:
				{
					IEdmAssertTypeExpression edmAssertTypeExpression = (IEdmAssertTypeExpression)expression;
					IEdmValue edmValue1 = this.Eval(edmAssertTypeExpression.Operand, context);
					IEdmTypeReference type = edmAssertTypeExpression.Type;
					return EdmExpressionEvaluator.AssertType(type, edmValue1);
				}
				case EdmExpressionKind.IsType:
				{
					IEdmIsTypeExpression edmIsTypeExpression = (IEdmIsTypeExpression)expression;
					IEdmValue edmValue2 = this.Eval(edmIsTypeExpression.Operand, context);
					IEdmTypeReference edmTypeReference = edmIsTypeExpression.Type;
					return new EdmBooleanConstant(EdmExpressionEvaluator.MatchesType(edmTypeReference, edmValue2));
				}
				case EdmExpressionKind.FunctionApplication:
				{
					IEdmApplyExpression edmApplyExpression = (IEdmApplyExpression)expression;
					IEdmExpression appliedFunction = edmApplyExpression.AppliedFunction;
					IEdmFunctionReferenceExpression edmFunctionReferenceExpression = appliedFunction as IEdmFunctionReferenceExpression;
					if (edmFunctionReferenceExpression != null)
					{
						IList<IEdmExpression> list = edmApplyExpression.Arguments.ToList<IEdmExpression>();
						IEdmValue[] edmValueArray = new IEdmValue[list.Count<IEdmExpression>()];
						int num = 0;
						foreach (IEdmExpression edmExpression in list)
						{
							int num1 = num;
							num = num1 + 1;
							edmValueArray[num1] = this.Eval(edmExpression, context);
						}
						IEdmFunction referencedFunction = edmFunctionReferenceExpression.ReferencedFunction;
						if (referencedFunction.IsBad() || !this.builtInFunctions.TryGetValue(referencedFunction, out func))
						{
							if (this.lastChanceFunctionApplier != null)
							{
								return this.lastChanceFunctionApplier(referencedFunction.FullName(), edmValueArray);
							}
						}
						else
						{
							return func(edmValueArray);
						}
					}
					if (edmFunctionReferenceExpression != null)
					{
						traceString = edmFunctionReferenceExpression.ReferencedFunction.ToTraceString();
					}
					else
					{
						traceString = string.Empty;
					}
					throw new InvalidOperationException(Strings.Edm_Evaluator_UnboundFunction(traceString));
				}
				case EdmExpressionKind.LabeledExpressionReference:
				{
					return this.MapLabeledExpressionToDelayedValue(((IEdmLabeledExpressionReferenceExpression)expression).ReferencedLabeledExpression, null, context).Value;
				}
				case EdmExpressionKind.Labeled:
				{
					return this.MapLabeledExpressionToDelayedValue(expression, new EdmExpressionEvaluator.DelayedExpressionContext(this, context), context).Value;
				}
			}
			int expressionKind1 = (int)expression.ExpressionKind;
			throw new InvalidOperationException(Strings.Edm_Evaluator_UnrecognizedExpressionKind(expressionKind1.ToString(CultureInfo.InvariantCulture)));
		}

		public IEdmValue Evaluate(IEdmExpression expression)
		{
			EdmUtil.CheckArgumentNull<IEdmExpression>(expression, "expression");
			return this.Eval(expression, null);
		}

		public IEdmValue Evaluate(IEdmExpression expression, IEdmStructuredValue context)
		{
			EdmUtil.CheckArgumentNull<IEdmExpression>(expression, "expression");
			return this.Eval(expression, context);
		}

		public IEdmValue Evaluate(IEdmExpression expression, IEdmStructuredValue context, IEdmTypeReference targetType)
		{
			EdmUtil.CheckArgumentNull<IEdmExpression>(expression, "expression");
			EdmUtil.CheckArgumentNull<IEdmTypeReference>(targetType, "targetType");
			return EdmExpressionEvaluator.AssertType(targetType, this.Eval(expression, context));
		}

Microsoft.Data.Edm.Library.Values.EdmStructuredValue : IEdmValue, IEdmElement, IEdmDelayedValue, IEdmStructuredValue

Constructors :

public EdmStructuredValue(IEdmStructuredTypeReference type = , IEnumerable<IEdmPropertyValue> propertyValues = )

Methods :

public IEnumerable<IEdmPropertyValue> get_PropertyValues()
public EdmValueKind get_ValueKind()
public IEdmPropertyValue FindPropertyValue(String propertyName = )
public IEdmTypeReference get_Type()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()