Esempio n. 1
0
        public static void decrementTrialDays(Session paramSession)
        {
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            System.Collections.IList list = paramSession.createQuery("from ConcLicenseTable").list();
            XStream xStream = new XStream();

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                if (licenseRowItem.Version == 2 && licenseRowItem.IsTrial)
                {
                    if (licenseRowItem.TrialDays < -1)
                    {
                        licenseRowItem.TrialDays = -1;
                    }
                    if (licenseRowItem.TrialDays != -1 && licenseRowItem.TrialDays != 0)
                    {
                        licenseRowItem.TrialDays = licenseRowItem.TrialDays - 10;
                        string str = xStream.toXML(licenseRowItem);
                        concLicenseTable.HashKey = str;
                        paramSession.update(concLicenseTable);
                    }
                }
            }
            if (paramSession.Open)
            {
                paramSession.flush();
                paramSession.close();
            }
        }
Esempio n. 2
0
        public static bool?unRegisterUserBySerial(Session paramSession, string paramString1, string paramString2, string paramString3)
        {
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            bool? @bool = Convert.ToBoolean(false);

            System.Collections.IList list = paramSession.createQuery("from ConcLicenseTable").list();
            XStream xStream = new XStream();
            License license = new License();

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                if (licenseRowItem.hasSameSerial(paramString3).Value&& licenseRowItem.CheckedIn)
                {
                    LicenseRowItem licenseRowItem1 = createRow("NULL", "NULL", paramString3, licenseRowItem, Convert.ToBoolean(false), "NULL");
                    string         str             = xStream.toXML(licenseRowItem1);
                    concLicenseTable.HashKey = str;
                    paramSession.update(concLicenseTable);
                    paramSession.flush();
                    @bool = Convert.ToBoolean(true);
                }
            }
            if (paramSession.Open)
            {
                paramSession.flush();
            }
            return(@bool);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void createNewTemplateXML(String paramString) throws Exception
        public virtual void createNewTemplateXML(string paramString)
        {
            ProjectTemplate projectTemplate = new ProjectTemplate();

            projectTemplate.ProjectName        = paramString;
            projectTemplate.ProjectDescription = paramString + " description";
            projectTemplate.ProjectBasementSqm = 0.0D;
            projectTemplate.ProjectMainSqm     = 0.0D;
            projectTemplate.ProjectType        = "construction";
            projectTemplate.ProjectSubtype     = "office";
            File file1 = new File("templates" + File.separator + paramString);

            file1.mkdirs();
            File file2 = new File("templates" + File.separator + paramString + File.separator + "template-info.xml");

            file2.createNewFile();
            XStream xStream = new XStream();

            ProjectTemplate.FieldAliases = xStream;
            StreamWriter fileWriter = new StreamWriter(file2);

            xStream.toXML(projectTemplate, fileWriter);
            fileWriter.Flush();
            fileWriter.Close();
        }
Esempio n. 4
0
        public static int serialVersion(Session paramSession)
        {
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            System.Collections.IList list = paramSession.createQuery("from ConcLicenseTable").list();
            XStream xStream = new XStream();

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                if (licenseRowItem.Version == 2)
                {
                    if (paramSession.Open)
                    {
                        paramSession.flush();
                        paramSession.close();
                    }
                    return(2);
                }
            }
            if (paramSession.Open)
            {
                paramSession.flush();
                paramSession.close();
            }
            return(1);
        }
        public void TestStreamSimpleArrayList()
        {
            ArrayList list = new ArrayList(5);

            list.Add(TestRandomizer.GetInt());
            list.Add(TestRandomizer.GetString());
            list.Add(TestRandomizer.GetDecimal());
            list.Add("last");

            XStream xs  = new XStream();
            string  xml = xs.ToXml(list);

            Assert.IsNotNull(xml);
            Assert.IsTrue(xml.Length > 0);

            IList rlist = xs.FromXml(xml) as IList;

            Assert.IsNotNull(rlist);
            Assert.AreEqual(list.Count, rlist.Count);

            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(list[i], rlist[i]);
            }
        }
