Exemplo n.º 1
0
        public void Receive()
        {
            Object obj = null;

            while (socket.Connected)
            {
                try
                {
                    obj = deserializer.Deserialize(stream);
                }
                catch (Exception)
                {
                    server.ClientClose(this);
                    Close();
                }
                if (obj is string && (string)obj == "/disconnect")
                {
                    server.ClientClose(this);
                    Close();
                }
                else if (obj is EntityMulti)
                {
                    playerMul = (EntityMulti)obj;
                }
            }
            server.ClientClose(this);
            Close();
        }
        public object DeserializeReply(Message message, object[] parameters)
        {
            Polenter.Serialization.SharpSerializer serializer = new Polenter.Serialization.SharpSerializer(true);

            using (var inStream = GetBodyInnerContentStream(message))
            {
                return serializer.Deserialize(DecompressStream(inStream, true));
            }
        }
Exemplo n.º 3
0
 public static IVisNode DeSerializeFromFile(string fn)
 {
     var x = new Polenter.Serialization.SharpSerializer();
     //XmlSerializer x = new XmlSerializer(typen);
     FileStream fs = new FileStream(fn, FileMode.Open);
     var n = (IVisNode)x.Deserialize(fs);
     fs.Close();
     return n;
 }
 public void DeserializeRequest(System.ServiceModel.Channels.Message message, object[] parameters)
 {
     Polenter.Serialization.SharpSerializer serializer = new Polenter.Serialization.SharpSerializer(true);
     using (var inStream = GetBodyInnerContentStream(message))
     {
         for (int i = 0; i < parameters.Length; i++)
         {
             parameters[i] = serializer.Deserialize(inStream);
         }
     }
 }
Exemplo n.º 5
0
 private void WaitStart()
 {
     while (true)
     {
         Object obj = deserializer.Deserialize(stream);
         if (obj is string && (string)obj == "/Lunch")
         {
             EndWaitStart();
             if (!IsLocalClient)
             {
                 MainGame.GetInstance().SetScreen(new MultiScreen(this));
             }
             return;
         }
         else if (obj is List <EntityMulti> )
         {
             OtherPlayers = (List <EntityMulti>)obj;
         }
     }
 }
        public static Person DeserializeSharpSerializerXml()
        {
            Person p = default(Person);

            // create instance of sharpSerializer
            // true - binary serialization, false - xml serialization
            var serializer = new Polenter.Serialization.SharpSerializer(false);

            // deserialize
            p = (Person)serializer.Deserialize(Path.Combine(path_root, "Person.SharpSerializer.xml"));

            return p;
        }
        public static Person DeserializeSharpSerializerXml()
        {
            Person p = default(Person);

            // create instance of sharpSerializer
            // true - binary serialization, false - xml serialization
            var serializer = new Polenter.Serialization.SharpSerializer(false);

            // deserialize
            p = (Person)serializer.Deserialize(Path.Combine(path_root, "Person.SharpSerializer.xml"));

            return(p);
        }
Exemplo n.º 8
0
        public static bool ObjectDeserialize(string fileName, out object obj, bool isEncrypt = false)
        {
            bool result = false;

            obj = null;
            try
            {
                string filePath = LkCommonUtil.GetFilePath(Path.Combine(DefaultDirectory, fileName));
                if (File.Exists(filePath))
                {
                    Polenter.Serialization.SharpSerializer serializer = new Polenter.Serialization.SharpSerializer();

                    if (isEncrypt)
                    {
                        string temp = string.Empty;
                        if (LkEncryptDecrypt.Decrypt(File.ReadAllText(filePath), out temp))
                        {
                            File.WriteAllText(filePath + ".temp", temp);
                            obj = serializer.Deserialize(filePath + ".temp");
                            File.Delete(filePath + ".temp");
                            result = true;
                        }
                    }
                    else
                    {
                        obj    = serializer.Deserialize(filePath);
                        result = true;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Exemplo n.º 9
0
        public virtual T Deserialize <T>(Stream stream, bool binaryMode = false) where T : class
        {
            var sharpSerializer = new Polenter.Serialization.SharpSerializer(binaryMode);

            T result = default(T);

            try
            {
                IsActive = true;

                result = sharpSerializer.Deserialize(stream) as T;
            }
            finally
            {
                IsActive = false;
            }

            return(result);
        }
Exemplo n.º 10
0
        public virtual object Deserialize(Stream stream, bool binaryMode = false)
        {
            var sharpSerializer = new Polenter.Serialization.SharpSerializer(binaryMode);

            object result = null;

            try
            {
                IsActive = true;

                result = sharpSerializer.Deserialize(stream);
            }
            finally
            {
                IsActive = false;
            }

            return(result);
        }
Exemplo n.º 11
0
 protected override T Deserialize(System.IO.Stream serializationStream)
 {
     return((T)formatter.Deserialize(serializationStream));
 }