public static DataContractObject DeSerialize(Stream inputStream)
        {
            CheckArg.Stream(inputStream);
            inputStream.Seek(0, SeekOrigin.Begin);
            IDataContractSurrogate dataContractSurrogate = new DataContractActorSurrogate();
            DataContractSerializer dcs = new DataContractSerializer(typeof(DataContractObject), null, 1000, true, true, dataContractSurrogate);

            return((DataContractObject)dcs.ReadObject(inputStream));
        }
Beispiel #2
0
        public void CheckArgReturnTest()
        {
            using (var stream = new MemoryStream())
            {
                CheckArg.Stream(stream);
            }

            try
            {
                CheckArg.Stream(null);
                Assert.Fail();
            }
            catch (ActorException)
            {
            }

            CheckArg.Address("My address");
            try
            {
                CheckArg.Address(string.Empty);
                Assert.Fail();
            }
            catch (ActorException)
            {
            }

            CheckArg.Behaviors(new Actor.Base.Behaviors());
            try
            {
                CheckArg.Behaviors(null);
                Assert.Fail();
            }
            catch (ActorException)
            {
            }

            CheckArg.Behavior(new Actor.Base.Behavior <string>());
            try
            {
                CheckArg.Behavior(null);
                Assert.Fail();
            }
            catch (ActorException)
            {
            }

            CheckArg.Actor(new Actor.Base.BaseActor());
            try
            {
                CheckArg.Actor(null);
                Assert.Fail();
            }
            catch (ActorException)
            {
            }
        }
        public void SendStream(string host, Stream stream)
        {
            CheckArg.Stream(stream);
            stream.Seek(0, SeekOrigin.Begin);
            MemoryStream clone = new MemoryStream();

            stream.CopyTo(clone);
            clone.Seek(0, SeekOrigin.Begin);
            _future.SendMessage((Stream)clone);
        }
        public static SerialObject DeSerialize(Stream inputStream)
        {
            CheckArg.Stream(inputStream);
            inputStream.Seek(0, SeekOrigin.Begin);
            NetDataContractSerializer dcs = new NetDataContractSerializer();

            dcs.SurrogateSelector = new ActorSurrogatorSelector();
            dcs.Binder            = new ActorBinder();
            return((SerialObject)dcs.ReadObject(inputStream));
        }
        public void SendStream(string uri, Stream stream)
        {
            CheckArg.Stream(stream);
            using (StreamReader srDebug = new StreamReader(stream))
            {
                while (!srDebug.EndOfStream)
                {
                    Debug.Print(srDebug.ReadLine());
                }

                stream.Seek(0, SeekOrigin.Begin);
                using (var client = new HttpClient())
                {
                    using (var hc = new StreamContent(stream))
                    {
                        client.PostAsync(uri, hc).Wait();
                    }
                }
            }
        }