public GetObjectByGuid ( System.Guid guid ) : IMappedObject | ||
guid | System.Guid | GUID of the requested object. |
return | IMappedObject |
public IMappedObject GetObjectByGuid(Guid guid) {
using (var tran = this.engine.GetTransaction()) {
var row = tran.Select<byte[], string>(MappedObjectsGuidsTable, guid.ToByteArray());
if (row.Exists) {
DbCustomSerializer<MappedObject> value = tran.Select<string, DbCustomSerializer<MappedObject>>(MappedObjectsTable, row.Value).Value;
if (value != null) {
MappedObject data = value.Get;
if (data == null) {
return null;
}
return new MappedObject(data);
}
}
}
return null;
}
public void GetObjectByGuidReturnsSavedObject([Values(true, false)]bool withValidation) { var storage = new MetaDataStorage(this.engine, Mock.Of<IPathMatcher>(), withValidation); var uuid = Guid.NewGuid(); var file = new MappedObject("name" , "rootId", MappedObjectType.File, null, "token") { Guid = uuid }; storage.SaveMappedObject(file); Assert.That(storage.GetObjectByGuid(uuid), Is.EqualTo(file)); }