Exemplo n.º 1
0
// BEGIN EXTRA METHODS (C:/GitHub/rafidzal/OpenADK-java/adk-generator/../adk-generator/datadef/core/sif20/SIF_Request.txt.cs)

        /// <summary>
        /// Parses the list of SIF_Version elements and returns an array of SIFVersions
        /// </summary>
        /// <param name="failureLog">The log to write failures to, if any of the SIFVersions fail
        /// to be parsed.</param>
        /// <returns><An array of SIFVersion elements. This will never be null/returns>
        internal SifVersion[] parseRequestVersions(log4net.ILog failureLog)
        {
            if (failureLog == null)
            {
                failureLog = Adk.Log;
            }
            System.Collections.Generic.List <SifVersion> versionList = new System.Collections.Generic.List <SifVersion>();
            foreach (SifElement element in GetChildList(InfraDTD.SIF_REQUEST_SIF_VERSION))
            {
                SIF_Version candidate = (SIF_Version)element;
                SifVersion  version   = null;
                try {
                    // Check for "1.*" and "2.*"
                    String ver = candidate.Value;
                    if (ver != null)
                    {
                        if (ver.IndexOf(".*") > 0)
                        {
                            version = SifVersion.GetLatest(int.Parse(ver.Substring(0, 1)));
                        }
                        else
                        {
                            version = SifVersion.Parse(ver);
                        }
                    }
                } catch (ArgumentException exc) {
                    failureLog.Warn(String.Format("Unable to parse '{0}' from SIF_Request/SIF_Version as SIFVersion.", candidate.Value), exc);
                }
                catch (FormatException exc)
                {
                    failureLog.Warn(String.Format("Unable to parse '{0}' from SIF_Request/SIF_Version as SIFVersion.", candidate.Value), exc);
                }
                if (version != null && !versionList.Contains(version))
                {
                    versionList.Add(version);
                }
            }

            return(versionList.ToArray());
        }
Exemplo n.º 2
0
        public void testReturningCorrectSifVersionSIF1x()
        {
            String test =
                "<SIF_Request xmlns=\"http://www.sifinfo.org/infrastructure/1.x\">" +
                "	<SIF_Query >"+
                "      <SIF_QueryObject ObjectName=\"SchoolInfo\" />" +
                "	</SIF_Query>"+
                "</SIF_Request>";

            SifParser  parser  = SifParser.NewInstance();
            SifElement element = parser.Parse(test, null);

            // Since the version was not passed in, the latest supported
            // SIF 2.x Version should be returned
            Assertion.AssertEquals(SifVersion.GetLatest(1), element.SifVersion);

            element = parser.Parse(test, null, 0, SifVersion.SIF11);
            // Since the version was passed in, 1.1 should be returned
            Assertion.AssertEquals(SifVersion.SIF11, element.SifVersion);

            test =
                "<SIF_Message Version=\"1.1\" xmlns=\"http://www.sifinfo.org/infrastructure/1.x\">" +
                "<SIF_Request>" +
                "	<SIF_Query >"+
                "      <SIF_QueryObject ObjectName=\"SchoolInfo\" />" +
                "	</SIF_Query>"+
                "</SIF_Request>" +
                "</SIF_Message>";

            element = parser.Parse(test, null);
            // The version attribute is specified, use it.
            Assertion.AssertEquals(SifVersion.SIF11, element.SifVersion);

            element = parser.Parse(test, null, 0, SifVersion.SIF15r1);
            // The version attribute is specified and should override the
            // version passed in
            Assertion.AssertEquals(SifVersion.SIF11, element.SifVersion);
        }
Exemplo n.º 3
0
 public void test2DotStar()
 {
     Assert.AreEqual(SifVersion.GetLatest(2), SifVersion.Parse("2.*"));
 }