/// <summary> /// Determines if the object is a singleton in a given container. /// </summary> /// <param name="obj">Target object to check.</param> /// <param name="container">Container to check for bindings.</param> /// <returns><c>true</c> if is singleton on container the specified obj container; otherwise, <c>false</c>.</returns> public static bool IsSingletonOnContainer(object obj, IInjectionContainer container) { var isSingleton = false; var bindings = container.GetBindingsFor(obj.GetType()); if (bindings == null) return false; for (var index = 0; index < bindings.Count; index++) { var binding = bindings[index]; if (binding.value == obj) { isSingleton = true; } } return isSingleton; }
/// <summary> /// Determines if the object is a singleton in a given container. /// </summary> /// <param name="obj">Target object to check.</param> /// <param name="container">Container to check for bindings.</param> /// <returns><c>true</c> if is singleton on container the specified obj container; otherwise, <c>false</c>.</returns> public static bool IsSingletonOnContainer(object obj, IInjectionContainer container) { var isSingleton = false; var bindings = container.GetBindingsFor(obj.GetType()); if (bindings == null) { return(false); } for (var index = 0; index < bindings.Count; index++) { var binding = bindings[index]; if (binding.value == obj) { isSingleton = true; } } return(isSingleton); }