/// <summary>
        /// Verify Entry.Core.4624
        /// </summary>
        /// <param name="context">Service context</param>
        /// <param name="info">out parameter to return violation information when rule fail</param>
        /// <returns>true if rule passes; false otherwise</returns>
        public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            bool?passed = null;

            info = null;

            // Get all properties.
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(context.ResponsePayload);
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);

            nsmgr.AddNamespace("m", Constants.V3NSMetadata);
            string MeataNS = Constants.V3NSMetadata;
            string DataNs  = Constants.V3NSData;

            if (context.Version == ODataVersion.V4)
            {
                nsmgr.AddNamespace("m", Constants.NSMetadata);
                MeataNS = Constants.NSMetadata;
                DataNs  = Constants.V4NSData;
            }

            XmlNodeList xmlNodeList = xmlDoc.SelectNodes(@"//m:properties/*", nsmgr);

            List <string> namesWithCollectionType = AtomSchemaHelper.GetAllComplexNameWithCollectionType(context.MetadataDocument, context.EntityTypeShortName);

            foreach (XmlNode xmlNode in xmlNodeList)
            {
                if (namesWithCollectionType.Contains(xmlNode.LocalName) && xmlNode.NamespaceURI.Equals(DataNs) && xmlNode.Attributes["type", MeataNS] != null)
                {
                    string metadataTypeValue = xmlNode.Attributes["type", MeataNS].Value;

                    if (AtomSchemaHelper.IsNamespaceOrAliasInCollection(metadataTypeValue) || AtomSchemaHelper.IsNamespaceOrAliasInCollection(metadataTypeValue))
                    {
                        passed = true;
                    }
                    else
                    {
                        passed = false;
                        info   = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload);
                        break;
                    }
                }
            }

            return(passed);
        }
        /// <summary>
        /// Verify Entry.Core.4627
        /// </summary>
        /// <param name="context">Service context</param>
        /// <param name="info">out parameter to return violation information when rule fail</param>
        /// <returns>true if rule passes; false otherwise</returns>
        public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            bool?passed = null;

            info = null;

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(context.ResponsePayload);
            string metadataNs = ODataVersion.V4 == context.Version ? Constants.NSMetadata : Constants.V3NSMetadata;

            XmlNodeList   xmlNodeList = xmlDoc.SelectNodes(@"//metadata:properties/*", ODataNamespaceManager.Instance);
            List <string> collectedComplexTypeNames = AtomSchemaHelper.GetAllComplexNameWithCollectionType(context.MetadataDocument, context.EntityTypeShortName);

            foreach (XmlNode xmlNode in xmlNodeList)
            {
                if (collectedComplexTypeNames.Contains(xmlNode.LocalName) && xmlNode.HasChildNodes)
                {
                    string basedComplexTypeName =
                        xmlNode.Attributes["type", metadataNs]
                        .Value
                        .Remove(0, 1)
                        .RemoveCollectionFlag();

                    List <string> propNames = GetAllPropertyNamesFromComplexType(context.MetadataDocument, basedComplexTypeName.GetLastSegment());

                    foreach (XmlElement xElem in xmlNode)
                    {
                        if (xElem.LocalName.Equals("element"))
                        {
                            var  nodes = xElem.SelectNodes("./*", ODataNamespaceManager.Instance);
                            bool flag  = false;

                            foreach (XmlNode node in nodes)
                            {
                                string propName = node.LocalName;

                                if ("link" == node.LocalName)
                                {
                                    if (null == node.Attributes["href"])
                                    {
                                        continue;
                                    }

                                    string hrefAttrib = node.Attributes["href"].Value;
                                    propName = hrefAttrib.Remove(0, hrefAttrib.LastIndexOf("/") + 1);
                                }

                                if (!propNames.Contains(propName))
                                {
                                    flag = true;
                                    break;
                                }
                            }

                            if (flag)
                            {
                                if (xElem.HasAttribute("type", metadataNs))
                                {
                                    string derivedComplexTypeName = xElem.GetAttribute("type", metadataNs).Remove(0, 1);
                                    if (derivedComplexTypeName == basedComplexTypeName)
                                    {
                                        continue;
                                    }

                                    if (IsDerivedComplexType(context, derivedComplexTypeName.GetLastSegment(), basedComplexTypeName))
                                    {
                                        passed = true;
                                    }
                                    else
                                    {
                                        passed = false;
                                        info   = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload);
                                        break;
                                    }
                                }
                                else
                                {
                                    passed = false;
                                    info   = new ExtensionRuleViolationInfo(this.ErrorMessage, context.Destination, context.ResponsePayload);
                                    break;
                                }
                            }
                        }
                    }

                    if (passed == false)
                    {
                        break;
                    }
                }
            }

            return(passed);
        }