Esempio n. 1
0
        public static CachedMetadata GetInitializedMetadata(BaseDomainService domainService)
        {
            return(_metadataCache.GetOrAdd(domainService.GetType(), (svcType) => {
                AsyncState asyncState = new AsyncState()
                {
                    domainService = domainService
                };

                ExecuteOnSTA(state =>
                {
                    AsyncState data = (AsyncState)state;
                    try
                    {
                        data.cachedMetadata = InitMetadata(data.domainService);
                    }
                    catch (Exception ex)
                    {
                        data.domainService._OnError(ex);
                        throw new DummyException(ex.Message, ex);
                    }
                }, asyncState);

                return asyncState.cachedMetadata;
            }));
        }
Esempio n. 2
0
        public async Task DeleteAsyncSucceeds()
        {
            // Arrange
            var options    = GetTestDbContextOptions("Delete_ScrapeJob_Database");
            var testEntity = GenerateTestEntity();

            using (var context = new WaasDbContext(options))
            {
                await context.AddAsync(testEntity);

                await context.SaveChangesAsync();
            }

            // Act
            bool result;

            using (var context = new WaasDbContext(options))
            {
                var testRepository = new BaseDomainService <ScrapeJob, long>(context);
                await testRepository.DeleteAsync(testEntity.Id);

                result = await context.CommitAsync();
            }

            // Assert
            Assert.True(result);
            using (var context = new WaasDbContext(options))
            {
                Assert.Null(await context.ScrapeJobs.FindAsync(testEntity.Id));
            }
        }
Esempio n. 3
0
        public static RunTimeMetadata GetInitializedMetadata(BaseDomainService domainService,
                                                             IDataHelper dataHelper,
                                                             IValueConverter valueConverter)
        {
            RunTimeMetadata result = _metadataCache.GetOrAdd(domainService.GetType(), (svcType) =>
            {
                RunTimeMetadata runTimeMetadata = null;

                try
                {
                    DesignTimeMetadata designTimeMetadata      = ((IMetaDataProvider)domainService).GetDesignTimeMetadata(false);
                    IDataManagerContainer dataManagerContainer = domainService.ServiceContainer.DataManagerContainer;
                    runTimeMetadata = _InitMetadata(domainService, designTimeMetadata, dataHelper, valueConverter, dataManagerContainer);
                }
                catch (Exception ex)
                {
                    domainService._OnError(ex);
                    throw new DummyException(ex.Message, ex);
                }

                return(runTimeMetadata);
            });

            return(result);
        }
Esempio n. 4
0
        public async Task GetAllSucceeds()
        {
            // Arrange
            var options = GetTestDbContextOptions("GetAll_ScrapeJob_Database");

            const int count          = 100;
            var       testScrapeJobs = Enumerable.Range(1, count).Select(e => GenerateTestEntity(e)).ToArray();

            using (var context = new WaasDbContext(options))
            {
                foreach (ScrapeJob scrapeJob in testScrapeJobs)
                {
                    await context.AddAsync(scrapeJob);
                }
                await context.SaveChangesAsync();
            }

            // Act
            using (var context = new WaasDbContext(options))
            {
                var testRepository = new BaseDomainService <ScrapeJob, long>(context);
                var result         = testRepository.GetAll();

                Assert.Equal(count, await result.CountAsync());
                Assert.Equal(testScrapeJobs.AsQueryable(), result);
            }
        }
Esempio n. 5
0
        public IDataManager <TModel> GetDataManager <TModel>(BaseDomainService dataService)
            where TModel : class
        {
            var res = GetDataManager(dataService, typeof(TModel));

            return((IDataManager <TModel>)res);
        }
Esempio n. 6
0
        public async Task AddAsyncSucceeds()
        {
            // Arrange
            var options = GetTestDbContextOptions("Add_ScrapeJob_Database");

            var testEntity = GenerateTestEntity();

            // Act
            bool result;

            using (var context = new WaasDbContext(options))
            {
                var testRepository = new BaseDomainService <ScrapeJob, long>(context);
                await testRepository.AddAsync(testEntity);

                result = await context.CommitAsync();
            }

            // Assert
            Assert.True(result);
            using (var context = new WaasDbContext(options))
            {
                var check = await context.ScrapeJobs.FindAsync(testEntity.Id);

                Assert.Equal(testEntity, check);
            }
        }
