Monday, July 29, 2013

MVP with Events and Delegates Simple Example

Events and Delegates Simple Example

With Delegates

using System;
 
namespace ConsoleApplication1
{
    public delegate void MyDelegate(int state);
 
    class Program
    {
        static void Main(string[] args)
        {
            var view = new View();
            new Presenter(view);
            view.ViewDelete();
        }
    }
 
    public class View
    {
        public delegate void VDelete();
 
        public event VDelete Delete;
 
        public void ViewDelete()
        {
            VDelete vd = new VDelete(Delete);
 
            if (Delete != null)
            {
                vd();
            }
        }
    }
 
    public class Presenter
    {
        public Presenter(View view)
        {
            view.Delete += view_Delete;
        }
 
        void view_Delete()
        {
 
        }
    }
}
 



Without Delegates
using System;
 
namespace ConsoleApplication1
{
    public delegate void MyDelegate(int state);
 
    class Program
    {
        static void Main(string[] args)
        {
            var view = new View();
            var presenter = new Presenter(view);
            view.ViewDelete();
        }
    }
 
 
 
 
 
    public class View
    {
        public event EventHandler Delete;
 
        public void ViewDelete()
        {
            Delete(thisEventArgs.Empty);
        }
    }
 
 
 
    public class Presenter
    {
        public Presenter(View view)
        {            
            view.Delete += view_Delete;
        }
 
        void view_Delete(object sender, EventArgs e)
        {
 
        }
    }
}

Wednesday, July 10, 2013

Simple SOA infrastructure (Call RESTful WCF Service, Recognize relevant Service and Execute)

Simple SOA infrastructure (Call RESTful WCF Service, Recognize relevant Service and Execute)


Let's start with Service Gateway part:


And Utils for:


And Request Object Model:

And WCF Service Part:

Service Contract



Service implementation:


...and Service Request Object (must be exactly like Client Request Object for JSON Serialization)