예제 #1
0
        private void Judge(JudgeContext context)
        {
            JudgeTask      task      = context.Task;
            ITaskSubmitter submitter = AdapterFactory.CreateTaskSubmitter();

            try
            {
                UpdateTestData(context);

                using (BaseJudger judger = JudgerFactory.Create(context))
                {
                    LogStartJudgeTask(task.SubmitId);
                    judger.Judge();
                }
            }
            catch (ExpectedJudgeStopException)
            { }
            catch (Exception ex) // 判题失败
            {
                context.Result = CreateFailedJudgeResult(context, ex.ToString());
                throw;
            }
            finally
            {
                LogJudgeResult(context.Result);
                submitter.Submit(context);
            }
        }
예제 #2
0
        /// <summary>
        /// Submits the hand.
        /// </summary>
        /// <param name="hand">The hand.</param>
        /// <param name="teamId">The team identifier.</param>
        /// <param name="gameId">The game identifier.</param>
        /// <returns></returns>
        public OperationOutcome SumbitHand(Hand hand, Guid teamId, Guid gameId)
        {
            var gameAdapter = AdapterFactory.GetGameAdapter();
            var game        = gameAdapter.GetGameById(gameId);

            if (game == null)
            {
                throw new BadRequestException();
            }

            var response = this.SubmitHandGeneric(hand, teamId, game);

            if (!game.IsSimulatedGame)
            {
                return(response);
            }

            gameAdapter = AdapterFactory.GetGameAdapter();
            game        = gameAdapter.GetGameById(gameId);

            if (!game.IsComplete)
            {
                this.SumbitSimulatedHand(game);
            }

            return(response);
        }
예제 #3
0
        public void Create_WhenTokenIssuedSuccessEvent_WillReturnTokenIssuedSuccessEventAdapter()
        {
            // Arrange
            var authResponse = new AuthorizeResponse()
            {
                Request = new ValidatedAuthorizeRequest()
                {
                    Client  = new Client(),
                    Subject = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim>()
                    {
                        new Claim(JwtClaimTypes.Subject, string.Empty)
                    }))
                }
            };

            var evt = new TokenIssuedSuccessEvent(authResponse);

            var sut = new AdapterFactory();

            // Act
            var adapter = sut.Create(evt);

            // Assert
            Assert.IsType <TokenIssuedSuccessEventAdapter>(adapter);
        }
예제 #4
0
        public static void Main(string[] args)
        {
            var sourceFile = "DATANORM.001";
            var resultFile = "result.xml";

            var adapterType = InferAdapterFromFile(sourceFile);

            var factory = new AdapterFactory(@"T:\Gemeinsame Dateien\trinity6");

            var adapter = factory.CreateAdapter(adapterType);

            AuthorizeAdapter(adapter);

            AttachEventHandlers(adapter);

            try
            {
                adapter.Run(sourceFile, resultFile);
                Console.WriteLine("Conversion completed.");
            }
            catch (AdapterFailureException ex)
            {
                Console.WriteLine("Conversion failed with error: " + ex.Message);
            }
        }
예제 #5
0
 private LogBookDataModel GetLogBook(int logNum, string environment, bool fetchWithDetails = false)
 {
     using (var adapter = AdapterFactory.CreateAdapter(MyNameSpace, environment))
     {
         return(GetLogBookWithDetails(logNum, adapter, fetchWithDetails));
     }
 }
        public IPoint TopRight()
        {
            double x        = Origin.X + Width;
            double y        = Origin.Y + Height;
            IPoint topRight = AdapterFactory.GetNewPoint(x, y);

            return(topRight);
        }
예제 #7
0
        public SqlExpBase(SqlAdapterType adater, SqlTableDefine tableDefine, List <SqlColumnDefine> columnDefines)
        {
            _type    = SqlType.Query;
            _adapter = adater;

            _builder  = new Builder.Builder(_type, tableDefine, columnDefines, AdapterFactory.GetAdapterInstance(_adapter));
            _resolver = new LambdaResolver(_builder);
        }
예제 #8
0
 public SqlExpBase(SqlAdapterType adater, Type entityType)
 {
     _type       = SqlType.Query;
     _adapter    = adater;
     _entityType = entityType;
     _builder    = new Builder.Builder(_type, entityType, AdapterFactory.GetAdapterInstance(_adapter));
     _resolver   = new LambdaResolver(_builder);
 }
예제 #9
0
        public void TestAttributesAdapterType()
        {
            TestInit();
            //todo:fix connection mock
            IAdapter <Document> adapter = AdapterFactory <Document> .GetAdapter(MapConfigEnum.ATTRIBUTESETTINGS, maps);

            Assert.IsTrue(typeof(AttributesAdapter <Document>).IsInstanceOfType(adapter));
        }
