Language: VB.NET
CompositionInitializer sample code illustrating design changes
Imports System.ComponentModel.Composition Imports System.ComponentModel.Composition.Hosting Imports System.ComponentModel.Composition.Deployment Namespace DeploymentCatalogDesignVB Namespace Setting_up_the_host_to_download_catalogs Public Class App Inherits Application Public Sub Initialize() Dim catalog1 = New DeploymentCatalog("Xap1.xap") Dim catalog2 = New DeploymentCatalog("Xap2.xap") CompositionHost.Initialize(catalog1, catalog2) End Sub End Class End Namespace Namespace Setting_up_the_host_to_download_catalogs_and_track_progress Public Class App Inherits Application Public Sub Initialize() Dim catalog1 = New DeploymentCatalog(New Uri("Xap1.xap", UriKind.Relative), AddressOf DownloadProgress) Dim catalog2 = New DeploymentCatalog(New Uri("Xap2.xap", UriKind.Relative), AddressOf DownloadProgress) End Sub Private Sub DownloadProgress(ByVal Progress As CatalogDownloadProgress) ShowProgress(Progress.Uri, Progress.DownloadedBytes, Progress.TotalBytes) End Sub Private Sub ShowProgress(ByVal Uri As String, ByVal DownloadBytes As Long, ByVal TotalBytes As Long) End Sub End Class End Namespace Namespace Setting_up_the_host_to_allow_parts_to_download_catalogs Public Class App Inherits Application Public Sub Initialize() Dim catalog As New AggregateCatalog() Dim container = CompositionHost.Initialize(catalog) container.ComposeExportedValue(New DeploymentCatalogService(catalog)) End Sub End Class <Export()> _ Public Class ModuleManager <Import()> _ Public Property CatalogService As DeploymentCatalogService <ImportMany(AllowRecomposition:=True)> _ Public Property Modules As IModule() Public Sub New() CatalogService.Add(New DeploymentCatalog("Module1.xap")) End Sub End Class Public Class DeploymentCatalogService Public Sub New(ByVal Catalog As AggregateCatalog) End Sub Public Sub Add(ByVal ParamArray Catalog As DeploymentCatalog()) End Sub End Class Public Interface IModule End Interface End Namespace Namespace Setting_up_a_host_part_to_download_catalogs Public Class ExtensibleGrid Public Sub Initialize() Dim catalog = New AggregateCatalog() catalog.Catalogs.Add(New DeploymentCatalog()) catalog.Catalogs.Add(New DeploymentCatalog("CoreGridCapabilities.xap")) catalog.Catalogs.Add(New DeploymentCatalog("CoreGridExtensions.xap")) Dim container = New CompositionContainer(catalog) container.ComposeParts(Me) End Sub Public Property Extensions As IGridExtension() Public Property Capabilities As ICapability() End Class Public Interface IGridExtension End Interface Public Interface ICapability End Interface End Namespace Public Class Application End Class End Namespace
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

