Ejemplo n.º 1
0
 public Reflector()
 {
     _gameObjectTypeInfo = new InjectTypeInfo(
         typeof(GameObject),
         new InjectConstructorInfo(null,
                                   new InvalidOperationException("GameObject cannot be instantiated manually."), null),
         Array.Empty <InjectMethodInfo>(),
         Array.Empty <InjectFieldOrPropertyInfo>());
 }
Ejemplo n.º 2
0
        private void InjectMethods(object obj, InjectTypeInfo typeInfo, IResolver resolver)
        {
            if (obj is GameObject)
            {
                InjectGameObjectMethods((GameObject)obj, resolver);
                return;
            }

            typeInfo.Methods.ForEach(method => InjectMethod(obj, method, resolver));
        }
Ejemplo n.º 3
0
        private void InjectFieldsAndProperties(object obj, InjectTypeInfo typeInfo, IResolver resolver)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            if (obj is GameObject)
            {
                InjectGameObjectFieldsAndProperties((GameObject)obj, resolver);
                return;
            }

            typeInfo.FieldsAndProperties.ForEach(x => InjectFieldOrProperty(obj, x, resolver));
        }
Ejemplo n.º 4
0
        public InjectTypeInfo GetTypeInfo(Type type)
        {
            if (type == typeof(GameObject))
            {
                return(_gameObjectTypeInfo);
            }

            var typeInfo = _typeInfos.GetValueOrDefault(type);

            if (typeInfo == null)
            {
                typeInfo = new InjectTypeInfo(
                    type,
                    GetConstructor(type),
                    GetMethods(type).ToArray(),
                    GetFieldsAndProperties(type));

                _typeInfos[type] = typeInfo;
            }

            return(typeInfo);
        }