• 和Keyle一起学StrangeIoc – Introduction


    StrangeIoC 

    Strange: the IoC framework for Unity

    Strange attractors create predictable patterns, often in chaotic systems. 在混乱的系统中创造出一个可以预测的模式 .

    Introduction

    StrangeIoc主要用于C#与Unity3d,我们已经在IOS,Web,Android项目中成功运用,他包含了如下功能,其中大部分功能都是可选的

    Strange is a super-lightweight and highly extensible Inversion-of-Control (IoC) framework, written specifically for C# and Unity. We’ve validated Strange on web, standalone, and iOS and Android. It contains the following features, most of which are optional:

    框架的核心是让你绑定一个或多个对象

    • A core binding framework that pretty much lets you bind one or more of anything to one or more of anything else.

      依赖注入

      1.映射单例,每次都可通过工厂返回新实例

      2.类名注入

      3.属性器注入

      4.构造注入

      5.方法注入

      6.Monobehaviors注入

      7.绑定多态

      8.反射与绑定结合,减少反射的性能开销

    • Dependency Injection
      • Map as singleton, value or factory (get a new instance each time you need one)
      • Name injections
      • Perform constructor or setter injection
      • Tag your preferred constructor
      • Tag a method to fire after construction
      • Inject into MonoBehaviours
      • Bind polymorphically (bind any or all of your interfaces to a single concrete class)
      • Reflection binding dramatically reduces overhead of employing reflectivity

      两种类型的事件共享总线

      1.二者的dispatch事件可在程序的任何一处调用

      2.二者为了实现本地通信都需要映射本地事件总线

      3.二者为了分离逻辑都需要映射事件

      4.新的Signals的实现增加了类型安全

    • Two styles of shared event bus.
      • Both dispatch events to any point in your application
      • Both map local event bus for local communication
      • Both map events to Command classes to separate business logic
      • The new Signals implementation adds type saftety
      • NB: Examples in this document use the default EventDispatcher. We've added a section explaining Signals, but didn't, frankly, have the patience to re-write the entire guide. Nevertheless, we encourage the use of Signals as the preferred means of communication.
    • MonoBehaviour mediation
      • Facilitate separation of a view from the application using it
      • Keep Unity-specific code isolated from the rest of the app
    • Optional MVCS (Model/View/Controller/Service) structure

      介绍可选MVCS部分

      1.多上下文,在单独的功能中使用自身的上下文,全局功能中使用程序级上下文

      2.允许多个上下文之间通信

    • Multiple contexts
      • Allow subcomponents (separate Scenes) to function on their own, or in the context of larger apps.
      • Allow communication between contexts.
    • Don’t see what you need? The core binding framework is simple to extend. Build new Binders like:
      • A different type of dispatcher
      • An entity framework
      • A multi-loader

      In addition to organizing your project into a sensible structure, Strange offers the following benefits:

      • Designed to play well with Unity3D. Also designed to play well without it.
      • Separate UnityEngine code from the rest of your app.
        • Improves portability
        • Improves unit testability
      • A common event bus makes information flow easy and highly decoupled. (Note: Unity’s SendMessage method does this, of course, but it’s dangerous as all get-out. I may write a whole article on just this topic at some point.)
      • The extensible binder really is amazing (a friend used to tell me “it’s good to like your own cookin’!”). The number of things you can accomplish with the tiny core framework would justify Strange all on its own.
      • Multiple contexts allow you to “bootstrap” subcomponents so they operate fine either on their own or as an integrated part. This can hugely speed up your development process and allow developers to work in isolation, then integrate in later stages of development.
  • 相关阅读:
    体验用yarp连接websocket
    从 ASP.NET Core 5.0 迁移到.NET 6
    对接网易云信音视频2.0呼叫组件集成到vue中,实现web端呼叫app,视频语音通话。
    .NET6 WebAPI 自定义过滤器
    .NET6 WebApi 获取访问者IP地址
    .NET6 部署到 IIS
    .NET6 WebApi JSON传到前台默认变成小驼峰
    开发环境 测试环境 生产环境
    .NET6 WebApi 使用 log4net
    .NET6 WebApi 解决跨域问题
  • 原文地址:https://www.cnblogs.com/Keyle/p/4292303.html
Copyright © 2020-2023  润新知