Esempio n. 7
0
        private static CachedMetadata InitMetadata(BaseDomainService domainService)
        {
            EventHandler <RegisteredDMEventArgs> fn_regDM = (sender, e) => {
                ProcessMethodDescriptions(domainService.ServiceContainer, e.DataManagerType, (CachedMetadata)sender);
            };

            CachedMetadata cachedMetadata = new CachedMetadata();

            //called on every data manager registered while bootstrapping
            cachedMetadata.RegisteredDM += fn_regDM;
            try
            {
                InitCachedMetadata(domainService, cachedMetadata);
            }
            catch (Exception ex)
            {
                domainService._OnError(ex);
                throw new DummyException(ex.Message, ex);
            }
            finally
            {
                cachedMetadata.RegisteredDM -= fn_regDM;
                cachedMetadata.InitCompleted();
            }

            return(cachedMetadata);
        }
Esempio n. 8
0
        public object GetDataManager(BaseDomainService dataService, Type modelType)
        {
            Func <BaseDomainService, object> factory;

            if (_managers.TryGetValue(modelType, out factory))
            {
                return(factory(dataService));
            }
            return(null);
        }
Esempio n. 9
0
 public static CachedMetadata EnsureMetadataInitialized(BaseDomainService domainService)
 {
     CachedMetadata cachedMetadata = null;
     Func<CachedMetadata> factory = () => {
         Type thisType = domainService.GetType();
         CachedMetadata result = null;
         if (MetadataHelper._metadataCache.TryGetValue(thisType, out result))
             return result;
         MetadataHelper.ExecuteOnSTA((state) => { MetadataHelper.InitMetadata((BaseDomainService)state); }, domainService);
         MetadataHelper._metadataCache.TryGetValue(thisType, out result);
         return result;
     };
     System.Threading.LazyInitializer.EnsureInitialized<CachedMetadata>(ref cachedMetadata, factory);
     return cachedMetadata;
 }
Esempio n. 10
0
        public ICodeGenProvider GetCodeGen(BaseDomainService dataService, string lang)
        {
            if (!IsCodeGenEnabled)
            {
                throw new InvalidOperationException(ErrorStrings.ERR_CODEGEN_DISABLED);
            }

            System.Collections.Generic.IEnumerable <ICodeGenProviderFactory <TService> > factories = dataService.ServiceContainer.GetServices <ICodeGenProviderFactory <TService> >();
            ICodeGenProviderFactory <TService> providerFactory = factories.Where(c => c.Lang == lang).FirstOrDefault();

            if (providerFactory == null)
            {
                throw new InvalidOperationException(string.Format(ErrorStrings.ERR_CODEGEN_NOT_IMPLEMENTED, lang));
            }

            return(providerFactory.Create(dataService));
        }
Esempio n. 11
0
        private static RunTimeMetadata _InitMetadata(BaseDomainService domainService,
                                                     DesignTimeMetadata designTimeMetadata,
                                                     IDataHelper dataHelper,
                                                     IValueConverter valueConverter,
                                                     IDataManagerContainer dataManagerContainer)
        {
            RunTimeMetadataBuilder runTimeMetadataBuilder = new RunTimeMetadataBuilder(domainService.GetType(), designTimeMetadata, dataHelper, valueConverter, dataManagerContainer);

            try
            {
                return(runTimeMetadataBuilder.Build());
            }
            catch (Exception ex)
            {
                domainService._OnError(ex);
                throw new DummyException(ex.Message, ex);
            }
        }
Esempio n. 12
0
 private static void InitMetadata(BaseDomainService domainService)
 {
     Type thisType = domainService.GetType();
     CachedMetadata cachedMetadata = null;
     if (MetadataHelper._metadataCache.TryGetValue(thisType, out cachedMetadata))
     {
         return;
     }
     try
     {
         cachedMetadata = CreateCachedMetadata(domainService);
     }
     catch(Exception ex)
     {
         domainService.OnError(ex);
         throw;
     }
     MetadataHelper._metadataCache.TryAdd(thisType, cachedMetadata);
 }
