示例#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>());
 }
示例#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));
        }
示例#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));
        }
示例#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);
        }