Ejemplo n.º 1
0
 public BlittableJsonDocumentBuilder(JsonOperationContext context, JsonParserState state, IJsonParser reader, BlittableWriter <UnmanagedWriteBuffer> writer = null)
 {
     _context = context;
     _state   = state;
     _reader  = reader;
     _writer  = writer ?? new BlittableWriter <UnmanagedWriteBuffer>(context);
 }
Ejemplo n.º 2
0
 public BomClient(IDataSource dataSourceReader, IBomRainFallService bomRainFallService, IJsonParser jsonParser, ILogger <BomClient> logger)
 {
     _dataSourceReader   = dataSourceReader;
     _bomRainFallService = bomRainFallService;
     _jsonParser         = jsonParser;
     _logger             = logger;
 }
Ejemplo n.º 3
0
        public void TestParseBasicJsonString()
        {
            IJsonParser jsonParser = this.GetJsonParserInstance();

            IJsonNode jsonNode = jsonParser.Parse(this.basicJson);

            Assert.IsNull(jsonNode.Key);

            Assert.IsTrue(jsonNode.KeyExists("id"));
            Assert.IsTrue(jsonNode["id"].IsString());
            Assert.AreEqual <string>("91939", (string)jsonNode["id"].InnerValue);
            Assert.AreEqual <Type>(typeof(string), jsonNode["id"].InnerType);

            Assert.IsTrue(jsonNode.KeyExists("name"));
            Assert.IsTrue(jsonNode["name"].IsString());
            Assert.AreEqual <string>("Bruce Wayne", (string)jsonNode["name"].InnerValue);
            Assert.AreEqual <Type>(typeof(string), jsonNode["name"].InnerType);

            Assert.IsTrue(jsonNode.KeyExists("p4ssw@rd"));
            Assert.IsTrue(jsonNode["p4ssw@rd"].IsString());
            Assert.AreEqual <string>("Th4D4rkKn!ghtR3turns", (string)jsonNode["p4ssw@rd"].InnerValue);
            Assert.AreEqual <Type>(typeof(string), jsonNode["p4ssw@rd"].InnerType);

            Assert.IsTrue(jsonNode.KeyExists("info"));
            Assert.IsTrue(jsonNode["info"].IsString());
            Assert.AreEqual <string>("\\\"You don\'t get it son. This isn\'t a mudhole . . . it\'s an operating table . . . And I\'m the surgeon.\\\"", (string)jsonNode["info"].InnerValue);
            Assert.AreEqual <Type>(typeof(string), jsonNode["info"].InnerType);
        }
Ejemplo n.º 4
0
        public static ItemModel GetItemModelFromCatalogItem(string itemId, string itemClass, string displayName, string description,
                                                            string customData, IJsonParser jsonParser)
        {
            ItemModel itemModel = null;

            PlayFabItemClass playFabItemClass = (PlayFabItemClass)Enum.Parse(typeof(PlayFabItemClass), itemClass);

            switch (playFabItemClass)
            {
            case PlayFabItemClass.Ability: itemModel = parseAbilityItemModel(customData, jsonParser); break;

            case PlayFabItemClass.Equipment: itemModel = parseEquipmentItemModel(customData, jsonParser); break;
            }

            if (itemModel != null)
            {
                itemModel.ID          = int.Parse(itemId);
                itemModel.Name        = displayName;
                itemModel.Description = description;
                ItemModelRaw itemModelRaw = jsonParser.DeserializeObject <ItemModelRaw>(customData);
                itemModelRaw.ApplyToItemModel(itemModel);
            }

            return(itemModel);
        }
Ejemplo n.º 5
0
            public override IEnumerable <KeyValuePair <string, string> > GetFields(IJsonParser jsonParser)
            {
                yield return(new KeyValuePair <string, string>("mch_billno", mch_billno));

                yield return(new KeyValuePair <string, string>("send_name", send_name));

                yield return(new KeyValuePair <string, string>("re_openid", re_openid));

                yield return(new KeyValuePair <string, string>("total_amount", $"{total_amount:D}"));

                yield return(new KeyValuePair <string, string>("total_num", $"{total_num:D}"));

                yield return(new KeyValuePair <string, string>("wishing", wishing));

                yield return(new KeyValuePair <string, string>("client_ip", client_ip));

                yield return(new KeyValuePair <string, string>("act_name", act_name));

                yield return(new KeyValuePair <string, string>("remark", remark));

                yield return(new KeyValuePair <string, string>("scene_id", $"{scene_id:G}"));

                yield return(new KeyValuePair <string, string>("risk_info", $"{risk_info}"));

                yield return(new KeyValuePair <string, string>("consume_mch_id", consume_mch_id));
            }
