コード例 #1
0
 public UIData(int uiID, string path, LoadStrategy loadMode)
 {
     m_UIID = uiID;
     //m_PanelClassType = type;
     m_ResPath      = path;
     m_LoadStrategy = loadMode;
 }
コード例 #2
0
        public virtual async Task <Tuple <IEnumerable <TEntity>, int> > GetAll
        (
            int skip,
            int take,
            LoadStrategy loadStrategy = LoadStrategy.AsNoTracking
        )
        {
            var databaseCount = await DbSet
                                .CountAsync()
                                .ConfigureAwait(false);

            if (loadStrategy == LoadStrategy.AsNoTracking)
            {
                return(new Tuple <IEnumerable <TEntity>, int>
                       (
                           await DbSet.AsNoTracking()
                           .Skip(skip)
                           .Take(take)
                           .ToListAsync()
                           .ConfigureAwait(false),
                           databaseCount
                       ));
            }

            return(new Tuple <IEnumerable <TEntity>, int>
                   (
                       await DbSet
                       .Skip(skip)
                       .Take(take)
                       .ToListAsync()
                       .ConfigureAwait(false),
                       databaseCount
                   ));
        }
コード例 #3
0
        /// <summary>
        /// Loads user strategy and extracts constructor parameters
        /// </summary>
        private void LoadUserStrategy(LoadStrategy loadStrategy)
        {
            try
            {
                if (_asyncClassLogger.IsInfoEnabled)
                {
                    _asyncClassLogger.Info("Trying to load user defined strategy from: " +
                                           loadStrategy.StrategyAssembly.FullName.Substring(0, loadStrategy.StrategyAssembly.FullName.IndexOf(",", System.StringComparison.Ordinal)),
                                           _type.FullName, "LoadUserStrategy");
                }

                var strategyDetails = LoadCustomStrategy.GetConstructorDetails(loadStrategy.StrategyAssembly);

                if (strategyDetails != null)
                {
                    if (_asyncClassLogger.IsInfoEnabled)
                    {
                        _asyncClassLogger.Info("Successfully loaded custom strategy: " + strategyDetails.Item1.Name, _type.Name, "LoadUserStrategy");
                    }

                    // Create new Strategy Constructor Info object
                    StrategyConstructorInfo strategyConstructorInfo = new StrategyConstructorInfo(
                        strategyDetails.Item2, strategyDetails.Item1);

                    // Publish Event to Notify Listener.
                    EventSystem.Publish <StrategyConstructorInfo>(strategyConstructorInfo);
                }
            }
            catch (Exception exception)
            {
                _asyncClassLogger.Error(exception, _type.FullName, "LoadUserStrategy");
            }
        }
コード例 #4
0
        /// <summary>
        /// Loads the selected Strategy Type
        /// </summary>
        private void LoadStrategy()
        {
            try
            {
                IUnityContainer container = new UnityContainer();

                // Open File Dialog Service to browse file
                var fileDialogService = container.Resolve <FileDialogService>();

                if (fileDialogService.OpenFileDialog(".dll", "Library Files") == true)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("File select browser opened.", _type.FullName, "LoadStrategy");
                    }

                    // Get the name of the selected file
                    string fileName = fileDialogService.FileName;

                    // Load Assembly file from the selected file
                    Assembly assembly = Assembly.LoadFrom(fileName);

                    if (assembly != null)
                    {
                        // Save File name
                        FileName = assembly.FullName.Substring(0, assembly.FullName.IndexOf(",", System.StringComparison.Ordinal));

                        // Save Assembly reference
                        _strategyAssembly = assembly;

                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Successfully loaded User Strategy: " + assembly.FullName, _type.FullName, "LoadStrategy");
                        }

                        // Clear previously saved parameters
                        _selectedConstuctorParameters.Clear();
                        // Reset Count
                        _parametersCount = 0;

                        // Create new Strategy Runner LoadStrategy Object
                        LoadStrategy loadStrategy = new LoadStrategy(_strategyAssembly);

                        // Publish Event to notify Listeners.
                        EventSystem.Publish <LoadStrategy>(loadStrategy);
                        return;
                    }

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info("Unable to load User Strategy", _type.FullName, "LoadStrategy");
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "LoadStrategy");
            }
        }
コード例 #5
0
 public UIData(int uiID, string path, bool singleton, int cacheCount, LoadStrategy loadMode)
 {
     m_UIID = uiID;
     //m_PanelClassType = type;
     m_ResPath      = path;
     m_IsSingleton  = singleton;
     m_CacheCount   = cacheCount;
     m_LoadStrategy = loadMode;
 }
コード例 #6
0
 public virtual async Task <TEntity> GetByIdAsync(int entityId, LoadStrategy loadStrategy = LoadStrategy.AsNoTracking)
 {
     return(loadStrategy == LoadStrategy.AsNoTracking
         ? await DbSet
            .AsNoTracking()
            .SingleOrDefaultAsync(entity => entity.Id == entityId)
            .ConfigureAwait(false)
         : await DbSet.FindAsync(entityId).ConfigureAwait(false));
 }
