Esempio n. 1
0
        protected SifDataObject(SerializationInfo info,
                                StreamingContext context)
            : base(info, context)
        {
            string versionString = info.GetString("fVersion");

            fVersion = SifVersion.Parse(versionString);
        }
Esempio n. 2
0
        /// <summary>
        /// Parses the SIF Version from the version attribute or namespace. If not able
        /// to parse the version, the default version is returned.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="dtd"></param>
        /// <param name="zone"></param>
        /// <param name="flags"></param>
        /// <param name="defaultVersion"></param>
        /// <returns></returns>
        private SifVersion ParseVersion(
            XmlReader reader,
            IDtd dtd,
            IZone zone,
            SifParserFlags flags,
            SifVersion defaultVersion)
        {
            SifVersion version;
            String     verAttr = reader.GetAttribute("Version");


            // Order of precedence:
            // 1) Version attribute of message
            // 2) The version passed in (if not null)
            // 3) The namespace version (if able to parse)
            // 4) The ADK SIF Version

            if (verAttr != null)
            {
                version = SifVersion.Parse(verAttr);
            }
            else if (defaultVersion != null)
            {
                version = defaultVersion;
            }
            else
            {
                String namespc = reader.NamespaceURI;
                version = SifVersion.ParseXmlns(namespc);
                if (version == null)
                {
                    version = Adk.SifVersion;
                }
            }

            // Do validation on the version
            if (!Adk.IsSIFVersionSupported(version))
            {
                throw new SifException(
                          SifErrorCategoryCode.Generic,
                          SifErrorCodes.GENERIC_VERSION_NOT_SUPPORTED_3,
                          string.Format("SIF {0} not supported", version.ToString()), reader.NamespaceURI, zone);
            }
            else if (zone != null && zone.Properties.StrictVersioning)
            {
                if (version.CompareTo(Adk.SifVersion) != 0)
                {
                    throw new SifException(
                              SifErrorCategoryCode.Generic,
                              SifErrorCodes.GENERIC_VERSION_NOT_SUPPORTED_3,
                              "SIF " + version.ToString() + " message support disabled by this agent",
                              string.Format("This agent is running in strict SIF {0} mode", Adk.SifVersion.ToString()), zone);
                }
            }
            return(version);
        }