// apply some rules to extension point. protected bool ApplyRules(IMessageDialog dialog, ResolutionContext ctx, out TypeResolution extensionType) { var result = true; if (!Type.IsClass || Type.IsAbstract) { dialog.AddError(string.Format("The specified extension point type [{0}] is not a concrete class!", Type.TypeName)); result = false; } //if (!this.DeclaresInSameAddin()) //{ // dialog.AddError(string.Format("The extension point type [{0}] is expected to be defined and declared in a same addin, while its defining addin is [{1}], and its declaring addin is [{2}], which is not the same as the former!", Type.TypeName, Type.Assembly.DeclaringAddin.AddinId.Guid, DeclaringAddin.AddinId.Guid)); // result = false; //} if (!this.InheritFromExtensionPointInterface(dialog, ctx, out extensionType)) { dialog.AddError(string.Format("The specified extension point type [{0}] does not implement the required interface (IExtensionPoint<TExtension, TRoot>)!", Type.TypeName)); result = false; } if (!this.HasPublicParameterLessConstructor()) { dialog.AddError(string.Format("The specified extension point type [{0}] do not have a public parameter-less constructor!", Type.TypeName)); result = false; } return(result); }
// @returns ResolutionStatus.Success when the type is: // 1. provided by the runtime (gac), and therefore no need to resolve (it is always there). // 2. defined in the same addin as the current asset (extension or extension point/builder), therefore it's self-sufficient and no need to resolve. // 3. defined in an addin that has been resolved. protected ResolutionStatus ResolveType(TypeResolution type) { var addin = type.Assembly.DeclaringAddin; return((addin == null || // the type is provided by runtime ReferenceEquals(addin, _declaringAddin)) // the type is defined in the same addin as the current asset ? ResolutionStatus.Success : addin.ResolutionStatus); // the type is defined in an addin that has been resolved }
// todo: extensionType:将会由 IExtensionBuilder<TExtension> 的实现类所在的程序集去引用 ExtensionType 所在的程序集,最后的结果会添加到 ReferencedAssemblies,此处不必解析 // apply some rules. bool ApplyRules(ResolutionResult resolutionResult, ResolutionContext ctx, out TypeResolution extensionType) { var result = true; if (!Type.IsClass || Type.IsAbstract) { resolutionResult.AddError(string.Format("The specified extension builder type [{0}] is not a concrete class!", Type.TypeName)); result = false; } //// Like extension point, An extension builder can be declared in an addin (extension schema), yet defined in another addin, thus we don't need the following check. //if (!this.DeclaresInSameAddin()) //{ // resolutionResult.AddError(string.Format("The extension builder type [{0}] is expected to be defined and declared in a same addin, while its defining addin is [{1}], and its declaring addin is [{2}], which is not the same as the former!", Type.TypeName, Type.Assembly.DeclaringAddin.AddinId.Guid, DeclaringAddin.AddinId.Guid)); // result = false; //} if (Children != null) { if (!this.InheritFromCompositeExtensionBuilderInterface(resolutionResult, ctx, out extensionType)) { resolutionResult.AddError(string.Format("The specified extension builder type [{0}] does not implement the required interface (ICompositeExtensionBuilder<TExtension>)!", Type.TypeName)); result = false; } } else { if (!this.InheritFromExtensionBuilderInterface(resolutionResult, ctx, out extensionType)) { resolutionResult.AddError(string.Format("The specified extension builder type [{0}] does not implement the required interface (IExtensionBuilder<TExtension>)!", Type.TypeName)); result = false; } } if (!this.Type.HasPublicParameterLessConstructor()) { resolutionResult.AddError(string.Format("The specified builder point type [{0}] do not have a public parameter-less constructor!", Type.TypeName)); result = false; } if (!this.ExtensionTypeMatchesParent(resolutionResult, extensionType)) { result = false; } return(result); }
internal ConstructorResolution(TypeResolution declaringType, MethodDefinition ctor) { _declaringType = declaringType; _ctor = ctor; }