Ejemplo n.º 6
0
            public override IEnumerable <KeyValuePair <string, string> > GetFields(IJsonParser jsonParser)
            {
                yield return(new KeyValuePair <string, string>("device_info", device_info));

                yield return(new KeyValuePair <string, string>("body", body));

                yield return(new KeyValuePair <string, string>("detail", detail?.goods_detail?.Length > 0 ? jsonParser.ToString(detail) : null));

                yield return(new KeyValuePair <string, string>("attach", attach));

                yield return(new KeyValuePair <string, string>("out_trade_no", out_trade_no));

                yield return(new KeyValuePair <string, string>("fee_type", fee_type.Code));

                yield return(new KeyValuePair <string, string>("total_fee", total_fee.ToString("D")));

                yield return(new KeyValuePair <string, string>("spbill_create_ip", spbill_create_ip));

                yield return(new KeyValuePair <string, string>("time_start", time_start.ToString("yyyy-MM-dd")));

                yield return(new KeyValuePair <string, string>("time_expire", time_expire.ToString("yyyy-MM-dd")));

                yield return(new KeyValuePair <string, string>("goods_tag", goods_tag));

                yield return(new KeyValuePair <string, string>("notify_url", notify_url));

                yield return(new KeyValuePair <string, string>("trade_type", trade_type.ToString("g")));

                yield return(new KeyValuePair <string, string>("product_id", product_id));

                yield return(new KeyValuePair <string, string>("limit_pay", limit_pay?.ToString("g")));

                yield return(new KeyValuePair <string, string>("openid", openid));
            }
Ejemplo n.º 7
0
 public AccountRequestAccess(
     IFileReaderWrapper fileReaderWrapper,
     IJsonParser jsonParser)
 {
     this.JsonParser        = jsonParser;
     this.FileReaderWrapper = fileReaderWrapper;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RequestService"/> class.
        /// </summary>
        /// <param name="httpClient">
        /// The HTTP client
        /// </param>
        /// <param name="jsonParser">
        /// The json parser
        /// </param>
        /// <param name="attributeReader">
        /// The attribute reader.
        /// </param>
        /// <param name="informationProvider">
        /// The information provider.
        /// </param>
        public RequestService(
            IHttpClient httpClient,
            IJsonParser jsonParser,
            IAttributeReader attributeReader,
            IInformationProvider informationProvider)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }

            if (jsonParser == null)
            {
                throw new ArgumentNullException(nameof(jsonParser));
            }

            if (attributeReader == null)
            {
                throw new ArgumentNullException(nameof(attributeReader));
            }

            if (informationProvider == null)
            {
                throw new ArgumentNullException(nameof(informationProvider));
            }

            this.httpClient          = httpClient;
            this.jsonParser          = jsonParser;
            this.attributeReader     = attributeReader;
            this.informationProvider = informationProvider;
        }
        private unsafe bool AboutToReadPropertyNameInternal(IJsonParser reader, JsonParserState state)
        {
            if (_state != State.None)
            {
                if (!AboutToReadWithStateUnlikely(reader, state))
                    return false;
            }

            _state = State.None;

            while (true)
            {
                if (reader.Read() == false)
                    return false;

                if (state.CurrentTokenType != JsonParserToken.String)
                    return true; // let the caller handle that

                if (_readingMetadataObject == false)
                {
                    if (state.StringSize == 9 && state.StringBuffer[0] == (byte)'@' && *(long*)(state.StringBuffer + 1) == 7022344802737087853)
                        _readingMetadataObject = true;

                    return true;
                }

                if (AboutToReadPropertyNameInMetadataUnlikely(reader, state, out bool aboutToReadPropertyName))
                    return aboutToReadPropertyName;
            }
        }