Esempio n. 6
0
        public static Device FromXML(string xml)
        {
            XStream xstream = new XStream();
            xstream.Alias("Device", typeof(Device));

            xstream.Alias("main", typeof(Main));
            xstream.Alias("mains", typeof(Main[]));

            xstream.Alias("CmdInfo", typeof(CmdInfo));
            xstream.Alias("CmdInfos", typeof(CmdInfo[]));
            try
            {
                if (xml != null)
                {
                    xml = xml.Replace(@"<\/", "</");
                    Device ddd = (Device)xstream.FromXml(xml);//"<Device><cmdInfos><CmdInfo><name>yearmonth</name> <address>002F</address> <csharpType>System.Int16</csharpType> <unitFactor>0</unitFactor></CmdInfo> <CmdInfo><name>dayhour</name> <address>002E</address> <csharpType>System.Int16</csharpType> <unitFactor>0</unitFactor></CmdInfo> <CmdInfo><name>minutesecond</name> <address>002D</address> <csharpType>System.Int16</csharpType> <unitFactor>0</unitFactor></CmdInfo> <CmdInfo><name>zljyggl</name> <address>006A</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>zssyggl</name> <address>0092</address> <csharpType>System.Int32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>a1</name> <address>00B4</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>a2</name> <address>00B6</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>a3</name> <address>00B8</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>v1</name> <address>00A4</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.1</unitFactor></CmdInfo> <CmdInfo><name>v2</name> <address>00A6</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.1</unitFactor></CmdInfo> <CmdInfo><name>v3</name> <address>00A8</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.1</unitFactor></CmdInfo> <CmdInfo><name>pf</name> <address>00C5</address> <csharpType>System.Int16</csharpType> <unitFactor>0.001</unitFactor></CmdInfo></cmdInfos></Device>");
                    if (ddd == null)
                    {
                        return new Device();
                    }
                    else
                    {
                        return ddd;
                    }
                }
                else
                {
                    return new Device();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
    public void Send(XSocket socket, string name, string pwd)
    {
        XStream stream = socket.BeginSend(m_ptID);

        stream.WriteString(name);
        stream.WriteString(pwd);
        socket.EndSend();
    }
            public void should_deserialize()
            {
                var xml    = "<TestArray35><people><TestPerson35><ID>12</ID><Name>Joe</Name></TestPerson35></people></TestArray35>";
                var map    = new XStream <TestArray35>();
                var actual = map.FromXml(xml);

                Assert.AreEqual(12, actual.people[0].ID);
            }
Esempio n. 9
0
            public void act()
            {
                XStream xs = new XStream();

                xs.Alias("person", typeof(TestPerson));
                string xml = xs.ToXml(person);

                actual = xs.FromXml <TestPerson>(xml);
            }
Esempio n. 10
0
            public void act()
            {
                XStream xs = new XStream();

                xs.Alias <TestPerson>("person");
                string xml = xs.ToXml(person);

                actual = xs.FromXml(xml) as TestPerson;
            }
Esempio n. 11
0
        public void ShouldAllowAliasingOfAClass()
        {
            var xStream = new XStream();
            xStream.Alias<Software>("software");

            const string expectedXml = "<software><name>apache</name></software>";

            Assert.That(xStream.ToXml(new Software("apache")), Is.EqualTo(expectedXml));
            Assert.That(xStream.FromXml(expectedXml), Is.EqualTo(new Software("apache")));
        }
Esempio n. 12
0
        public static bool?registerUserBySerial(Session paramSession, string paramString1, string paramString2, string paramString3)
        {
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            bool? @bool = Convert.ToBoolean(false);

            System.Collections.IList list = paramSession.createQuery("from ConcLicenseTable").list();
            XStream xStream = new XStream();
            License license = new License();

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                if (licenseRowItem.hasSameSerial(paramString3).Value&& !licenseRowItem.CheckedIn)
                {
                    try
                    {
                        bool?bool1 = Convert.ToBoolean(false);
                        System.Collections.IEnumerator enumeration = NetworkInterface.NetworkInterfaces;
                        List <object> arrayList = new List <object>();
                        foreach (NetworkInterface networkInterface in Collections.list(enumeration))
                        {
                            foreach (InetAddress inetAddress in Collections.list(networkInterface.InetAddresses))
                            {
                                arrayList.Add(inetAddress);
                                if (inetAddress.HostAddress.equalsIgnoreCase(licenseRowItem.ServerIP))
                                {
                                    bool1 = Convert.ToBoolean(true);
                                    InetAddress inetAddress1 = inetAddress;
                                }
                            }
                        }
                        if (!bool1.Value)
                        {
                            @bool = Convert.ToBoolean(false);
                            break;
                        }
                    }
                    catch (SocketException socketException)
                    {
                        Console.WriteLine(socketException.ToString());
                        Console.Write(socketException.StackTrace);
                    }
                    DateTime         date             = DateTime.Now;
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyyMMddHHmmssZ");
                    string           str1             = simpleDateFormat.format(date);
                    LicenseRowItem   licenseRowItem1  = createRow(paramString1, paramString2, paramString3, licenseRowItem, Convert.ToBoolean(true), str1);
                    string           str2             = xStream.toXML(licenseRowItem1);
                    concLicenseTable.HashKey = str2;
                    paramSession.update(concLicenseTable);
                    @bool = Convert.ToBoolean(true);
                }
            }
            paramSession.flush();
            return(@bool);
        }
Esempio n. 13
0
        /**
         * Initialize socket server connections through xml configuration file.
         */
        public static void initialize() {
            //http://code.google.com/p/xstream-dot-net/
            StreamReader reader = File.OpenText("controller.xml");
            string xml = reader.ReadToEnd();
            reader.Close();

            XStream xstream = new XStream();
            xstream.Alias<List<SocketConnection>>("connections");
            xstream.Alias<SocketConnection>("connection");
            connectionList = xstream.FromXml<List<SocketConnection>>(xml);
        }
Esempio n. 14
0
            public void should_serialize_without_the_full_class_name()
            {
                var map = new XStream().AutoAlias <TestArray35>();
                var xml = map.ToXml(new TestArray35 {
                    people = new[] { new TestPerson35 {
                                         ID = 12, Name = "Joe"
                                     } }
                });

                Assert.AreEqual("<TestArray35><people><TestPerson35><ID>12</ID><Name>Joe</Name></TestPerson35></people></TestArray35>", xml);
            }
        public void should_be_able_to_use_a_setter_property()
        {
            string xml = "<person><ID>2</ID></person>";

            XStream xs = new XStream();

            xs.Alias <TestPerson35>("person");
            var person = xs.FromXml <TestPerson35>(xml);

            Assert.AreEqual(2, person.ID);
        }
Esempio n. 16
0
            public void should_deserialize_a_generic_list()
            {
                string  xml = "<TestPeople><People><TestPerson><ID>12</ID><Name>Joe</Name></TestPerson></People></TestPeople>";
                XStream xs  = new XStream();

                xs.Alias <TestPeople35>("TestPeople");
                xs.Alias <TestPerson35>("TestPerson");

                TestPeople35 value = xs.FromXml <TestPeople35>(xml);

                Assert.AreEqual(1, value.People.Count);
            }
Esempio n. 17
0
        public static Plugin Read(string fileName)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(fileName);
            }
            catch (Exception)
            {
                InvalidPluginException e = new InvalidPluginException("Error while parsing plugin file: " + fileName);
                throw e;
            }
            XmlNode pluginNode = doc.GetElementsByTagName("Plugin").Item(0);

            if (pluginNode == null)
            {
                InvalidPluginException e = new InvalidPluginException("There is no plugin definition in file: " + fileName);
                throw e;
            }

            XStream xs = new XStream();

            xs.Alias("Plugin", typeof(PluginConfig));
            PluginConfig pluginXML = null;

            try
            {
                pluginXML = xs.FromXml(pluginNode.OuterXml) as PluginConfig;
            }
            catch (Exception)
            {
                InvalidPluginException e = new InvalidPluginException("Wrong plugin definition in file: " + fileName);
                throw e;
            }

            try
            {
                pluginXML.Valid();
            }
            catch (InvalidPluginException ex)
            {
                InvalidPluginException e = new InvalidPluginException(ex.Message + " in file: " + fileName, ex);
                e.Plugin = pluginXML;
                throw e;
            }

            Plugin plugin = new Plugin(pluginXML);

            plugin.Xml = pluginNode.OuterXml;
            return(plugin);
        }
        public void should_be_able_to_get_properties()
        {
            int     id = 2;
            XStream xs = new XStream();

            xs.Alias <TestPerson35>("person");
            var person = new TestPerson35 {
                ID = id
            };
            string xml = xs.ToXml(person);

            Assert.IsTrue(xml.Contains("<ID>2</ID>"));
        }
