public IEnumerable <ConceptInfoRestMetadata> GetConceptInfoRestMetadata(RhetosHost rhetosHost) { var dslModel = rhetosHost.GetRootContainer().Resolve <IDslModel>(); var domainObjectModel = rhetosHost.GetRootContainer().Resolve <IDomainObjectModel>(); var dataStructureReadParameters = rhetosHost.GetRootContainer().Resolve <IDataStructureReadParameters>(); DataStructureInfoMetadata CreateFromGenericController(Type genericControllerType, DataStructureInfo dataStructureInfo) { var parameters = dataStructureReadParameters.GetReadParameters(dataStructureInfo.FullName, true) .Select(parameter => Tuple.Create(parameter.Name, parameter.Type)) .ToArray(); var dataStructureInfoMetadata = new DataStructureInfoMetadata(parameters) { ControllerType = genericControllerType.MakeGenericType(domainObjectModel.GetType($"{dataStructureInfo.FullName}")), ControllerName = $"{dataStructureInfo.Module.Name}.{dataStructureInfo.Name}", RelativeRoute = $"{dataStructureInfo.Module.Name}/{dataStructureInfo.Name}", ApiExplorerGroupName = dataStructureInfo.Module.Name, }; return(dataStructureInfoMetadata); } var dataStructuresByWriteInfo = dslModel .FindByType <WriteInfo>() .Select(writeInfo => writeInfo.DataStructure) .Distinct() .ToHashSet(); Type DataStructureControllerType(DataStructureInfo dataStructureInfo) { if (dataStructureInfo is IWritableOrmDataStructure || dataStructuresByWriteInfo.Contains(dataStructureInfo)) { return(typeof(ReadWriteDataApiController <>)); } else if (IsDataStructureTypeSupported(dataStructureInfo)) { return(typeof(ReadDataApiController <>)); } return(null); } var restMetadata = dslModel .FindByType <DataStructureInfo>() .Select(dataStructureInfo => (dataStructureInfo, controllerType: DataStructureControllerType(dataStructureInfo))) .Where(implementation => implementation.controllerType != null) .Select(implementation => CreateFromGenericController(implementation.controllerType, implementation.dataStructureInfo)); return(restMetadata); }
public IEnumerable <ConceptInfoRestMetadata> GetConceptInfoRestMetadata(RhetosHost rhetosHost) { var dslModel = rhetosHost.GetRootContainer().Resolve <IDslModel>(); var domainObjectModel = rhetosHost.GetRootContainer().Resolve <IDomainObjectModel>(); var restMetadata = dslModel .FindByType <ReportDataInfo>() .Select(reportDataInfo => new ConceptInfoRestMetadata() { ControllerType = typeof(ReportApiController <>).MakeGenericType(domainObjectModel.GetType($"{reportDataInfo.FullName}")), ControllerName = $"{reportDataInfo.Module.Name}.{reportDataInfo.Name}", RelativeRoute = $"{reportDataInfo.Module.Name}/{reportDataInfo.Name}", ApiExplorerGroupName = reportDataInfo.Module.Name }); return(restMetadata); }
public IEnumerable <ConceptInfoRestMetadata> GetConceptInfoRestMetadata(RhetosHost rhetosHost) { var dslModel = rhetosHost.GetRootContainer().Resolve <IDslModel>(); var domainObjectModel = rhetosHost.GetRootContainer().Resolve <IDomainObjectModel>(); var restMetadata = dslModel .FindByType <DataStructureInfo>() .Where(dataStructureInfo => dataStructureInfo.Module.Name == "AspNetDemo") .Select(dataStructureInfo => new ConceptInfoRestMetadata() { ControllerType = typeof(RhetosExtendedController <>).MakeGenericType(domainObjectModel.GetType($"{dataStructureInfo.FullName}")), ControllerName = $"{dataStructureInfo.Module.Name}.{dataStructureInfo.Name}", RelativeRoute = $"{dataStructureInfo.Module.Name}/{dataStructureInfo.Name}", ApiExplorerGroupName = dataStructureInfo.Module.Name, }); return(restMetadata); }