Ejemplo n.º 10
0
        private static AbilityItemModel parseAbilityItemModel(string customData, IJsonParser jsonParser)
        {
            AbilityItemModel    abilityItemModel    = new AbilityItemModel();
            AbilityItemModelRaw abilityItemModelRaw = jsonParser.DeserializeObject <AbilityItemModelRaw>(customData);

            abilityItemModelRaw.ApplyToAbilityItemModel(abilityItemModel, jsonParser);
            return(abilityItemModel);
        }
Ejemplo n.º 11
0
 public Requester(string appid, string mch_id, string key, X509Certificate2 cert, IJsonParser jsonParser)
 {
     _appid      = appid;
     _mch_id     = mch_id;
     _key        = key;
     _cert       = cert;
     _jsonParser = jsonParser;
 }
Ejemplo n.º 12
0
 public ScheduleDataProvider(IJsonParser jsonParser
                             , IJsonRepository jsonRepository
                             , IRESTfulURLProvider urlProvider)
 {
     this.jsonParser     = jsonParser;
     this.jsonRepository = jsonRepository;
     this.urlProvider    = urlProvider;
 }
        private void InitializeFakeObjects()
        {
            _schemaStoreStub = new Mock <ISchemaStore>();
            var parser = new RepresentationRequestParser(_schemaStoreStub.Object);

            _requestParser = parser;
            _jsonParser    = parser;
        }
 public BatchCreateTaskOperationHandler(IEnumerable <IContentParser <IEnumerable <TaskDto> > > contentParser,
                                        IEnumerable <IEnricher <TaskDto> > enrichers,
                                        IValidator <TaskDto> validator,
                                        IDomainRepository <Task> repository,
                                        IWorkerOperationStatusRepository workerOperationStatusRepository,
                                        ILogger <BatchCreateTaskOperationHandler> logger,
                                        IJsonParser parser)
     : base(contentParser, enrichers, validator, repository, workerOperationStatusRepository, logger) => this.parser = parser;
Ejemplo n.º 15
0
        private static ItemModel parseEquipmentItemModel(string customData, IJsonParser jsonParser)
        {
            EquipmentItemModel    equipmentItemModel    = new EquipmentItemModel();
            EquipmentItemModelRaw equipmentItemModelRaw = jsonParser.DeserializeObject <EquipmentItemModelRaw>(customData);

            equipmentItemModelRaw.ApplyToEquipmentItemModel(equipmentItemModel);
            return(equipmentItemModel);
        }
 public NumericSpecificationExpression(IJsonParser jsonParser,
     ArithmeticExpression leftArithmeticExpression,
     ArithmeticExpression rightArithmeticExpression)
     : base(jsonParser)
 {
     this.leftArithmeticExpression = leftArithmeticExpression;
     this.rightArithmeticExpression = rightArithmeticExpression;
 }
Ejemplo n.º 17
0
 public InformationProvider(IOperationProvider operationProvider, IHttpClient httpClient, IJsonParser jsonParser)
 {
     IsCacheEmtpy = true;
     FullyLoadApiInformationCache = true; //add config and read this from it.
     this._operationProvider      = operationProvider;
     _httpClient = httpClient;
     _jsonParser = jsonParser;
 }
Ejemplo n.º 18
0
 public CardRepository(
     ITrelloConfiguration trelloConfiguration,
     ITrelloGateway trelloGateway,
     IJsonParser jsonParser)
 {
     _trelloConfiguration = trelloConfiguration;
     _trelloGateway       = trelloGateway;
     _jsonParser          = jsonParser;
 }
Ejemplo n.º 19
0
 public CardRepository(
     ITrelloConfiguration trelloConfiguration, 
     ITrelloGateway trelloGateway, 
     IJsonParser jsonParser)
 {
     _trelloConfiguration = trelloConfiguration;
     _trelloGateway = trelloGateway;
     _jsonParser = jsonParser;
 }