Esempio n. 19
0
 public ArraySegment <byte> Encode(object data, IServer server, byte[] buffer)
 {
     using (XStream stream = new XStream(server.BufferPool))
     {
         IBinaryWriter writer = ServerFactory.CreateWriter(stream, server.Config.Encoding,
                                                           server.Config.LittleEndian);
         OnEncode(data, writer);
         stream.Position = 0;
         int count = (int)writer.Length;
         stream.Read(buffer, 0, count);
         return(new ArraySegment <byte>(buffer, 0, count));
     }
 }
        /// <summary>
        /// To get the shape (may also be a group...) as a translucent png in a byte array.
        /// </summary>
        /// <param name="pngFileData">The png file data as byte array.</value>
        /// <returns>the png file size (only > 0 if successful)</returns>
        virtual public int GetShapeAsPng(out byte[] pngFileData)
        {
            pngFileData = new byte[0];
            object doc = GetDocument();

            // see https://blog.oio.de/2010/10/27/copy-and-paste-without-clipboard-using-openoffice-org-api/
            if (IsValid(false) && doc != null && Shape != null)
            {
                System.Drawing.Rectangle rectDom = GetRelativeScreenBoundsByDom();

                // See <http://www.oooforum.org/forum/viewtopic.phtml?t=50783>
                // properties for the png export filter:
                PropertyValue[] aFilterData = new PropertyValue[5];
                aFilterData[0] = new PropertyValue(); aFilterData[0].Name = "PixelWidth"; aFilterData[0].Value = tud.mci.tangram.models.Any.Get(rectDom.Width);   // bounding box width
                aFilterData[1] = new PropertyValue(); aFilterData[1].Name = "PixelHeight"; aFilterData[1].Value = tud.mci.tangram.models.Any.Get(rectDom.Height); // bounding box height
                aFilterData[2] = new PropertyValue(); aFilterData[2].Name = "Translucent"; aFilterData[2].Value = new uno.Any(true);                              // png with translucent background
                aFilterData[3] = new PropertyValue(); aFilterData[3].Name = "Compression"; aFilterData[3].Value = new uno.Any(0);                                 // png compression level 0..9 (set to 0 to be fastest, smallest files would be produced by 9)
                aFilterData[4] = new PropertyValue(); aFilterData[4].Name = "Interlaced"; aFilterData[4].Value = new uno.Any(0);                                  // png interlacing (off=0)

                /* create com.sun.star.comp.MemoryStream, Debug.GetAllInterfacesOfObject(memoryOutStream) gets:
                 *  unoidl.com.sun.star.io.XStream
                 *  unoidl.com.sun.star.io.XSeekableInputStream
                 *  unoidl.com.sun.star.io.XOutputStream
                 *  unoidl.com.sun.star.io.XTruncate
                 *  unoidl.com.sun.star.lang.XTypeProvider
                 *  unoidl.com.sun.star.uno.XWeak
                 */
                //XMultiServiceFactory xmsf = OO.GetMultiServiceFactory(OO.GetContext(), OO.GetMultiComponentFactory(OO.GetContext()));
                XStream memoryStream = (XStream)OO.GetContext().getServiceManager().createInstanceWithContext("com.sun.star.comp.MemoryStream", OO.GetContext());
                //XStream memoryStream = (XStream)xmsf.createInstance("com.sun.star.comp.MemoryStream");

                // the filter media descriptor: media type, destination, and filterdata containing the export settings from above
                PropertyValue[] aArgs = new PropertyValue[3];
                aArgs[0] = new PropertyValue(); aArgs[0].Name = "MediaType"; aArgs[0].Value = tud.mci.tangram.models.Any.Get("image/png");
                aArgs[1] = new PropertyValue(); aArgs[1].Name = "OutputStream"; aArgs[1].Value = tud.mci.tangram.models.Any.Get(memoryStream);   // filter to our memory stream
                aArgs[2] = new PropertyValue(); aArgs[2].Name = "FilterData"; aArgs[2].Value = tud.mci.tangram.models.Any.GetAsOne(aFilterData);

                // create exporter service
                XExporter exporter = (XExporter)OO.GetContext().getServiceManager().createInstanceWithContext("com.sun.star.drawing.GraphicExportFilter", OO.GetContext());
                exporter.setSourceDocument((XComponent)Shape);

                // call the png export filter
                ((XFilter)exporter).filter(aArgs);

                // read all bytes from stream into byte array
                int pngFileSize = ((XInputStream)memoryStream).available();
                ((XInputStream)memoryStream).readBytes(out pngFileData, pngFileSize);
                return(pngFileSize);
            }
            return(0);
        }
