public IEnumerable <IMajorRecordGetter> ResolveAll(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) { if (TryResolve(formKey, out var rec, target)) { yield return(rec); } }
/// <inheritdoc /> public IEnumerable <TMajor> ResolveAll <TMajor>(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordGetter { if (TryResolve <TMajor>(formKey, out var rec, target)) { yield return(rec); } }
/// <inheritdoc /> public IModContext <TMajor> ResolveSimpleContext <TMajor>(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordGetter { if (TryResolveSimpleContext <TMajor>(formKey, out var commonRec, target)) { return(commonRec); } throw new MissingRecordException(formKey, typeof(TMajor)); }
/// <inheritdoc /> public IMajorRecordGetter Resolve(FormKey formKey, IEnumerable <Type> types, ResolveTarget target = ResolveTarget.Winner) { if (TryResolve(formKey, types, out var commonRec, target)) { return(commonRec); } throw new MissingRecordException(formKey, types.ToArray()); }
/// <inheritdoc /> public IMajorRecordGetter Resolve(FormKey formKey, Type type, ResolveTarget target = ResolveTarget.Winner) { if (TryResolve(formKey, type, out var commonRec, target)) { return(commonRec); } throw new MissingRecordException(formKey, type); }
/// <inheritdoc /> public IMajorRecordGetter Resolve(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) { if (TryResolve <IMajorRecordGetter>(formKey, out var majorRec, target)) { return(majorRec); } throw new MissingRecordException(formKey, typeof(IMajorRecordGetter)); }
/// <inheritdoc /> public bool TryResolveSimpleContext(FormKey formKey, Type type, [MaybeNullWhen(false)] out IModContext <IMajorRecordGetter> majorRec, ResolveTarget target = ResolveTarget.Winner) { if (target == ResolveTarget.Origin && formKey.ModKey != _sourceMod.ModKey) { majorRec = default; return(false); } return(_formKeyContexts.TryResolveSimpleContext(formKey, type, out majorRec)); }
/// <inheritdoc /> public bool TryResolveSimpleContext <TMajor>(FormKey formKey, [MaybeNullWhen(false)] out IModContext <TMajor> majorRec, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordGetter { if (TryResolveContext(formKey, typeof(TMajor), out var resolve, target)) { majorRec = resolve.AsType <IMajorRecordGetter, TMajor>(); return(true); } majorRec = default; return(false); }
/// <inheritdoc /> public bool TryResolveSimpleContext(FormKey formKey, Type type, [MaybeNullWhen(false)] out IModContext <IMajorRecordGetter> majorRec, ResolveTarget target = ResolveTarget.Winner) { if (TryResolveContext(formKey, type, out var resolve, target)) { majorRec = resolve; return(true); } majorRec = default; return(false); }
/// <inheritdoc /> public IEnumerable <IModContext <IMajorRecordGetter> > ResolveAllSimpleContexts(FormKey formKey, Type type, ResolveTarget target = ResolveTarget.Winner) { if (TryResolveSimpleContext(formKey, type, out var rec, target)) { yield return(rec); } }
public IEnumerable <IMajorRecordCommonGetter> ResolveAll(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) { return(ResolveAll(formKey, typeof(IMajorRecordCommonGetter), target)); }
/// <inheritdoc /> public IModContext <IMajorRecordGetter> ResolveSimpleContext(FormKey formKey, Type type, ResolveTarget target = ResolveTarget.Winner) { return(ResolveContext(formKey, type, target)); }
/// <inheritdoc /> public bool TryResolveSimpleContext <TMajor>(FormKey formKey, [MaybeNullWhen(false)] out IModContext <TMajor> majorRec, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordGetter { if (formKey.IsNull) { majorRec = default; return(false); } if (target == ResolveTarget.Origin && formKey.ModKey != _sourceMod.ModKey) { majorRec = default; return(false); } // ToDo // Upgrade to EnumerateGroups<TMajor>() foreach (var major in _sourceMod.EnumerateMajorRecordSimpleContexts <TMajor>(this) // ToDo // Capture and expose errors optionally via TryResolve /w out param .Catch((Exception ex) => { })) { if (major.Record.FormKey == formKey) { majorRec = major; return(true); } } majorRec = default; return(false); }
/// <inheritdoc /> public bool TryResolveIdentifier(FormKey formKey, Type type, [MaybeNullWhen(false)] out string?editorId, ResolveTarget target = ResolveTarget.Winner) { if (formKey.IsNull) { editorId = default; return(false); } switch (target) { case ResolveTarget.Origin: if (WrappedImmutableCache.TryResolveIdentifier(formKey, type, out editorId, target)) { return(true); } foreach (var mod in _mutableMods) { if (mod.TryResolveIdentifier(formKey, type, out editorId)) { return(true); } } return(false); case ResolveTarget.Winner: for (int i = _mutableMods.Count - 1; i >= 0; i--) { if (_mutableMods[i].TryResolveIdentifier(formKey, type, out editorId, target)) { return(true); } } return(WrappedImmutableCache.TryResolveIdentifier(formKey, type, out editorId, target)); default: throw new NotImplementedException(); } }
/// <inheritdoc /> public bool TryResolveIdentifier <TMajor>(FormKey formKey, out string?editorId, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordGetter { if (TryResolve <TMajor>(formKey, out var rec, target)) { editorId = rec.EditorID; return(true); } editorId = default; return(false); }
/// <inheritdoc /> public bool TryResolve(FormKey formKey, IEnumerable <Type> types, [MaybeNullWhen(false)] out IMajorRecordGetter majorRec, ResolveTarget target = ResolveTarget.Winner) { foreach (var type in types) { if (TryResolve(formKey, type, out majorRec, target)) { return(true); } } majorRec = default; return(false); }
public bool TryResolve(FormKey formKey, [MaybeNullWhen(false)] out IMajorRecordCommonGetter majorRec, ResolveTarget target = ResolveTarget.Winner) { return(TryResolve(formKey, typeof(IMajorRecordCommonGetter), out majorRec, target)); }
/// <inheritdoc /> public bool TryResolve(FormKey formKey, Type type, [MaybeNullWhen(false)] out IMajorRecordCommonGetter majorRec, ResolveTarget target = ResolveTarget.Winner) { if (formKey.IsNull) { majorRec = default; return(false); } switch (target) { case ResolveTarget.Origin: if (WrappedImmutableCache.TryResolve(formKey, type, out majorRec, target)) { return(true); } foreach (var mod in _mutableMods) { if (mod.TryResolve(formKey, type, out majorRec, target)) { return(true); } } return(false); case ResolveTarget.Winner: for (int i = _mutableMods.Count - 1; i >= 0; i--) { if (_mutableMods[i].TryResolve(formKey, type, out majorRec, target)) { return(true); } } return(WrappedImmutableCache.TryResolve(formKey, type, out majorRec, target)); default: throw new NotImplementedException(); } }
/// <inheritdoc /> public bool TryResolve(FormKey formKey, Type type, [MaybeNullWhen(false)] out IMajorRecordGetter majorRec, ResolveTarget target = ResolveTarget.Winner) { if (formKey.IsNull) { majorRec = default; return(false); } if (target == ResolveTarget.Origin && formKey.ModKey != _sourceMod.ModKey) { majorRec = default; return(false); } // ToDo // Upgrade to EnumerateGroups<TMajor>() foreach (var major in this._sourceMod.EnumerateMajorRecords(type) // ToDo // Capture and expose errors optionally via TryResolve /w out param .Catch((Exception ex) => { })) { if (major.FormKey == formKey) { majorRec = major; return(true); } } majorRec = default; return(false); }
/// <inheritdoc /> public bool TryResolveIdentifier(FormKey formKey, IEnumerable <Type> types, [MaybeNullWhen(false)] out string?editorId, ResolveTarget target = ResolveTarget.Winner) { foreach (var type in types) { if (TryResolveIdentifier(formKey, type, out editorId, target)) { return(true); } } editorId = default; return(false); }
/// <inheritdoc /> public bool TryResolveIdentifier <TMajor>(FormKey formKey, out string?editorId, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordCommonGetter { return(TryResolveIdentifier(formKey, typeof(TMajor), out editorId)); }
/// <inheritdoc /> public bool TryResolve <TMajor>(FormKey formKey, [MaybeNullWhen(false)] out TMajor majorRec, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordCommonGetter { if (TryResolve(formKey, typeof(TMajor), out var majorRecInner, target)) { majorRec = majorRecInner as TMajor; return(majorRec != null); } majorRec = default; return(false); }
/// <inheritdoc /> public IEnumerable <IModContext <TMod, TModGetter, TMajor, TMajorGetter> > ResolveAllContexts <TMajor, TMajorGetter>(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecord, TMajorGetter where TMajorGetter : class, IMajorRecordGetter { if (TryResolveContext <TMajor, TMajorGetter>(formKey, out var rec, target)) { yield return(rec); } }
public bool TryResolve(FormKey formKey, [MaybeNullWhen(false)] out IMajorRecordGetter majorRec, ResolveTarget target = ResolveTarget.Winner) { if (formKey.IsNull) { majorRec = default; return(false); } if (target == ResolveTarget.Origin && formKey.ModKey != _sourceMod.ModKey) { majorRec = default; return(false); } // ToDo // Upgrade to call EnumerateGroups(), which will perform much better foreach (var item in this._sourceMod.EnumerateMajorRecords() // ToDo // Capture and expose errors optionally via TryResolve /w out param .Catch((Exception ex) => { })) { if (item.FormKey == formKey) { majorRec = item; return(true); } } majorRec = default; return(false); }
public IEnumerable <IModContext <TMod, TModGetter, IMajorRecord, IMajorRecordGetter> > ResolveAllContexts(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) { if (TryResolveContext(formKey, out var rec, target)) { yield return(rec); } }
public IEnumerable <IModContext <TMod, TModGetter, IMajorRecordCommon, IMajorRecordCommonGetter> > ResolveAllContexts(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) { return(ResolveAllContexts(formKey, typeof(IMajorRecordCommonGetter), target)); }
/// <inheritdoc /> public IEnumerable <TMajor> ResolveAll <TMajor>(FormKey formKey, ResolveTarget target = ResolveTarget.Winner) where TMajor : class, IMajorRecordCommonGetter { return(ResolveAll(formKey, typeof(TMajor), target).Cast <TMajor>()); }
/// <inheritdoc /> public IEnumerable <IModContext <TMod, TModGetter, IMajorRecordCommon, IMajorRecordCommonGetter> > ResolveAllContexts(FormKey formKey, Type type, ResolveTarget target = ResolveTarget.Winner) { switch (target) { case ResolveTarget.Origin: foreach (var rec in WrappedImmutableCache.ResolveAllContexts(formKey, type, target)) { yield return(rec); } foreach (var mod in _mutableMods) { if (mod.TryResolveContext(formKey, type, out var majorRec, target)) { yield return(majorRec); } } break; case ResolveTarget.Winner: for (int i = _mutableMods.Count - 1; i >= 0; i--) { if (_mutableMods[i].TryResolveContext(formKey, type, out var majorRec)) { yield return(majorRec); } } foreach (var rec in WrappedImmutableCache.ResolveAllContexts(formKey, type)) { yield return(rec); } break; default: throw new NotImplementedException(); } }
/// <inheritdoc /> public bool TryResolveIdentifier(FormKey formKey, IEnumerable <Type> types, [MaybeNullWhen(false)] out string?editorId, ResolveTarget target = ResolveTarget.Winner) { if (TryResolve(formKey, types, out var rec, target)) { editorId = rec.EditorID; return(true); } editorId = default; return(false); }
/// <inheritdoc /> public bool TryResolveIdentifier(FormKey formKey, [MaybeNullWhen(false)] out string?editorId, ResolveTarget target = ResolveTarget.Winner) { return(TryResolveIdentifier(formKey, typeof(IMajorRecordCommonGetter), out editorId, target)); }