예제 #10
0
        /// <summary>
        /// Gets all games for dashboard games.
        /// </summary>
        /// <param name="numberOfGames">The number of games.</param>
        /// <returns>DashboardGames</returns>
        public IEnumerable <Game> GetAllGamesForDashboardGames(int?numberOfGames = null)
        {
            numberOfGames = numberOfGames ?? Properties.Settings.Default.DefaultMaxDashboardGames;

            var adapter = AdapterFactory.GetGameAdapter();

            return(adapter.GetGamesForDashbaord(numberOfGames.Value));
        }
        public IPoint TopRight()
        {
            double x        = _textBox.Origin.X + _textBox.Width;
            double y        = _textBox.Origin.Y + _textBox.Height;
            IPoint topRight = AdapterFactory.GetNewPoint(x, y);

            return(topRight);
        }
        protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
            var factory = Container.GetExportedValue <IRegionBehaviorFactory>();

            mappings.RegisterMapping(typeof(NavBarControl), AdapterFactory.Make <RegionAdapterBase <NavBarControl> >(factory));
            return(mappings);
        }
예제 #13
0
        public void GetAdapterTest()
        {
            IAdapterFactory factory = new AdapterFactory();

            IAdapter actualAdapter = factory.GetAdapter(nameof(PingAdapter));

            Assert.AreEqual(typeof(PingAdapter), actualAdapter.GetType());
        }
        public static void CreateTable(this IDbConnection db, SqlTableDefine tableDefine, List <SqlColumnDefine> columnList, IDbTransaction transaction = null)
        {
            var dbAdapter = AdapterFactory.GetAdapterInstance(db.GetAdapter());

            var createTableSql = dbAdapter.CreateTableSql(tableDefine, columnList);

            db.Execute(createTableSql, transaction: transaction);
        }
예제 #15
0
        public void GetAdapterTest_UnknownAdapter()
        {
            IAdapterFactory factory = new AdapterFactory();

            Assert.ThrowsException <InvalidOperationException>(() => {
                IAdapter actualAdapter = factory.GetAdapter("UnknownAdapter");
            });
        }
        public static void TruncateTable(this IDbConnection db, string tableName, string tableSchema, IDbTransaction transaction = null)
        {
            var dbAdapter = AdapterFactory.GetAdapterInstance(db.GetAdapter());

            var sql = dbAdapter.TruncateTableSql(tableName, tableSchema);

            db.Execute(sql, transaction: transaction);
        }
        public static bool TableExist(this IDbConnection db, string tableName, string tableSchema = null, IDbTransaction transaction = null)
        {
            var dbAdapter = AdapterFactory.GetAdapterInstance(db.GetAdapter());

            var tableExistSql = dbAdapter.TableExistSql(tableName, tableSchema);

            return(db.ExecuteScalar <int>(tableExistSql, transaction: transaction) > 0);
        }
예제 #18
0
        static void Main(string[] args)
        {
            var chunkSizeBytes = Int32.Parse(args[0]);
            var sourcePath     = args[1];
            var adapterFactory = new AdapterFactory();
            var senderService  = new SenderService(adapterFactory, chunkSizeBytes, sourcePath);

            senderService.Send();
        }
예제 #19
0
        /// <summary>
        /// Gets the simulated game.
        /// </summary>
        /// <param name="team">The team.</param>
        /// <returns>The simulated team</returns>
        protected Guid GetSimulatedGame(Team team)
        {
            var gameAdapter = AdapterFactory.GetGameAdapter();
            var game        = gameAdapter.RegisiterSimulatorGame(Properties.Settings.Default.SimulatorTeamName);

            gameAdapter.SaveChanges();

            return(game.Id);
        }
예제 #20
0
        public static Task CreateTableAsync(this IDbConnection db, SqlTableDefine tableDefine,
                                            List <SqlColumnDefine> columnList, IDbTransaction transaction = null)
        {
            var dbAdapter = AdapterFactory.GetAdapterInstance(db.GetAdapter());

            var createTableSql = dbAdapter.CreateTableSql(tableDefine, columnList);

            return(db.ExecuteSqlAsync(transaction, createTableSql));
        }
예제 #21
0
        /// <summary>
        /// Sumbits the simulated hand.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <returns>The opperation outcome</returns>
        public OperationOutcome SumbitSimulatedHand(Game game)
        {
            var teamAdapter = AdapterFactory.GetTeamAdapter();

            var randomHand = this.GetRandomHand();
            var team       = teamAdapter.GetTeamByName(Properties.Settings.Default.SimulatorTeamName);

            return(this.SubmitHandGeneric(randomHand, team.Id, game));
        }