Esempio n. 21
0
        public static void storeToTable(Session paramSession, License paramLicense)
        {
            validateTableAndFixTable(paramSession);
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            XStream xStream = new XStream();

            foreach (LicenseRowItem licenseRowItem in paramLicense.RowItems)
            {
                ConcLicenseTable concLicenseTable = new ConcLicenseTable();
                string           str = xStream.toXML(licenseRowItem);
                concLicenseTable.HashKey = str;
                paramSession.save(concLicenseTable);
            }
        }
Esempio n. 22
0
        /**
         * Initialize socket server connections through xml configuration file.
         */
        public static void initialize()
        {
            //http://code.google.com/p/xstream-dot-net/
            StreamReader reader = File.OpenText("controller.xml");
            string       xml    = reader.ReadToEnd();

            reader.Close();

            XStream xstream = new XStream();

            xstream.Alias <List <SocketConnection> >("connections");
            xstream.Alias <SocketConnection>("connection");
            connectionList = xstream.FromXml <List <SocketConnection> >(xml);
        }
Esempio n. 23
0
 public byte[] Encode(object data, IServer server)
 {
     byte[] result = null;
     using (XStream stream = new XStream(server.BufferPool))
     {
         IBinaryWriter writer = ServerFactory.CreateWriter(stream, server.Config.Encoding,
                                                           server.Config.LittleEndian);
         OnEncode(data, writer);
         stream.Position = 0;
         result          = new byte[stream.Length];
         stream.Read(result, 0, result.Length);
     }
     return(result);
 }
