/// <summary>
        /// This method determines whether this instance can manage the specified object.
        /// </summary>
        /// <param name="pParentElement">The element to manage.</param>
        /// <param name="pSerializationContext">The serialization context.</param>
        /// <returns>The depth of inheritance or -1 if the contract cannot support.</returns>
        public override SupportPriority CanManage(XElement pParentElement, IXSerializationContext pSerializationContext)
        {
            bool lVersionFound;
            Version lXVersion = pSerializationContext.GetSerializationParameter<Version>("Version", out lVersionFound);
            if (lVersionFound == false)
            {
                // When no version is specified, only allowing the contract handling the last version.
                if (this.CanManageLastVersion == false)
                {
                    return SupportPriority.CANNOT_SUPPORT;
                }
            }
            else if (lXVersion < this.MinVersion || lXVersion > this.MaxVersion)
            {
                // Version out of range.
                return SupportPriority.CANNOT_SUPPORT;
            }

            return base.CanManage(pParentElement, pSerializationContext);
        }
示例#2
0
        /// <summary>
        /// This method determines whether this instance can manage the specified object.
        /// </summary>
        /// <param name="pType">The type to test.</param>
        /// <param name="pSerializationContext">The serialization context.</param>
        /// <returns>The depth of inheritance or -1 if the contract cannot support.</returns>
        public override SupportPriority CanManage(Type pType, IXSerializationContext pSerializationContext)
        {
            bool lVersionFound;
            int  lXVersion = pSerializationContext.GetSerializationParameter <int>("Version", out lVersionFound);

            if (lVersionFound == false)
            {
                // When no version is specified, only allowing the contract handling the last version.
                if (this.CanManageLastVersion == false)
                {
                    return(SupportPriority.CANNOT_SUPPORT);
                }
            }
            else if (lXVersion < this.MinVersion || lXVersion > this.MaxVersion)
            {
                // Version out of range.
                return(SupportPriority.CANNOT_SUPPORT);
            }

            return(base.CanManage(pType, pSerializationContext));
        }