Questions tagged [lifetime-scoping]

97 questions
1
vote
2 answers

Rust lifetimes for struct references

I've just started with Rust but can't quite grasp lifetimes so I could resolve following issue by myself: This test project is about simulating a bit to allow tracing it through various bitwise operations, e.g. let newbit = oldbit1 ^ oldbit2 and…
grasbueschel
  • 879
  • 2
  • 8
  • 24
1
vote
0 answers

autofac singleton initialization

I have a interface and class like this: public sealed class UserService : IUserService { private readonly ILifetimeScope container; public UserService() { this.container = this.ConfigureBuilder(new ContainerBuilder()).Build(); …
1
vote
2 answers

What is the advantage of using the same lifetime for multiple arguments?

fn xory<'a>(x: &'a str, y: &'a str) -> &'a str { x } What is the advantage of the above code over using two lifetimes? Are there any situations in which the above code will work, but 2 lifetimes won't?
Snark
  • 1,664
  • 14
  • 27
1
vote
2 answers

Lifetime errors with a simple resource Allocator struct

I'm trying to make a simple allocator that allocates and deallocates buffers from a fixed pool of buffers. struct AllocatedMemory<'a> { mem: &'a mut [u8], next: Option<&'a mut AllocatedMemory<'a>>, } struct Alloc<'a> { glob: Option<&'a…
hellcatv
  • 573
  • 4
  • 21
1
vote
1 answer

Does Destruction of Arguments Occur Prior to Return?

OK I have this sequence of events: I construct an r-value object I pass an iterator to that r-value object into a function as a parameter The function operates on this iterator The function returns this iterator by value I dereference the…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
1
vote
1 answer

How can I increase ownership count of std::shared pointer

I have a struct that has a pointer as member: struct MyStruct { char *ptr; } I want to initialize the ptr in a scope and then be able to use it outside of that scope: { // scope 0 { //scope 1 { // scope 2 mystruct.ptr =…
Mert Mertce
  • 1,614
  • 3
  • 21
  • 32
1
vote
1 answer

Passing data to dependencies registered with Execution Context Scope lifetime in Simple Injector

Is there a way to pass data to dependencies registered with either Execution Context Scope or Lifetime Scope in Simple Injector? One of my dependencies requires a piece of data in order to be constructed in the dependency chain. During HTTP and WCF…
1
vote
1 answer

ServiceStack self-hosted application with per-request lifetime scope

Working with ServiceStack I've stuck with the problem of objects lifetime management in self-hosted web application. My requirements: Need of per-request objects lifetime scope. I'm using Castle Windsor IoC with implemented ServiceStack IoC…
1
vote
1 answer

can Autofac do different instance scoping per interface?

Suppose I have this line in my bootstrap code: builder.RegisterType().As().As().ExternallyOwned(); I want it such that whenever I use container.Resolve() I get a new instance of MyType. However, if I use…
Brannon
  • 5,324
  • 4
  • 35
  • 83
1
vote
1 answer

Sporadic LifetimeScope issues

Crosspost: https://orchard.codeplex.com/discussions/471475 Sometimes, I get this error: "Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed." when querying some Content…
AnimaSola
  • 7,146
  • 14
  • 43
  • 62
1
vote
1 answer

Autofac LifetimeScope with BeginLifetimeScope not working

I am trying to evaluate the scoping of Autofac and as I understand it, when an instance has been declared as InstancePerLifetimeScope, then within the using(container.BeginLifetimeScope()) block, we should get the same instance. But in another such…
vikramka
  • 27
  • 7
1
vote
1 answer

Autofac lifetime scope issue with asp.net webforms

I'm having an issue with the lifetime scope of autofac lasting across a request in an asp.net webforms site. I'm register a factory in auto fac…
wdhough
  • 155
  • 3
  • 12
1
vote
1 answer

Wcf with SimpleInjector throws "WCF scopes can not be nested"

The service layer is seperated into command and query side and each side has their handlers. The following configuration is used // EF context _container.RegisterPerWcfOperation
1
vote
3 answers

Autofac Conundrum

I use Autofac as my IoC container of choice. The rest of this question refers to SignalR in conjunction with SignalR, but no real SignalR knowledge is needed to answer; this is a problem rooted in Autofac. As part of using Autofac as the dependency…
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202
1
vote
1 answer

Simple Injector async life time scoping and security exception

I have a AsyncCommandHandlerDecorator and LifetimeScopedCommandHandlerDecorator as shown below: public class AsyncCommandHandlerDecorator : ICommandHandler where TCommand : ICommand { private…
amiry jd
  • 27,021
  • 30
  • 116
  • 215