Ejemplo n.º 20
0
 public BlittableJsonDocumentBuilder(
     JsonOperationContext context,
     UsageMode mode, string debugTag,
     IJsonParser reader, JsonParserState state,
     BlittableWriter <UnmanagedWriteBuffer> writer = null,
     IBlittableDocumentModifier modifier           = null) : this(context, state, reader, writer, modifier)
 {
     Renew(debugTag, mode);
 }
 public BlittableJsonDocumentBuilder(JsonOperationContext context, UsageMode mode, string debugTag, IJsonParser reader, JsonParserState state)
 {
     _reader   = reader;
     _debugTag = debugTag;
     _stream   = context.GetStream();
     _context  = context;
     _mode     = mode;
     _state    = state;
 }
        public bool AboutToReadPropertyName(IJsonParser reader, JsonParserState state)
        {
            if (reader is UnmanagedJsonParser)
                return AboutToReadPropertyNameInternal((UnmanagedJsonParser)reader, state);
            if (reader is ObjectJsonParser)
                return AboutToReadPropertyNameInternal((ObjectJsonParser)reader, state);

            return AboutToReadPropertyNameInternal(reader, state);
        }
        public void Setup()
        {
            RestClient = MockRepository.GenerateMock<IRestClient>();
            RestClient.Stub(r => r.GetResponse(string.Empty)).IgnoreArguments().Return(_jsonData);

            JsonParser = MockRepository.GenerateStub<IJsonParser>();
            JsonParser.Stub(j => j.Parse(_jsonData)).Return(new List<Tweet> {new Tweet()});

            Searcher = new TwitterSearcher(RestClient, JsonParser);
        }
Ejemplo n.º 24
0
        private DocumentFlags ReadFlags(JsonParserState state, IJsonParser reader)
        {
            var str = CreateLazyStringValueFromParserState(state);

            if (Enum.TryParse(str, true, out DocumentFlags flags) == false)
            {
                ThrowInvalidFlagsProperty(str, reader);
            }
            return(flags);
        }
Ejemplo n.º 25
0
            public override IEnumerable <KeyValuePair <string, string> > GetFields(IJsonParser jsonParser)
            {
                yield return(new KeyValuePair <string, string>("transaction_id", transaction_id));

                yield return(new KeyValuePair <string, string>("out_trade_no", out_trade_no));

                yield return(new KeyValuePair <string, string>("out_refund_no", out_refund_no));

                yield return(new KeyValuePair <string, string>("refund_id", refund_id));
            }
Ejemplo n.º 26
0
            public override IEnumerable <KeyValuePair <string, string> > GetFields(IJsonParser jsonParser)
            {
                yield return(new KeyValuePair <string, string>("device_info", device_info));

                yield return(new KeyValuePair <string, string>("bill_date", bill_date.ToString("yyyyMMdd")));

                yield return(new KeyValuePair <string, string>("bill_type", bill_type.ToString("G")));

                yield return(new KeyValuePair <string, string>("tar_type", tar_type?.ToString("G")));
            }
        private unsafe DateTime ReadDateTime(JsonParserState jsonParserState, IJsonParser reader, State state)
        {
            var str = CreateLazyStringValueFromParserState(jsonParserState);

            var result = LazyStringParser.TryParseDateTime(str.Buffer, str.Size, out DateTime dt, out DateTimeOffset _);
            if (result != LazyStringParser.Result.DateTime)
                ThrowInvalidLastModifiedProperty(state, str, reader);

            return dt;
        }
Ejemplo n.º 28
0
        public IJsonParser CreateJsonParser(ParserType parserType)
        {
            IJsonParser parser = _parsers.GetValueOrDefault(parserType);

            if (parser == null)
            {
                throw new Exception("Parser Not Found!");
            }

            return(parser);
        }
Ejemplo n.º 29
0
        public void TestInitialize()
        {
            this.jsonParser     = new JsonParser();
            this.jsonRepository = new JsonRepository();
            this.urlProvider    = new RESTfulURLProvider();

            this.dataProvider = new ScheduleDataProvider(this.jsonParser
                                                         , this.jsonRepository
                                                         , this.urlProvider
                                                         );
        }
Ejemplo n.º 30
0
 public ProtocolProcessor(
     IJsonParser jsonParser,
     IHttpMetricFactory metricFactory,
     HttpRouteOptions routeOptions,
     ILogger logger)
 {
     this._jsonParser    = jsonParser;
     this._metricFactory = metricFactory;
     this._logger        = logger;
     this._routeOptions  = routeOptions;
 }
