Anders G. Nordby

Lead Software Engineer at Sopra Steria

Tag Archives: PIM

Ensuring an inRiver PIM Connection

In my current inRiver PIM integration project, there are places all over where I need to make sure that I’m connected to my inRiver PIM instance. I’ve found it helpful to create a singleton that reads the connection data from the _Web.config_ file, and then use this in combination with a small helper method that ensures my connection to PIM.

The singleton looks like this:

public sealed class PimCredentials 
	private static readonly Lazy Lazy = new Lazy(() => new PimCredentials()); 
	public static PimCredentials Instance => Lazy.Value; 
	public string Url { get; private set; } 
	public string UserName { get; private set; } 
	public string Password { get; private set; } 
	private PimCredentials() { 
		var appSettings = System.Configuration.ConfigurationManager.AppSettings; 
		Url = appSettings["Pim.Url"]; 
		UserName = appSettings["Pim.Username"]; 
		Password = appSettings["Pim.Password"]; 

Implentation of singleton pattern found on

The helper method:

public static class PimHelpers 
	public static void EnsurePimConnection() 
		if (RemoteManager.Instance != null) 

		var credentials = PimCredentials.Instance; 
		RemoteManager.CreateInstance(credentials.Url, credentials.UserName, credentials.Password); 

Now, wherever in my code that I need to do something to my inRiver PIM instance, I simply make sure I have a connection before doing anything else:

// Do stuff to PIM...