Ejemplo n.º 1
0
 private Type CheckForCollection(Type type)
 {
     ElementType = CollectionServices.GetEnumerableElementType(type);
     if (ElementType != null)
     {
         return(ElementType);
     }
     return(type);
 }
        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.º 3
0
        public ImportType(Type type, ImportCardinality cardinality)
        {
            Assumes.NotNull(type);

            this._type = type;
            this._isAssignableCollectionType = IsTypeAssignableCollectionType(type);

            if (cardinality == ImportCardinality.ZeroOrMore)
            {
                this._elementType = CollectionServices.GetEnumerableElementType(type);
            }

            this._lazyType = CreateLazyType(this._elementType ?? this._type);
        }