/// <summary> /// Constructs a new instance of the class, based on /// the specified plug-in component prototype. /// </summary> /// <param name="template"></param> public AfxComponent(AfxComponentTemplate template) { // Assign a unique identifier to the component // instance, for use in keeping track of connections // betweeen individual components, and when the workflow // needs to serializer a workflow out to a file, whatever: this.Id = System.Guid.NewGuid(); // Retrieve the plug-in component's title from the // prototype information: this.Title = template.Name; // Maintain a reference to the plug-in component's // original prototype for use by the system later on: this.Template = template; // Retrieve the fully-qualified type name from the // plug-in component's prototype: var typeName = template.Type.FullName; // Instantiate a new instance of the corresponding // plug-in implementation type and maintain a local // reference to it for later use: this.Instance = CreateInstance(template); }
private BitmapImage GetComponentBitmap(AfxComponentTemplate template, IAfxComponentCatalog catalog) { var resolver = catalog.GetComponentResolver(template.Resolver); if (resolver != null) { return resolver.GetProperty(template.Id, "Component.Bitmap") as BitmapImage; } return null; }
private IAfxComponent CreateInstance(AfxComponentTemplate template) { return template.Assembly.CreateInstance(template.Type.FullName) as IAfxComponent; }