protected virtual void Commit(int id, RegMemElem mem, RegRtElem rtxOrRtf) { // TODO: Rtf var member = Members.SafeGet(id); try { if (member == null) { Members[id] = member = Create(id, mem, rtxOrRtf); return; } member.Update(mem, rtxOrRtf); } finally { OnMemberAddedOrUpdated(member); } }
// // Native format parsing protected static RegRtElem ParseRtStream(Stream rtxStream, RegMemElem mem) { if (mem.rtxOffset == 0) { return new RegRtElem() { value = null, no = 0, unknown = 2, } } ; using (BinaryReader binStream = new BinaryReader(rtxStream, Encoding.Default, true)) { rtxStream.Seek(mem.rtxOffset - 1, SeekOrigin.Begin); RegRtElem rtx = new RegRtElem { value = binStream.ReadBytes(mem.rtxLength - sizeof(int) - sizeof(byte)), no = binStream.ReadInt32(), unknown = binStream.ReadByte() }; return(rtx); } }
protected override Image Create(int id, RegMemElem mem, RegRtElem rtxOrRtf) { return(new Image(id, mem, rtxOrRtf)); }
public Template(int id, RegMemElem mem, RegRtElem rt) : base(id, mem, rt) { }
public Video(int id, RegMemElem mem, RegRtElem rt) : base(id, mem, rt) { }
public Binary(int id, RegMemElem mem, RegRtElem rt) : base(id, mem, rt) { }
public Sound(int id, RegMemElem mem, RegRtElem rt) : base(id, mem, rt) { }
public Concept(int id, RegMemElem mem, RegRtElem rt) : base(id, mem, rt) { }
public Image(int id, RegMemElem mem, RegRtElem rt) : base(id, mem, rt) { }
protected override Binary Create(int id, RegMemElem mem, RegRtElem rtxOrRtf) { return(new Binary(id, mem, rtxOrRtf)); }
public void Update(RegMemElem mem, RegRtElem rt) { #if DEBUG && !DEBUG_IN_PROD LogTo.Debug("[{0} {1}] Updating", GetType().Name, Id); #endif if (mem.rtxOffset == 0) { Empty = SetDbg(Empty, true, nameof(Empty)); return; } UseCount = SetDbg(UseCount, mem.useCount, nameof(UseCount)); LinkType = SetDbg(LinkType, (RegistryLinkType)mem.linkType, nameof(LinkType)); RtxOffset = SetDbg(RtxOffset, mem.rtxOffset, nameof(RtxOffset)); RtxLength = SetDbg(RtxLength, mem.rtxLength, nameof(RtxLength)); if (rt != null) { RtxId = SetDbg(RtxId, rt.no, nameof(RtxId)); RtxValue = SetDbg(RtxValue, Encoding.UTF8.GetString(rt.value), nameof(RtxValue)); } SlotIdOrOffset = SetDbg(SlotIdOrOffset, mem.slotIdOrOffset, nameof(SlotIdOrOffset)); SlotLengthOrConceptGroupId = SetDbg(SlotLengthOrConceptGroupId, mem.slotLengthOrConceptGroup, nameof(SlotLengthOrConceptGroupId)); }
protected RegistryMemberBase(int id, RegMemElem mem, RegRtElem rt) { Id = id; #if DEBUG && !DEBUG_IN_PROD LogTo.Debug("[{0} {1}] Creating", GetType().Name, Id); #endif UseCount = SetDbg(mem.useCount, nameof(UseCount)); LinkType = SetDbg((RegistryLinkType)mem.linkType, nameof(LinkType)); RtxId = SetDbg(rt.no, nameof(RtxId)); RtxOffset = SetDbg(mem.rtxOffset, nameof(RtxOffset)); RtxLength = SetDbg(mem.rtxLength, nameof(RtxLength)); if (rt.value != null) { RtxValue = SetDbg(Encoding.UTF8.GetString(rt.value), nameof(RtxValue)); } SlotIdOrOffset = SetDbg(mem.slotIdOrOffset, nameof(SlotIdOrOffset)); SlotLengthOrConceptGroupId = SetDbg(mem.slotLengthOrConceptGroup, nameof(SlotLengthOrConceptGroupId)); Empty = SetDbg(RtxValue == null, nameof(Empty)); }
protected override Template Create(int id, RegMemElem mem, RegRtElem rtxOrRtf) { return(new Template(id, mem, rtxOrRtf)); }
protected override Video Create(int id, RegMemElem mem, RegRtElem rtxOrRtf) { return(new Video(id, mem, rtxOrRtf)); }
protected abstract TMember Create(int id, RegMemElem mem, RegRtElem rtxOrRtf);
protected override Sound Create(int id, RegMemElem mem, RegRtElem rtxOrRtf) { return(new Sound(id, mem, rtxOrRtf)); }
protected override Concept Create(int id, RegMemElem mem, RegRtElem rtxOrRtf) { return(new Concept(id, mem, rtxOrRtf)); }