INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Checking library type using automation  (Read 2243 times)

pahunt

  • World Citizen
  • ***
  • Posts: 236
Checking library type using automation
« on: November 11, 2014, 10:17:19 am »

Is there a way to check if the current library is a local one or a library client using the automation interface?

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Checking library type using automation
« Reply #1 on: November 13, 2014, 11:24:28 pm »

Yep.  Easy-peasy.

Code: [Select]
/// <summary>
/// Tests to see if MC is running with a network Library or not.
/// </summary>
/// <returns></returns>
public static Boolean IsNetworkLibrary()
{
string libraryName = null, libraryPath = null;
MCCore.Instance.GetLibrary(ref libraryName, ref libraryPath);
if (libraryName == null || libraryPath == null)
throw new InvalidOperationException("Media Center does not appear to have a valid Library loaded.");
else if (libraryPath.IndexOf("\\Connected Library\\", StringComparison.OrdinalIgnoreCase) > 0)
return true;
else
return false;
}

MCCore.Instance is, in this case, just a reference to the "root" IMJAutomation interface.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

pahunt

  • World Citizen
  • ***
  • Posts: 236
Re: Checking library type using automation
« Reply #2 on: November 14, 2014, 04:36:51 am »

That looks perfect, thanks Glynor :)
Pages: [1]   Go Up