private void TryRegisterObjectMap(object obj) { Type type = obj.GetType(); ScopeAttribute scope = type.GetAttributeRecursive <ScopeAttribute>(); if (scope == null || scope.Scope == Scope.Singleton) { objectMap[type] = obj; } }
public object GetObject(Type type) { if (!type.HasAttributeRecursive <CrofanaObjectAttribute>()) { return(null); } ScopeAttribute scope = type.GetAttributeRecursive <ScopeAttribute>(); if (scope == null || scope.Scope == Scope.Singleton) { if (!objectMap.ContainsKey(type)) { return(NewObject(type)); } return(objectMap[type]); } return(NewObject(type)); }