private static bool CanInjectBehaviour(PropertyInfo prop, Inject inject) { return((inject.Type == InjectType.EasyBehaviour || inject.Type == InjectType.Auto) && (typeof(EasyBehaviour).IsAssignableFrom(prop.PropertyType) || typeof(EasySupplier).IsAssignableFrom(prop.PropertyType))); }
private static bool CanInjectComponentInChildren(PropertyInfo prop, Inject inject, object obj) { return(inject.Type == InjectType.ComponentInChildren && (typeof(UnityEngine.Component).IsAssignableFrom(prop.PropertyType)) && obj as MonoBehaviour != null); }
static void InjectPropertyIntoObjByAttribute(object obj, PropertyInfo prop, Inject injectAttribute) { var propType = prop.PropertyType; switch (injectAttribute.Type) { case InjectType.Auto: if (propType.IsInterface) { InjectInterfaceProperty(prop, obj); } else if (BASE_BEHAVIOUR_TYPE.IsAssignableFrom(propType)) { InjectBehaviourProperty(prop, injectAttribute, obj); } else if (BASE_SIGNAL_TYPE.IsAssignableFrom(propType)) { InjectSignalProperty(prop, injectAttribute, obj); } else if (MONO_TYPE.IsAssignableFrom(propType)) { InjectComponentProperty(prop, injectAttribute, obj); } else if (CanInjectListener(prop)) { InjectListener(prop, obj); } else if (CanInjectInvoker(prop)) { InjectInvoker(prop, obj); } else if (CanInjectCloud(prop, injectAttribute, obj)) { InjectCloud(prop, obj); } else { InjectRegisterable(prop, obj); } break; case InjectType.EasyBehaviour: InjectBehaviourProperty(prop, injectAttribute, obj); break; case InjectType.Signal: InjectSignalProperty(prop, injectAttribute, obj); break; case InjectType.Component: case InjectType.ComponentInChildren: InjectComponentProperty(prop, injectAttribute, obj); break; case InjectType.Cloud: InjectCloudProperty(prop, injectAttribute, obj); break; case InjectType.Listener: if (CanInjectListener(prop)) { InjectListener(prop, obj); } break; case InjectType.Invoker: if (CanInjectInvoker(prop)) { InjectInvoker(prop, obj); } break; case InjectType.Registerable: InjectRegisterable(prop, obj); break; case InjectType.Interface: InjectInterfaceProperty(prop, obj); break; } #if UNITY_EDITOR _systemDelegate._injectionsCount++; #endif }