public PxzRecord(string data, string name, PxzRecordType recordType = PxzRecordType.Text, bool protectedRecord = false) { var content = new PxzRecordContent(data, protectedRecord); var header = new PxzRecordHeader { Checksums = new PxzRecordChecksum(content), Size = new PxzRecordSize(content), Naming = new PxzRecordNaming { RecordName = name, StoredName = $"{Guid.NewGuid()}.record", DataType = recordType } }; ProtectedRecord = protectedRecord; Header = header; Content = content; }
/// <summary> /// Select all records of a specific type /// </summary> /// <param name="type"></param> /// <returns></returns> public List <PxzRecord> SelectType(PxzRecordType type) { try { if (Records.Count > 0 && FileIndex.RecordReference.Count > 0) { //store all record matches here var matchedRecords = new List <PxzRecord>(); //go through each reference foreach (var recRef in FileIndex.RecordReference) { //perform match if (recRef.DataType == type) { //load the record in its entirety into memory foreach (var recObj in Records) { if (recObj.Header.Naming.RecordName == recRef.RecordName && recObj.Header.Naming.StoredName == recRef.StoredName) { matchedRecords.Add(recObj); break; } } } } //return the matches return(matchedRecords); } } catch { //nothing } //default return(new List <PxzRecord>()); }