/// <summary> /// Iterates a MajorRecordFrame's subrecords and locates the first occurance of the desired type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <param name="offset">Offset within the Major Record's contents to start searching</param> /// <exception cref="System.ArgumentException">Thrown if target type cannot be found.</exception> /// <returns>First encountered SubrecordPin with the given type</returns> public static SubrecordPinFrame LocateSubrecordPinFrame(this MajorRecordFrame majorFrame, RecordType type, int offset) { if (!TryLocateSubrecordPinFrame(majorFrame, type, offset, out var pin)) { throw new ArgumentException($"Could not locate subrecord of type: {type}"); } return(pin); }
/// <summary> /// Finds and iterates subrecords of a given type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <param name="onlyFirstSet"> /// If true, iteration will stop after finding the first non-applicable record after some applicable ones.<br/> /// If false, records will continue to be searched in their entirety for all matching subrecords. /// </param> /// <returns>First encountered SubrecordFrame with the given type</returns> public static IEnumerable <SubrecordPinFrame> FindEnumerateSubrecords(this MajorRecordFrame majorFrame, RecordType type, bool onlyFirstSet = false) { bool encountered = false; foreach (var subrecord in majorFrame) { if (subrecord.RecordType == type) { encountered = true; yield return(subrecord); } else if (onlyFirstSet && encountered) { yield break; } } }
/// <summary> /// Iterates a MajorRecordFrame's subrecords and locates the first occurance of the desired type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <param name="offset">Offset within the Major Record's contents to start searching</param> /// <param name="loc">Location of the subrecord, relative to the parent record's RecordType data</param> /// <exception cref="System.ArgumentException">Thrown if target type cannot be found.</exception> /// <returns>First encountered SubrecordHeader with the given type</returns> public static SubrecordHeader LocateSubrecord(this MajorRecordFrame majorFrame, RecordType type, int offset, out int loc) { if (!TryLocateSubrecord(majorFrame, type, offset, out var header, out loc)) { throw new ArgumentException($"Could not locate subrecord of type: {type}"); } return(header); }
/// <summary> /// Iterates a MajorRecordFrame's subrecords and locates the first occurance of the desired type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <param name="loc">Location of the subrecord, relative to the parent record's RecordType data</param> /// <exception cref="System.ArgumentException">Thrown if target type cannot be found.</exception> /// <returns>First encountered SubrecordFrame with the given type</returns> public static SubrecordFrame LocateSubrecordFrame(this MajorRecordFrame majorFrame, RecordType type, out int loc) { if (!TryLocateSubrecordFrame(majorFrame, type, out var frame, out loc)) { throw new ArgumentException($"Could not locate subrecord of type: {type}"); } return(frame); }
/// <summary> /// Iterates a MajorRecordFrame's subrecords and locates the first occurance of the desired type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <param name="offset">Offset within the Major Record's contents to start searching</param> /// <param name="pin">SubrecordPinFrame if found</param> /// <returns>True if matching subrecord is found</returns> public static bool TryLocateSubrecordPinFrame(this MajorRecordFrame majorFrame, RecordType type, int offset, out SubrecordPinFrame pin) { var find = PluginUtilityTranslation.FindFirstSubrecord(majorFrame.Content.Slice(offset - majorFrame.HeaderLength), majorFrame.Meta, type, navigateToContent: false); if (find == null) { pin = default; return(false); } pin = new SubrecordPinFrame(majorFrame.Meta, majorFrame.Content.Slice(find.Value + offset - majorFrame.HeaderLength), find.Value + offset); return(true); }
/// <summary> /// Iterates a MajorRecordFrame's subrecords and locates the first occurance of the desired type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <exception cref="System.ArgumentException">Thrown if target type cannot be found.</exception> /// <returns>First encountered SubrecordHeader with the given type</returns> public static SubrecordHeader LocateSubrecord(this MajorRecordFrame majorFrame, RecordType type) { return(majorFrame.LocateSubrecord(type, loc: out var _)); }
/// <summary> /// Iterates a MajorRecordFrame's contents and locates the first occurance of the desired type /// </summary> /// <param name="majorFrame">Frame to read from</param> /// <param name="type">Type to search for</param> /// <param name="header">SubrecordHeader if found</param> /// <returns>True if matching subrecord is found</returns> public static bool TryLocateSubrecord(this MajorRecordFrame majorFrame, RecordType type, out SubrecordHeader header) { return(majorFrame.TryLocateSubrecord(type, header: out header, loc: out var _)); }
/// <summary> /// Default constructor that creates an EDIDLink linked to the target EditorID /// </summary> public EDIDLink(RecordType edid) : this() { this.EDID = edid; }
public static SubrecordException Factory(Exception ex, RecordType record) { return(new SubrecordException(record, formKey: null, modKey: null, edid: null, innerException: ex)); }
public SubrecordException(RecordType record, FormKey?formKey, ModKey?modKey, string?edid, string message, Exception innerException) : base(formKey, modKey, edid: edid, message: message, innerException: innerException) { Subrecord = record; }
public SubrecordException(RecordType record, FormKey?formKey, ModKey?modKey, string?edid) : base(formKey, modKey, edid: edid) { Subrecord = record; }