예제 #1
0
        public void CharacterSerialization()
        {
            var item = new { V1 = Rng.GetDouble().ToPercent(), V2 = Rng.GetDouble().ToPercent() };
            var json = Jsonizer.Serialize(item);

            Console.WriteLine(json);
            Assert.AreEqual(json, json);
        }
예제 #2
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("offset", Offset, false);
     builder.AddMember("result_count", ResultCount, false);
     builder.AddMember("audience", Audience, false);
     builder.AddMember("language", Language, false);
     builder.AddMember("message", Messages, true);
 }
예제 #3
0
        public void JsonObjectOutput()
        {
            var item = new TestItem2 {
                Amount = Rng.GetDecimal()
            };
            var expected = Jsonizer.Serialize(item, true);
            var actual   = item.ToString();

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
 public override IDictionary <string, VueComponentDefinition[]> ConvertFormToVues(
     IDictionary <string, ContentModifierForm> modifierForm, ApplicationRole datum,
     DatumModifyOperation operation,
     Type datumType)
 {
     if (operation.IsCreateOrUpdateOperation())
     {
         return(new Dictionary <string, VueComponentDefinition[]> {
             [FORM_KEY] = new[] {
                 new VueComponentDefinition {
                     Name = "cms-form-field-hidden",
                     Props = new {
                         valuePath = nameof(RoleDatumModifierForm.Id)
                     }
                 },
                 new VueComponentDefinition {
                     Name = "cms-form-field-text",
                     Props = new {
                         label = "Name",
                         valuePath = nameof(RoleDatumModifierForm.Name)
                     }
                 },
                 new VueComponentDefinition {
                     Name = "cms-form-field-textarea",
                     Props = new {
                         label = "Description",
                         valuePath = nameof(RoleDatumModifierForm.Description)
                     }
                 },
                 new VueComponentDefinition {
                     Name = "cms-form-field-select",
                     Props = new {
                         label = "Permissions",
                         valuePath = nameof(RoleDatumModifierForm.Permissions),
                         isMultiSelect = true,
                         optionsHandlerId = DatumSelectFieldOptionsHandler.HANDLER_ID,
                         optionsHandlerParam = Jsonizer.Convert(new DatumSelectFieldOptionsHandlerParam {
                             DatumTypeId = "permission"
                         })
                     }
                 }
             }
         });
     }
     if (operation.IsDeleteOperation())
     {
         return(new Dictionary <string, VueComponentDefinition[]> {
             [FORM_KEY] = new VueComponentDefinition[] {
                 new VueHtmlWidget("Proceed to delete?")
             }
         });
     }
     return(null);
 }
예제 #5
0
        public void CompareJsonFormatted()
        {
            var expected = Jsonizer.Serialize(Item, true);

            Console.WriteLine($"Expected: {expected}\n");
            var clone  = Jsonizer.Deserialize <TestItem0>(expected);
            var actual = Jsonizer.Serialize(clone, true);

            Console.WriteLine($"  Actual: {actual}\n");
            Assert.AreEqual(expected.GetHashCode(), actual.GetHashCode(), expected.Diff(actual).ToString());
        }
예제 #6
0
        public static string GenerateNewNodeCommand(Type nodeType, string name, Vector2 position, BaseGraphCLIAttributes datas = null)
        {
            string cmd = "NewNode " + nodeType.Name + " \"" + name + "\" (" + (int)position.x + ", " + (int)position.y + ")";

            if (datas != null && datas.Count != 0)
            {
                cmd += " attr=" + Jsonizer.Generate(datas);
            }

            return(cmd);
        }
예제 #7
0
        public void GenerateClassFromJson()
        {
            var json   = "{\"next\":\"https://api.robinhood.com/options/orders/?cursor=cD0yMDE5LTA0LTIyKzE3JTNBMzElM0E1Ni44MjQzNzYlMkIwMCUzQTAw\",\"previous\":null,\"results\":[{\"cancel_url\":null,\"canceled_quantity\":\"0.00000\",\"created_at\":\"2020-02-28T17:55:05.955191Z\",\"direction\":\"credit\",\"id\":\"e2d8dc8d-6637-469c-9b27-61499069d300\",\"legs\":[{\"executions\":[{\"id\":\"5bba6932-93c7-4e77-91ee-c3da36106f73\",\"price\":\"$6.85000000\",\"quantity\":\"2.00000\",\"settlement_date\":\"2020-03-02\",\"timestamp\":\"2020-02-28T21:00:00.059000Z\"},{\"id\":\"c730e53c-eaf8-4b30-b258-344ff7d3bf21\",\"price\":\"$6.85000000\",\"quantity\":\"2.00000\",\"settlement_date\":\"2020-03-02\",\"timestamp\":\"2020-02-28T21:02:17.765000Z\"},{\"id\":\"2da9a6b4-61a8-4726-a42d-e43c68333b0b\",\"price\":\"6.85000000\",\"quantity\":\"6.00000\",\"settlement_date\":\"2020-03-02\",\"timestamp\":\"2020-02-28T21:02:17.773000Z\"},{\"id\":\"e202d522-0eb9-4932-8323-c030368a20eb\",\"price\":\"6.85000000\",\"quantity\":\"2.00000\",\"settlement_date\":\"2020-03-02\",\"timestamp\":\"2020-02-28T21:02:17.609000Z\"}],\"id\":\"c91e3aed-ace2-488b-9cb6-19acc8e64b44\",\"option\":\"https://api.robinhood.com/options/instruments/2de556d4-fde0-43a3-83bf-9ff8aaa41d46/\",\"position_effect\":\"close\",\"ratio_quantity\":1,\"side\":\"sell\"}],\"pending_quantity\":\"0.00000\",\"premium\":\"685.00000000\",\"processed_premium\":\"8220.00000000000000000\",\"price\":\"6.85000000\",\"processed_quantity\":\"12.00000\",\"quantity\":\"12.00000\",\"ref_id\":\"560047e3-a3ee-47a6-858e-17c5cab67bc7\",\"state\":\"filled\",\"time_in_force\":\"gfd\",\"trigger\":\"immediate\",\"type\":\"limit\",\"updated_at\":\"2020-02-28T21:02:18.447276Z\",\"chain_id\":\"c277b118-58d9-4060-8dc5-a3b5898955cb\",\"chain_symbol\":\"SPY\",\"response_category\":\"success\",\"opening_strategy\":null,\"closing_strategy\":\"long_call\",\"stop_price\":null}]}";
            var result = new JsonClassGenerator
            {
                Settings = new JsonClassGeneratorSettings {
                    RootName = "MarketdataOptions"
                }
            }.FromString(json);

            Console.WriteLine(result);
            Console.WriteLine(Jsonizer.Format(json));
        }
예제 #8
0
        public void DiffTest()
        {
            var item     = Jsonizer.DeepCopy(JsonTests.Item);
            var expected = Jsonizer.Serialize(item);

            item.ListDate = Date.Today.AddDays(17);
            var actual = Jsonizer.Serialize(item);
            var diff   = expected.Diff(actual);

            Console.WriteLine(diff);
            Assert.IsTrue(diff.DifferenceFound);
            Assert.IsTrue(diff.Expected.IsNotNullOrWhiteSpace());
            Assert.IsTrue(diff.Actual.IsNotNullOrWhiteSpace());
            Assert.AreNotEqual(diff.Expected, diff.Actual);
        }
예제 #9
0
        public async Task GenerateClassFromJsonUrl()
        {
            using var client = new HttpClient();
            var json = await client.GetStringAsync("https://api.fda.gov/download.json");

            var result = new JsonClassGenerator
            {
                Settings = new JsonClassGeneratorSettings {
                    RootName = "FdaDownloadModel"
                }
            }.FromString(json);

            Console.WriteLine(result);
            Console.WriteLine(Jsonizer.Format(json));
        }
        public static void WellFormatedNewNodeWithPositionAndDataCommand()
        {
            string s = BaseGraphCLI.GenerateNewNodeCommand(typeof(NodePerlinNoise2D), "perlin noise", new Vector2(21, 84), new BaseGraphCLIAttributes {
                { "persistence", 1.4f }, { "octaves", 2 }
            });
            BaseGraphCommand cmd = BaseGraphCLI.Parse(s);

            var parsedAttrs     = Jsonizer.Parse(cmd.attributes);
            var persistenceAttr = parsedAttrs[0];
            var octavesAttr     = parsedAttrs[1];

            Assert.That(persistenceAttr.first == "persistence", "The persistence name expected to be 'persistence' but was '" + persistenceAttr.first + "'");
            Assert.That((float)persistenceAttr.second == 1.4f, "The persistence value expected to be 1.4 but was '" + persistenceAttr.second + "'");
            Assert.That(octavesAttr.first == "octaves", "The octaves name expected to be 'octaves' but was '" + octavesAttr.first + "'");
            Assert.That((int)octavesAttr.second == 2, "The octaves value expected to be 2 but was '" + octavesAttr.second + "'");
        }
예제 #11
0
        public void CompareJsonSerializePerformance()
        {
            var r1    = Benchmark.Run(() => Newtonsoft.Json.JsonConvert.SerializeObject(Item));
            var r2    = Benchmark.Run(() => Utf8Json.JsonSerializer.ToJsonString(Item));
            var r3    = Benchmark.Run(() => System.Text.Json.JsonSerializer.Serialize(Item));
            var r4    = Benchmark.Run(() => Jsonizer.Serialize(Item));
            var stats = new StatsBuilder()
                        .Add(typeof(Newtonsoft.Json.JsonConvert).FullName, r1)
                        .Add(typeof(Utf8Json.JsonSerializer).FullName, r2)
                        .Add(typeof(System.Text.Json.JsonSerializer).FullName, r3)
                        .Add(typeof(Jsonizer).FullName, r4)
                        .ToString();

            Console.WriteLine(stats);
            Assert.IsTrue(r4.PerSecond > r1.PerSecond);
        }
예제 #12
0
        public async Task CompareJsonSerializePerformance()
        {
            var r0 = await Benchmark.Run(() => Jsonizer.Serialize(Item));

            var r1 = await Benchmark.Run(() => Newtonsoft.Json.JsonConvert.SerializeObject(Item));

            var r2 = await Benchmark.Run(() => System.Text.Json.JsonSerializer.Serialize(Item));

            var stats = new StatsBuilder()
                        .Add(typeof(Jsonizer).FullName, r0)
                        .Add(typeof(Newtonsoft.Json.JsonConvert).FullName, r1)
                        .Add(typeof(System.Text.Json.JsonSerializer).FullName, r2)
                        .ToString();

            Console.WriteLine(stats);
            Assert.IsTrue(r0.PerSecond > r1.PerSecond);
        }
예제 #13
0
        static void     CreateNode(BaseGraph graph, BaseGraphCommand command, string inputCommand)
        {
            Vector2  position = command.position;
            BaseNode node     = null;

            //if we receive a CreateNode with input/output graph nodes, we assign them so we don't have multiple inout/output nodes
            if (NodeTypeProvider.inputGraphTypes.Contains(command.nodeType))
            {
                node = graph.inputNode;
            }
            else if (NodeTypeProvider.outputGraphTypes.Contains(command.nodeType))
            {
                node = graph.outputNode;
            }
            else
            {
                node = graph.CreateNewNode(command.nodeType, position);
            }

            //set the position again for input/output nodes
            node.rect.position = position;

            Type nodeType = node.GetType();

            if (!String.IsNullOrEmpty(command.attributes))
            {
                foreach (var attr in Jsonizer.Parse(command.attributes))
                {
                    FieldInfo attrField = nodeType.GetField(attr.first, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

                    if (attrField != null)
                    {
                        attrField.SetValue(node, attr.second);
                    }
                    else
                    {
                        Debug.LogError("Attribute " + attr.first + " can be found in node " + node);
                    }
                }
            }

            node.name = command.name;
        }
예제 #14
0
        public MainWindow()
        {
            Title   = "Input Mapper";
            Content = new Grid
            {
            };

            _input = new InputSimulator();
            _mouse = new HookMouse();
            _init  = Task.Run(async() =>
            {
                var file = new FileInfo("./mappings.json");
                if (file.Exists)
                {
                    using var stream = File.OpenRead("./mappings.json");
                    var mappings     = await Jsonizer.DeserializeAsync <List <InputMapping> >(stream);
                    foreach (var m in mappings)
                    {
                        _mappings.GetOrAdd(m.Trigger).Add(m);
                    }
                }
                _mappings.GetOrAdd(MouseAction.XButton2Up).Add(new InputMapping
                {
                    Trigger             = MouseAction.XButton2Up,
                    Modifiers           = new[] { VirtualKeyCode.CONTROL },
                    Keys                = new[] { VirtualKeyCode.VK_W },
                    IncludedFiles       = new[] { "chrome.exe" },
                    ExcludedWindowNames = new[] { "Play - Stadia" },
                });
                _mappings.GetOrAdd(MouseAction.XButton1Up).Add(new InputMapping
                {
                    Trigger             = MouseAction.XButton1Up,
                    Modifiers           = new[] { VirtualKeyCode.CONTROL, VirtualKeyCode.SHIFT },
                    Keys                = new[] { VirtualKeyCode.LBUTTON },
                    IncludedFiles       = new[] { "chrome.exe" },
                    ExcludedWindowNames = new[] { "Play - Stadia" },
                });
                _mouse.On += _mouse_On;
            });
        }
예제 #15
0
        public static async Task <List <NugetQueryData> > GetPackages(string query)
        {
            var packages = new List <NugetQueryData>();
            var flurl    = "https://azuresearch-usnc.nuget.org/query"
                           .SetQueryParams(new { q = query, take = 0, });
            var json = await flurl.GetStringAsync();

            var       expected  = Jsonizer.Deserialize <NugetQueryResponse>(json).totalHits;
            const int take      = 100;
            var       relevance = expected.ToDouble();

            for (var skip = 0; skip < expected; skip += take)
            {
                json = await flurl.SetQueryParams(new { q = query, skip, take, })
                       .GetStringAsync();

                var response = Jsonizer.Deserialize <NugetQueryResponse>(json);
                foreach (var d in response.data)
                {
                    packages.Add(new NugetQueryData
                    {
                        Id             = d.id,
                        Relevance      = (relevance-- / expected).ToPercentage(),
                        TotalDownloads = d.totalDownloads,
                        Version        = d.version,
                        Verified       = d.verified,
                        Authors        = string.Join(", ", d.authors),
                        Description    = d.description,
                    });
                }
            }
            if (packages.Count != expected)
            {
                throw new Exception($"packages.Count:{packages.Count} != expected:{expected}");
            }
            return(packages);
        }
 public override IDictionary <string, VueComponentDefinition[]> ConvertFormToVues(
     IDictionary <string, ContentModifierForm> modifierForm, ApplicationUser datum,
     DatumModifyOperation operation,
     Type datumType)
 {
     if (operation.IsCreateOrUpdateOperation())
     {
         var vues = new List <VueComponentDefinition>();
         vues.AddRange(new[] {
             new VueComponentDefinition {
                 Name  = "cms-form-field-hidden",
                 Props = new {
                     valuePath = nameof(UserDatumModifierForm.Id)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-text",
                 Props = new {
                     label     = "UserName",
                     valuePath = nameof(UserDatumModifierForm.UserName)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-checkbox",
                 Props = new {
                     label     = "Activated?",
                     valuePath = nameof(UserDatumModifierForm.IsActivated),
                     yesLabel  = "Activated",
                     noLabel   = "Deactivated"
                 }
             }
         });
         if (operation.IsUpdateOperation())
         {
             vues.Add(new VueComponentDefinition {
                 Name  = "cms-form-field-checkbox",
                 Props = new {
                     label     = "Change Password?",
                     valuePath = nameof(UserDatumModifierForm.ChangePassword),
                     helpText  = "Enable this to also change user password when updating data.",
                     yesLabel  = "Change",
                     noLabel   = "Don't Change"
                 }
             });
         }
         vues.AddRange(new[] {
             new VueComponentDefinition {
                 Name  = "cms-form-field-password",
                 Props = new {
                     label     = "Password",
                     valuePath = nameof(UserDatumModifierForm.Password)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-password",
                 Props = new {
                     label     = "Password Confirmation",
                     valuePath = nameof(UserDatumModifierForm.PasswordConfirmation)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-text",
                 Props = new {
                     label     = "Display Name",
                     valuePath = nameof(UserDatumModifierForm.DisplayName)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-file-picker",
                 Props = new {
                     label               = "Photo",
                     valuePath           = nameof(UserDatumModifierForm.PhotoUrl),
                     fileExplorerPageUrl = _urlProv.GenerateManageFileExplorerUrl()
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-text",
                 Props = new {
                     label     = "Email",
                     valuePath = nameof(UserDatumModifierForm.Email)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-checkbox",
                 Props = new {
                     label     = "Email Confirmed?",
                     valuePath = nameof(UserDatumModifierForm.EmailConfirmed),
                     yesLabel  = "Confirmed",
                     noLabel   = "Not Confirmed"
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-text",
                 Props = new {
                     label     = "Phone No.",
                     valuePath = nameof(UserDatumModifierForm.PhoneNumber)
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-checkbox",
                 Props = new {
                     label     = "Phone No. Confirmed?",
                     valuePath = nameof(UserDatumModifierForm.PhoneNumberConfirmed),
                     yesLabel  = "Confirmed",
                     noLabel   = "Not Confirmed"
                 }
             },
             new VueComponentDefinition {
                 Name  = "cms-form-field-select",
                 Props = new {
                     label               = "Roles",
                     valuePath           = nameof(UserDatumModifierForm.RoleIds),
                     isMultiSelect       = true,
                     optionsHandlerId    = DatumSelectFieldOptionsHandler.HANDLER_ID,
                     optionsHandlerParam = Jsonizer.Convert(new DatumSelectFieldOptionsHandlerParam {
                         DatumTypeId = "role",
                         SortInfos   = new[] { Tuple.Create("Name", false) }
                     })
                 }
             }
         });
         return(new Dictionary <string, VueComponentDefinition[]> {
             [FORM_KEY] = vues.ToArray()
         });
     }
     if (operation.IsDeleteOperation())
     {
         return(new Dictionary <string, VueComponentDefinition[]> {
             [FORM_KEY] = new VueComponentDefinition[] {
                 new VueHtmlWidget("Proceed to delete?")
             }
         });
     }
     return(null);
 }
예제 #17
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("meta", Meta, false);
     builder.AddMember("result", Result, true);
 }
예제 #18
0
        public void NonStandardEnumValue()
        {
            var item = Jsonizer.Deserialize <TestItem1>("{\"Type\":\"test/2\"}");

            Assert.AreEqual(TestEnum0.test2, item.Type);
        }
예제 #19
0
        public void NullToNumber()
        {
            var item = Jsonizer.Deserialize <TestItem2>("{\"Amount\":null}");

            Assert.AreEqual(0m, item.Amount);
        }
예제 #20
0
        public string StartProcess(string definitionId, Dictionary <string, object> inputData)
        {
            string ret = null;

            RunProcessTransaction(this.DefaultPersistenceMode, ps =>
            {
                var pd      = this.GetProcessDef(definitionId);
                var pscript = this.GetProcessScriptRuntime(definitionId);

                string instanceId  = Guid.NewGuid().ToString("N");
                ProcessInstance pi = new ProcessInstance
                {
                    InstanceId          = instanceId,
                    ProcessDefinitionId = definitionId,
                    ProcessInstanceId   = instanceId,
                    TaskId = pd.Body.Id
                };
                pi.Activate(ps, pd, pscript);
                ps.TaskPersister.SaveNew(pi);
                log.Info("\n --- Created process {0} instance {1}. Data: {2}", pi.ProcessDefinitionId, pi.InstanceId, Jsonizer.ToJsonString(inputData));
                pi.Enable(inputData);
                pi.Deactivate();
                ps.TaskPersister.Update(pi);
                ret = pi.InstanceId;
            });
            return(ret);
        }
예제 #21
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("audience", Audience, false);
     builder.AddMember("language", Language, false);
     builder.AddMember("message", Messages, true);
 }
예제 #22
0
 public IEnumerable <ContentType> DefineContentTypes()
 {
     yield return(new ContentType(
                      "sample-article",
                      "Sample Article",
                      "A sample article content.",
                      new[] {
         new ContentFieldDefinition("KataKata", typeof(TextField), new TextFieldConfiguration {
             Label = "Title",
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null,
                 ["regex"] = new TextFieldRegexValidatorConfiguration {
                     Pattern = @"^[a-zA-Z0-9\ ]+$"
                 },
                 ["length"] = new TextFieldLengthValidatorConfiguration {
                     MaxLength = 256
                 }
             }
         }),
         new ContentFieldDefinition("IsPowerful", typeof(BooleanField), new BooleanFieldConfiguration {
             Label = "Does it happen?",
             InitialValue = false,
             TrueBoolLabel = "Indeed",
             FalseBoolLabel = "Never",
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null
             }
         }),
         new ContentFieldDefinition("MagicUtc", typeof(ChronoField), new ChronoFieldConfiguration {
             Label = "When It Happen",
             Kind = DateTimeKind.Local,
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null
             }
         }),
         new ContentFieldDefinition("AngkaMantab", typeof(NumberField), new NumberFieldConfiguration {
             Label = "Magic Number",
             DefaultValue = 250,
             NumberKind = NumberValueKind.Integer,
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null,
                 ["range"] = new NumberFieldRangeValidatorConfiguration {
                     MinValue = 100,
                     MaxValue = 1000000
                 }
             }
         }),
         new ContentFieldDefinition("UrlSlug", typeof(FauxUrlSlugField), new FauxUrlSlugFieldConfiguration {
             Label = "URL Slug",
             ContentIdSlugPartLength = 8,
             SlugPattern = "mantab/[###]/[MagicUtc:year]/[MagicUtc:month]/[KataKata:lowercase]"
         }),
         new ContentFieldDefinition("MyStuffs", typeof(SelectField), new SelectFieldConfiguration {
             Label = "My Stuffs",
             IsMultiSelect = true,
             OptionsHandlerId = ContentSelectFieldOptionsHandler.HANDLER_ID,
             OptionsHandlerParam = Jsonizer.Convert(new ContentSelectFieldOptionsHandlerParam {
                 ContentTypeIds = new[] { "sample-article" },
                 SortInfos = new[] { Tuple.Create("KataKata.Val", true) }
             })
         }),
         new ContentFieldDefinition("MyFavArticle", typeof(SelectField), new SelectFieldConfiguration {
             Label = "My Fav Article",
             IsMultiSelect = false,
             OptionsHandlerId = ContentSelectFieldOptionsHandler.HANDLER_ID,
             OptionsHandlerParam = Jsonizer.Convert(new ContentSelectFieldOptionsHandlerParam {
                 ContentTypeIds = new[] { "sample-article" }
             }),
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null
             }
         }),
         new ContentFieldDefinition("File", typeof(FilePickerField), new FilePickerFieldConfiguration {
             Label = "File",
             IsMultiSelect = false,
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null,
                 ["file-extension"] = new FileExtensionValidatorConfiguration {
                     AllowedFileExtensions = new[] { "jpg", "png", "gif" }
                 }
             }
         }),
         new ContentFieldDefinition("Files", typeof(FilePickerField), new FilePickerFieldConfiguration {
             Label = "Files",
             IsMultiSelect = true,
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null,
                 ["file-extension"] = new FileExtensionValidatorConfiguration {
                     AllowedFileExtensions = new[] { "jpg", "png", "gif" }
                 }
             }
         }),
         new ContentFieldDefinition("BestMantapMan", typeof(SelectField), new SelectFieldConfiguration {
             Label = "Best Mantap Man",
             IsMultiSelect = false,
             OptionsHandlerId = DatumSelectFieldOptionsHandler.HANDLER_ID,
             OptionsHandlerParam = Jsonizer.Convert(new DatumSelectFieldOptionsHandlerParam {
                 DatumTypeId = "user",
                 WhereConditions = new[] { Tuple.Create("IsInRole", (object)new[] { "Mantap" }) }
             }),
             Validators = new Dictionary <string, ContentFieldValidatorConfiguration> {
                 ["required"] = null
             }
         })
     },
                      new[] {
         "KataKata"
     },
                      new[] {
         "KataKata",
         "IsPowerful",
         "MagicUtc",
         "AngkaMantab",
         "UrlSlug",
         "MyStuffs",
         "MyFavArticle",
         "File.Val",
         "Files.Val",
         "BestMantapMan",
         $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.IsPublished",
         $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.IsDraft",
         $"{ContentType.FIELD_NAME_TRASH_STATUS}.IsTrashed",
         $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.PublishedAt",
         $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.UnpublishedAt",
         $"{ContentType.FIELD_NAME_COMMON_META}.UpdatedAt",
         $"{ContentType.FIELD_NAME_COMMON_META}.CreatedAt",
         $"{ContentType.FIELD_NAME_COMMON_META}.Id"
     },
                      "KataKata.Val",
                      false,
                      null,
                      null
                      )
     {
         PreModifyOperationFormVues = new GetExtraModifyOperationFormVues[] {
             (contentType, content, operation) => {
                 if (operation.IsCreateOperation())
                 {
                     return new VueComponentDefinition[] {
                         new VueHtmlWidget($"<p class='note note-info'>Let the creating magic happen!</p>")
                     };
                 }
                 if (operation.IsUpdateOperation())
                 {
                     return new VueComponentDefinition[] {
                         new VueHtmlWidget($"<p class='note note-info'>Let the updating magic happen!</p>")
                     };
                 }
                 return null;
             }
         }
     });
 }
예제 #23
0
 public override string ToString()
 {
     return(Jsonizer.ToJsonString(this));
 }
예제 #24
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("id", ID, false);
     builder.AddMember("term", Term, true);
 }
예제 #25
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("result_count", ResultCount, false);
     builder.AddMember("message", Messages, true);
 }
예제 #26
0
 public override string ToString() => Jsonizer.Serialize(this, true);
예제 #27
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("id", ID, false);
     builder.AddMember("matched", MatchedTerm, false);
     builder.AddJsonString("term", TermDetail, true);
 }
예제 #28
0
        public void StringToNumber()
        {
            var item = Jsonizer.Deserialize <TestItem2>("{\"Amount\":\"1234.5678\"}");

            Assert.AreEqual(1234.5678m, item.Amount);
        }
예제 #29
0
 /// <summary>
 /// Hook for storing data members by calling the various AddMember() overloads.
 /// </summary>
 /// <param name="builder">The Jsonizer instance to use for storing data members.</param>
 public void Jsonize(Jsonizer builder)
 {
     builder.AddMember("meta", Meta, false);
     builder.AddJsonString("term", Term, true);
 }
 private ContentSelectFieldOptionsHandlerParam ParseParam(string handlerParam)
 {
     return(Jsonizer.Parse <ContentSelectFieldOptionsHandlerParam>(handlerParam));
 }