private static object findObj(object o, FieldInfo f, InjectAttribute ia) { if (ia.type == InjectAttribute.Type.global) { return(BeansRepo.bean(f.FieldType, ia.name)); } else { if (!(o is MonoBehaviour)) { throw new System.Exception("this not MonoBehaviour=" + o + " f=" + f); } MonoBehaviour mo = (MonoBehaviour)o; if (ia.type == InjectAttribute.Type.getcomponent) { return(mo.GetComponent(f.FieldType)); } if (ia.type == InjectAttribute.Type.getcomponentinchildren) { return(mo.GetComponentInChildren(f.FieldType)); } if (ia.type == InjectAttribute.Type.getComponentInParent) { return(mo.GetComponentInParent(f.FieldType)); } throw new System.Exception("this not Support this type=" + ia.type); } }
private void saveBean(UnityEngine.Object o, string name) { Beans.Bean b = new Beans.Bean(); b.instanced = true; b.name = name; b.returnType = o.GetType(); b.beanInstance = o; BeansRepo.getInstance().addOne(b, true); }
public static BeansRepo getInstance() { if (instance == null) { if (_debug_recursively) { throw new System.Exception("_debug_recursively"); } _debug_recursively = true; instance = new BeansRepo(); } return(instance); }
public static void enable() { BeansRepo.getInstance().setFindFunc(new UnityBeansFinder()); }