コード例 #1
0
        /// <summary>
        /// Overrides the default equality function. Two NestedPropertyRefs are
        /// equal if the have the same property name, and the types are the same
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            NestedPropertyRef other = obj as NestedPropertyRef;

            return(other != null &&
                   m_inner.Equals(other.m_inner) &&
                   m_outer.Equals(other.m_outer));
        }
コード例 #2
0
        /// <summary>
        /// Get the datatype for a propertyRef. The only concrete classes that we
        /// handle are TypeIdPropertyRef, and BasicPropertyRef.
        /// AllPropertyRef is illegal here.
        /// For BasicPropertyRef, we simply pick up the type from the corresponding
        /// property. For TypeIdPropertyRef, we use "string" as the default type
        /// or the discriminator property type where one is available.
        /// </summary>
        /// <param name="typeInfo">typeinfo of the current type</param>
        /// <param name="p">current property ref</param>
        /// <returns>the datatype of the property</returns>
        private md.TypeUsage GetPropertyType(RootTypeInfo typeInfo, PropertyRef p)
        {
            md.TypeUsage result = null;

            PropertyRef innerProperty = null;

            // Get the "leaf" property first
            while (p is NestedPropertyRef)
            {
                NestedPropertyRef npr = (NestedPropertyRef)p;
                p             = npr.OuterProperty;
                innerProperty = npr.InnerProperty;
            }

            if (p is TypeIdPropertyRef)
            {
                //
                // Get to the innermost type that specifies this typeid (the entity type),
                // get the datatype for the typeid column from that type
                //
                if (innerProperty != null && innerProperty is SimplePropertyRef)
                {
                    md.TypeUsage innerType     = ((SimplePropertyRef)innerProperty).Property.TypeUsage;
                    TypeInfo     innerTypeInfo = GetTypeInfo(innerType);
                    result = innerTypeInfo.RootType.TypeIdType;
                }
                else
                {
                    result = typeInfo.TypeIdType;
                }
            }
            else if (p is EntitySetIdPropertyRef || p is NullSentinelPropertyRef)
            {
                result = m_intType;
            }
            else if (p is RelPropertyRef)
            {
                result = (p as RelPropertyRef).Property.ToEnd.TypeUsage;
            }
            else
            {
                SimplePropertyRef simpleP = p as SimplePropertyRef;
                if (simpleP != null)
                {
                    result = md.Helper.GetModelTypeUsage(simpleP.Property);
                }
            }

            result = GetNewType(result);
            PlanCompiler.Assert(null != result, "unrecognized property type?");
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Determines the offset for structured types in Flattened type. For instance, if the original type is of the form:
        ///
        ///     { int X, ComplexType Y }
        ///
        /// and the flattened type is of the form:
        ///
        ///     { int X, Y_ComplexType_Prop1, Y_ComplexType_Prop2 }
        ///
        /// GetNestedStructureOffset(Y) returns 1
        /// </summary>
        /// <param name="property">Complex property.</param>
        /// <returns>Offset.</returns>
        internal int GetNestedStructureOffset(PropertyRef property)
        {
            // m_propertyRefList contains every element of the flattened type
            for (int i = 0; i < m_propertyRefList.Count; i++)
            {
                NestedPropertyRef nestedPropertyRef = m_propertyRefList[i] as NestedPropertyRef;

                // match offset of the first element of the complex type property
                if (null != nestedPropertyRef && nestedPropertyRef.InnerProperty.Equals(property))
                {
                    return(i);
                }
            }
            PlanCompiler.Assert(false, "no complex structure " + property + " found in TypeInfo");
            // return something so that the compiler doesn't complain
            return(default(int));
        }