Exemplo n.º 1
0
        public IEnumerable <ImportDefinition> GetImports()
        {
            if (_imports == null)
            {
                yield break;
            }

            IEnumerable <ImportDefinition> imports = _imports.Value;

            if (imports == null)
            {
                yield break;
            }

            foreach (ImportDefinition import in imports)
            {
                ReflectionImportDefinition?reflectionImport = import as ReflectionImportDefinition;
                if (reflectionImport == null)
                {
                    throw new InvalidOperationException(
                              SR.Format(SR.ReflectionModel_InvalidMemberImportDefinition, import.GetType()));
                }
                yield return(reflectionImport);
            }
        }
Exemplo n.º 2
0
        public static bool IsImportingParameter(ImportDefinition importDefinition)
        {
            Requires.NotNull(importDefinition, nameof(importDefinition));

            ReflectionImportDefinition?reflectionImportDefinition = importDefinition as ReflectionImportDefinition;

            if (reflectionImportDefinition == null)
            {
                throw new ArgumentException(
                          SR.Format(SR.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()),
                          nameof(importDefinition));
            }

            return(importDefinition is ReflectionParameterImportDefinition);
        }
        private List <ImportDefinition> PopulateImports(List <LazyMemberInfo> members, List <Lazy <ParameterInfo> > parameters)
        {
            List <ImportDefinition> imports = new List <ImportDefinition>();

            foreach (ImportDefinition originalImport in _originalPartCreationInfo.GetImports())
            {
                ReflectionImportDefinition?reflectionImport = originalImport as ReflectionImportDefinition;
                if (reflectionImport == null)
                {
                    // we always ignore these
                    continue;
                }

                imports.Add(TranslateImport(reflectionImport, members, parameters));
            }

            return(imports);
        }