Esempio n. 24
0
        // NOTE!! In future probably would be best to delete the "RawEncrypt / RawDecrypt"
        // methods and use these Stream based alogrithms instead.

        public static void Encrypt(this Stream readStream, Stream writeStreamEncryptDest,
                                   byte[] privateKey, bool useDeflateCompression)
        {
            if (readStream == null)
            {
                throw new ArgumentNullException(nameof(readStream));
            }
            if (writeStreamEncryptDest == null)
            {
                throw new ArgumentNullException(nameof(writeStreamEncryptDest));
            }
            if (privateKey == null)
            {
                throw new ArgumentNullException(nameof(privateKey));
            }
            byte[] initVector = GetIVFromEncryptionKey(privateKey);
            if (initVector == null)
            {
                throw new ArgumentNullException(nameof(initVector));
            }

            CryptoStream  cryptS    = null;
            DeflateStream compressS = null;

            try {
                // what, no usings? no Dispose (in finally)?! See notes on Decrypt, STINKING CryptoStream disposes base stream
                SymmetricAlgorithm aesAlgorithm = Rijndael.Create();
                ICryptoTransform   aesEncryptor = aesAlgorithm.CreateEncryptor(privateKey, initVector);
                cryptS = new CryptoStream(writeStreamEncryptDest, aesEncryptor, CryptoStreamMode.Write);
                {
                    if (useDeflateCompression)
                    {
                        using (compressS = new DeflateStream(cryptS, CompressionMode.Compress, true))
                            XStream.Write(compressS, readStream);
                    }
                    else
                    {
                        XStream.Write(cryptS, readStream);
                    }
                }
            }
            finally {
                if (cryptS != null)
                {
                    cryptS.FlushFinalBlock();                     //
                }
            }
        }
