using System; using System.Collections.Generic; namespace EGFramework { public interface IEGObject { void RegisterObject(T object_); T GetObject() where T : class,new(); } public class EGObject : EGModule,IEGObject { private IOCContainer ObjectContainer = new IOCContainer(); public override void Init() { } public TObject GetObject() where TObject : class,new() { if (!ObjectContainer.self.ContainsKey(typeof(TObject))) { this.RegisterObject(new TObject()); } return ObjectContainer.Get(); } public void RegisterObject(TObject object_) { ObjectContainer.Register(object_); } public bool ContainsObject(){ return ObjectContainer.self.ContainsKey(typeof(TObject)); } } public static class CanGetObjectExtension { public static T EGGetObject(this IEGFramework self) where T : class,new() { return EGArchitectureImplement.Interface.GetModule().GetObject(); } } public static class CanRegisterObjectExtension { public static void EGRegisterObject(this IArchitecture self,T object_) where T : class,new() { self.GetModule().RegisterObject(object_); } public static void EGRegisterObject(this IEGFramework self,T object_) where T : class,new() { EGArchitectureImplement.Interface.GetModule().RegisterObject(object_); } } public static class CanContainsObjectExtension{ public static bool EGContainsObject(this IEGFramework self) { return EGArchitectureImplement.Interface.GetModule().ContainsObject(); } } }