Under the Hood on Under the Hood on Extending the My Extending the My NamespaceNamespace
Joe BinderJoe BinderTLN414TLN414Program ManagerProgram ManagerMicrosoft CorporationMicrosoft Corporation
AgendaAgenda
Design goalsDesign goals
My and the .NET FrameworkMy and the .NET Framework
Extensibility ModelExtensibility Model
Customizing My, Step-by-StepCustomizing My, Step-by-Step
Deploying My Extensions and Deploying My Extensions and CustomizationsCustomizations
QuestionsQuestions
The My Namespace VisionThe My Namespace Vision
… … To provide a highly To provide a highly approachable, unified runtime approachable, unified runtime environment for Visual Basic environment for Visual Basic developers. developers.
Design PillarsDesign PillarsTask-based APIsTask-based APIs
Default configurations for extensible Default configurations for extensible componentscomponents
Promote best-practice usage patternsPromote best-practice usage patterns
Use .NET Framework constructs Use .NET Framework constructs directlydirectly
Example Interaction ModelExample Interaction ModelMy.Application.LogMy.Application.Log
.NET Framework 2.0 contains powerful .NET Framework 2.0 contains powerful and extensible tracing architectureand extensible tracing architecture
Highly factored designHighly factored design
Enterprise scenarios require extension to Enterprise scenarios require extension to existing servicesexisting services
Configuration is hard!Configuration is hard!
My.Application.Log provides a simple My.Application.Log provides a simple entry point and default configurationentry point and default configuration
Inside The My NamespaceInside The My NamespaceExtensibility PointsExtensibility Points
My
Application
Computer
User
Resources
Settings
WebServices
Forms
— Customize application model, events, …
— Add device support, hardware events, …
— Custom authorization and authentication
— Use external store (e.g., settings) for settings
Devices — Add new top-level properties
Inside The My NamespaceInside The My NamespaceArchitectural OverviewArchitectural Overview
WindowsApplication1WindowsApplication1Namespace MyNamespace My
ReadOnly Property Application As MyApplicationReadOnly Property Application As MyApplication
......
Class MyApplication Class MyApplication
Inherits ApplicationServices.ApplicationBaseInherits ApplicationServices.ApplicationBase
End ClassEnd Class
End NamespaceEnd Namespace
Microsoft.VisualBasic.dllMicrosoft.VisualBasic.dllNamespace ApplicationServicesNamespace ApplicationServices
Public Class ApplicationBasePublic Class ApplicationBase
ReadOnly Property Log As LogReadOnly Property Log As Log
… …
End ClassEnd Class
End NamespaceEnd Namespace
Extending My at the Root-Extending My at the Root-LevelLevel
Adding My.Devices to the HierarchyAdding My.Devices to the Hierarchy
Application ModelApplication ModelArchitectural OverviewArchitectural OverviewShared Sub Main(ByVal Args As String()) Shared Sub Main(ByVal Args As String())
My.Application.Run(Args) My.Application.Run(Args) End Sub End Sub
Namespace MyNamespace My Partial Friend Class MyApplicationPartial Friend Class MyApplication Inherits WindowsFormsApplicationBaseInherits WindowsFormsApplicationBase End ClassEnd ClassEnd NamespaceEnd Namespace
Namespace Namespace MMicrosoft.VisualBasic.ApplicationServicesicrosoft.VisualBasic.ApplicationServices Class Class WindowsFormsApplicationBaseWindowsFormsApplicationBase Inherits Inherits ConsoleConsoleApplicationBaseApplicationBase End ClassEnd ClassEnd NamespaceEnd Namespace
StartupStartup
NetStatusChangedNetStatusChanged
……
My.Settings My.Settings Architectural OverviewArchitectural Overview
SettingsBaseSettingsBase
ApplicationSettingsBaseApplicationSettingsBase
My.SettingsMy.SettingsProperty FavoriteColor As ColorProperty FavoriteColor As ColorProperty LastLoggedIn As DateProperty LastLoggedIn As Date……
SettingsProviderSettingsProvider
LocalFileSettingsProviderLocalFileSettingsProvider<userSettings><userSettings> <WindowsApplication1.My.MySettings><WindowsApplication1.My.MySettings> <setting name="FavoriteColor"><setting name="FavoriteColor"> <value>0, 192, 0</value><value>0, 192, 0</value> </setting></setting> </WindowsApplication1.My.MySettings></WindowsApplication1.My.MySettings></userSettings></userSettings>
Customizing My.UserCustomizing My.User
Thin wrapper atop IPrincipal/IIdentityThin wrapper atop IPrincipal/IIdentity
WindowsPrincipal used as defaultWindowsPrincipal used as default
Custom Authentication and Custom Authentication and Authorization are wired in through Authorization are wired in through IPrincipal/IIdentityIPrincipal/IIdentity
My.UserMy.User
IPrincipalIPrincipal
IIdentityIIdentity
WindowsPrincipalWindowsPrincipal
WindowsIdentityWindowsIdentity
Customizing My.UserCustomizing My.User
Leveraging ASP.NET Personalization Leveraging ASP.NET Personalization in Windows Formsin Windows Forms
Extending the My Extending the My NamespaceNamespaceDesign GuidelinesDesign GuidelinesStateless APIs when appropriateStateless APIs when appropriate
Global Instances.Global Instances.
Simple Parameter TypesSimple Parameter Types
Factory MethodsFactory Methods
Thread-safeThread-safe
.NET Framework Guidelines still .NET Framework Guidelines still apply!apply!
Extending the My Extending the My NamespaceNamespaceDeploymentDeploymentClass libraries factored into Class libraries factored into
standalone assembliesstandalone assemblies
Extensibility code factored into Visual Extensibility code factored into Visual Studio TemplateStudio Template
All components packaged and All components packaged and deployed as .VSIdeployed as .VSI
CustomTypes.dllCustomTypes.dll
MyAppExtension.vbMyAppExtension.vb
.vstemplate.vstemplate .vsi.vsi
Where to go from here?Where to go from here?
Attend HOL TLN023!Attend HOL TLN023!
Stop by Tools & Language Track Stop by Tools & Language Track Lounge!Lounge!
Additional resources:Additional resources:http://msdn.microsoft.com/msdnmag/isshttp://msdn.microsoft.com/msdnmag/issues/05/07/My/default.aspxues/05/07/My/default.aspx
http://msdn.microsoft.com/vbasic/defaulthttp://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/vb.aspx?pull=/library/en-us/dnvs05/html/vbmy.aspmy.asp
Two ways to access Online Evaluation Forms:Two ways to access Online Evaluation Forms:
1.1. CommNet stations located throughout conference CommNet stations located throughout conference venuesvenues
2.2. From any wired or wireless connection to: From any wired or wireless connection to: http://www.MyTechReady.comhttp://www.MyTechReady.com
For more information please refer to your Pocket For more information please refer to your Pocket Guide Guide
Please Complete An Evaluation Please Complete An Evaluation FormFormYour Input Is Important!Your Input Is Important!