Esempio n. 25
0
    public void StartUp()
    {
        LoadConfig();
        RegisterWnd();
        RegisterProto();

        m_wndMgr.OpenWindow(WndID.Login);


        XStream stream = new XStream();

        stream.WriteInt(123);
        stream.Seek(0, System.IO.SeekOrigin.Begin);
//		stream.Seek(0,System.IO.SeekOrigin.Current);
        m_protoMgr.OnProtocol(Protocol.GNP_ACCOUNT_LOGIN, stream);
    }
Esempio n. 26
0
        public static License loadFromTable(Session paramSession)
        {
            validateTableAndFixTable(paramSession);
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            System.Collections.IList list = paramSession.createQuery("from ConcLicenseTable").list();
            XStream xStream = new XStream();
            License license = new License();
            bool    @bool   = false;

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                license.addRowItemToSet(licenseRowItem);
            }
            return(license);
        }
Esempio n. 27
0
        public static void Decrypt(this Stream readStreamEncrypted, Stream writeStream,
                                   byte[] privateKey, bool useDeflateCompression)
        {
            if (readStreamEncrypted == null)
            {
                throw new ArgumentNullException(nameof(readStreamEncrypted));
            }
            if (writeStream == null)
            {
                throw new ArgumentNullException(nameof(writeStream));
            }
            if (privateKey == null)
            {
                throw new ArgumentNullException(nameof(privateKey));
            }
            byte[] initVector = GetIVFromEncryptionKey(privateKey);
            if (initVector == null)
            {
                throw new ArgumentNullException(nameof(initVector));
            }
            try {
                SymmetricAlgorithm aesAlgorithm = Rijndael.Create();
                ICryptoTransform   aesDecryptor = aesAlgorithm.CreateDecryptor(privateKey, initVector);
                CryptoStream       cryptS;

                if (!useDeflateCompression)
                {
                    using (cryptS = new CryptoStream(writeStream, aesDecryptor, CryptoStreamMode.Write))
                        XStream.Write(cryptS, readStreamEncrypted);
                }
                else
                {
                    cryptS = new CryptoStream(readStreamEncrypted, aesDecryptor, CryptoStreamMode.Read);

                    using (DeflateStream deflS = new DeflateStream(cryptS, CompressionMode.Decompress, true))
                        XStream.Write(writeStream, deflS);
                }
            }
            finally {
                // do NOT call flush or flushxyz on CryptoStream, bec here, DeflStrm wraps it
                // and already calls it. CryptStrm is AMAZINGLY STUPIDLY designed, breaking ALL
                // contracts usually expected, like Flush should not throw errors. OH NO, IT DOES.
                // No wonder so many by pass .NET's version with couple open source options. TOTAL EMBARRASSMENT.
            }
        }
Esempio n. 28
0
            public void should_serialize_a_generic_list()
            {
                XStream xs = new XStream();

                xs.Alias <TestPeople35>("TestPeople");
                xs.Alias <TestPerson35>("TestPerson");
                TestPeople35 ppl    = new TestPeople35();
                TestPerson35 person = new TestPerson35();

                person.ID   = 12;
                person.Name = "Joe";
                ppl.People.Add(person);
                //ppl.people1 = new[] {person};

                string xml = xs.ToXml(ppl);

                Assert.AreEqual("<TestPeople><People><TestPerson><ID>12</ID><Name>Joe</Name></TestPerson></People></TestPeople>", xml);
            }
