public AttributeControlledFacilityBase(Type interceptorType, LifestyleType lifestyleType) { ParameterCheck.ParameterRequired(interceptorType, "interceptorType"); this.interceptorType = interceptorType; this.lifestyleType = lifestyleType; }
public AttributeControlledFacilityBase(Type interceptorType, LifestyleType lifestyleType) { Check.IsNotNull(interceptorType, "interceptorType"); this.interceptorType = interceptorType; this.lifestyleType = lifestyleType; }
public LifestyleRegistrationMutator( LifestyleType originalLifestyle = LifestyleType.PerWebRequest, LifestyleType newLifestyleType = LifestyleType.Scoped) { _originalLifestyle = originalLifestyle; _newLifestyleType = newLifestyleType; }
private void LifestyleSingle(Func<ComponentRegistration<A>, IRegistration> assingLifestyle, LifestyleType expectedLifestyle) { var registration = Component.For<A>(); Kernel.Register(assingLifestyle(registration)); var handler = Kernel.GetHandler(typeof(A)); Assert.AreEqual(expectedLifestyle, handler.ComponentModel.LifestyleType); }
private void LifestyleMany(Func<BasedOnDescriptor, IRegistration> assingLifestyle, LifestyleType expectedLifestyle) { var registration = Classes.FromThisAssembly().BasedOn<A>(); Kernel.Register(assingLifestyle(registration)); var handler = Kernel.GetHandler(typeof(A)); Assert.AreEqual(expectedLifestyle, handler.ComponentModel.LifestyleType); }
private void Register(Type serviceType, Type implementationType, LifestyleType lifestyle) { var registration = Component.For(serviceType) .ImplementedBy(implementationType) .LifeStyle.Is(lifestyle); this.container.Register(registration); }
public ServiceEntry(Type serviceType, Type implementationType, LifestyleType lifestyleType, string key) { AssertValidTypes(serviceType, implementationType); _serviceType = serviceType; _implementationType = implementationType; _lifestyleType = lifestyleType; _key = key; }
public ServiceEntry(Type implementationType, LifestyleType lifestyleType, string key) { AssertValidTypes(implementationType); _serviceType = implementationType; _lifestyleType = lifestyleType; _key = key; _lock = ServiceEntryLockBroker.Singleton.GetLockForEntry(this); }
private string TestHandlersLifestyleWithService(Type componentType, LifestyleType lifestyle, bool overwrite) { var key = Guid.NewGuid().ToString(); Kernel.Register(Component.For<IComponent>().ImplementedBy(componentType).Named(key).LifeStyle.Is(lifestyle)); var handler = Kernel.GetHandler(key); Assert.AreEqual(lifestyle, handler.ComponentModel.LifestyleType); return key; }
public ComponentInfo(string key, IEnumerable<Type> serviceType, Type classType, LifestyleType lifestyle) { if (key == null) throw new ArgumentNullException("key"); Key = key; ServiceTypes = serviceType; Classtype = classType; Lifestyle = lifestyle; }
public static IContainerEntry GetEntry(LifestyleType lifestyleType, Type dataType) { IContainerEntry result = null; switch(lifestyleType) { case LifestyleType.Transient: result = new TransientEntry(dataType); break; case LifestyleType.Singleton: result = new SingletonEntry(dataType); break; } return result; }
private void TestLifestyleWithServiceAndSameness(Type componentType, LifestyleType lifestyle, bool overwrite, bool areSame) { string key = TestHandlersLifestyleWithService(componentType, lifestyle, overwrite); TestSameness(key, areSame); }
public static void InstallDependencies(LifestyleType lifestyleType) { Container = new WindsorContainer(); Container.Install(new WebInstaller(lifestyleType)); }
private void TestLifestyleAndSameness(Type componentType, LifestyleType lifestyle, bool overwrite, bool areSame) { var key = TestHandlersLifestyle(componentType, lifestyle, overwrite); TestSameness(key, areSame); }
public Component(string name, Type service, Type impl, LifestyleType lifestyleType) : this(name, service, impl) { _lifestyle = lifestyleType; }
private string TestHandlersLifestyleWithService(Type componentType, LifestyleType lifestyle, bool overwrite) { string key = Guid.NewGuid().ToString(); kernel.AddComponent(key, typeof(IComponent), componentType, lifestyle, overwrite); IHandler handler = kernel.GetHandler(key); Assert.AreEqual(lifestyle, handler.ComponentModel.LifestyleType); return key; }
public ProvidesServiceAttribute(LifestyleType type, Type serviceType) : base(type) { _serviceType = serviceType; }
public void AddComponent(string key, Type serviceType, Type classType, LifestyleType lifestyle) { AddComponent(key, serviceType, classType, lifestyle, false); }
public ServiceAttribute(LifestyleType lifestyleType = LifestyleType.Scoped, string name = null) : base(lifestyleType, name) { }
public static IWindsorContainer RegisterType <TClassType>(this IWindsorContainer container, string name, LifestyleType theLifestyleType) where TClassType : class { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } if (!Enum.IsDefined(typeof(LifestyleType), theLifestyleType)) { throw new InvalidEnumArgumentException(nameof(theLifestyleType), (int)theLifestyleType, typeof(LifestyleType)); } switch (theLifestyleType) { case LifestyleType.Undefined: return(container.Register(Component.For(typeof(TClassType)) .Named(name))); case LifestyleType.Singleton: return(container.Register(Component.For(typeof(TClassType)) .Named(name) .LifeStyle.Singleton)); case LifestyleType.Thread: return(container.Register(Component.For(typeof(TClassType)) .Named(name) .LifeStyle.PerThread)); case LifestyleType.Transient: return(container.Register(Component.For(typeof(TClassType)) .Named(name) .LifeStyle.Transient)); case LifestyleType.Pooled: return(container.Register(Component.For(typeof(TClassType)) .Named(name) .LifeStyle.Pooled)); case LifestyleType.Custom: break; case LifestyleType.Scoped: return(container.Register(Component.For(typeof(TClassType)) .Named(name) .LifeStyle.Scoped(typeof(TClassType)))); case LifestyleType.Bound: break; default: throw new ArgumentOutOfRangeException(nameof(theLifestyleType), theLifestyleType, null); } return(container.Register(Component.For(typeof(TClassType)) .Named(name) .LifeStyle.Transient)); }
/// <summary> /// Registers an interface and associates it with a concrete class /// </summary> /// <typeparam name="interfaceType">The interface type</typeparam> /// <typeparam name="classType">The concrete class type</typeparam> public void Register(Type interfaceType, Type classType, LifestyleType lifestyleType = LifestyleType.Transient) { RegisterInterfaceType(interfaceType, classType, lifestyleType); }
/// <summary> /// Registers an interface and associates it with a concrete class /// </summary> /// <typeparam name="T">The interface type</typeparam> /// <typeparam name="T2">The concrete class type</typeparam> public void Register <T, T2>(LifestyleType lifestyleType = LifestyleType.Transient) { Register(typeof(T), typeof(T2), lifestyleType); }
/// <summary> /// Registers a concrete class type in the container /// </summary> /// <typeparam name="classType">The class type to register</typeparam> /// <typeparam name="lifestyle">The object lifestyle to use</typeparam> public void Register(Type classType, LifestyleType lifestyleType = LifestyleType.Transient) { RegisterClassType(classType, lifestyleType); }
private void TestLifestyleAndSameness(Type componentType, LifestyleType lifestyle, bool overwrite, bool areSame) { string key = TestHandlersLifestyle(componentType, lifestyle, overwrite); TestSameness(key, areSame); }
/// <summary> /// Registers current component with given lifestyle type /// </summary> /// <param name="type">Lifestyle for the component</param> /// <returns>Current component registration</returns> public PropertyResolvingComponentRegistration <TService> WithLifestyle(LifestyleType type) { m_lifestyle = type; return(this); }
public void ActivateModule(ModuleType moduleType) { //only one thread at a time System.Threading.Monitor.Enter(lockObject); string assemblyQualifiedName = moduleType.ClassName + ", " + moduleType.AssemblyName; if (log.IsDebugEnabled) { log.DebugFormat("Loading module {0}.", assemblyQualifiedName); } // First, try to get the CLR module type Type moduleTypeType = Type.GetType(assemblyQualifiedName); if (moduleTypeType == null) { throw new Exception("Could not find module: " + assemblyQualifiedName); } try { // double check, if we should continue if (this._kernel.HasComponent(moduleTypeType)) { // Module is already registered if (log.IsDebugEnabled) { log.DebugFormat("The module with type {0} is already registered in the container.", moduleTypeType.ToString()); } return; } // First, register optional module services that the module might depend on. foreach (ModuleService moduleService in moduleType.ModuleServices) { Type serviceType = Type.GetType(moduleService.ServiceType); Type classType = Type.GetType(moduleService.ClassType); if (log.IsDebugEnabled) { log.DebugFormat("Loading module service {0}, (1).", moduleService.ServiceKey, moduleService.ClassType); } LifestyleType lifestyle = LifestyleType.Singleton; if (moduleService.Lifestyle != null) { try { lifestyle = (LifestyleType)Enum.Parse(typeof(LifestyleType), moduleService.Lifestyle); } catch (ArgumentException ex) { throw new Exception(String.Format("Unable to load module service {0} with invalid lifestyle {1}." , moduleService.ServiceKey, moduleService.Lifestyle), ex); } } this._kernel.AddComponent(moduleService.ServiceKey, serviceType, classType, lifestyle); } //Register the module this._kernel.AddComponent("module." + moduleTypeType.FullName, moduleTypeType); //Configure NHibernate mappings and make sure we haven't already added this assembly to the NHibernate config if (typeof(INHibernateModule).IsAssignableFrom(moduleTypeType) && ((HttpContext.Current.Application[moduleType.AssemblyName]) == null)) { if (log.IsDebugEnabled) { log.DebugFormat("Adding module assembly {0} to the NHibernate mappings.", moduleTypeType.Assembly.ToString()); } this._sessionFactoryHelper.AddAssembly(moduleTypeType.Assembly); //set application variable to remember the configurated assemblies HttpContext.Current.Application.Lock(); HttpContext.Current.Application[moduleType.AssemblyName] = moduleType.AssemblyName; HttpContext.Current.Application.UnLock(); } } finally { System.Threading.Monitor.Exit(lockObject); } }//end method
/// <summary> /// Lifestyle to update when editing. /// </summary> /// <param name="objLifestyle">Lifestyle to edit.</param> public void SetLifestyle(Lifestyle objLifestyle) { _objSourceLifestyle = objLifestyle ?? throw new ArgumentNullException(nameof(objLifestyle)); StyleType = objLifestyle.StyleType; }
public void InitApp(LifestyleType lifestyleType) { Bootstrapper.InstallDependencies(lifestyleType); DependencyResolver.SetResolver(new WindsorDependencyResolver(Bootstrapper.Container)); }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> /// <param name="blnCopy"></param> public void Load(XmlNode objNode, bool blnCopy = false) { //Can't out property and no backing field if (objNode.TryGetField("sourceid", Guid.TryParse, out Guid source)) { SourceID = source; } if (blnCopy) { _guiID = Guid.NewGuid(); _intMonths = 0; } else { objNode.TryGetInt32FieldQuickly("months", ref _intMonths); objNode.TryGetField("guid", Guid.TryParse, out _guiID); } objNode.TryGetStringFieldQuickly("name", ref _strName); objNode.TryGetDecFieldQuickly("cost", ref _decCost); objNode.TryGetInt32FieldQuickly("dice", ref _intDice); objNode.TryGetDecFieldQuickly("multiplier", ref _decMultiplier); objNode.TryGetInt32FieldQuickly("area", ref _intArea); objNode.TryGetInt32FieldQuickly("security", ref _intSecurity); objNode.TryGetInt32FieldQuickly("comforts", ref _intComforts); objNode.TryGetInt32FieldQuickly("roommates", ref _intRoommates); objNode.TryGetDecFieldQuickly("percentage", ref _decPercentage); objNode.TryGetStringFieldQuickly("lifestylename", ref _strLifestyleName); objNode.TryGetBoolFieldQuickly("purchased", ref _blnPurchased); if (objNode.TryGetStringFieldQuickly("baselifestyle", ref _strBaseLifestyle)) { if (_strBaseLifestyle == "Middle") { _strBaseLifestyle = "Medium"; } } objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetBoolFieldQuickly("trustfund", ref _blnTrustFund); objNode.TryGetStringFieldQuickly("page", ref _strPage); // Lifestyle Qualities XmlNodeList objXmlNodeList = objNode.SelectNodes("lifestylequalities/lifestylequality"); if (objXmlNodeList != null) { foreach (XmlNode objXmlQuality in objXmlNodeList) { var objQuality = new LifestyleQuality(_objCharacter); objQuality.Load(objXmlQuality, this); _lstLifestyleQualities.Add(objQuality); } } // Free Grids provided by the Lifestyle objXmlNodeList = objNode.SelectNodes("freegrids/lifestylequality"); if (objXmlNodeList != null) { foreach (XmlNode objXmlQuality in objXmlNodeList) { var objQuality = new LifestyleQuality(_objCharacter); objQuality.Load(objXmlQuality, this); FreeGrids.Add(objQuality); } } objNode.TryGetStringFieldQuickly("notes", ref _strNotes); var strtemp = string.Empty; if (objNode.TryGetStringFieldQuickly("type", ref strtemp)) { _objType = ConverToLifestyleType(strtemp); } LegacyShim(); }
public SessionManagerFacility(LifestyleType sessionManagerLifestyleType, ISessionFactory sessionFactory) { _sessionManagerLifestyleType = sessionManagerLifestyleType; _sessionFactory = sessionFactory; }
/// <summary> /// Initializes a new instance of the <see cref = "LifestyleAttribute" /> class. /// </summary> /// <param name = "type">The type.</param> protected LifestyleAttribute(LifestyleType type) { Lifestyle = type; }
public CastleComponentAttribute(String name, LifestyleType lifestyle, params Type[] services) : base(lifestyle) { Name = name; Services = services ?? Type.EmptyTypes; }
/// <summary> /// Lifestyle to update when editing. /// </summary> /// <param name="objLifestyle">Lifestyle to edit.</param> public void SetLifestyle(Lifestyle objLifestyle) { _objSourceLifestyle = objLifestyle; StyleType = objLifestyle.StyleType; }
public Component(string name, Type service, Type impl, LifestyleType lifestyleType, IDictionary configuration) : this(name, service, impl, configuration) { _lifestyle = lifestyleType; }
public IWindsorContainer AddComponentLifeStyle(string key, Type serviceType, Type classType, LifestyleType lifestyle) { kernel.AddComponent(key, serviceType, classType, lifestyle, true); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="LifestyleAttribute"/> class. /// </summary> /// <param name="type">The type.</param> protected LifestyleAttribute(LifestyleType type) { this.type = type; }
public void AddComponent(string key, Type classType, LifestyleType lifestyle) { AddComponent(key, classType, classType, lifestyle); }
public ServiceEntry CreateServiceEntry(Type implementationType, LifestyleType lifestyleType) { return new ServiceEntry(implementationType, lifestyleType); }
public void AddComponent <T>(Type serviceType, LifestyleType lifestyle, bool overwriteLifestyle) { var classType = typeof(T); AddComponent(classType.FullName, serviceType, classType, lifestyle, overwriteLifestyle); }
public void AddComponent <T>(LifestyleType lifestyle) { var classType = typeof(T); AddComponent(classType.FullName, classType, lifestyle); }
private void LifestyleMany(Func <BasedOnDescriptor, IRegistration> assingLifestyle, LifestyleType expectedLifestyle) { var registration = AllTypes.FromThisAssembly().BasedOn <A>(); Kernel.Register(assingLifestyle(registration)); var handler = Kernel.GetHandler(typeof(A)); Assert.AreEqual(expectedLifestyle, handler.ComponentModel.LifestyleType); }
private string TestHandlersLifestyle(Type componentType, LifestyleType lifestyle, bool overwrite) { string key = Guid.NewGuid().ToString(); kernel.Register(Component.For(componentType).Named(key).LifeStyle.Is(lifestyle)); IHandler handler = kernel.GetHandler(key); Assert.AreEqual(lifestyle, handler.ComponentModel.LifestyleType); return key; }
public ComponentInfo(string key, Type serviceType, Type classType, LifestyleType lifestyle) : this(key, new[] {serviceType}, classType, lifestyle) { }
/// <summary> /// Initializes a new instance of the <see cref="CastleComponentAttribute"/> class. /// </summary> /// <param name="key">The key.</param> /// <param name="service">The service.</param> /// <param name="lifestyle">The lifestyle.</param> public CastleComponentAttribute(String key, Type service, LifestyleType lifestyle) : base(lifestyle) { this.key = key; this.service = service; }
private static void RegisterWithLifestyle <Interface, Implementation>(string key, LifestyleType lifestyleType) { var serviceType = typeof(Interface); var implType = typeof(Implementation); _container.AddComponentLifeStyle(key, serviceType, implType, lifestyleType); }
protected LifestyleAttribute(LifestyleType type) { this.type = type; }
public IOCObject(Type type, Type implementation, LifestyleType lifestyleType) { _type = type; _implementation = implementation; _lifestyleType = lifestyleType; }
/// <summary> /// Lifestyle to update when editing. /// </summary> /// <param name="objLifestyle">Lifestyle to edit.</param> public void SetLifestyle(Lifestyle objLifestyle) { _objSourceLifestyle = objLifestyle; _objType = objLifestyle.StyleType; }
public void AddComponent(string key, Type classType, LifestyleType lifestyle, bool overwriteLifestyle) { AddComponent(key, classType, classType, lifestyle, overwriteLifestyle); }
public LifestyleExtension(LifestyleType lifestyle) { this.lifestyle = lifestyle; }
private static ComponentRegistration <TImplementation> CreateComponent <TImplementation>(LifestyleType lifestyle) where TImplementation : class { return(Component .For <TImplementation>() .AddDescriptor(new LifestyleDescriptor <TImplementation>(lifestyle))); }
private void LifestyleSingle(Func <ComponentRegistration <A>, IRegistration> assingLifestyle, LifestyleType expectedLifestyle) { var registration = Component.For <A>(); Kernel.Register(assingLifestyle(registration)); var handler = Kernel.GetHandler(typeof(A)); Assert.AreEqual(expectedLifestyle, handler.ComponentModel.LifestyleType); }
/// <summary> /// Load the CharacterAttribute from the XmlNode. /// </summary> /// <param name="objNode">XmlNode to load.</param> /// <param name="blnCopy"></param> public void Load(XmlNode objNode, bool blnCopy = false) { //Can't out property and no backing field if (objNode.TryGetField("sourceid", Guid.TryParse, out Guid source)) { SourceID = source; } if (blnCopy) { _guiID = Guid.NewGuid(); _intIncrements = 0; } else { objNode.TryGetInt32FieldQuickly("months", ref _intIncrements); objNode.TryGetField("guid", Guid.TryParse, out _guiID); } objNode.TryGetStringFieldQuickly("name", ref _strName); objNode.TryGetDecFieldQuickly("cost", ref _decCost); objNode.TryGetInt32FieldQuickly("dice", ref _intDice); objNode.TryGetDecFieldQuickly("multiplier", ref _decMultiplier); objNode.TryGetInt32FieldQuickly("area", ref _intArea); objNode.TryGetInt32FieldQuickly("comforts", ref _intComforts); objNode.TryGetInt32FieldQuickly("security", ref _intSecurity); objNode.TryGetInt32FieldQuickly("basearea", ref _intBaseArea); objNode.TryGetInt32FieldQuickly("basecomforts", ref _intBaseComforts); objNode.TryGetInt32FieldQuickly("basesecurity", ref _intBaseSecurity); objNode.TryGetDecFieldQuickly("costforarea", ref _decCostForArea); objNode.TryGetDecFieldQuickly("costforcomforts", ref _decCostForComforts); objNode.TryGetDecFieldQuickly("costforsecurity", ref _decCostForSecurity); objNode.TryGetInt32FieldQuickly("roommates", ref _intRoommates); objNode.TryGetDecFieldQuickly("percentage", ref _decPercentage); objNode.TryGetStringFieldQuickly("baselifestyle", ref _strBaseLifestyle); if (XmlManager.Load("lifestyles.xml").SelectSingleNode($"/chummer/lifestyles/lifestyle[name =\"{_strBaseLifestyle}\"]") == null && XmlManager.Load("lifestyles.xml").SelectSingleNode($"/chummer/lifestyles/lifestyle[name =\"{_strName}\"]") != null) { string baselifestyle = _strName; _strName = _strBaseLifestyle; _strBaseLifestyle = baselifestyle; } if (string.IsNullOrWhiteSpace(_strBaseLifestyle)) { objNode.TryGetStringFieldQuickly("lifestylename", ref _strBaseLifestyle); if (string.IsNullOrWhiteSpace(_strBaseLifestyle)) { List <ListItem> lstQualities = new List <ListItem>(); using (XmlNodeList xmlLifestyleList = XmlManager.Load("lifestyles.xml").SelectNodes("/chummer/lifestyles/lifestyle")) if (xmlLifestyleList != null) { foreach (XmlNode xmlLifestyle in xmlLifestyleList) { string strName = xmlLifestyle["name"]?.InnerText ?? LanguageManager.GetString("String_Error", GlobalOptions.Language); lstQualities.Add(new ListItem(strName, xmlLifestyle["translate"]?.InnerText ?? strName)); } } frmSelectItem frmSelect = new frmSelectItem { GeneralItems = lstQualities, Description = LanguageManager.GetString("String_CannotFindLifestyle", GlobalOptions.Language).Replace("{0}", _strName) }; frmSelect.ShowDialog(); if (frmSelect.DialogResult == DialogResult.Cancel) { return; } _strBaseLifestyle = frmSelect.SelectedItem; } } if (_strBaseLifestyle == "Middle") { _strBaseLifestyle = "Medium"; } if (!objNode.TryGetBoolFieldQuickly("allowbonuslp", ref _blnAllowBonusLP)) { GetNode()?.TryGetBoolFieldQuickly("allowbonuslp", ref _blnAllowBonusLP); } if (!objNode.TryGetInt32FieldQuickly("bonuslp", ref _intBonusLP) && _strBaseLifestyle == "Traveler") { _intBonusLP = 1 + GlobalOptions.RandomGenerator.NextD6ModuloBiasRemoved(); } objNode.TryGetStringFieldQuickly("source", ref _strSource); objNode.TryGetBoolFieldQuickly("trustfund", ref _blnTrustFund); if (objNode["primarytenant"] == null) { _blnIsPrimaryTenant = _intRoommates == 0; } else { objNode.TryGetBoolFieldQuickly("primarytenant", ref _blnIsPrimaryTenant); } objNode.TryGetStringFieldQuickly("page", ref _strPage); // Lifestyle Qualities using (XmlNodeList xmlQualityList = objNode.SelectNodes("lifestylequalities/lifestylequality")) if (xmlQualityList != null) { foreach (XmlNode xmlQuality in xmlQualityList) { LifestyleQuality objQuality = new LifestyleQuality(_objCharacter); objQuality.Load(xmlQuality, this); _lstLifestyleQualities.Add(objQuality); } } // Free Grids provided by the Lifestyle using (XmlNodeList xmlQualityList = objNode.SelectNodes("freegrids/lifestylequality")) if (xmlQualityList != null) { foreach (XmlNode xmlQuality in xmlQualityList) { LifestyleQuality objQuality = new LifestyleQuality(_objCharacter); objQuality.Load(xmlQuality, this); _lstFreeGrids.Add(objQuality); } } objNode.TryGetStringFieldQuickly("notes", ref _strNotes); string strTemp = string.Empty; if (objNode.TryGetStringFieldQuickly("type", ref strTemp)) { _eType = ConvertToLifestyleType(strTemp); } if (objNode.TryGetStringFieldQuickly("increment", ref strTemp)) { _eIncrement = ConvertToLifestyleIncrement(strTemp); } else if (_eType == LifestyleType.Safehouse) { _eIncrement = LifestyleIncrement.Week; } else { XmlNode xmlLifestyleNode = GetNode(); if (xmlLifestyleNode != null && xmlLifestyleNode.TryGetStringFieldQuickly("increment", ref strTemp)) { _eIncrement = ConvertToLifestyleIncrement(strTemp); } } LegacyShim(objNode); }