Ejemplo n.º 31
0
 public JsonProcessorConsumer(
     IFileWriter writer,
     IJsonParser jsonParser,
     IConfiguration configuration,
     ILogger logger)
 {
     this._writer     = writer;
     this._jsonParser = jsonParser;
     this._logger     = logger;
     this._fileName   = configuration.JsonFileName;
 }
            public override IEnumerable <KeyValuePair <string, string> > GetFields(IJsonParser jsonParser)
            {
                yield return(new KeyValuePair <string, string>("coupon_stock_id", coupon_stock_id));

                yield return(new KeyValuePair <string, string>("op_user_id", op_user_id));

                yield return(new KeyValuePair <string, string>("device_info", device_info));

                yield return(new KeyValuePair <string, string>("version", version));

                yield return(new KeyValuePair <string, string>("type", type));
            }
Ejemplo n.º 33
0
        public Command(IYamlParser yamlParser, IJsonParser jsonParser, IResolver resolver,
                       IFormatter formatter, IFuncs funcs, ISimulator simulator)
        {
            this.yamlParser = yamlParser;
            this.jsonParser = jsonParser;
            this.resolver   = resolver;
            this.formatter  = formatter;
            this.funcs      = funcs;
            this.simulator  = simulator;

            IsAdminMode = false;
        }
Ejemplo n.º 34
0
 public JsonRequestBodyBindingSource(IRequest request, IJsonParser jsonParser)
 {
     this.request = request;
     this.jsonParser = jsonParser;
 }
 public RuleSetCompiler(IJsonParser jsonParser)
 {
     this.jsonParser = jsonParser;
 }
 public TwitterSearcher()
 {
     _restClient = new RestClient();
     _jsonParser = new JsonParser();
 }
 public TwitterSearcher(IRestClient restClient, IJsonParser jsonParser)
 {
     _restClient = restClient;
     _jsonParser = jsonParser;
 }
 public OrSpecification(IJsonParser jsonParser, ISpecification left, ISpecification right)
     : base(jsonParser)
 {
     this.leftSpecification = left;
     this.rightSpecification = right;
 }
Ejemplo n.º 39
0
 public StringContains(IJsonParser jsonParser, string jsonPathExpression, string value)
     : base(jsonParser, jsonPathExpression, value)
 {
 }
 public StringSpecificationExpression(IJsonParser jsonParser, string jsonPathExpression, string value)
     : base(jsonParser)
 {
     this.jsonPathExpression = jsonPathExpression;
     this.value = value;
 }
 public CompositeSpecification(IJsonParser jsonParser)
 {
     this.jsonParser = jsonParser;
 }
Ejemplo n.º 42
0
 public GreaterThan(IJsonParser jsonParser,
     ArithmeticExpression left,
     ArithmeticExpression right)
     : base(jsonParser, left, right)
 {
 }
Ejemplo n.º 43
0
 /// <summary>
 /// 注册自定义的JsonParser
 /// 实现IJsonParser,然后调用该方法。即可以实现自己的JSON序列化的功能。
 /// </summary>
 /// <param name="parser">parser</param>
 internal static void register(IJsonParser parser)
 {
     JsonAdapter.JSON = parser;
 }
Ejemplo n.º 44
0
 public WeatherService(IWeatherDataProviderFactory factory, IJsonParser parser)
 {
     this._factory = factory;
     this._parser = parser;
 }
 public RuleSetTreeBuilder(IJsonParser jsonPathParser)
 {
     this.jsonPathParser = jsonPathParser;
     this.arithmeticExpressions = looseArithmeticExpressions;
 }
 public ArrayIncludeOne(IJsonParser jsonParser, string jsonPathExpression, List<string> values)
     : base(jsonParser)
 {
     this.jsonPathExpression = jsonPathExpression;
     this.values = values;
 }
 public TotalFromJsonPathExpression(IJsonParser jsonParser, string jsonPathExpression)
 {
     this.jsonParser = jsonParser;
     this.jsonPathExpression = jsonPathExpression;
 }
Ejemplo n.º 48
0
 public NumericField(IJsonParser jsonParser, string jsonPathExpression)
 {
     this.parser = jsonParser;
     this.jsonPathExpression = jsonPathExpression;
 }
 public NotSpecification(IJsonParser jsonParser, ISpecification specification)
     : base(jsonParser)
 {
     this.specification = specification;
 }