public IServiceCache GetCache(IActivationContext context) { var key = GetType(); var cache = (IServiceCache)context.Data.TryGetValue(key, CreateCache); return(cache); }
protected override async Task OnActivateAsync(IActivationContext context) { var all = await _transmitterProvider.GetAllAsync(); _applicationSettings = context.ServiceProvider.GetRequiredService <IApplicationSettings>(); Transmitters = CreateTransmitters(all); }
public virtual void CascadeActivationToTarget() { IActivationContext context = ClassMetadata().DescendOnCascadingActivation() ? Descend () : this; CascadeActivation(context); }
public object ActivateService(IActivationContext context) { var serviceLoader = _serviceLoaderFactory(context); var service = serviceLoader.LoadService(); return(service); }
private void CascadeActivation(IActivationContext context) { IActivationDepth depth = context.Depth(); if (!depth.RequiresActivation()) { return; } if (depth.Mode().IsDeactivate()) { Container().StillToDeactivate(_transaction, context.TargetObject(), depth, false); } else { // FIXME: [TA] do we really need to check for isValueType here? Db4objects.Db4o.Internal.ClassMetadata classMetadata = context.ClassMetadata(); if (classMetadata.IsStruct()) { classMetadata.CascadeActivation(context); } else { Container().StillToActivate(context); } } }
internal virtual void ActivateInternal(IActivationContext context) { if (null == context) { throw new ArgumentNullException(); } if (!context.Depth().RequiresActivation()) { return; } ObjectContainerBase container = context.Container(); if (context.Depth().Mode().IsRefresh()) { LogActivation(container, "refresh"); } else { if (IsActive()) { _class.CascadeActivation(context); return; } LogActivation(container, "activate"); } ReadForActivation(context); }
public IServiceCache GetCache(IActivationContext context) { var httpContext = HttpContext.Current; if (httpContext == null) { throw new HttpContextNotSetException(); } var session = httpContext.Session; if (session == null) { throw new HttpSessionNotSetException(); } var cache = (IServiceCache)session[SessionKey]; if (cache == null) { cache = new DictionaryServiceCache(); session[SessionKey] = cache; } return(cache); }
public override void Deactivate(IActivationContext context) { if (!Alive() || !ShouldStoreField()) { return; } bool isEnumClass = _containingClass.IsEnum(); if (_isPrimitive && !_isArray) { if (!isEnumClass) { object nullValue = _reflectField.GetFieldType().NullValue(); FieldAccessor().Set(_reflectField, context.TargetObject(), nullValue); } return; } if (context.Depth().RequiresActivation()) { CascadeActivation(context); } if (!isEnumClass) { FieldAccessor().Set(_reflectField, context.TargetObject(), null); } }
/// <inheritdoc /> protected override async Task OnActivateAsync(IActivationContext context) { _someMemory = new byte[200000000]; await Task.Delay(3000); Window.Title = $"Title updated: {DateTime.Now.ToString("F")} {_someMemory.Length}"; }
public object ActivateService(IActivationContext context) { var cache = Scope.GetCache(context); var service = cache.Get(Identity, () => Factory.CreateService(context)); return(service); }
public override void CascadeActivation(IActivationContext context) { if (!Handlers4.IsCascading(_typeHandler)) { return; } Handlers4.CascadeActivation(context, _typeHandler); }
public void CascadeActivation(IActivationContext context) { ICollection collection = ((ICollection)context.TargetObject()); foreach (object item in collection) { context.CascadeActivationToChild(item); } }
public ResolutionScope(IActivationContext activationContext, IServiceRegistrator serviceRegistrator, IExpressionBuilder expressionBuilder, IResolutionScope rootScope) { this.activationContext = activationContext; this.serviceRegistrator = serviceRegistrator; this.expressionBuilder = expressionBuilder; this.rootScope = rootScope; }
public override void Deactivate(IActivationContext context) { if (context.Depth().RequiresActivation()) { CascadeActivation(context); } SetOn(context.Transaction(), context.TargetObject(), null); }
public void CascadeActivation(IActivationContext context) { var all = ((ICollection) context.TargetObject()).GetEnumerator(); while (all.MoveNext()) { context.CascadeActivationToChild(all.Current); } }
protected override async Task OnActivateAsync(IActivationContext context) { Transmitters = new TransmittersOverviewViewModel(this, context.ServiceProvider.GetRequiredService <IDialogService>(), context.ServiceProvider.GetRequiredService <ITabControllerManager>(), context.ServiceProvider.GetRequiredService <ITransmitterProvider>()); Receivers = new ReceiversOverviewViewModel(this, context.ServiceProvider.GetRequiredService <IDialogService>(), context.ServiceProvider.GetRequiredService <ITabControllerManager>(), context.ServiceProvider.GetRequiredService <IReceiverProvider>()); this.RightWindowCommands.Add(new WindowTextCommand(new TaskCommand(OpenSettingsExecute), "Settings")); await Task.WhenAll(Transmitters.ActivateAsync(context), Receivers.ActivateAsync(context)); }
public static void CascadeActivation(IActivationContext context, ITypeHandler4 handler ) { if (!(handler is ICascadingTypeHandler)) { return; } ((ICascadingTypeHandler)handler).CascadeActivation(context); }
public void CascadeActivation(IActivationContext context) { var all = ((ICollection)context.TargetObject()).GetEnumerator(); while (all.MoveNext()) { context.CascadeActivationToChild(all.Current); } }
protected override Task OnActivateAsync(IActivationContext context) { SaveCommand = new ActionCommand(SaveExecute); var settings = ServiceProvider.GetRequiredService <IApplicationSettings>(); FocusTabOnCreate = settings.FocusTabOnCreate; FocusTabOnOpen = settings.FocusTabOnOpen; return(Task.CompletedTask); }
public virtual void CascadeActivation(IActivationContext context) { object targetObject = context.TargetObject(); if (IsPlainObject(targetObject)) { return; } ITypeHandler4 typeHandler = TypeHandlerForObject(targetObject); Handlers4.CascadeActivation(context, typeHandler); }
/// <summary> /// Build a Handler based on the node configuration /// </summary> /// <typeparam name="T"></typeparam> /// <param name="nodeCtx"></param> /// <param name="node"></param> /// <returns></returns> public T BuildHandler <T>(IActivationContext nodeCtx, HandlerNode node) { nodeCtx.Register <IEventDataConverter>(node.BuildDataFilter); nodeCtx.Register <ConfiguredArguments>(node.BuildArguments); var plugin = _pluginManager.GetPlugin(typeof(T), node); var handler = nodeCtx.Resolve <T>(plugin.Type); return(handler); }
public void CascadeActivation(IActivationContext context) { var map = (IDictionary) context.TargetObject(); var keys = (map).Keys.GetEnumerator(); while (keys.MoveNext()) { var key = keys.Current; context.CascadeActivationToChild(key); context.CascadeActivationToChild(map[key]); } }
public void CascadeActivation(IActivationContext context) { IEnumerable collection = ((IEnumerable)context.TargetObject()); // TODO: detect the element type // and return immediately when it's a primitive foreach (object item in collection) { context.CascadeActivationToChild(item); } }
protected object CascadingTarget(IActivationContext context) { if (context.Depth().Mode().IsDeactivate()) { if (null == _reflectField) { return(null); } return(FieldAccessor().Get(_reflectField, context.TargetObject())); } return(GetOrCreate(context.Transaction(), context.TargetObject())); }
public void CascadeActivation(IActivationContext context) { IDictionary map = (IDictionary)context.TargetObject(); IEnumerator keys = (map).Keys.GetEnumerator(); while (keys.MoveNext()) { object key = keys.Current; context.CascadeActivationToChild(key); context.CascadeActivationToChild(map[key]); } }
public IServiceCache GetCache(IActivationContext context) { var httpContext = HttpContext.Current; if (httpContext == null) { throw new HttpContextNotSetException(); } var cache = (IServiceCache)httpContext.Items.TryGetValue(RequestItemKey, CreateCache); return(cache); }
protected override async Task OnActivateAsync(IActivationContext context) { NewReceiverCommand = new TaskCommand(NewReceiverExecute); OpenItemCommand = new TaskCommand(OpenItemExecute); DeleteItemCommand = new TaskCommand(DeleteItemExecute); CopyItemCommand = new TaskCommand(CopyItemExecute); ToggleAllCommand = new TaskCommand(ToggleAllExecute); var all = await _receiverProvider.GetAllAsync(); _applicationSettings = context.ServiceProvider.GetRequiredService <IApplicationSettings>(); Receivers = CreateReceivers(all); }
public void CascadeActivation(IActivationContext context) { if (!Handlers4.IsCascading(_handler)) { return; } ObjectContainerBase container = context.Container(); IEnumerator all = AllElements(container, context.TargetObject()); while (all.MoveNext()) { context.CascadeActivationToChild(all.Current); } }
public virtual void CascadeActivationToChild(object obj) { if (obj == null) { return; } IActivationContext cascadingContext = ForObject(obj); Db4objects.Db4o.Internal.ClassMetadata classMetadata = cascadingContext.ClassMetadata (); if (classMetadata == null || !classMetadata.HasIdentity()) { return; } CascadeActivation(cascadingContext.Descend()); }
internal StashboxContainer(IStashboxContainer parentContainer, IContainerExtensionManager containerExtensionManager, IResolverSelector resolverSelector) { this.disposed = new AtomicBool(); this.ParentContainer = parentContainer; this.containerExtensionManager = containerExtensionManager; this.resolverSelector = resolverSelector; this.registrationRepository = new RegistrationRepository(); this.ContainerContext = new ContainerContext(this.registrationRepository, new DelegateRepository(), this, new ResolutionStrategy(this.resolverSelector), parentContainer.ContainerContext.ContainerConfigurator, parentContainer.ContainerContext.DecoratorRepository); this.activationContext = new Resolution.ActivationContext(this.ContainerContext, this.resolverSelector, this); this.containerExtensionManager.ReinitalizeExtensions(this.ContainerContext); this.expressionBuilder = new ExpressionBuilder(this.ContainerContext, this.containerExtensionManager); this.objectBuilderSelector = new ObjectBuilderSelector(this.ContainerContext, this.expressionBuilder); this.ServiceRegistrator = new ServiceRegistrator(this.ContainerContext, this.containerExtensionManager, this.objectBuilderSelector); }
/// <summary> /// Constructs a <see cref="StashboxContainer"/> /// </summary> public StashboxContainer(Action <IContainerConfigurator> config = null) { this.disposed = new AtomicBool(); this.containerExtensionManager = new BuildExtensionManager(); this.resolverSelector = new ResolverSelector(); var configurator = new ContainerConfigurator(); config?.Invoke(configurator); this.registrationRepository = new RegistrationRepository(); this.ContainerContext = new ContainerContext(this.registrationRepository, new DelegateRepository(), this, new ResolutionStrategy(this.resolverSelector), configurator, new DecoratorRepository()); this.activationContext = new Resolution.ActivationContext(this.ContainerContext, this.resolverSelector, this); this.expressionBuilder = new ExpressionBuilder(this.ContainerContext, this.containerExtensionManager); this.objectBuilderSelector = new ObjectBuilderSelector(this.ContainerContext, this.expressionBuilder); this.ServiceRegistrator = new ServiceRegistrator(this.ContainerContext, this.containerExtensionManager, this.objectBuilderSelector); this.RegisterResolvers(); }
private void EnsureInitialized(IActivationContext context) { if (_factoryDelegate != null) { return; } lock (_initializationLock) { if (_factoryDelegate != null) { return; } _factoryDelegate = TryCreateFactoryDelegate(ConstructionType, context.Container); if (_factoryDelegate == null) { throw new NoValidConstructorFoundException(ConstructionType); } } }
public virtual void CascadeActivation(IActivationContext context) { }
public virtual void CascadeActivation(IActivationContext context) { if (!ObjectCanActivate(context.Transaction(), context.TargetObject())) { return; } TraverseAllAspects(new _ITraverseAspectCommand_162(context)); }
public abstract void Deactivate(IActivationContext context);
public abstract void CascadeActivation(IActivationContext context);
public virtual void CascadeActivation(IActivationContext context) { AssertClassMetadata(context.ClassMetadata()); context.CascadeActivationToTarget(); }
public override void Deactivate(IActivationContext context) { CascadeActivation(context); }
protected object CascadingTarget(IActivationContext context) { if (context.Depth().Mode().IsDeactivate()) { if (null == _reflectField) { return null; } return FieldAccessor().Get(_reflectField, context.TargetObject()); } return GetOrCreate(context.Transaction(), context.TargetObject()); }
public virtual void CascadeActivation(IActivationContext context) { throw new NotImplementedException(); }
public _ITraverseAspectCommand_703(IActivationContext context) { this.context = context; }
private void ReadForActivation(IActivationContext context) { Read(context.Transaction(), null, context.TargetObject(), context.Depth(), Const4 .AddMembersToIdTreeOnly, false); }
public void StillToActivate(IActivationContext context) { // TODO: We don't want the simple classes to search the hc_tree // Kick them out here. // if (a_object != null) { // Class clazz = a_object.getClass(); // if(! clazz.isPrimitive()){ if (ProcessedByImmediateActivation(context)) { return; } _stillToActivate = StillTo1(context.Transaction(), _stillToActivate, context.TargetObject (), context.Depth()); }
private void EnsureObjectIsActive(IActivationContext context) { if (!context.Depth().Mode().IsActivate()) { return; } if (Handlers4.IsValueType(GetHandler())) { return; } ObjectContainerBase container = context.Container(); ClassMetadata classMetadata = container.ClassMetadataForObject(context.TargetObject ()); if (classMetadata == null || !classMetadata.HasIdentity()) { return; } if (container.IsActive(context.TargetObject())) { return; } container.StillToActivate(context.Descend()); }
private bool ProcessedByImmediateActivation(IActivationContext context) { if (!StackIsSmall()) { return false; } if (!context.Depth().RequiresActivation()) { return true; } ObjectReference @ref = context.Transaction().ReferenceForObject(context.TargetObject ()); if (@ref == null) { return false; } if (HandledInCurrentTopLevelCall(@ref)) { return true; } FlagAsHandled(@ref); IncStackDepth(); try { @ref.ActivateInternal(context); } finally { DecStackDepth(); } return true; }
public sealed override void CascadeActivation(IActivationContext context) { if (!Alive()) { return; } object cascadeTo = CascadingTarget(context); if (cascadeTo == null) { return; } IActivationContext cascadeContext = context.ForObject(cascadeTo); ClassMetadata classMetadata = cascadeContext.ClassMetadata(); if (classMetadata == null) { return; } EnsureObjectIsActive(cascadeContext); Handlers4.CascadeActivation(cascadeContext, classMetadata.TypeHandler()); }
public override void CascadeActivation(IActivationContext context) { }
// QBE constraint collection call // There isn't anything useful to do here, since virtual fields // are not on the actual object. public override void Deactivate(IActivationContext context) { }
internal void DeactivateFields(IActivationContext context) { TraverseAllAspects(new _ITraverseAspectCommand_703(context)); }