Esempio n. 29
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void loadProjects() throws Exception
        private void loadProjects()
        {
            File file = new File("templates");

            if (!file.Directory)
            {
                file.mkdir();
            }
            File[] arrayOfFile = file.listFiles(new TemplateFileFilter(this, null));
            foreach (File file1 in arrayOfFile)
            {
                File   file2        = null;
                File   file3        = null;
                File[] arrayOfFile1 = file1.listFiles();
                foreach (File file4 in arrayOfFile1)
                {
                    if (file4.Name.ToLower().Equals("template-info.xml"))
                    {
                        file2 = file4;
                    }
                    else if (file4.Name.ToLower().Equals("template.cep"))
                    {
                        file3 = file4;
                    }
                }
                XStream xStream = new XStream();
                ProjectTemplate.FieldAliases = xStream;
                StreamReader    fileReader      = new StreamReader(file2);
                ProjectTemplate projectTemplate = (ProjectTemplate)xStream.fromXML(fileReader);
                projectTemplate.ProjectCEPFile = file3;
                this.o_descMap[file1.Name]     = projectTemplate;
                fileReader.Close();
                if (!string.ReferenceEquals(projectTemplate.ProjectGroup, null) && !projectTemplate.ProjectGroup.Equals(""))
                {
                    List <object> vector = (List <object>) this.o_groupMap[projectTemplate.ProjectGroup];
                    if (vector == null)
                    {
                        vector = new List <object>();
                        this.o_groupMap[projectTemplate.ProjectGroup] = vector;
                    }
                    vector.Add(projectTemplate);
                }
            }
        }
Esempio n. 30
0
        public static bool updateDate(PongEvent paramPongEvent, Session paramSession)
        {
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            System.Collections.IList list     = paramSession.createQuery("from ConcLicenseTable").list();
            XStream          xStream          = new XStream();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyyMMddHHmmssZ");
            bool             @bool            = false;

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                if (licenseRowItem.CheckedIn && licenseRowItem.Serial.Equals(paramPongEvent.Serial) && licenseRowItem.Userid.Equals(paramPongEvent.UserId, StringComparison.OrdinalIgnoreCase))
                {
                    @bool = true;
                    string str1 = simpleDateFormat.format(DateTime.Now);
                    licenseRowItem.CheckedInDate = str1;
                    string str2 = xStream.toXML(licenseRowItem);
                    concLicenseTable.HashKey = str2;
                    paramSession.update(concLicenseTable);
                }
            }
            return(@bool);
        }
Esempio n. 31
0
        public static void validateTableAndFixTable(Session paramSession)
        {
            EncryptedStringUserType.Key = CryptUtil.Instance.encryptHexString("oasj419][f'ar;;34").ToCharArray();
            System.Collections.IList list = paramSession.createQuery("from ConcLicenseTable").list();
            XStream          xStream      = new XStream();
            HashSet <object> hashSet1     = new HashSet <object>();
            bool?            @bool        = true;
            Hashtable        hashMap      = new Hashtable();
            HashSet <object> hashSet2     = new HashSet <object>();

            foreach (ConcLicenseTable concLicenseTable in list)
            {
                LicenseRowItem licenseRowItem = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                if (hashMap.ContainsKey(licenseRowItem.Serial))
                {
                    @bool = false;
                    hashSet2.Add(concLicenseTable.Id);
                    hashSet2.Add(((ConcLicenseTable)hashMap[licenseRowItem.Serial]).Id);
                    continue;
                }
                hashMap[licenseRowItem.Serial] = concLicenseTable;
            }
            if ([email protected])
            {
                int?integer = Convert.ToInt32(hashSet2.Count);
                foreach (long?long in hashSet2)
                {
                    ConcLicenseTable concLicenseTable = (ConcLicenseTable)paramSession.load(typeof(ConcLicenseTable), long);
                    LicenseRowItem   licenseRowItem   = (LicenseRowItem)xStream.fromXML(concLicenseTable.HashKey);
                    if (integer.Value > 1)
                    {
                        paramSession.delete(concLicenseTable);
                        paramSession.flush();
                    }
                }
            }
        }