Esempio n. 13
0
        public async Task UpdateAsyncSucceeds()
        {
            // Arrange
            var options    = GetTestDbContextOptions("Update_ScrapeJob_Database");
            var testEntity = GenerateTestEntity();

            using (var context = new WaasDbContext(options))
            {
                await context.AddAsync(testEntity);

                await context.SaveChangesAsync();
            }

            // Act
            bool result;

            using (var context = new WaasDbContext(options))
            {
                var testRepository = new BaseDomainService <ScrapeJob, long>(context);
                await testRepository.UpdateAsync(testEntity.Id, job =>
                {
                    job.Pattern = "updatedPattern";
                    job.Url     = "updatedUrl";
                    job.Enabled = !testEntity.Enabled;
                });

                result = await context.CommitAsync();
            }

            // Assert
            Assert.True(result);
            using (var context = new WaasDbContext(options))
            {
                var updatedEntity = await context.ScrapeJobs.FindAsync(testEntity.Id);

                Assert.NotEqual(testEntity.Pattern, updatedEntity.Pattern);
                Assert.NotEqual(testEntity.Url, updatedEntity.Url);
                Assert.NotEqual(testEntity.Enabled, updatedEntity.Enabled);
            }
        }
Esempio n. 14
0
        public async Task GetAsyncSucceeds()
        {
            // Arrange
            var options = GetTestDbContextOptions("Get_ScrapeJob_Database");

            var testEntity = GenerateTestEntity();

            using (var context = new WaasDbContext(options))
            {
                await context.AddAsync(testEntity);

                await context.SaveChangesAsync();
            }

            // Act
            using (var context = new WaasDbContext(options))
            {
                var testRepository = new BaseDomainService <ScrapeJob, long>(context);
                var result         = await testRepository.GetAsync(testEntity.Id);

                // Assert
                Assert.Equal(testEntity, result);
            }
        }
Esempio n. 15
0
 public BaseCsharpProvider(BaseDomainService owner)
 {
     this._owner = owner;
 }
Esempio n. 16
0
 public static void CheckMethod(BaseDomainService domainService, DbSetInfo dbSetInfo, MethodType methodType)
 {
     Type thisType = domainService.GetType();
     string methodName = dbSetInfo.getOperationMethodName(methodType);
     if (string.IsNullOrWhiteSpace(methodName))
         return;
     MethodInfo minfo = DataHelper.GetMethodInfo(thisType, methodName);
     if (minfo != null)
     {
         switch (methodType)
         {
             case MethodType.Refresh:
                 dbSetInfo._refreshDataMethod = minfo;
                 break;
             case MethodType.Insert:
                 dbSetInfo._insertDataMethod = minfo;
                 break;
             case MethodType.Update:
                 dbSetInfo._updateDataMethod = minfo;
                 break;
             case MethodType.Delete:
                 dbSetInfo._deleteDataMethod = minfo;
                 break;
             case MethodType.Validate:
                 dbSetInfo._validateDataMethod = minfo;
                 break;
             default:
                 throw new DomainServiceException(string.Format("Invalid Method Type {0}", methodType));
         }
     }
     else
     {
         throw new DomainServiceException(string.Format("The DataService: {0} has no method: {2} specified for DbSet: {1} and operation: {3}", thisType.Name, dbSetInfo.dbSetName, methodName, Enum.GetName(typeof(MethodType), methodType)));
     }
 }
Esempio n. 17
0
        private static void CheckDataServiceMethods(BaseDomainService domainService, CachedMetadata metadata)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var dbSet in metadata.dbSets.Values)
            {
                try
                {
                    MetadataHelper.CheckMethod(domainService, dbSet, MethodType.Insert);
                    MetadataHelper.CheckMethod(domainService, dbSet, MethodType.Update);
                    MetadataHelper.CheckMethod(domainService, dbSet, MethodType.Delete);
                    MetadataHelper.CheckMethod(domainService, dbSet, MethodType.Validate);
                    MetadataHelper.CheckMethod(domainService, dbSet, MethodType.Refresh);
                }
                catch (DomainServiceException ex)
                {
                    sb.AppendLine(ex.Message);
                }
            }
           
            if (sb.Length > 0)
                throw new DomainServiceException(sb.ToString());
        }
 public BaseController(BaseDomainService <T> service)
 {
     Service = service;
 }
Esempio n. 19
0
 public XamlProvider(BaseDomainService owner)
 {
     this._owner = owner;
 }
