Giter Club home page Giter Club logo

unitygameframework's Introduction

简单的分层框架

这是一个基于QFramework再改造的框架,简单的分为SystemModelUtility三层,再加上CommandQuery作为通用功能处理。同层之间理论不允许互相访问,下层不允许访问上层。

  • System层是模块化的逻辑功能,给多个Controller提供共享的逻辑功能,允许访问System(但注意不要循环引用),ModelUtility,可以执行CommandQuery,可以发送和接收事件。
  • Model层是数据模块,给System层和Controller提供共享的数据功能。允许访问Utility,可以发送事件。
  • Utility层是工具模块,比如一些持久化数据,配置读取,SDK之类的就可以放到这一层。可以发送事件
  • CommandSystem差不多,但这是一个无状态对象,可以做成struct。如果一个功能涉及到多个模块,不知道放哪里的时候就可以直接做成Command。允许访问SystemModelUtility,可以执行CommandQuery,可以发送事件。
  • Query一般用于多模块的组合数据查询。允许访问SystemModelUtility,可以执行Query,可以发送事件。

关于Controller

QFramework中的Controller层在这框架中不直接提供,可以每个项目自己定义一个对应的接口,参考如下

internal interface IController : ICanGetModel, ICanGetSystem, ICanGetUtility, ICanSendCommand, ICanSendEvent, ICanSendQuery, ICanRegisterEvent
{
    IArchitecture IBelongArchitecture.GetArchitecture() => MyArchitecture.Instance;
}

关于ICommandProviderIQueryProvider两个接口

这两个接口分别是ICommandIQuery执行接口中传入的对象,QFramworkCommandQuery也是使用扩展接口的方式去处理,但如果是结构体的话会有装箱,所以这里就改成了把Architecture作为Provider传递进去使用。

关于BindableProperty

这边使用IEqualityComparer<T>接口来做两个数值是否相等的判断,默认情况下使用EqualityComparer<T>.Default,如果需要自定义Comparer,可以修改BindableProperty<T>.Comparer静态属性。

unitygameframework's People

Contributors

kunagisa avatar

Watchers

 avatar

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.