コード例 #1
0
 public bool Parse <T>(
     XElement node,
     out FormLink <T> item,
     ErrorMaskBuilder?errorMask,
     TranslationCrystal?translationMask)
     where T : class, IMajorRecordCommonGetter
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public static MenuItem AsMenuItem(this FormLink formLink, string menuGroup, int orderIndex = 0)
 {
     return(new MenuItem(menuGroup, orderIndex)
     {
         Label = formLink.Label,
         Form = formLink.Form,
         InputFieldValues = formLink.InputFieldValues
     });
 }
コード例 #3
0
        public void FormLink_Direct_ResolveAllContexts_Typed_Empty(LinkCacheTestTypes cacheType, AContextRetriever contextRetriever)
        {
            var formLink = new FormLink <IPlacedGetter>(UnusedFormKey);

            var(style, package) = GetLinkCache(new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE), cacheType);
            WrapPotentialThrow(cacheType, style, () =>
            {
                contextRetriever.ResolveAllContexts <IPlacedGetter, IPlacedNpc, IPlacedNpcGetter>(formLink, package).Should().BeEmpty();
            });
        }
コード例 #4
0
ファイル: Extensions.cs プロジェクト: niaher/inboxy
 public static FormLink WithAction(this FormLink formLink, string action)
 {
     return(new FormLink
     {
         Label = formLink.Label,
         Form = formLink.Form,
         InputFieldValues = formLink.InputFieldValues,
         Action = action
     });
 }
コード例 #5
0
        public void FormLink_Direct_TryResolveContext_DeepRecord_NoLink(LinkCacheTestTypes cacheType, AContextRetriever contextRetriever)
        {
            var formLink = new FormLink <IPlacedNpcGetter>(UnusedFormKey);

            var(style, package) = GetLinkCache(new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE), cacheType);
            WrapPotentialThrow(cacheType, style, () =>
            {
                Assert.False(contextRetriever.TryResolveContext <IPlacedNpc, IPlacedNpcGetter>(formLink, package, out var _));
            });
        }
コード例 #6
0
ファイル: Extensions.cs プロジェクト: niaher/inboxy
 public static Tab AsTab(this FormLink formLink, string style = null)
 {
     return(new Tab
     {
         Form = formLink.Form,
         InputFieldValues = formLink.InputFieldValues,
         Label = formLink.Label,
         Style = style
     });
 }
コード例 #7
0
        public void FormLink_Direct_ResolveContext_MarkerInterface_DeepRecord_NoLink(LinkCacheTestTypes cacheType, AContextRetriever contextRetriever)
        {
            var formLink = new FormLink <IPlacedGetter>(UnusedFormKey);

            var(style, package) = GetLinkCache(new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE), cacheType);
            WrapPotentialThrow(cacheType, style, () =>
            {
                var resolved = contextRetriever.ResolveContext <IPlaced, IPlacedGetter>(formLink, package);
                Assert.Null(resolved);
            });
        }
コード例 #8
0
 public static StyledFormLink WithCssClass(this FormLink formLink, string cssClass)
 {
     return(new StyledFormLink
     {
         Label = formLink.Label,
         Form = formLink.Form,
         InputFieldValues = formLink.InputFieldValues,
         Action = formLink.Action,
         CssClass = cssClass
     });
 }
コード例 #9
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);
        }
コード例 #10
0
        public static string AsUrl(this FormLink link, AppConfig appConfig)
        {
            var param = "";

            foreach (var inputValue in link.InputFieldValues)
            {
                param += $"{inputValue.Key}={inputValue.Value}";
            }

            return($"{appConfig.SiteRoot}/#/form/{link.Form}?" + param);
        }
コード例 #11
0
 private void SetAllowable(bool allowType, FormLink <Keyword> kwyd)
 {
     if (allowType)
     {
         allowedKeywords.Add(kwyd.FormKey);
     }
     else
     {
         disallowedKeywords.Add(kwyd.FormKey);
     }
 }
コード例 #12
0
        public void FormLinkSet_DifferingTypes()
        {
            FormLink <IConstructibleGetter> link1 = new FormLink <IConstructibleGetter>(Utility.Form1);
            FormLink <IWeaponGetter>        link2 = new FormLink <IWeaponGetter>(Utility.Form1);
            HashSet <IFormLinkGetter <IConstructibleGetter> > set = new HashSet <IFormLinkGetter <IConstructibleGetter> >()
            {
                link1,
                link2,
            };

            set.Should().HaveCount(1);
        }
コード例 #13
0
 public static MyFormLink WithCustomUi(this FormLink formLink, string cssClass, string confirmationMessage = null)
 {
     return(new MyFormLink
     {
         Label = formLink.Label,
         Form = formLink.Form,
         InputFieldValues = formLink.InputFieldValues,
         Action = formLink.Action,
         CssClass = cssClass,
         ConfirmationMessage = confirmationMessage
     });
 }