Esempio n. 20
0
 public TypeScriptProvider(BaseDomainService owner, IEnumerable <Type> clientTypes = null)
 {
     this._owner       = owner;
     this._clientTypes = clientTypes ?? Enumerable.Empty <Type>();
 }
Esempio n. 21
0
        private static CachedMetadata CreateCachedMetadata(BaseDomainService domainService)
        {
            Metadata metadata = domainService.GetMetadata(false);
            CachedMetadata cachedMetadata = new CachedMetadata();
            foreach (var dbSetInfo in metadata.DbSets)
            {
                dbSetInfo.Initialize(domainService.ServiceContainer);
                //indexed by dbSetName
                cachedMetadata.dbSets.Add(dbSetInfo.dbSetName, dbSetInfo);
            }

            MetadataHelper.ProcessMethodDescriptions(domainService, cachedMetadata);
            MetadataHelper.CheckDataServiceMethods(domainService, cachedMetadata);

            foreach (var assoc in metadata.Associations)
            {
                if (string.IsNullOrWhiteSpace(assoc.name))
                {
                    throw new DomainServiceException(ErrorStrings.ERR_ASSOC_EMPTY_NAME);
                }
                if (!cachedMetadata.dbSets.ContainsKey(assoc.parentDbSetName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_PARENT, assoc.name, assoc.parentDbSetName));
                }
                if (!cachedMetadata.dbSets.ContainsKey(assoc.childDbSetName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_CHILD, assoc.name, assoc.childDbSetName));
                }
                var childDb = cachedMetadata.dbSets[assoc.childDbSetName];
                var parentDb = cachedMetadata.dbSets[assoc.parentDbSetName];
                var parentDbFields = parentDb.GetFieldByNames();
                var childDbFields = childDb.GetFieldByNames();

                //check navigation field
                //dont allow to define  it explicitly, the association adds the field by itself (implicitly)
                if (!string.IsNullOrEmpty(assoc.childToParentName) && childDbFields.ContainsKey(assoc.childToParentName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name, assoc.childToParentName));
                }

                //check navigation field
                //dont allow to define  it explicitly, the association adds the field by itself (implicitly)
                if (!string.IsNullOrEmpty(assoc.parentToChildrenName) && parentDbFields.ContainsKey(assoc.parentToChildrenName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name, assoc.parentToChildrenName));
                }

                if (!string.IsNullOrEmpty(assoc.parentToChildrenName) && !string.IsNullOrEmpty(assoc.childToParentName) && assoc.childToParentName == assoc.parentToChildrenName)
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name, assoc.parentToChildrenName));
                }

                foreach (var frel in assoc.fieldRels)
                {
                    if (!parentDbFields.ContainsKey(frel.parentField))
                    {
                        throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_PARENT_FIELD, assoc.name, frel.parentField));
                    }
                    if (!childDbFields.ContainsKey(frel.childField))
                    {
                        throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_CHILD_FIELD, assoc.name, frel.childField));
                    }
                }
                //indexed by Name
                cachedMetadata.associations.Add(assoc.name, assoc);

                if (!string.IsNullOrEmpty(assoc.childToParentName))
                {
                    var sb = new System.Text.StringBuilder(120);
                    var dependentOn = assoc.fieldRels.Aggregate(sb, (a, b) => a.Append((a.Length == 0 ? "" : ",") + b.childField), a => a).ToString();
                    //add navigation field to dbSet's field collection
                    childDb.fieldInfos.Add(new Field()
                    {
                        fieldName = assoc.childToParentName,
                        fieldType = FieldType.Navigation,
                        dataType = DataType.None,
                        dependentOn = dependentOn,
                        _TypeScriptDataType = TypeScriptHelper.GetEntityTypeName(parentDb.dbSetName)
                    });
                }

                if (!string.IsNullOrEmpty(assoc.parentToChildrenName))
                {
                    var sb = new System.Text.StringBuilder(120);
                    //add navigation field to dbSet's field collection
                    parentDb.fieldInfos.Add(new Field()
                    {
                        fieldName = assoc.parentToChildrenName,
                        fieldType = FieldType.Navigation,
                        dataType = DataType.None,
                        _TypeScriptDataType = string.Format("{0}[]", TypeScriptHelper.GetEntityTypeName(childDb.dbSetName))
                    });
                }
            } //foreach (var assoc in metadata.Associations)

            return cachedMetadata;
        }
 public Model2Controller(BaseDomainService <Model2> service) : base(service)
 {
 }
