Пример #1
0
        public static PropertyDatabaseRecord FromBinary(BinaryReader br)
        {
            var recordKey   = PropertyDatabaseRecordKey.FromBinary(br);
            var valid       = br.ReadByte();
            var recordValue = PropertyDatabaseRecordValue.FromBinary(br);

            return(new PropertyDatabaseRecord(recordKey, recordValue, valid));
        }
Пример #2
0
        public object GetObjectFromRecordValue(PropertyDatabaseRecordValue recordValue, PropertyStringTableView stringTableView)
        {
            if (!IsSupportedPropertyType(recordValue.propertyType))
            {
                throw new ArgumentException($"Property type \"{recordValue.propertyType}\" of {nameof(recordValue)} is not supported.");
            }

            return(PropertyDatabaseSerializerManager.Deserialize(recordValue, stringTableView));
        }
Пример #3
0
        public static object Deserialize(PropertyDatabaseRecordValue value, PropertyStringTableView stringTableView)
        {
            var type = (PropertyDatabaseType)value.propertyType;

            if (!s_Deserializers.ContainsKey(type))
            {
                return(PropertyDatabaseRecordValue.invalid);
            }

            var args = new PropertyDatabaseDeserializationArgs(value, stringTableView);

            return(s_Deserializers[type].handler(args));
        }
Пример #4
0
        public bool TryLoad(PropertyDatabaseRecordKey recordKey, out PropertyDatabaseRecordValue data)
        {
            if (m_MemoryStoreView.TryLoad(recordKey, out data))
            {
                return(true);
            }
            if (!m_FileStoreView.TryLoad(recordKey, out data))
            {
                return(false);
            }

            // Cache loaded value into memory store.
            var record = CreateRecord(recordKey, data);

            m_MemoryStoreView.Store(record, !m_DelayedSync);
            return(true);
        }
Пример #5
0
        public bool TryLoad(PropertyDatabaseRecordKey recordKey, out PropertyDatabaseRecordValue data)
        {
            data = PropertyDatabaseRecordValue.invalid;
            using (LockRead())
            {
                var foundRecord = Find(recordKey, out var index);
                if (!foundRecord)
                {
                    return(false);
                }

                var record = GetRecord(index);
                if (!record.IsValid())
                {
                    return(false);
                }

                data = record.recordValue;
                return(true);
            }
        }
Пример #6
0
 public object GetObjectFromRecordValue(PropertyDatabaseRecordValue recordValue)
 {
     return(m_PropertyDatabase.GetObjectFromRecordValue(recordValue, m_StringTableView));
 }
Пример #7
0
 public PropertyDatabaseRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue, byte valid)
 {
     this.recordKey   = recordKey;
     this.recordValue = recordValue;
     this.valid       = valid;
 }
Пример #8
0
 public PropertyDatabaseRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue, bool valid)
 {
     this.recordKey   = recordKey;
     this.recordValue = recordValue;
     this.valid       = valid ? (byte)1 : (byte)0;
 }
Пример #9
0
 public PropertyDatabaseRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue)
 {
     this.recordKey   = recordKey;
     this.recordValue = recordValue;
     valid            = 1;
 }
Пример #10
0
 public PropertyDatabaseRecord(ulong documentKey, Hash128 propertyKey, PropertyDatabaseRecordValue recordValue)
     : this(new PropertyDatabaseRecordKey(documentKey, propertyKey), recordValue)
 {
 }
Пример #11
0
 static byte GetFixedStringLength(PropertyDatabaseRecordValue value)
 {
     return(value[0]);
 }
Пример #12
0
 public bool TryLoad(PropertyDatabaseRecordKey recordKey, out PropertyDatabaseRecordValue data)
 {
     using (var view = GetView())
         return(view.TryLoad(recordKey, out data));
 }
Пример #13
0
 public bool Store(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue value)
 {
     using (var view = GetView())
         return(view.Store(recordKey, value));
 }
Пример #14
0
 public PropertyDatabaseRecord CreateRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue)
 {
     return(PropertyDatabase.CreateRecord(recordKey, recordValue));
 }
Пример #15
0
        public bool Store(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue value)
        {
            var record = CreateRecord(recordKey, value);

            return(Store(record));
        }
Пример #16
0
 public static PropertyDatabaseRecord CreateRecord(PropertyDatabaseRecordKey recordKey, PropertyDatabaseRecordValue recordValue)
 {
     if (!IsSupportedPropertyType(recordValue.propertyType))
     {
         throw new ArgumentException($"Property type of {nameof(recordValue)} is not supported.");
     }
     return(new PropertyDatabaseRecord(recordKey, recordValue));
 }
Пример #17
0
 public object GetObjectFromRecordValue(PropertyDatabaseRecordValue recordValue)
 {
     using (var view = m_StringTable.GetView())
         return(GetObjectFromRecordValue(recordValue, view));
 }
Пример #18
0
 public PropertyDatabaseDeserializationArgs(PropertyDatabaseRecordValue value, PropertyStringTableView stringTableView)
 {
     this.value           = value;
     this.stringTableView = stringTableView;
 }
Пример #19
0
 public bool TryLoad(PropertyDatabaseRecordKey recordKey, out PropertyDatabaseRecordValue data)
 {
     throw new NotSupportedException();
 }