コード例 #14
0
        public void FormLinkSet()
        {
            FormLink <INpcGetter>            link1 = new FormLink <INpcGetter>(Utility.Form1);
            FormLink <INpcGetter>            link2 = new FormLink <INpcGetter>(Utility.Form1);
            HashSet <FormLink <INpcGetter> > set   = new HashSet <FormLink <INpcGetter> >()
            {
                link1,
                link2
            };

            set.Should().HaveCount(1);
        }
コード例 #15
0
        public void FormLink_Direct_Resolve_MarkerInterface(LinkCacheTestTypes cacheType)
        {
            var mod   = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE);
            var spell = mod.Spells.AddNew();

            var(style, package) = GetLinkCache(mod, cacheType);
            var formLink = new FormLink <IEffectRecordGetter>(spell.FormKey);

            WrapPotentialThrow(cacheType, style, () =>
            {
                Assert.Same(spell, formLink.TryResolve(package));
            });
        }
コード例 #16
0
        public void FormLinkEquals_DifferingGetterSetter()
        {
            FormLink <INpcGetter> getter = new FormLink <INpcGetter>(Utility.Form1);
            FormLink <INpc>       setter = new FormLink <INpc>(Utility.Form1);
            FormLink <Npc>        direct = new FormLink <Npc>(Utility.Form1);

            getter.Should().Be(setter);
            getter.Should().Be(direct);
            setter.Should().Be(direct);
            setter.Should().Be(getter);
            direct.Should().Be(getter);
            direct.Should().Be(setter);
        }
コード例 #17
0
 public bool Parse <T>(
     MutagenFrame frame,
     [MaybeNullWhen(false)] out IFormLink <T> item)
     where T : class, IMajorRecordCommonGetter
 {
     if (FormKeyBinaryTranslation.Instance.Parse(frame, out FormKey id))
     {
         item = new FormLink <T>(id);
         return(true);
     }
     item = new FormLink <T>();
     return(false);
 }
コード例 #18
0
        public FormLinkWithRedirect(FormLink self, FormLink redirectTo)
        {
            this.Label            = self.Label;
            this.Form             = self.Form;
            this.InputFieldValues = self.InputFieldValues;
            this.RedirectTo       = redirectTo;

            // Only "run" action supports redirecting to another form after the action was run.
            // This is because other `FormLinkActions` do not actually run the child form and therefore
            // it makes no sense to redirect (e.g. - it makes no sense to redirect after having opened a modal dialog,
            // or after having already redirected to another page with `FormLinkAction.Redirect`).
            this.Action = FormLinkActions.Run;
        }
コード例 #19
0
        public void FormLink_Direct_Resolve_Linked(LinkCacheTestTypes cacheType)
        {
            var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE);
            var npc = mod.Npcs.AddNew();

            var(style, package) = GetLinkCache(mod, cacheType);
            FormLink <INpc> formLink = new FormLink <INpc>(npc.FormKey);

            WrapPotentialThrow(cacheType, style, () =>
            {
                Assert.Same(npc, formLink.TryResolve(package));
            });
        }
コード例 #20
0
        public static T WithRedirect <T>(this T response, FormLink form)
            where T : FormResponse <MyFormResponseMetadata>
        {
            response.Metadata = response.Metadata ?? new MyFormResponseMetadata();
            response.Metadata.FunctionsToRun = response.Metadata.FunctionsToRun ?? new List <ClientFunctionMetadata>();
            var customProperties = new Dictionary <string, object>()
                                   .Set("Form", form.Form)
                                   .Set("InputFieldValues", form.InputFieldValues);
            var clientMetadata = new ClientFunctionMetadata("redirect", customProperties);

            response.Metadata.FunctionsToRun.Add(clientMetadata);

            return(response);
        }
コード例 #21
0
        public void FormLinkSet_DifferingGetterSetter()
        {
            FormLink <INpcGetter> getter = new FormLink <INpcGetter>(Utility.Form1);
            FormLink <INpc>       setter = new FormLink <INpc>(Utility.Form1);
            FormLink <Npc>        direct = new FormLink <Npc>(Utility.Form1);
            HashSet <IFormLinkGetter <INpcGetter> > set = new HashSet <IFormLinkGetter <INpcGetter> >()
            {
                getter,
                setter,
                direct,
            };

            set.Should().HaveCount(1);
        }
コード例 #22
0
        public static FormLink Secure <T>(this FormLink <T> formLink, UserSecurityContext userSecurityContext)
            where T : class
        {
            if (formLink.ContextId != null)
            {
                return(userSecurityContext.CanAccess <T>(formLink.ContextId.Value)
                                        ? formLink
                                        : formLink.AsText());
            }

            return(userSecurityContext.CanAccess <T>()
                                ? formLink
                                : formLink.AsText());
        }
コード例 #23
0
ファイル: FormLinkOutput.cs プロジェクト: UNOPS/uimf-android
        public TextView InitializeLink(FormLink btn, MyFormHandler myFormHandler)
        {
            var text = new TextView(Application.Context)
            {
                Text = btn.Label
            };

            text.Click += async(sender, args) =>
            {
                var formMetadata = myFormHandler.GetFormMetadata(btn.Form);
                myFormHandler.FormWrapper.UpdateView(myFormHandler, new FormParameter(formMetadata, btn.InputFieldValues));
            };
            return(text);
        }