Esempio n. 23
0
 public AuthorizationContext(BaseDomainService service, IUserProvider userProvider, IServiceFactory serviceFactory)
 {
     Service        = service;
     _userProvider  = userProvider ?? throw new ArgumentNullException(nameof(userProvider), ErrorStrings.ERR_NO_USER);
     ServiceFactory = serviceFactory ?? throw new ArgumentNullException(nameof(serviceFactory));
 }
Esempio n. 24
0
        private static void InitCachedMetadata(BaseDomainService domainService, CachedMetadata cachedMetadata)
        {
            var metadata = domainService.GetMetadata(false);

            foreach (var dbSetInfo in metadata.DbSets)
            {
                dbSetInfo.Initialize(domainService.ServiceContainer);
                //indexed by dbSetName
                cachedMetadata.dbSets.Add(dbSetInfo.dbSetName, dbSetInfo);
            }
            //bootstrapping
            domainService.Bootstrap(new ServiceConfig(cachedMetadata));

            ProcessMethodDescriptions(domainService.ServiceContainer, domainService.GetType(), cachedMetadata);

            foreach (var assoc in metadata.Associations)
            {
                if (string.IsNullOrWhiteSpace(assoc.name))
                {
                    throw new DomainServiceException(ErrorStrings.ERR_ASSOC_EMPTY_NAME);
                }
                if (!cachedMetadata.dbSets.ContainsKey(assoc.parentDbSetName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_PARENT, assoc.name,
                                                                   assoc.parentDbSetName));
                }
                if (!cachedMetadata.dbSets.ContainsKey(assoc.childDbSetName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_CHILD, assoc.name,
                                                                   assoc.childDbSetName));
                }
                var childDb        = cachedMetadata.dbSets[assoc.childDbSetName];
                var parentDb       = cachedMetadata.dbSets[assoc.parentDbSetName];
                var parentDbFields = parentDb.GetFieldByNames();
                var childDbFields  = childDb.GetFieldByNames();

                //check navigation field
                //dont allow to define  it explicitly, the association adds the field by itself (implicitly)
                if (!string.IsNullOrEmpty(assoc.childToParentName) && childDbFields.ContainsKey(assoc.childToParentName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name,
                                                                   assoc.childToParentName));
                }

                //check navigation field
                //dont allow to define  it explicitly, the association adds the field by itself (implicitly)
                if (!string.IsNullOrEmpty(assoc.parentToChildrenName) &&
                    parentDbFields.ContainsKey(assoc.parentToChildrenName))
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name,
                                                                   assoc.parentToChildrenName));
                }

                if (!string.IsNullOrEmpty(assoc.parentToChildrenName) && !string.IsNullOrEmpty(assoc.childToParentName) &&
                    assoc.childToParentName == assoc.parentToChildrenName)
                {
                    throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_NAV_FIELD, assoc.name,
                                                                   assoc.parentToChildrenName));
                }

                foreach (var frel in assoc.fieldRels)
                {
                    if (!parentDbFields.ContainsKey(frel.parentField))
                    {
                        throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_PARENT_FIELD,
                                                                       assoc.name, frel.parentField));
                    }
                    if (!childDbFields.ContainsKey(frel.childField))
                    {
                        throw new DomainServiceException(string.Format(ErrorStrings.ERR_ASSOC_INVALID_CHILD_FIELD,
                                                                       assoc.name, frel.childField));
                    }
                }
                //indexed by Name
                cachedMetadata.associations.Add(assoc.name, assoc);

                if (!string.IsNullOrEmpty(assoc.childToParentName))
                {
                    var sb          = new StringBuilder(120);
                    var dependentOn =
                        assoc.fieldRels.Aggregate(sb, (a, b) => a.Append((a.Length == 0 ? "" : ",") + b.childField),
                                                  a => a).ToString();
                    //add navigation field to dbSet's field collection
                    childDb.fieldInfos.Add(new Field
                    {
                        fieldName           = assoc.childToParentName,
                        fieldType           = FieldType.Navigation,
                        dataType            = DataType.None,
                        dependentOn         = dependentOn,
                        _TypeScriptDataType = TypeScriptHelper.GetEntityInterfaceName(parentDb.dbSetName)
                    });
                }

                if (!string.IsNullOrEmpty(assoc.parentToChildrenName))
                {
                    var sb = new StringBuilder(120);
                    //add navigation field to dbSet's field collection
                    parentDb.fieldInfos.Add(new Field
                    {
                        fieldName           = assoc.parentToChildrenName,
                        fieldType           = FieldType.Navigation,
                        dataType            = DataType.None,
                        _TypeScriptDataType = string.Format("{0}[]", TypeScriptHelper.GetEntityInterfaceName(childDb.dbSetName))
                    });
                }
            } //foreach (var assoc in metadata.Associations)
        }