예제 #22
0
        public static Task <int> TruncateTableAsync(this IDbConnection db, string tableName, string tableSchema,
                                                    IDbTransaction transaction = null)
        {
            var dbAdapter = AdapterFactory.GetAdapterInstance(db.GetAdapter());

            var sql = dbAdapter.TruncateTableSql(tableName, tableSchema);

            return(db.ExecuteAsync(sql, transaction: transaction));
        }
예제 #23
0
        public List <ProductEx> Consolidate <TProductType>(IQueryable <TProductType> products) where TProductType : class
        {
            var adapter = AdapterFactory.GetAdapter <TProductType>();

            products.ToList().ForEach(
                p => consolidatedProducts.Add(new ProductEx(adapter.Adapt(p), this)));

            return(consolidatedProducts);
        }
예제 #24
0
    public static InterfaceT ToInterface <InterfaceT>(object target) where InterfaceT : class
    {
        var i = target as InterfaceT;

        if (i == null)
        {
            i = AdapterFactory <InterfaceT> .Create(target);
        }
        return(i);
    }
예제 #25
0
        protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)
        {
            base.ConfigureRegionAdapterMappings(regionAdapterMappings);
            var factory = base.Container.Resolve <IRegionBehaviorFactory>();

            regionAdapterMappings.RegisterMapping(typeof(DocumentGroup), AdapterFactory.Make <RegionAdapterBase <DocumentGroup> >(factory));
            regionAdapterMappings.RegisterMapping(typeof(LayoutPanel), AdapterFactory.Make <RegionAdapterBase <LayoutPanel> >(factory));
            regionAdapterMappings.RegisterMapping(typeof(LayoutGroup), AdapterFactory.Make <RegionAdapterBase <LayoutGroup> >(factory));
            regionAdapterMappings.RegisterMapping(typeof(TabbedGroup), AdapterFactory.Make <RegionAdapterBase <TabbedGroup> >(factory));
        }
예제 #26
0
 public AdapterController(ILoggerFactory loggerFactory,
                          IHostingEnvironment env,
                          IObjectStorageService objectStorageService,
                          AdapterFactory adapterFactory)
 {
     _logger = loggerFactory.CreateLogger <AdapterController>();
     _env    = env;
     _objectStorageService = objectStorageService;
     _adapterFactory       = adapterFactory;
 }
예제 #27
0
 public SqlExpBase(SqlAdapterType adater, Type entityType, string specialSchema)
 {
     _type       = SqlType.Query;
     _adapter    = adater;
     _entityType = entityType;
     SqlAdapter  = AdapterFactory.GetAdapterInstance(_adapter);
     _builder    = new Builder.Builder(_type, entityType, SqlAdapter, specialSchema);
     //_builder = new Builder.Builder(_type, entityType, AdapterFactory.GetAdapterInstance(_adapter));
     _resolver = new LambdaResolver(_builder);
 }
        /// <summary>
        /// 根据实体类创建数据库表
        /// </summary>
        /// <typeparam name="T">实体类类型</typeparam>
        /// <param name="db"></param>
        /// <param name="transaction"></param>
        public static void CreateTable <T>(this IDbConnection db, IDbTransaction transaction = null)
        {
            var dbAdapter = AdapterFactory.GetAdapterInstance(db.GetAdapter());

            var entityDef = EntityHelper.GetEntityDefine <T>();

            var createTableSql = dbAdapter.CreateTableSql(entityDef.Item1, entityDef.Item2);

            db.Execute(createTableSql, transaction: transaction);
        }
        protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
            var factory = Container.GetExportedValue <IRegionBehaviorFactory>();

            mappings.RegisterMapping(typeof(LayoutPanel), AdapterFactory.Make <RegionAdapterBase <LayoutPanel> >(factory));
            mappings.RegisterMapping(typeof(LayoutGroup), AdapterFactory.Make <RegionAdapterBase <LayoutGroup> >(factory));
            mappings.RegisterMapping(typeof(TabbedGroup), AdapterFactory.Make <RegionAdapterBase <TabbedGroup> >(factory));
            mappings.RegisterMapping(typeof(DocumentGroup), AdapterFactory.Make <RegionAdapterBase <DocumentGroup> >(factory));
            return(mappings);
        }
예제 #30
0
        public void GetPocoAdapterForGenericObjects()
        {
            // Arrange
            var factory = new AdapterFactory();

            //Act:
            var adapter = factory.Create(new PocoModel(), typeof(PocoModel));

            // Assert
            Assert.Equal(typeof(PocoAdapter), adapter.GetType());
        }