コード例 #1
0
        public bool IsPartDiscoverable()
        {
            // The part should not be marked with the "NonDiscoverable"
            if (_type.IsAttributeDefined <PartNotDiscoverableAttribute>())
            {
                CompositionTrace.DefinitionMarkedWithPartNotDiscoverableAttribute(_type);
                return(false);
            }

            // The part should have exports
            if (!HasExports())
            {
                CompositionTrace.DefinitionContainsNoExports(_type);
                return(false);
            }

            // If the part is generic, all exports should have the same number of generic parameters
            // (otherwise we have no way to specialize the part based on an export)
            if (!AllExportsHaveMatchingArity())
            {
                // The function has already reported all violations via tracing
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public bool IsPartDiscoverable()
        {
            if (this._type.IsAttributeDefined <PartNotDiscoverableAttribute>())
            {
                CompositionTrace.DefinitionMarkedWithPartNotDiscoverableAttribute(this._type);
                return(false);
            }

            if (!HasExports())
            {
                CompositionTrace.DefinitionContainsNoExports(this._type);
                return(false);
            }

            return(true);
        }