Exemple #1
0
        /// <summary>
        /// Finds the first resolver that knows about <param name="moduleReference"/>, asserts it is the only module
        /// descriptor with that name and returns the corresponding module definition.
        /// </summary>
        internal async Task <Possible <ModuleDefinition> > FindUniqueModuleDefinitionWithName(ModuleReferenceWithProvenance moduleReference)
        {
            // Find a resolver that claims ownership of this module name
            var maybeResolver = await FindResolverAsync(moduleReference);

            if (!maybeResolver.Succeeded)
            {
                return(maybeResolver.Failure);
            }

            var resolver = maybeResolver.Result;

            // Get the set of module descriptors from the module name. There must be only one.
            var maybeDescriptors = await resolver.TryGetModuleDescriptorsAsync(moduleReference);

            if (!maybeDescriptors.Succeeded)
            {
                return(maybeDescriptors.Failure);
            }

            var descriptors = maybeDescriptors.Result;

            Contract.Assert(descriptors.Count == 1);

            // Get the module definition from the resolver and enqueue it
            return(await resolver.TryGetModuleDefinitionAsync(descriptors.First()));
        }