Ejemplo n.º 1
0
        private static void DisplayDebugWarnings(ImportCardinality cardinality, ReflectionItem item, ImportType importType)
        {
            if ((importType.ElementType == ExportType) || (importType.Type == ExportType))
            {
                System.Diagnostics.Debug.WriteLine(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} : Imports of type Export are no longer supported", item.GetDisplayName()));
            }

            // Output a debug warning if someone is using ImportAttribute where it looks like they might want to use ImportMany
            if (cardinality != ImportCardinality.ZeroOrMore && CollectionServices.GetEnumerableElementType(importType.Type) != null)
            {
                System.Diagnostics.Debug.WriteLine("May want to use ImportMany on " + item.GetDisplayName());
            }
        }
Ejemplo n.º 2
0
        private static IAttributedImport GetAttributedImport(ReflectionItem item, ICustomAttributeProvider attributeProvider)
        {
            IAttributedImport[] imports = attributeProvider.GetAttributes<IAttributedImport>(false);

            // For constructor parameters they may not have an ImportAttribute
            if (imports.Length == 0)
            {
                return new ImportAttribute();
            }

            if (imports.Length == 1)
            {
                return imports[0];
            }

            // DiscoveryError (Dev10:602872): This should go through the discovery error reporting when
            // we add a way to report discovery errors properly.
            throw ExceptionBuilder.CreateDiscoveryException(Strings.Discovery_MultipleImportAttributes, item.GetDisplayName());
        }
        internal static void MemberMarkedWithMultipleImportAndImportMany(ReflectionItem item)
        {
            Assumes.NotNull(item);

            if (CompositionTraceSource.CanWriteError)
            {
                CompositionTraceSource.WriteError(CompositionTraceId.Discovery_MemberMarkedWithMultipleImportAndImportMany,
                                                  Strings.CompositionTrace_Discovery_MemberMarkedWithMultipleImportAndImportMany,
                                                  item.GetDisplayName());
            }
        }