public object GetService(Type serviceType) { try { return(container.GetInstance(serviceType)); } catch (Exception) { return(null); } }
public IMapper GetMapper() { var mce = new MapperConfigurationExpression(); mce.ConstructServicesUsing(_container.GetInstance); mce.AddProfile <MappingProfile>(); var mc = new MapperConfiguration(mce); mc.AssertConfigurationIsValid(); IMapper m = new Mapper(mc, t => _container.GetInstance(t)); return(m); }
/// <summary> /// Initializes a new view model using the given service locator. /// </summary> /// <param name="services">The service locator. If null, the default will be used.</param> protected ValidatingViewModel(ISimpleIoc services) : base(services) { PropertyGetterCache cache = PropertyGetterCache.Default; if (Services.IsRegistered <PropertyGetterCache>()) { cache = services.GetInstance <PropertyGetterCache>(); } Type thisType = GetType(); GetterCache = cache[thisType]; PropertyChanged += PropertyChangedToErrorsChanged; }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> /// <param name="dialogService"></param> /// <param name="messenger"></param> /// <param name="ioc"></param> public MainViewModel(IDialogService dialogService, IMessenger messenger, ISimpleIoc ioc) : base(messenger) { if (IsInDesignMode) { // Code runs in Blend --> create design time data. Title = "Design Mode"; } else { // Code runs "for real" var assembly = Assembly.GetEntryAssembly(); Title = ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute), false))?.Title ?? "error retriving assembly title"; } _dialogService = dialogService; _ioc = ioc; _databaseViewModel = _ioc.GetInstance <DatabaseViewModel>(); Tabs = new ObservableCollection <PaneViewModelBase>(); SpyUsedMemory(); RegisterMessages(); }
public object GetService(Type serviceType) { return(container.GetInstance(serviceType)); }
public static T Get <T>() => Container.GetInstance <T>();