Example #1
0
        private InjectDefinition <T> CreateInjectDefinition(Type type)
        {
            InjectDefinition <T> definition = new InjectDefinition <T>();

            definition.AddTypeInfo(type);
            return(definition);
        }
Example #2
0
 protected override void InjectInto(Type type, InjectDefinition <ServiceAttribute> definition, object target)
 {
     foreach (KeyValuePair <FieldInfo, ServiceAttribute> pair in definition.Fields)
     {
         Type   injectType = pair.Value.InjectType ?? pair.Key.FieldType;
         object id         = pair.Value.Id ?? ServiceLocator.DEFAULT_SERVICE_KEY;
         object instance   = ServiceLocator.Instance.GetInstance(injectType, id);
         pair.Key.SetValue(target, instance);
     }
 }
        protected override void InjectInto(Type type, InjectDefinition <ComponentAttribute> definition, object target)
        {
            GameObject gameObject = ((MonoBehaviour)target).gameObject;

            foreach (KeyValuePair <FieldInfo, ComponentAttribute> pair in definition.Fields)
            {
                Type      injectType = pair.Value.InjectType ?? pair.Key.FieldType;
                Component instance   = gameObject.GetComponent(injectType);
                pair.Key.SetValue(target, instance);
            }
        }
Example #4
0
 protected abstract void InjectInto(Type type, InjectDefinition <T> definition, object target);