Esempio n. 25
0
        /// <summary>
        /// Test if public methods on the service has Invoke or Query Attribute
        /// and generates from this methods their invocation method descriptions 
        /// </summary>
        /// <returns></returns>
        private static void ProcessMethodDescriptions(BaseDomainService domainService, CachedMetadata metadata)
        {
            Type thisType= domainService.GetType();
            IServiceContainer services = domainService.ServiceContainer;
            Func<MethodInfo, MethodType> fn_getMethodType = (m) =>
            {
                if (m.IsDefined(typeof(QueryAttribute), false))
                    return MethodType.Query;
                else if (m.IsDefined(typeof(InvokeAttribute), false))
                    return MethodType.Invoke;
                else if (m.IsDefined(typeof(InsertAttribute), false))
                    return MethodType.Insert;
                else if (m.IsDefined(typeof(UpdateAttribute), false))
                    return MethodType.Update;
                else if (m.IsDefined(typeof(DeleteAttribute), false))
                    return MethodType.Delete;
                else if (m.IsDefined(typeof(ValidateAttribute), false))
                    return MethodType.Validate;
                else if (m.IsDefined(typeof(RefreshAttribute), false))
                    return MethodType.Refresh;
                else
                    return MethodType.None;
            };
            var dbsetsLookUp = metadata.dbSets.Values.ToLookup(v => v.EntityType);
            var dbsetsByType = dbsetsLookUp.ToDictionary(v => v.Key);
            var methodInfos = thisType.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
            var allList = methodInfos.Select(m => new { method = m, methodType = fn_getMethodType(m) });
            var queryAndInvokes = allList.Where((info) => info.methodType == MethodType.Query || info.methodType == MethodType.Invoke).ToArray();
            MethodsList methodList = new MethodsList();
            Array.ForEach(queryAndInvokes, (info) =>
            {
                methodList.Add(MethodDescription.FromMethodInfo(info.method, info.methodType, services));
            });
            metadata.InitMethods(methodList);

            var otherMethods = allList.Where((info) => !(info.methodType == MethodType.Query || info.methodType == MethodType.Invoke || info.methodType == MethodType.None)).ToArray();

            Array.ForEach(otherMethods, (info) =>
            {
                Type entityType = null;
                if (info.methodType == MethodType.Refresh)
                {
                    entityType = RemoveTaskFromType(info.method.ReturnType);
                }
                else
                {
                    entityType = info.method.GetParameters().First().ParameterType;
                }

                IGrouping<Type, DbSetInfo> dbSets = null;
                if (!dbsetsByType.TryGetValue(entityType, out dbSets))
                    return;

                foreach (var dbSet in dbSets)
                {
                    switch (info.methodType)
                    {
                        case MethodType.Insert:
                            dbSet.insertDataMethod = info.method.Name;
                            break;
                        case MethodType.Update:
                            dbSet.updateDataMethod = info.method.Name;
                            break;
                        case MethodType.Delete:
                            dbSet.deleteDataMethod = info.method.Name;
                            break;
                        case MethodType.Validate:
                            dbSet.validateDataMethod = info.method.Name;
                            break;
                        case MethodType.Refresh:
                            dbSet.refreshDataMethod = info.method.Name;
                            break;
                        default:
                            throw new DomainServiceException(string.Format("Unknown Method Type: {0}", info.methodType));
                    }
                }
            });

        }
Esempio n. 26
0
 public SubResultsGenerator(BaseDomainService domainService)
 {
     this._domainService = domainService;
     this._dataHelper = this._domainService.ServiceContainer.DataHelper;
 }
Esempio n. 27
0
 public ICodeGenProvider Create(BaseDomainService owner)
 {
     return(this.Create((TService)owner));
 }