예제 #1
0
        public static TypeFactory GetFactoryFor(string typeName)
        {
            int  typeId;
            Type clrType;

            try
            {
                typeId  = TypeManager.GetTypeByName(typeName).ID;
                clrType = TypeManager.GetImplementingClass(typeId);
            }
            catch (RuntimeException e)
            {
                if (NewInstanceHandler != null)
                {
                    clrType = NewInstanceHandler;
                }
                else
                {
                    throw new RuntimeException("Конструктор не найден (" + typeName + ")", e);
                }
            }

            if (!_factories.TryGetValue(clrType, out var factory))
            {
                factory             = new TypeFactory(clrType);
                _factories[clrType] = factory;
            }

            return(factory);
        }
예제 #2
0
        public static Type GetFactoryFor(string typeName)
        {
            int  typeId;
            Type clrType;

            try
            {
                typeId  = TypeManager.GetTypeByName(typeName).ID;
                clrType = TypeManager.GetImplementingClass(typeId);
            }
            catch (KeyNotFoundException)
            {
                if (NewInstanceHandler != null)
                {
                    clrType = NewInstanceHandler;
                }
                else
                {
                    throw new RuntimeException("Конструктор не найден (" + typeName + ")");
                }
            }

            return(clrType);
        }