Exemple #1
0
 protected override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     RepositoryProxy.SaveIfContext();
     base.OnActionExecuted(filterContext);
 }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.WriteLine("Console size: " + Console.WindowWidth + "x" + Console.WindowHeight);
            //Console.
            //Console.SetWindowSize(Console.WindowWidth + 8, Console.WindowHeight/* + 8*/);
            //Console.WriteLine("Console size: " + Console.WindowWidth + "x" + Console.WindowHeight);

            Console.WriteLine();
            bool serverExit = false;

            try
            {
                Task serverTask = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        object buf;
                        //Service service = new Service("http://localhost:80/Artefacts/");
                        TcpListener listener = new TcpListener(IPAddress.Any, 99);
                        listener.Start();
                        while (!serverExit)
                        {
                            while (!listener.Pending())
                            {
                                System.Threading.Thread.Sleep(100);
                            }

                            TcpClient server = listener.AcceptTcpClient();
                            object result    = BsonSerializer.Deserialize(new BsonBinaryReader(server.GetStream()), typeof(object));
                            //new ByteBufferStream(ByteBufferFactory.Create(
                            //new SingleChunkBuffer(new ByteArrayChunk(2048), 2048), 2048)

                            Artefact artefact = result as Artefact;
                            Console.WriteLine("\nSERVER: {0}\n\tartefact: {1}\n\n", result, artefact);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console /*.Error*/.WriteLine(nameof(Service) + ".ServiceTask: \n" + ex.ToString() + "\n");
                        //Console./*.Error*/.NewLine + + Console/*.Error*/.NewLine);
                    }
                });

                //Service service = new Service("http://localhost:80/Artefacts/");
                //BsonSerializer.RegisterSerializer<Artefact>(ArtefactSerializer.Instance);

                Artefact dsArtefact;
                dynamic  a1 = new Artefact();
                a1.prop1 = "one";
                a1.prop2 = 2;
                a1.date  = DateTime.Now;

                SocketClient client = new SocketClient("localhost", 99);
                IRepository  repo   = new RepositoryProxy(client);
                repo.Save(a1);
            }
            catch (Exception ex)
            {
                Console /*.Error*/.WriteLine(nameof(Service) + ": \n" + ex.ToString() + "\n");
                //Console/*.Error*/.NewLine+ Console/*.Error*/.NewLine);
            }
            finally
            {
                Console.ReadKey();
                serverExit = true;
                //await se
            }
        }
 public RepositoryMetadataTest()
 {
     fakeRepositoryMock = new Mock <IFakeRepository>();
     fakeRepository     = RepositoryProxy.Create <IFakeRepository>(() =>
                                                                   fakeRepositoryMock.Object);
 }