Exemplo n.º 1
0
        public static void FormLink()
        {
            var mod   = new SkyrimMod(Utility.LightMasterModKey, SkyrimRelease.SkyrimLE);
            var light = mod.Lights.AddNew();
            var cache = mod.ToImmutableLinkCache();

            var link         = new FormLink <ISkyrimMajorRecordGetter>(light.FormKey);
            var nullableLink = new FormLinkNullable <ISkyrimMajorRecordGetter>(light.FormKey);
            IFormLink <ISkyrimMajorRecordGetter> iLink = link;

            // Normal resolution
            link.TryResolve(cache, out var _);
            link.TryResolve(cache, out ISkyrimMajorRecordGetter _);
            link.Resolve(cache);
            link.TryResolve <ILightGetter>(cache, out var _);
            link.TryResolve(cache, out ILightGetter _);
            link.Resolve <ILightGetter>(cache);

            nullableLink.TryResolve(cache, out var _);
            nullableLink.TryResolve(cache, out ISkyrimMajorRecordGetter _);
            nullableLink.Resolve(cache);
            nullableLink.TryResolve <ILightGetter>(cache, out var _);
            nullableLink.TryResolve(cache, out ILightGetter _);
            nullableLink.Resolve <ILightGetter>(cache);

            iLink.TryResolve(cache, out var _);
            iLink.Resolve(cache);
            iLink.TryResolve <ISkyrimMajorRecordGetter, ILightGetter>(cache, out var _);
            iLink.TryResolve(cache, out ILightGetter _);
            iLink.Resolve <ISkyrimMajorRecordGetter, ILightGetter>(cache);

            // Context resolution
            // ToDo
            // Enable when generic querying is supported
            //link.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out var _);
            //link.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out IModContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _);
            //link.ResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache);
            link.TryResolveContext <ISkyrimMod, ILight, ILightGetter>(cache, out var _);
            link.TryResolveContext(cache, out IModContext <ISkyrimMod, ILight, ILightGetter> _);
            link.ResolveContext <ISkyrimMod, ILight, ILightGetter>(cache);

            //nullableLink.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out var _);
            //nullableLink.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache, out IModContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _);
            //nullableLink.ResolveContext<ISkyrimMod, ISkyrimMajorRecord>(cache);
            nullableLink.TryResolveContext <ISkyrimMod, ILight, ILightGetter>(cache, out var _);
            nullableLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ILight, ILightGetter> _);
            nullableLink.ResolveContext <ISkyrimMod, ILight, ILightGetter>(cache);

            //iLink.TryResolveContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _);
            //iLink.ResolveContext<ISkyrimMod, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache);
            iLink.TryResolveContext <ISkyrimMod, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _);
            iLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ILight, ILightGetter> _);
            iLink.ResolveContext <ISkyrimMod, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache);
        }
Exemplo n.º 2
0
        public static void FormLink()
        {
            var mod   = new SkyrimMod(Utility.LightMasterModKey, SkyrimRelease.SkyrimLE);
            var light = mod.Lights.AddNew();
            var cache = mod.ToImmutableLinkCache();

            var link         = new FormLink <ISkyrimMajorRecordGetter>(light.FormKey);
            var nullableLink = new FormLinkNullable <ISkyrimMajorRecordGetter>(light.FormKey);
            IFormLinkGetter <ISkyrimMajorRecordGetter> iLink = link;

            // Normal resolution
            link.TryResolve(cache, out var _);
            link.TryResolve <ISkyrimMajorRecordGetter>(cache, out var _);
            link.Resolve(cache);
            link.TryResolve <ILightGetter>(cache, out var _);
            link.TryResolve(cache, out ILightGetter _);
            link.Resolve <ILightGetter>(cache);

            nullableLink.TryResolve(cache, out var _);
            nullableLink.TryResolve <ISkyrimMajorRecordGetter>(cache, out var _);
            nullableLink.Resolve(cache);
            nullableLink.TryResolve <ILightGetter>(cache, out var _);
            nullableLink.TryResolve(cache, out ILightGetter _);
            nullableLink.Resolve <ILightGetter>(cache);

            iLink.TryResolve(cache, out var _);
            iLink.Resolve(cache);
            iLink.TryResolve <ISkyrimMajorRecordGetter, ILightGetter>(cache, out var _);
            iLink.TryResolve(cache, out ILightGetter _);
            iLink.Resolve <ISkyrimMajorRecordGetter, ILightGetter>(cache);

            // Context resolution
            link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _);
            link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _);
            link.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache);
            link.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _);
            link.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _);
            link.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache);

            nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _);
            nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter> _);
            nullableLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache);
            nullableLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _);
            nullableLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _);
            nullableLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache);

            iLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache, out var _);
            iLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecord, ISkyrimMajorRecordGetter>(cache);
            iLink.TryResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache, out var _);
            iLink.TryResolveContext(cache, out IModContext <ISkyrimMod, ISkyrimModGetter, ILight, ILightGetter> _);
            iLink.ResolveContext <ISkyrimMod, ISkyrimModGetter, ISkyrimMajorRecordGetter, ILight, ILightGetter>(cache);

            // Getter interface conversion
            IPerkGetter             getter   = new Perk(Utility.Form1, SkyrimRelease.SkyrimLE);
            Perk                    direct   = new Perk(Utility.Form2, SkyrimRelease.SkyrimLE);
            IPerk                   setter   = new Perk(Utility.Form2, SkyrimRelease.SkyrimLE);
            IFormLink <IPerkGetter> formLink = new FormLink <IPerkGetter>();

            formLink = getter.AsLink();
            formLink = direct.AsLink();
            formLink = setter.AsLink();
            formLink.SetTo(direct);
            formLink.SetTo(getter);
            formLink.SetTo(setter);
            formLink.SetTo(formLink);

            IObjectEffectGetter             objGetter = null !;
            IFormLink <IEffectRecordGetter> aLink     = new FormLink <IEffectRecordGetter>();

            aLink.SetTo(objGetter);

            IFormLink <ISkyrimMajorRecordGetter> majRecordLink = new FormLink <ISkyrimMajorRecordGetter>();
            IFormLink <IKeywordGetter>           keywordLink   = new FormLink <IKeywordGetter>();

            majRecordLink.SetTo(keywordLink);
            majRecordLink.TryResolve <IKeywordGetter>(cache, out var keyw);
        }