/// Collect all Compoent-Types in current domain private static Dictionary <string, List <Type> > CollectAllComponents() { var compType = typeof(IComponent); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => p.IsClass && p.IsPublic && !p.IsAbstract && compType.IsAssignableFrom(p)); Dictionary <string, List <Type> > comps = new Dictionary <string, List <Type> >(); comps[DefaultContext.Name] = new List <Type>(); var scopeType = typeof(ContextScope); foreach (var t in types) { var scopes = t.GetCustomAttributes(scopeType, false); if (scopes == null || scopes.Length <= 0) { CollectComponent(comps, DefaultContext.Name, t); } else { foreach (var scope in scopes) { string name = ContextScopeHelper.GetName(scope.GetType()); CollectComponent(comps, name, t); } } } return(comps); }
public static Context Get <S>() where S : ContextScope { return(sharedInstance._contextLookup[ContextScopeHelper.GetName <S>()]); }
public Context GetContext <S>() where S : ContextScope { return(_contextLookup[ContextScopeHelper.GetName <S>()]); }
static DefaultContext() { Name = ContextScopeHelper.GetName <DefaultContext>(); }