CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: VB.NET

CompositionInitializer sample code illustrating design changes

468 Views
Copy Code Show/Hide Line Numbers
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
 
by Glenn Block
  December 16, 2009 @ 10:41pm

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate