public async Task <ContextProcessingResult> GetModelMetadata(ModelType modelType)
        {
            if (modelType == null)
            {
                throw new ArgumentNullException(nameof(modelType));
            }

            var projectCompilation = await _workspace.CurrentSolution.Projects
                                     .First(project => project.AssemblyName == _projectContext.AssemblyName)
                                     .GetCompilationAsync();

            var reflectedTypesProvider = new ReflectedTypesProvider(
                projectCompilation,
                (c) => c,
                _projectContext,
                _loader,
                _logger);
            var modelReflectionType = reflectedTypesProvider.GetReflectedType(
                modelType: modelType.FullName,
                lookInDependencies: true);

            if (modelReflectionType == null)
            {
                throw new InvalidOperationException(string.Format(MessageStrings.ModelTypeNotFound, modelType.Name));
            }

            var modelMetadata = new CodeModelMetadata(modelReflectionType);

            return(new ContextProcessingResult()
            {
                ContextProcessingStatus = ContextProcessingStatus.ContextAvailable,
                ModelMetadata = modelMetadata
            });
        }
Beispiel #2
0
        public Task <ContextProcessingResult> GetModelMetadata(ModelType modelType)
        {
            Type modelReflectionType;

            CompileAndGetModelType(
                modelType.FullName,
                (c) => c,
                out modelReflectionType);
            var modelMetadata = new CodeModelMetadata(modelReflectionType);

            return(Task.FromResult(new ContextProcessingResult()
            {
                ContextProcessingStatus = ContextProcessingStatus.ContextAvailable,
                ModelMetadata = modelMetadata
            }));
        }