Exemplo n.º 1
0
        public static ArchiveInfo fromJson(JsonObject jo)
        {
            try
            {
                ArchiveInfo info = new ArchiveInfo()
                {
                    Name         = jo["name"].ToString(),
                    Domain       = jo["domain"].ToString(),
                    SupportHttp  = Convert.ToBoolean(jo["http"]),
                    SupportHttps = Convert.ToBoolean(jo["https"]),
                    Software     = "foolfuuka" == jo["software"].ToString() ? ArchiverSoftware.FoolFuuka : ArchiverSoftware.Fuuka
                };

                JsonArray boards = (JsonArray)jo["boards"];
                foreach (string b in boards.Cast <string>())
                {
                    info.AddPostBoard(b);
                }

                JsonArray files = (JsonArray)jo["files"];
                foreach (string b in boards.Cast <string>())
                {
                    info.AddFileBoard(b);
                }

                return(info);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        private static IEnumerable <(string Name, string Type, string ClrType, string AsFunction)> GetFields(JsonArray fields)
        {
            foreach (var field in fields.Cast <JsonObject>())
            {
                var fieldName = field.Keys.Single();
                var fieldType = field.Values.Single() as string;

                var clrType = ConvertToClrType(fieldType);
                fieldType = ConvertToFieldType(fieldType);

                var asFunction = $"As{fieldType}()";

                yield return(Name : fieldName, Type : fieldType, ClrType : clrType, AsFunction : asFunction);
            }
        }