Giter Site home page Giter Site logo

bubdm / dframework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from witterlee/dframework

0.0 0.0 0.0 1.88 MB

A Framework with command Bus

License: GNU General Public License v3.0

C# 93.46% CSS 0.12% ASP 0.02% HTML 1.21% JavaScript 4.65% Batchfile 0.54%

dframework's Introduction

#DFramework
a command bus framework,this framework have some plugins

IOC --> Autofac plugin
Cache --> Couchbase cache
Cache --> Memcached/ali OCS cache
Log --> Log4net


##Use Case

####application start #####Couchbase cache

 DEnvironment.Initialize()
 .UseAutofac()
 .UseCouchbaseCache(clientConfig, "datastore")
 .UseLog4net()
 .UseDefaultCommandBus(GetAllAssembly())
 .UseDefaultJsonSerialaizer();

#####Memcached

 //IPAddress newaddress = Dns.GetHostByName("xxxxxxxx.ocs.aliyuncs.com").AddressList.FirstOrDefault();
 DEnvironment.Initialize()
 .UseAutofac()
 .UseMemcached("memcached server") //not support memcached cluster now, will support later
 //.UseMemcached(newaddress.ToString(),ocsUser: "xxx", ocsPassword: "xxx")
 .UseLog4net()
 .UseDefaultCommandBus(GetAllAssembly())
 .UseDefaultJsonSerialaizer();

####controller

[HttpGet]
public ActionResult Index()
{
    var cmd = new TestCommand("nameA", "pwdB");
    this.CommandBus.Send(cmd);
    return View();
}
[HttpGet]
public async Task<ActionResult> Index()
{
    var cmd = new TestCommand("nameA", "pwdB");
    await this.CommandBus.SendAsync(cmd);
    var reuslt=cmd.CommandResult;
    return View();
}
[HttpGet]
public async Task<ActionResult> Index()
{
    var cmd = new TestHasReturnValueCommand("nameA", "pwdB");
    await this.CommandBus.SendAsync(cmd);
    var reuslt=cmd.CommandResult;
    Console.WriteLine(result.ToString());
    return View();
}

####command

public class TestCommand:DFramework.Command
{
    public TestCommand(string name, string password)
    {
        this.Name = name;
        this.Password = password;
    }

    public string Name { get; set; }
    public string Password { get; set; }
}
public class TestHasReturnValueCommand:Command<int>
{
    public TestReturnResultCommand(string name, string password)
    {
        this.Name = name;
        this.Password = password;
    }

    public string Name { get; set; }
    public string Password { get; set; } 
}

####command-executor

 public class SampleCommandExecutor : ICommandExecutor<TestCommand>,
                                      ICommandExecutor<TestHasReturnValueCommand>
    {
        public Task ExecuteAsync(TestCommand cmd)
        {
            return Task.Factory.StartNew(() =>
             {
                 Console.WriteLine("TestCommand Executed.");
             });
        }

        public async Task ExecuteAsync(TestReturnResultCommand cmd)
        {
             await Task.Factory.StartNew(() =>
             {
                 Console.WriteLine("TestHasReturnValueCommand Executed.");
                 cmd.CommandResult=1;
             });
        }
    }

dframework's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.