コード例 #1
0
 public IEnumerable <IMajorRecordGetter> ResolveAll(FormKey formKey, ResolveTarget target = ResolveTarget.Winner)
 {
     if (TryResolve(formKey, out var rec, target))
     {
         yield return(rec);
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
 /// <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));
 }
コード例 #4
0
 /// <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());
 }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
 /// <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));
 }
コード例 #7
0
        /// <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));
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
 /// <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);
     }
 }
コード例 #11
0
 public IEnumerable <IMajorRecordCommonGetter> ResolveAll(FormKey formKey, ResolveTarget target = ResolveTarget.Winner)
 {
     return(ResolveAll(formKey, typeof(IMajorRecordCommonGetter), target));
 }
コード例 #12
0
 /// <inheritdoc />
 public IModContext <IMajorRecordGetter> ResolveSimpleContext(FormKey formKey, Type type, ResolveTarget target = ResolveTarget.Winner)
 {
     return(ResolveContext(formKey, type, target));
 }
コード例 #13
0
        /// <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);
        }
コード例 #14
0
        /// <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();
            }
        }
コード例 #15
0
 /// <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);
 }
コード例 #16
0
 /// <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);
 }
コード例 #17
0
 public bool TryResolve(FormKey formKey, [MaybeNullWhen(false)] out IMajorRecordCommonGetter majorRec, ResolveTarget target = ResolveTarget.Winner)
 {
     return(TryResolve(formKey, typeof(IMajorRecordCommonGetter), out majorRec, target));
 }
コード例 #18
0
        /// <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();
            }
        }
コード例 #19
0
        /// <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);
        }
コード例 #20
0
 /// <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);
 }
コード例 #21
0
 /// <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));
 }
コード例 #22
0
        /// <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);
        }
コード例 #23
0
 /// <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);
     }
 }
コード例 #24
0
        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);
        }
コード例 #25
0
 public IEnumerable <IModContext <TMod, TModGetter, IMajorRecord, IMajorRecordGetter> > ResolveAllContexts(FormKey formKey, ResolveTarget target = ResolveTarget.Winner)
 {
     if (TryResolveContext(formKey, out var rec, target))
     {
         yield return(rec);
     }
 }
コード例 #26
0
 public IEnumerable <IModContext <TMod, TModGetter, IMajorRecordCommon, IMajorRecordCommonGetter> > ResolveAllContexts(FormKey formKey, ResolveTarget target = ResolveTarget.Winner)
 {
     return(ResolveAllContexts(formKey, typeof(IMajorRecordCommonGetter), target));
 }
コード例 #27
0
 /// <inheritdoc />
 public IEnumerable <TMajor> ResolveAll <TMajor>(FormKey formKey, ResolveTarget target = ResolveTarget.Winner)
     where TMajor : class, IMajorRecordCommonGetter
 {
     return(ResolveAll(formKey, typeof(TMajor), target).Cast <TMajor>());
 }
コード例 #28
0
        /// <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();
            }
        }
コード例 #29
0
 /// <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);
 }
コード例 #30
0
 /// <inheritdoc />
 public bool TryResolveIdentifier(FormKey formKey, [MaybeNullWhen(false)] out string?editorId, ResolveTarget target = ResolveTarget.Winner)
 {
     return(TryResolveIdentifier(formKey, typeof(IMajorRecordCommonGetter), out editorId, target));
 }