예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConditionContext"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="mapDescriptor">A reference to the map descriptor in use.</param>
        /// <param name="map">A reference to the map in use.</param>
        /// <param name="creatureFinder">A reference to the creature finder in use.</param>
        /// <param name="itemFactory">A reference to the item factory in use.</param>
        /// <param name="scheduler">A reference to the scheduler instance.</param>
        public ConditionContext(
            ILogger logger,
            IMapDescriptor mapDescriptor,
            IMap map,
            ICreatureFinder creatureFinder,
            IItemFactory itemFactory,
            IScheduler scheduler)
            : base(logger, () => scheduler.CurrentTime)
        {
            mapDescriptor.ThrowIfNull(nameof(mapDescriptor));
            map.ThrowIfNull(nameof(map));
            creatureFinder.ThrowIfNull(nameof(creatureFinder));
            itemFactory.ThrowIfNull(nameof(itemFactory));
            scheduler.ThrowIfNull(nameof(scheduler));

            this.MapDescriptor  = mapDescriptor;
            this.Map            = map;
            this.CreatureFinder = creatureFinder;
            this.ItemFactory    = itemFactory;
            this.Scheduler      = scheduler;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationContext"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="mapDescriptor">A reference to the map descriptor in use.</param>
        /// <param name="map">A reference to the map in use.</param>
        /// <param name="creatureFinder">A reference to the creature finder in use.</param>
        /// <param name="itemFactory">A reference to the item factory in use.</param>
        /// <param name="creatureFactory">A reference to the creature factory in use.</param>
        /// <param name="containerManager">A reference to the container manager in use.</param>
        /// <param name="gameOperationsApi">A reference to the game operations api.</param>
        /// <param name="combatOperationsApi">A reference to the combat operations api.</param>
        /// <param name="pathFinderAlgo">A reference to the path finding algorithm in use.</param>
        /// <param name="predefinedItemSet">A reference to the predefined item set declared.</param>
        /// <param name="scheduler">A reference to the scheduler instance.</param>
        public OperationContext(
            ILogger logger,
            IMapDescriptor mapDescriptor,
            IMap map,
            ICreatureFinder creatureFinder,
            IItemFactory itemFactory,
            ICreatureFactory creatureFactory,
            IContainerManager containerManager,
            IGameOperationsApi gameOperationsApi,
            ICombatOperationsApi combatOperationsApi,
            IPathFinder pathFinderAlgo,
            IPredefinedItemSet predefinedItemSet,
            IScheduler scheduler)
            : base(logger, () => scheduler.CurrentTime)
        {
            mapDescriptor.ThrowIfNull(nameof(mapDescriptor));
            map.ThrowIfNull(nameof(map));
            creatureFinder.ThrowIfNull(nameof(creatureFinder));
            itemFactory.ThrowIfNull(nameof(itemFactory));
            creatureFactory.ThrowIfNull(nameof(creatureFactory));
            containerManager.ThrowIfNull(nameof(containerManager));
            gameOperationsApi.ThrowIfNull(nameof(gameOperationsApi));
            combatOperationsApi.ThrowIfNull(nameof(combatOperationsApi));
            pathFinderAlgo.ThrowIfNull(nameof(pathFinderAlgo));
            predefinedItemSet.ThrowIfNull(nameof(predefinedItemSet));
            scheduler.ThrowIfNull(nameof(scheduler));

            this.MapDescriptor     = mapDescriptor;
            this.Map               = map;
            this.CreatureFinder    = creatureFinder;
            this.ItemFactory       = itemFactory;
            this.CreatureFactory   = creatureFactory;
            this.ContainerManager  = containerManager;
            this.GameApi           = gameOperationsApi;
            this.CombatApi         = combatOperationsApi;
            this.PathFinder        = pathFinderAlgo;
            this.PredefinedItemSet = predefinedItemSet;
            this.Scheduler         = scheduler;
        }
예제 #3
0
        // datareader 转实体
        T GetResult <T>(IDataReader reader, IMapDescriptor map)
        {
            T result = default(T);

            if (typeof(T) == typeof(DataTable))
            {
                DataTable table = new DataTable();
                table.Load(reader);
                result = (T)(object)table;
            }
            else if (typeof(T) == typeof(DataSet))
            {
                InternalDataSet data = new InternalDataSet();
                data.Load(reader, LoadOption.OverwriteChanges, null, new DataTable[] { });
                result = (T)(object)data;
            }
            else
            {
                TypeDeserializer deserializer = new TypeDeserializer(_context, reader, map);
                result = deserializer.Deserialize <T>();
            }
            return(result);
        }
예제 #4
0
 /// <summary>
 /// 实体化 <see cref="TypeDeserializer"/> 类的新实例
 /// </summary>
 /// <param name="context">当前查询上下文</param>
 /// <param name="reader">DataReader</param>
 /// <param name="map">命令描述对象,用于解析实体的外键</param>
 public TypeDeserializer(IDbContext context, IDataReader reader, IMapDescriptor map)
 {
     _map     = map;
     _reader  = reader;
     _context = context;
 }