Esempio n. 32
0
        public static Device FromXML(string xml)
        {
            XStream xstream = new XStream();

            xstream.Alias("Device", typeof(Device));

            xstream.Alias("main", typeof(Main));
            xstream.Alias("mains", typeof(Main[]));

            xstream.Alias("CmdInfo", typeof(CmdInfo));
            xstream.Alias("CmdInfos", typeof(CmdInfo[]));
            try
            {
                if (xml != null)
                {
                    xml = xml.Replace(@"<\/", "</");
                    Device ddd = (Device)xstream.FromXml(xml);//"<Device><cmdInfos><CmdInfo><name>yearmonth</name> <address>002F</address> <csharpType>System.Int16</csharpType> <unitFactor>0</unitFactor></CmdInfo> <CmdInfo><name>dayhour</name> <address>002E</address> <csharpType>System.Int16</csharpType> <unitFactor>0</unitFactor></CmdInfo> <CmdInfo><name>minutesecond</name> <address>002D</address> <csharpType>System.Int16</csharpType> <unitFactor>0</unitFactor></CmdInfo> <CmdInfo><name>zljyggl</name> <address>006A</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>zssyggl</name> <address>0092</address> <csharpType>System.Int32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>a1</name> <address>00B4</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>a2</name> <address>00B6</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>a3</name> <address>00B8</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.01</unitFactor></CmdInfo> <CmdInfo><name>v1</name> <address>00A4</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.1</unitFactor></CmdInfo> <CmdInfo><name>v2</name> <address>00A6</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.1</unitFactor></CmdInfo> <CmdInfo><name>v3</name> <address>00A8</address> <csharpType>System.UInt32</csharpType> <unitFactor>0.1</unitFactor></CmdInfo> <CmdInfo><name>pf</name> <address>00C5</address> <csharpType>System.Int16</csharpType> <unitFactor>0.001</unitFactor></CmdInfo></cmdInfos></Device>");
                    if (ddd == null)
                    {
                        return(new Device());
                    }
                    else
                    {
                        return(ddd);
                    }
                }
                else
                {
                    return(new Device());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 33
0
        static void HandleonConnectionEstablished(XStream stream)
        {
            driver.onConnectionEstablished-= HandleonConnectionEstablished;
            int reqcount = currentRequest.headers.Count;
            BinaryWriter mwriter = new BinaryWriter(stream);
            mwriter.Write(reqcount);
            mwriter.Write("GET /"+currentURL.PathAndQuery+" HTTP/1.0");
            for(int i = 1;i<reqcount;i++) {
            mwriter.Write(currentRequest.headers[i]);
            }
            mwriter.Flush();
            byte[] buffer = new byte[16384];
            while(true) {
            try {
                int count = stream.Read(buffer,0,buffer.Length);

                    Console.WriteLine("DGRAM len: "+count.ToString());
                currentRequest.stream.Write(buffer,0,count);
                }catch(Exception er) {
                break;
                }
            }
            Console.WriteLine("Request complete");
            currentRequest.stream.Flush();
            mvent.Set();
        }
Esempio n. 34
0
 public override void OnAnalyze(XStream stream)
 {
     m_playerKey = stream.ReadInt();
 }
Esempio n. 35
0
 // Methods
 public FileXStream(string fileName)
 {
     this.fileName = fileName;
     xStream = new XStream();
 }
 void thetar(object sender)
 {
     try
     {
         ParallelSocket msock = sender as ParallelSocket;
         XStream mstream = new XStream(msock);
         List<string> headers = new List<string>();
         BinaryReader mreader = new BinaryReader(mstream);
         int count = mreader.ReadInt32();
         for (int i = 0; i < count; i++)
         {
             headers.Add(mreader.ReadString());
         }
         //Create a new ClientWebRequest. Note that WE will be the server for this remoting object
         //as it is created on our end. So unlike most reuqests, we'll have a really complex route
         //Execution route: server->Protocol driver->Server->Application
         ClientWebRequest request = new ClientWebRequest(mstream, headers);
         request.SecureConnection = true;
         request.SecurityIdentifier = _session.pubKey;
         //Inject the request into the server execution framework
         NetProvider.instance._engine.NtfyConnection(request);
     }
     catch (Exception er)
     {
         Console.WriteLine(er);
     }
 }