示例#1
0
        /// <summary>
        /// Determine if a cycle exists in the type hierarchy: use two pointers to
        /// walk the chain, if one catches up with the other, we have a cycle.
        /// </summary>
        /// <returns>true if a cycle exists in the type hierarchy, false otherwise</returns>
        private bool CheckForInheritanceCycle()
        {
            StructuredType baseType = BaseType;

            Debug.Assert(baseType != null);

            StructuredType ref1 = baseType;
            StructuredType ref2 = baseType;

            do
            {
                ref2 = ref2.BaseType;

                if (Object.ReferenceEquals(ref1, ref2))
                {
                    return(true);
                }

                if (ref1 == null)
                {
                    return(false);
                }

                ref1 = ref1.BaseType;

                if (ref2 != null)
                {
                    ref2 = ref2.BaseType;
                }
            }while (ref2 != null);

            return(false);
        }
示例#2
0
        /// <summary>
        /// Determines whether this type is of the same type as baseType,
        /// or is derived from baseType.
        /// </summary>
        /// <param name="baseType"></param>
        /// <returns>true if this type is of the baseType, false otherwise</returns>
        public bool IsOfType(StructuredType baseType)
        {
            StructuredType type = this;

            while (type != null && type != baseType)
            {
                type = type.BaseType;
            }

            return(type == baseType);
        }
        /// <summary>
        ///
        /// </summary>
        internal override void Validate()
        {
            base.Validate();

            System.Diagnostics.Debug.Assert(_fromEnd != null && _toEnd != null,
                                            "FromEnd and ToEnd must not be null in Validate. ResolveNames must have resolved it or added error");

            if (_fromEnd.Type != ParentElement)
            {
                AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.BadNavigationPropertyBadFromRoleType(this.Name,
                                                                                         _fromEnd.Type.FQName, _fromEnd.Name, _relationship.FQName, ParentElement.FQName));
            }

            StructuredType type = _toEnd.Type;
        }
        internal static void GetElementLocationInfo(System.Data.EntityModel.SchemaObjectModel.Schema schema, string parentIdentity, string itemIdentity, out int lineNumber, out int linePosition)
        {
            lineNumber = linePosition = -1;

            System.Data.EntityModel.SchemaObjectModel.SchemaElement  element             = GetSchemaElement(schema, parentIdentity);
            System.Data.EntityModel.SchemaObjectModel.StructuredType elementWithProperty =
                element as System.Data.EntityModel.SchemaObjectModel.StructuredType;

            if (null != elementWithProperty && elementWithProperty.Properties.ContainsKey(itemIdentity))
            {
                lineNumber   = elementWithProperty.Properties[itemIdentity].LineNumber;
                linePosition = elementWithProperty.Properties[itemIdentity].LinePosition;
            }
            else if (null != element)
            {
                lineNumber   = element.LineNumber;
                linePosition = element.LinePosition;
            }
        }
示例#5
0
        /// <summary>
        /// See if a name is a member in a type or any of its base types
        /// </summary>
        /// <param name="name">name to look for</param>
        /// <param name="definingType">if defined, the type that defines it</param>
        /// <param name="definingMember">if defined, the member that defines it</param>
        /// <returns>how name was defined</returns>
        private HowDefined DefinesMemberName(string name, out StructuredType definingType, out SchemaElement definingMember)
        {
            if (NamedMembers.ContainsKey(name))
            {
                definingType   = this;
                definingMember = NamedMembers[name];
                return(HowDefined.AsMember);
            }

            definingMember = NamedMembers.LookUpEquivalentKey(name);
            Debug.Assert(definingMember == null, "we allow the scenario that members can have same name but different cases");

            if (IsTypeHierarchyRoot)
            {
                definingType   = null;
                definingMember = null;
                return(HowDefined.NotDefined);
            }

            return(BaseType.DefinesMemberName(name, out definingType, out definingMember));
        }
        //private static System.Text.RegularExpressions.Regex _binaryValueValidator = new System.Text.RegularExpressions.Regex("0[xX][0-9a-fA-F]+");
        #endregion
        #region Public Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentElement"></param>
        internal StructuredProperty(StructuredType parentElement)
            : base(parentElement)
        {
            _typeUsageBuilder = new TypeUsageBuilder(this);
        }
示例#7
0
 /// <summary>
 /// Creates a Property object
 /// </summary>
 /// <param name="parentElement">The parent element</param>
 internal Property(StructuredType parentElement)
     : base(parentElement)
 {
 }
示例#8
0
 /// <summary>
 /// Creates a Property object
 /// </summary>
 /// <param name="parentElement">The parent element</param>
 internal Property(StructuredType parentElement)
     : base(parentElement)
 {
 }
        /// <summary>
        /// See if a name is a member in a type or any of its base types
        /// </summary>
        /// <param name="name">name to look for</param>
        /// <param name="definingType">if defined, the type that defines it</param>
        /// <param name="definingMember">if defined, the member that defines it</param>
        /// <returns>how name was defined</returns>
        private HowDefined DefinesMemberName(string name, out StructuredType definingType, out SchemaElement definingMember)
        {
            if (NamedMembers.ContainsKey(name))
            {
                definingType = this;
                definingMember = NamedMembers[name];
                return HowDefined.AsMember;
            }

            definingMember = NamedMembers.LookUpEquivalentKey(name);
            Debug.Assert(definingMember == null, "we allow the scenario that members can have same name but different cases");

            if (IsTypeHierarchyRoot)
            {
                definingType = null;
                definingMember = null;
                return HowDefined.NotDefined;
            }

            return BaseType.DefinesMemberName(name, out definingType, out definingMember);
        }
        /// <summary>
        /// Determines whether this type is of the same type as baseType, 
        /// or is derived from baseType.
        /// </summary>
        /// <param name="baseType"></param>
        /// <returns>true if this type is of the baseType, false otherwise</returns>
        public bool IsOfType(StructuredType baseType)
        {
            StructuredType type = this;

            while (type != null && type != baseType)
            {
                type = type.BaseType;
            }

            return (type == baseType);
        }
示例#11
0
        //private static System.Text.RegularExpressions.Regex _binaryValueValidator = new System.Text.RegularExpressions.Regex("0[xX][0-9a-fA-F]+");
        #endregion
        #region Public Methods

        /// <summary>
        ///
        /// </summary>
        /// <param name="parentElement"></param>
        internal StructuredProperty(StructuredType parentElement)
            : base(parentElement)
        {
            _typeUsageBuilder = new TypeUsageBuilder(this);
        }