void LoadFacetFactory(TypeDescriptor factoryType, AssemblyDescriber describer) { if (factoryType.IsAbstract || !factoryType.HasPublicParameterlessConstructor) { return; } var attr = describer.GetClassAttributes(factoryType).OfType <FacetFactoryAttribute>().FirstOrDefault(); var factory = CreateLoaderInstance <IFacetFactory>(factoryType); var info = new LoaderFacetFactory(this, factory, factoryType, attr); ExtensionStore.InitFacetFactory(info); factory.Initialize(Hooks); AddItem(info); }
void LoadFacetType(TypeDescriptor type, AssemblyDescriber describer) { if (!type.IsInterface && !type.IsAbstract) { if (!type.GetImplementedTypes(true).Any(x => x.IsInterface && x.Implements(typeof(IFacet)))) { throw new LoaderItemInitException("None of the interfaces implemented by facet class implements IFacet"); } } LoaderAmbientFacet ambientInfo = null; if (!type.IsInterface) { var ambientAttr = describer.GetClassAttributes(type).OfType <AmbientFacetAttribute>().FirstOrDefault(); if (ambientAttr != null) { if (!type.HasPublicParameterlessConstructor || type.IsAbstract) { throw new LoaderItemInitException("No public parameterless constructor for ambient facet type"); } var facet = CreateLoaderInstance <IFacet>(type); facet.Initialize(Hooks); ambientInfo = new LoaderAmbientFacet(this, ambientAttr.Token, facet, new FacetMoniker(ambientAttr.Token, type, facet.DisplayName)); } } var info = new LoaderFacetType(this, type); ExtensionStore.InitFacetType(info); AddItem(info); if (ambientInfo != null) { AddItem(ambientInfo); } }