Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3786520
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:41:46+00:00 2026-05-19T11:41:46+00:00

I found this little snippet of code on the web: public abstract class ConverterExtension<T>:

  • 0

I found this little snippet of code on the web:

public abstract class ConverterExtension<T>: MarkupExtension, IValueConverter
    where T: class, new()
{
    private static T _converter = null;

    public override Object ProvideValue(IServiceProvider serviceProvider)
    {
        return _converter ?? (_converter = new T());
    }

    public abstract Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture);

    public abstract Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture);
}

It basically does 2 things:
1. creates a singleton (very handy)
2. Allows you to use the converter without creating a static control (MarkupExtension)

What I’m wondering is if I use Prism v4 as my framework, is something like this already built in. I’d rather use whatever tools Prism has built in it than to write similar or duplicate code. I’m not that familiar with Prism, but I couldn’t find anything like this in there. Oh, and I have a similar function for IMultiValueConverter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:41:47+00:00Added an answer on May 19, 2026 at 11:41 am

    IMHO the need for a singleton with regards to your converters to avoid the multiple instances is a bit of overkill as they are a resource of the View which they reside and will be GC’ed with the View and are in and of themselves very lightweight.

    To your question though…Prism is geared towards building modular applications and is not in the realm of providing utility type classes/methods if that is what you were assuming. In terms of registering a singleton within Prism; this is certainly possible.

    IUnityContainer container;
    container.RegisterType<ISingleton, Singleton>(new ContainerControlledLifetimeManager());
    

    The above code will associate any resolution for ISingleton with Singleton and by use of the ContainerControlledLifetimeManager() parameter will provide a single instance throughout the containers lifetime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

found this little code snippet that seems to do what i want, but im
I was wondering what this snippet exactly does? (found here: http://code.google.com/p/google-app-engine-samples/source/browse/trunk/django_example/django_bootstrap.py ) # Make
I'm working in Microsoft Visual C# 2008 Express. I found this snippet of code:
I have this cool little snippet that I found, which adds a shadow to
I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[]
I wanted to use groovy for a little ftp script and found this post
I'm a little confused as to why this doesn't give an error. I found
I've been struggling with this issue for a little while now. Found several posts
I have this little piece of code that just checks for a particular text
I have found this little script in PHP that send a simple request to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.