| recordKey | 记录键。 |
| data | 属性值。 |
bool 如果记录存在且有效,则返回 true;否则返回 false。
加载单个属性(已反序列化为对象)。
// Load the value already deserialized.
using (var view = propertyDatabase.GetView())
{
var colorRecordKey = view.CreateRecordKey("path/to/my/asset", "m_Color");
if (!view.TryLoad(colorRecordKey, out object colorObject))
Assert.Fail("Failed to load color property.");
var color = (Color)colorObject;
Assert.AreEqual(new Color(1, 0, 1), color);
}
| recordKey | 记录键。 |
| data | 属性记录。 |
bool 如果记录存在且有效,则返回 true;否则返回 false。
加载单个属性(仍包含在记录中)。
此方法不会对值反序列化。你必须通过调用 IPropertyDatabaseView.GetObjectFromRecordValue 自行反序列化。
// Load the record value to do a deserialization at the appropriate time.
using (var view = propertyDatabase.GetView())
{
var sizeRecordKey = view.CreateRecordKey("path/to/my/asset", "m_Size");
if (!view.TryLoad(sizeRecordKey, out IPropertyDatabaseRecordValue sizeRecordValue))
Assert.Fail("Failed to load size property.");
var size = view.GetValueFromRecord<int>(sizeRecordValue);
Assert.AreEqual(42, size);
}
| documentKey | 文档键。 |
| data | 文档属性值。 |
bool 如果记录存在且有效,则返回 true;否则返回 false。
加载文档的所有属性(已反序列化为对象)。
// Load all values not associated with a document, already deserialized.
using (var view = propertyDatabase.GetView())
{
var nullDocumentKey = view.CreateDocumentKey(null);
if (!view.TryLoad(nullDocumentKey, out IEnumerable<object> noDocumentProperties))
Assert.Fail("Failed to load properties with no documents.");
Assert.IsNotEmpty(noDocumentProperties);
Assert.AreEqual("myDocs_", noDocumentProperties.First());
}
| documentKey | 文档键。 |
| records | 文档属性记录。 |
bool 如果记录存在且有效,则返回 true;否则返回 false。
加载文档的所有属性(仍包含在记录中)。
此方法不会对值反序列化。你必须通过调用 IPropertyDatabaseView.GetObjectFromRecordValue 自行反序列化。
// Load all values associated with a document, not deserialized.
using (var view = propertyDatabase.GetView())
{
var myAssetDocumentKey = view.CreateDocumentKey("path/to/my/asset");
if (!view.TryLoad(myAssetDocumentKey, out IEnumerable<IPropertyDatabaseRecord> myDocumentRecords))
Assert.Fail("Failed to load records for my asset document.");
var deserializedValues = new Dictionary<PropertyDatabaseRecordKey, object>();
foreach (var myDocumentRecord in myDocumentRecords)
{
var value = view.GetValueFromRecord<object>(myDocumentRecord.value);
deserializedValues.Add(myDocumentRecord.key, value);
}
Assert.AreEqual(5, deserializedValues.Count);
}