Example #1
0
        public static ItemStringTemplate Parse(int id, IDataProperty property)
        {
            var t = new ItemStringTemplate {
                ID = id
            };

            property.Resolve(p =>
            {
                t.Name = p.ResolveOrDefault <string>("name") ?? "NO-NAME";
                //t.Desc = p.ResolveOrDefault<string>("desc");
            });
            return(t);
        }
Example #2
0
        public override Task LoadAll()
        {
            var property = Collection.Resolve("String");

            property.Resolve(p =>
            {
                p.Resolve("Eqp.img/Eqp").Children
                .SelectMany(c => c.Children)
                .DistinctBy(c => c.Name)
                .Where(c => c.Name.All(char.IsDigit))
                .ToDictionary(
                    c => Convert.ToInt32(c.Name),
                    c => ItemStringTemplate.Parse(Convert.ToInt32(c.Name), c)
                    )
                .ForEach(kv => Templates.Add(kv.Key, kv.Value));
                p.Resolve("Etc.img/Etc").Children
                .DistinctBy(c => c.Name)
                .Where(c => c.Name.All(char.IsDigit))
                .ToDictionary(
                    c => Convert.ToInt32(c.Name),
                    c => ItemStringTemplate.Parse(Convert.ToInt32(c.Name), c)
                    )
                .ForEach(kv => Templates.Add(kv.Key, kv.Value));
                new[] { "Consume", "Ins", "Cash" }.ForEach(d =>
                {
                    p.Resolve($"{d}.img").Children
                    .DistinctBy(c => c.Name)
                    .Where(c => c.Name.All(char.IsDigit))
                    .ToDictionary(
                        c => Convert.ToInt32(c.Name),
                        c => ItemStringTemplate.Parse(Convert.ToInt32(c.Name), c)
                        )
                    .ForEach(kv => Templates.Add(kv.Key, kv.Value));
                });
            });
            return(Task.CompletedTask);
        }