private void LoadOid(TestRun.TestRunState state, XmlElement config, Oid def) {
var configkey = state.ToString() + "Oid";
var oidconfig = config[configkey];
var oidtoken = oidconfig != null ? oidconfig.InnerText : null;
var oid = def;
try {
oid = Services.GetOid(oidtoken);
} catch(OidException) {
}
//the oid is null-null or its not oid-null and we can't find it in the V1 system. (Oid.Null is ok!)
if(oid == null) {
throw new InvalidOperationException(string.Format("Invalid Oid Token for {0}: {1}", configkey, oidtoken));
}
if(oid != Oid.Null) {
if(oid.AssetType != TestStatusType) {
throw new InvalidOperationException(string.Format("Oid for {0} is not a TestStatus Type: {1}", configkey, oidtoken));
}
var q = new Query(oid.AssetType);
var term = new FilterTerm(oid.AssetType.GetAttributeDefinition("Key"));
term.Equal(oid.Key);
q.Filter = term;
var assetlist = Services.Retrieve(q).Assets;
if(assetlist.Count == 0) {
throw new InvalidOperationException(string.Format("TestStatus for {0} does not exist: {1}", configkey, oidtoken));
}
}
states.Add(state, oid);
}