public void FillContext(ApplicationMetadataSchemaKey key) { var context = (ContextHolder)ReflectionUtil.Clone(new ContextHolder(), LookupContext()); Log.DebugFormat("filling {0} into context {1}", key, context); if (context.ApplicationLookupContext == null) { Log.DebugFormat("no context found"); context.ApplicationLookupContext = new ApplicationLookupContext(); } var appContext = (ApplicationLookupContext)ReflectionUtil.Clone(new ApplicationLookupContext(), context.ApplicationLookupContext); appContext.Schema = key.SchemaId; appContext.Mode = key.Mode.ToString(); context.ApplicationLookupContext = appContext; var isHttp = System.Web.HttpContext.Current != null; if (isHttp) { System.Web.HttpContext.Current.Items["context"] = context; } else { LogicalThreadContext.SetData("context", context); } }