コード例 #7
0
ファイル: World.cs プロジェクト: dpisanu/xrunuo
        public static void Load()
        {
            if (Loaded)
            {
                return;
            }

            Loaded = true;

            log.Info("Loading started");

            var start = DateTime.UtcNow;

            Loading = true;

            m_AddQueue    = new Queue <IEntity>();
            m_DeleteQueue = new Queue <IEntity>();

            var strategy = LoadStrategy.Acquire();

            strategy.LoadEntities(m_Repositories);

            EventSink.InvokeWorldLoad();

            Loading = false;

            ProcessSafetyQueues();

            foreach (var item in m_Items.Values)
            {
                if (item.Parent == null)
                {
                    item.UpdateTotals();
                }

                item.ClearProperties();
            }

            foreach (var m in m_Mobiles.Values)
            {
                m.UpdateRegion();                 // Is this really needed?
                m.UpdateTotals();

                m.ClearProperties();
            }

            if (ManualGC)
            {
                GC.Collect();
            }

            log.Info("Loading done: {1} items, {2} mobiles ({0:F1} seconds)", (DateTime.UtcNow - start).TotalSeconds, m_Items.Count, m_Mobiles.Count);
        }
コード例 #8
0
        public void Load()
        {
            if (m_Loaded)
            {
                return;
            }

            m_Loaded = true;

            Console.Write("World: Loading...");

            DateTime start = DateTime.Now;

            m_Loading = true;

            m_AddQueue    = new Queue <IEntity>();
            m_DeleteQueue = new Queue <IEntity>();

            LoadStrategy strategy = LoadStrategy.Acquire();

            strategy.LoadEntities(m_Repositories);

            EventSink.Instance.InvokeWorldLoad();

            m_Loading = false;

            ProcessSafetyQueues();

            foreach (Item item in m_Items.Values)
            {
                if (item.Parent == null)
                {
                    item.UpdateTotals();
                }

                item.ClearProperties();
            }

            foreach (Mobile m in m_Mobiles.Values)
            {
                m.UpdateRegion();                 // Is this really needed?
                m.UpdateTotals();

                m.ClearProperties();
            }

            if (ManualGC)
            {
                System.GC.Collect();
            }

            Console.WriteLine(String.Format("done: {1} items, {2} mobiles ({0:F1} seconds)", (DateTime.Now - start).TotalSeconds, m_Items.Count, m_Mobiles.Count));
        }
コード例 #9
0
        public virtual async Task <Tuple <IEnumerable <TEntity>, int> > GetAll
        (
            int skip,
            int take,
            Expression <Func <TEntity, bool> > where,
            Expression <Func <TEntity, object> > orderBy,
            LoadStrategy loadStrategy = LoadStrategy.AsNoTracking
        )
        {
            var databaseCount = await DbSet
                                .CountAsync()
                                .ConfigureAwait(false);

            if (loadStrategy == LoadStrategy.AsNoTracking)
            {
                return(new Tuple <IEnumerable <TEntity>, int>
                       (
                           await DbSet
                           .AsNoTracking()
                           .OrderBy(orderBy)
                           .Where(where)
                           .Skip(skip)
                           .Take(take)
                           .ToListAsync()
                           .ConfigureAwait(false),
                           databaseCount
                       ));
            }

            return(new Tuple <IEnumerable <TEntity>, int>
                   (
                       await DbSet
                       .OrderBy(orderBy)
                       .Where(where)
                       .Skip(skip)
                       .Take(take)
                       .ToListAsync()
                       .ConfigureAwait(false),
                       databaseCount
                   ));
        }
コード例 #10
0
 public PanelData(int uiID, string path, bool singleton, int cacheCount, LoadStrategy loadMode) : base(uiID, path, singleton, cacheCount, loadMode)
 {
 }
コード例 #11
0
 public PanelData(int uiID, string path, LoadStrategy loadMode) : base(uiID, path, loadMode)
 {
 }
コード例 #12
0
 public HasOneAttribute(string rltnName, LoadStrategy strategy)
 {
 }
コード例 #13
0
 public HasOneAttribute(LoadStrategy strategy)
 {
 }
コード例 #14
0
ファイル: UIDataTable.cs プロジェクト: tkonexhh/NewWorld
 public static void SetLoadMode(LoadStrategy loadMode)
 {
     m_LoadStrategy = loadMode;
 }
コード例 #15
0
 /// <summary>
 ///     Reads new data file.
 /// </summary>
 /// <param name="filePath">Path to file.</param>
 /// <returns>IEnumerable of read data.</returns>
 private protected override IEnumerable <Computer> ReadNewDataFile(string filePath)
 {
     return(LoadStrategy.ReadData(filePath));
 }
コード例 #16
0
 public HasManyAttribute(LoadStrategy strategy)
 {
 }