コード例 #24
0
        public void FormLink_Direct_ResolveAll_Linked(LinkCacheTestTypes cacheType)
        {
            var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE);
            var npc = mod.Npcs.AddNew();

            var(style, package) = GetLinkCache(mod, cacheType);
            FormLink <INpc> formLink = new FormLink <INpc>(npc.FormKey);

            WrapPotentialThrow(cacheType, style, () =>
            {
                var resolved = formLink.ResolveAll(package).ToArray();
                resolved.Should().HaveCount(1);
                resolved.First().Should().BeSameAs(npc);
            });
        }
コード例 #25
0
        public Button InitializeActionButton(FormLink btn, MyFormHandler myFormHandler)
        {
            var button = new Button(Application.Context)
            {
                Text = btn.Label
            };

            button.Click += async(sender, args) =>
            {
                var formMetadata = myFormHandler.GetFormMetadata(btn.Form);
                var action       = btn.Action ?? FormLinkActions.OpenModal;
                myFormHandler.FormWrapper.UpdateView(myFormHandler, new FormParameter(formMetadata, btn.InputFieldValues), action);
            };
            return(button);
        }
コード例 #26
0
        public void FormLink_Direct_TryResolveContext_Linked(LinkCacheTestTypes cacheType, AContextRetriever contextRetriever)
        {
            var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE);
            var npc = mod.Npcs.AddNew();

            var(style, package) = GetLinkCache(mod, cacheType);
            var formLink = new FormLink <INpcGetter>(npc.FormKey);

            WrapPotentialThrow(cacheType, style, () =>
            {
                Assert.True(contextRetriever.TryResolveContext <INpc, INpcGetter>(formLink, package, out var linkedRec));
                linkedRec.Record.Should().BeSameAs(npc);
                linkedRec.ModKey.Should().Be(TestConstants.PluginModKey);
                linkedRec.Parent.Should().BeNull();
            });
        }
コード例 #27
0
        public void FormLink_Direct_ResolveContext_MarkerInterface(LinkCacheTestTypes cacheType, AContextRetriever contextRetriever)
        {
            var mod   = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE);
            var spell = mod.Spells.AddNew();

            var(style, package) = GetLinkCache(mod, cacheType);
            var formLink = new FormLink <IEffectRecordGetter>(spell.FormKey);

            WrapPotentialThrow(cacheType, style, () =>
            {
                var resolved = contextRetriever.ResolveContext <IEffectRecord, IEffectRecordGetter>(formLink, package);
                resolved.Record.Should().BeSameAs(spell);
                resolved.ModKey.Should().Be(TestConstants.PluginModKey);
                resolved.Parent.Should().BeNull();
            });
        }
コード例 #28
0
        public void FormLink_Direct_ResolveAllContexts_Linked(LinkCacheTestTypes cacheType, AContextRetriever contextRetriever)
        {
            var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimLE);
            var npc = mod.Npcs.AddNew();

            var(style, package) = GetLinkCache(mod, cacheType);
            var formLink = new FormLink <INpcGetter>(npc.FormKey);

            WrapPotentialThrow(cacheType, style, () =>
            {
                var resolved = contextRetriever.ResolveAllContexts <INpc, INpcGetter>(formLink, package).ToArray();
                resolved.Should().HaveCount(1);
                resolved.First().Record.Should().BeSameAs(npc);
                resolved.First().ModKey.Should().Be(TestConstants.PluginModKey);
                resolved.First().Parent.Should().BeNull();
            });
        }
コード例 #29
0
 public void Write <T>(
     MutagenWriter writer,
     FormLink <T> item,
     RecordType header)
     where T : class, IMajorRecordCommonGetter
 {
     try
     {
         FormKeyBinaryTranslation.Instance.Write(
             writer,
             item.FormKey,
             header);
     }
     catch (Exception ex)
     {
         throw SubrecordException.Enrich(ex, header);
     }
 }
コード例 #30
0
ファイル: ActionListOutput.cs プロジェクト: UNOPS/uimf-ios
        public UIButton InitializeActionButton(FormLink formLink, MyFormHandler myFormHandler, int yAxis)
        {
            var button = new UIButton();

            button.SetTitle(formLink.Label, UIControlState.Normal);
            button.BackgroundColor = UIColor.LightGray;
            var btnSize = new CGSize(UIScreen.MainScreen.Bounds.Width - 60, 40);

            button.Frame = new CGRect(new CGPoint(0, yAxis), btnSize);

            button.TouchUpInside += (sender, args) =>
            {
                var formMetadata = myFormHandler.GetFormMetadataAsync(formLink.Form);
                var action       = formLink.Action ?? FormLinkActions.OpenModal;
                myFormHandler.FormWrapper.UpdateView(myFormHandler, new FormParameter(formMetadata, formLink.InputFieldValues), action);
            };
            return(button);
        }