Convertion between Item and IConfigurationItem

Hello,

Just want to confirm how we are supposed to convert between Item and IConfigurationItem, especially for CameraGroup.

var ms = new ManagementServer(EnvironmentManager.Instance.MasterSite);
 
// 1 Hardware
var hardware = ms.RecordingServerFolder.RecordingServers.First().HardwareFolder.Hardwares.First();
var hardwareItem = Configuration.Instance.GetItem(new Guid(hardware.Id), Kind.Hardware);
var hardware2 = new Hardware(hardwareItem.FQID);
 
// 2 CameraGroup
var group = ms.CameraGroupFolder.CameraGroups.First()
var item = Configuration.Instance.GetItem(new Guid(group.Id), Kind.Camera);
// var group2 = new CameraGroup(item.FQID); // error here
var group2 = new CameraGroup(item.FQID.ServerId, String.Format("CameraGroup[{0}]", item.FQID.ObjectId));

Can you confirm that section 1 is all correct (going to Item and back to IConfigurationItem) ?

Can you confirm that section 2 is the way to go for CameraGroup? Especially Kind.Camera as there’s no other Kind that makes sense when going to Item.

I can confirm.

We had this prepared..

Unfortunately FQIDs does not contain specific types for different folders/groups, so it just has the kind “Folder” and therefore the constructor cannot initialize just based on FQID. Instead you can do the following:

var group2 = new CameraGroup(item.FQID.ServerId, ConfigurationItemPath.CreateItemPath(“CameraGroup”, group.Id.ToString()).Path);