예제 #1
0
        public void fromXmlString7Test()
        {
            MyList <CarOptions> obj_ = (MyList <CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.MyList types=\"`1[[Util.CarOptions, Util]]\"><Util.Util.CarOptions class=\"mscorlib.System.Collections.IEnumerable\" value=\"SunRoof\" /></Util.Util.MyList>");

            Assert.AreEqual(1, obj_.size());
            Assert.AreEqual(CarOptions.SunRoof, obj_.get(0));
        }
예제 #2
0
        public void fromXmlString8Test()
        {
            Map <string, CarOptions> obj_ = (Map <string, CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.Map types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"hello\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\" /></Util.Util.Map>");

            Assert.AreEqual(1, obj_.size());
            Assert.AreEqual(CarOptions.SunRoof, obj_.getVal("hello"));
        }
예제 #3
0
        public void fromXmlString13Test()
        {
            ArrayClass arr_ = (ArrayClass)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.ArrayClass><array field=\"sampleArray\" class=\"StreamTests.StreamTests.ArrayClass\" type=\"mscorlib.System.Int32\"><mscorlib.System.Int32 value=\"5\" /><mscorlib.System.Int32 value=\"3\" /></array></StreamTests.StreamTests.ArrayClass>");

            Assert.AreEqual(2, arr_.getSampleArray().Length);
            Assert.AreEqual(5, arr_.getSampleArray().ElementAt(0));
            Assert.AreEqual(3, arr_.getSampleArray().ElementAt(1));
        }
예제 #4
0
        /*public void setFiles(String _assembly, String _resourcesFile)
         * {
         *  assembly = _assembly;
         *  List<String> list_ = StreamZipFile.zippedFiles(_assembly);
         *  if (list_.isEmpty())
         *  {
         *      list_ = StreamTextFile.files(_resourcesFile);
         *  }
         *  files = new Map<String, String>();
         *  foreach (String f in list_)
         *  {
         *      if (f.EndsWith(PNG) || f.EndsWith(JPG))
         *      {
         *          try
         *          {
         *              files.put(f, toBaseSixtyFour(f));
         *          }
         *          catch (Exception)
         *          {
         *              //e.printStackTrace();
         *          }
         *          continue;
         *      }
         *      if (f.EndsWith(TXT))
         *      {
         *          try
         *          {
         *              BufferedImage buff_ = ConverterBufferedImageIo.readImage(f);
         *              String txt_ = ConverterBufferedImage.toBaseSixtyFour(buff_, FORMAT_PNG);
         *              files.put(f, txt_);
         *          }
         *          catch (Exception)
         *          {
         *              files.put(f, StreamTextFile.getContentFileInJar(assembly, f));
         *          }
         *      }
         *      if (f.EndsWith(HTML) || f.EndsWith(XML) || f.EndsWith(CSS) || f.EndsWith(PROPERTIES))
         *      {
         *          files.put(f, StreamTextFile.getContentFileInJar(assembly, f));
         *      }
         *  }
         * }*/
        public void loadConfiguration(String _conf)
        {
            string confFile_ = _conf.ToLower();
            bool   found_    = false;
            String fileName_ = EMPTY_STRING;

            foreach (Entry <String, String> e in files.entryList())
            {
                if (e.getKey().ToLower().Equals(confFile_))
                {
                    fileName_ = e.getKey();
                    found_    = true;
                    break;
                }
            }
            String content_;

            if (found_)
            {
                content_ = files.getVal(fileName_);
            }
            else
            {
                content_ = StreamTextFile.getContentFileInJar(assembly, _conf);
            }
            content_ = content_.Replace("<.", "<" + assembly + ".");
            content_ = content_.Replace("</.", "</" + assembly + ".");
            //content_ = content_.Replace(".]", assembly + "]");
            XmlDocument doc_    = XmlParser.parseSax(content_);
            XmlNodeList list_   = doc_.GetElementsByTagName("*");
            int         length_ = list_.Count;

            for (int i = 0; i < length_; i++)
            {
                XmlElement elt_   = list_.Item(i) as XmlElement;
                string     class_ = elt_.GetAttribute("class");
                class_ = class_.Replace(".]", assembly + "]");
                if (class_.StartsWith("."))
                {
                    elt_.SetAttribute("class", assembly + class_);
                }
            }
            content_ = XmlParser.toXml(doc_);
            session  = (Configuration)SerializeXmlObject.fromXmlStringObject(content_);
            session.setAssembly(assembly);
            foreach (String b in session.getBeans().getKeys())
            {
                Bean bean_ = session.getBeans().getVal(b);
                if (bean_.getClassName().StartsWith("."))
                {
                    bean_.setClassName(assembly + bean_.getClassName().Replace(".]", assembly + "]"));
                }
                else
                {
                    bean_.setClassName(bean_.getClassName().Replace(".]", assembly + "]"));
                }
            }
        }
예제 #5
0
        public void fromXmlString10Test()
        {
            TreeMap <string, CarOptions> obj_ = (TreeMap <string, CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.TreeMap types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><StreamTests.StreamTests.ReverseComparer class=\"Util.Util.ListableKey\" Comparer=\"\" /><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"2\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"FogLights\" /><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"1\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\" /></Util.Util.TreeMap>");

            Assert.AreEqual(2, obj_.size());
            Assert.AreEqual("2", obj_.getKey(0));
            Assert.AreEqual(CarOptions.FogLights, obj_.getValue(0));
            Assert.AreEqual("1", obj_.getKey(1));
            Assert.AreEqual(CarOptions.SunRoof, obj_.getValue(1));
        }
예제 #6
0
        public void fromXmlString12Test()
        {
            char obj_ = (char)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.Char value=\"1\" />");

            Assert.AreEqual('1', obj_);
        }
예제 #7
0
        public void fromXmlString11Test()
        {
            CarOptions obj_ = (CarOptions)SerializeXmlObject.fromXmlStringObject("<Util.Util.CarOptions value=\"Spoiler, SunRoof\" />");

            Assert.AreEqual(CarOptions.Spoiler | CarOptions.SunRoof, obj_);
        }
예제 #8
0
        public void fromXmlString6Test()
        {
            Composite obj_ = (Composite)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.Composite><mscorlib.System.Int64 field=\"num\" class=\"StreamTests.StreamTests.Composite\" value=\"1\" /><mscorlib.System.Int64 field=\"den\" class=\"StreamTests.StreamTests.Composite\" value=\"2\" /></StreamTests.StreamTests.Composite>");

            Assert.AreEqual(new Composite(1, 2), obj_);
        }
예제 #9
0
        public void fromXmlString5Test()
        {
            Rate obj_ = (Rate)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.Rate value=\"1/2\" />");

            Assert.AreEqual(new Rate(1, 2), obj_);
        }
예제 #10
0
        public void fromXmlString4Test()
        {
            int obj_ = (int)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.Int32 value=\"4\" />");

            Assert.AreEqual(4, obj_);
        }
예제 #11
0
        public void fromXmlString3Test()
        {
            string obj_ = (string)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.String value=\"hello\" />");

            Assert.AreEqual("hello", obj_);
        }
예제 #12
0
        public void fromXmlString1Test()
        {
            long obj_ = (long)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.Int64 value=\"1\" />");

            Assert.AreEqual(1, obj_);
        }