JasinCole
Well-known member
- Joined
- Feb 16, 2023
- Messages
- 66
- Programming Experience
- 1-3
Simple question here, but in the following class code a property that creates and returns an instance of itself.
What is the object lifetime?, if the calling code is
I assume that since NavigationService field _frame references an object lifetime that exist for the entire program that NavigationService object will have the same lifetime and it essentially makes this a singleton?
C#:
public class NavigationService : INavigationService
{
public static NavigationService Instance { get; } = new NavigationService();
public void SetFrame(Frame frame)
{
_frame = frame;
}
public void Navigate(Type type)
{
_frame.Navigate(type);
}
private Frame _frame;
}
What is the object lifetime?, if the calling code is
C#:
_frameView = this.FindControl<Frame>("RootFrame");
NavigationService.Instance.SetFrame(_frameView);
I assume that since NavigationService field _frame references an object lifetime that exist for the entire program that NavigationService object will have the same lifetime and it essentially makes this a singleton?