<#@ template debug="false" hostspecific="false" language="C#" #> <#@ import namespace="System.Collections.Generic"#> <#@ output extension=".cs" #> <# var singleList = new List { "MainContent", "LeftMainContent", "NoUserContent" }; var controlList = new List { "GrowlDemoCtl", "LoadingDemoCtl", "ImageBrowserDemoCtl", "ColorPickerDemoCtl", "CarouselDemoCtl", "CompareSliderDemoCtl", "TimeBarDemoCtl", "PaginationDemoCtl", "AnimationPathDemoCtl" }; var styleList = new List { "ButtonDemoCtl", "ToggleButtonDemoCtl", "ExpanderDemoCtl", "ProgressBarDemoCtl", "TabControlDemoCtl" }; #> using System; using CommonServiceLocator; using GalaSoft.MvvmLight.Ioc; namespace HandyControlDemo.UserControl { /// /// 控件定位器 /// public class ControlLocator { private ControlLocator() { <#foreach(var item in singleList){#> SimpleIoc.Default.Register<<#=item#>>(); <#}#> <#foreach(var item in controlList){#> SimpleIoc.Default.Register<<#=item#>>(); <#}#> <#foreach(var item in styleList){#> SimpleIoc.Default.Register<<#=item#>>(); <#}#> } public static ControlLocator Instance => new Lazy(() => new ControlLocator()).Value; #region Main <#foreach(var item in singleList){#> public <#=item#> <#=item#> => ServiceLocator.Current.GetInstance<<#=item#>>(); <#}#> #endregion #region Controls <#foreach(var item in controlList){#> public <#=item#> <#=item#> => new <#=item#>(); <#}#> #endregion #region Styles <#foreach(var item in styleList){#> public <#=item#> <#=item#> => new <#=item#>(); <#}#> #endregion } }