コード例 #1
0
        protected async Task <DbLazyLoad <T> > InitializeAsync(IDatabaseAsync db)
        {
            ITableMapping tableMapping = await db.GetTableMappingAsync <T>().ConfigureAwait(false);

            PrimaryKeyPropName = tableMapping.GetPrimaryKeyProp();

            PropertyInfoMap = new Dictionary <string, PropertyInfo>();

            List <string> permanentPropertiesList    = new List <string>();
            List <string> lazyLoadedPropertiesList   = new List <string>();
            List <string> lazyUnloadedPropertiesList = new List <string>();

            foreach (string propName in tableMapping.GetColumnMarkedProperties())
            {
                PropertyInfo propInfo = tableMapping.GetPropertyInfo(propName);

                var lazyLoadedAttribute   = propInfo.GetCustomAttribute <LazyLoadedAttribute>();
                var lazyUnloadedAttribute = propInfo.GetCustomAttribute <LazyUnloadedAttribute>();

                if (propName == PrimaryKeyPropName)
                {
                    permanentPropertiesList.Add(propName);
                    lazyLoadedPropertiesList.Add(propName);
                    lazyUnloadedPropertiesList.Add(propName);
                }

                else if (lazyUnloadedAttribute != null && lazyLoadedAttribute != null)
                {
                    lazyLoadedPropertiesList.Add(propName);
                    lazyUnloadedPropertiesList.Add(propName);
                }

                else if (lazyLoadedAttribute != null)
                {
                    lazyLoadedPropertiesList.Add(propName);
                }

                else
                {
                    permanentPropertiesList.Add(propName);
                }

                PropertyInfoMap.Add(propName, propInfo);
            }

            PermanentProperties    = permanentPropertiesList.ToArray();
            LazyLoadedProperties   = lazyLoadedPropertiesList.ToArray();
            LazyUnloadedProperties = lazyUnloadedPropertiesList.ToArray();

            return(this);
        }
コード例 #2
0
        private async Task <bool> InitializeAsync(CollectionConfig config)
        {
            _cardTableName =
                (await _db.GetTableMappingAsync <Card>().ConfigureAwait(false)).GetTableName();

            ReviewSession reviewSession =
                await ReviewSession.ComputeSessionAsync(_db, config).ConfigureAwait(false);

            ReviewCollectionNew   = new ReviewCollectionNew(_db, config, reviewSession.New);
            ReviewCollectionLearn = new ReviewCollectionLearn(_db);
            ReviewCollectionDue   = new ReviewCollectionDue(_db, reviewSession.Due);

            NextAction[ReviewCollectionNew]   = () => ReviewCollectionNew.MoveNextAsync();
            NextAction[ReviewCollectionLearn] = () => ReviewCollectionLearn.MoveNextAsync();
            NextAction[ReviewCollectionDue]   = () => ReviewCollectionDue.MoveNextAsync();

            await
            Task.WhenAll(
                ReviewCollectionNew.IsInitializedAsync(), ReviewCollectionLearn.IsInitializedAsync(),
                ReviewCollectionDue.IsInitializedAsync()).ConfigureAwait(false);

            return(await DoNextAsync().ConfigureAwait(false));
        }