Пример #1
0
        /// <summary>
        /// The locations this name can be imported from.  The names are fully qualified with
        /// the module/package names and the name its self.  For example for "fob" defined in the "oar"
        ///  module the name here is oar.fob.  This list is lazily calculated (including loading of cached intellisense data)
        ///  so that you can break from the enumeration early and save significant work.
        /// </summary>
        /// <remarks>New in 2.2</remarks>
        public async Task <IEnumerable <ExportedMemberInfo> > GetAvailableImportsAsync(CancellationToken cancellationToken)
        {
            if (_imports != null)
            {
                return(_imports);
            }
            var imports = await Task.Run(() => {
                var r = new List <ExportedMemberInfo>();
                foreach (var i in _state.FindNameInAllModules(_name))
                {
                    r.Add(i);
                    cancellationToken.ThrowIfCancellationRequested();
                }
                return(r);
            });

            cancellationToken.ThrowIfCancellationRequested();
            return(Interlocked.CompareExchange(ref _imports, imports, null) ?? imports);
        }