Example #1
0
 /// <summary>
 /// Parse ContractPermission from json
 /// </summary>
 /// <param name="json">Json</param>
 /// <returns>Return ContractPermission</returns>
 public static ContractPermission FromJson(JObject json)
 {
     return(new ContractPermission
     {
         Contract = ContractPermissionDescriptor.FromJson(json["contract"]),
         Methods = WildcardContainer <string> .FromJson(json["methods"], u => u.AsString()),
     });
 }
Example #2
0
        /// <summary>
        /// Parse ContractPermission from json
        /// </summary>
        /// <param name="json">Json</param>
        /// <returns>Return ContractPermission</returns>
        public static ContractPermission FromJson(JObject json)
        {
            ContractPermission permission = new ContractPermission
            {
                Contract = ContractPermissionDescriptor.FromJson(json["contract"]),
                Methods  = WildcardContainer <string> .FromJson(json["methods"], u => u.GetString()),
            };

            if (permission.Methods.Any(p => string.IsNullOrEmpty(p)))
            {
                throw new FormatException();
            }
            _ = permission.Methods.ToDictionary(p => p);
            return(permission);
        }