当前位置: 首页>>代码示例>>C#>>正文


C# ByteString.ToString方法代码示例

本文整理汇总了C#中ByteString.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ByteString.ToString方法的具体用法?C# ByteString.ToString怎么用?C# ByteString.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteString的用法示例。


在下文中一共展示了ByteString.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMutation

            public async Task<Mutation> GetMutation(ByteString hash)
            {
                Mutation mutation;
                if (!Transactions.TryGetValue(hash, out mutation))
                {
                    string account = $"/asset/{assetName}/out/";
                    string asset = $"/asset/{assetName}/";

                    HttpClient client = new HttpClient();

                    HttpResponseMessage getTransactionResponse = await client.GetAsync(new Uri(openChainUri, $"query/transaction?mutation_hash={hash.ToString()}"));
                    JToken rawTransaction = JToken.Parse(await getTransactionResponse.EnsureSuccessStatusCode().Content.ReadAsStringAsync());

                    Transaction transaction = MessageSerializer.DeserializeTransaction(ByteString.Parse((string)rawTransaction["raw"]));
                    mutation = MessageSerializer.DeserializeMutation(transaction.Mutation);

                    Transactions.Add(hash, mutation);
                }

                return mutation;
            }
开发者ID:openchain,项目名称:sidechain,代码行数:21,代码来源:OpenchainClient.cs

示例2: MoveToRedemption

        public async Task MoveToRedemption(IList<OutboundTransaction> transactions, ByteString btcTransaction)
        {
            List<Record> records = new List<Record>();

            foreach (OutboundTransaction transaction in transactions)
            {
                // TODO: Allow double spending
                records.Add(new Record(
                    key: Encode($"/asset/{assetName}/tx/:DATA:{transaction.Version.ToString()}"),
                    value: Encode(JObject.FromObject(new { transactions = new[] { btcTransaction.ToString() } }).ToString()),
                    version: ByteString.Empty));

                records.Add(new Record(
                    key: transaction.RecordKey,
                    value: ByteString.Empty,
                    version: transaction.Version));
            }

            HttpClient client = new HttpClient();
            ByteString finalKey = Encode($"/asset/{assetName}/final/:ACC:/asset/{assetName}/");
            HttpResponseMessage getValueResponse = await client.GetAsync(new Uri(openChainUri, $"record?key={finalKey.ToString()}"));
            string stringResponse = await getValueResponse.EnsureSuccessStatusCode().Content.ReadAsStringAsync();
            ByteString finalVersion = ByteString.Parse((string)JObject.Parse(stringResponse)["version"]);
            long currentValue = ParseInt(ByteString.Parse((string)JObject.Parse(stringResponse)["value"]));

            records.Add(new Record(
                key: finalKey,
                value: Encode(currentValue + transactions.Sum(transaction => transaction.Amount)),
                version: finalVersion));

            Mutation mutation = new Mutation(Encode(this.openChainUri.ToString()), records, ByteString.Empty);

            byte[] serializedMutation = MessageSerializer.SerializeMutation(mutation);

            await SignAndSubmit(serializedMutation);
        }
开发者ID:openchain,项目名称:sidechain,代码行数:36,代码来源:OpenchainClient.cs

示例3: DecodeRespTextString

 private string DecodeRespTextString(ByteString text)
 {
     /*
        * RFC 5255 - Internet Message Access Protocol Internationalization
        * http://tools.ietf.org/html/rfc5255
        * 3.5. Formal Syntax
        *     resp-text         = ["[" resp-text-code "]" SP ] UTF8-TEXT-CHAR
        *                         *(UTF8-TEXT-CHAR / "[")
        *         ; After the server is changed to a language other than
        *         ; i-default, this resp-text rule replaces the resp-text
        *         ; rule from [RFC3501].
        */
       if (ReceiveResponseAsUTF8)
     return Encoding.UTF8.GetString(text.ByteArray);
       else
     return text.ToString();
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:17,代码来源:ImapResponseReceiver.cs

示例4: GetKeyStartingFrom

 public Task<IReadOnlyList<Record>> GetKeyStartingFrom(ByteString prefix)
 {
     return Task.FromResult((IReadOnlyList<Record>)records.Where(record => record.Key.ToString().StartsWith(prefix.ToString())).ToList());
 }
开发者ID:packetlost,项目名称:openchain,代码行数:4,代码来源:LedgerQueriesExtensionsTests.cs

示例5: ParseResponce

        private ImapResponse ParseResponce(ByteString line, ref IParsingContext parsingContext)
        {
            // response        = *(continue-req / response-data) response-done

              // continue-req    = "+" SP (resp-text / base64) CRLF
              if (line.StartsWith(continueReqMark))
            return new ImapCommandContinuationRequest(line.ToString(2, line.Length - 4)); // remove leading "+" SP and trailing CRLF

              // greeting        = "*" SP (resp-cond-auth / resp-cond-bye) CRLF
              // response-done   = response-tagged / response-fatal
              // response-data   = "*" SP (resp-cond-state / resp-cond-bye /
              //                   mailbox-data / message-data / capability-data) CRLF
              // response-fatal  = "*" SP resp-cond-bye CRLF
              //                     ; Server closes connection immediately
              // response-tagged = tag SP resp-cond-state CRLF

              // ("*" / tag) SP
              var tagSep = line.IndexOf(Octets.SP);

              if (tagSep == -1)
            // response-done and response-data must contain SP
            throw new ImapMalformedResponseException("malformed response-done/response-data", line.ToString());

              var untagged = (tagSep == 1 && line[0] == ImapOctets.Asterisk);

              // ("OK" / "BAD" / "NO" / "BYE" / "PREAUTH" / text) SP
              var respCondSep = line.IndexOf(Octets.SP, tagSep + 1);
              var cond = ImapResponseCondition.Undefined;

              if (respCondSep == -1) {
            if (!untagged)
              throw new ImapMalformedResponseException("malformed response-data", line.ToString());
            //else
              // '* SEARCH\r\n' (mailbox-data which contains no SP)
              }
              else {
            cond = ParseCondition(line.Substring(tagSep + 1, respCondSep - tagSep - 1));
              }

              if (cond != ImapResponseCondition.Undefined || line.StartsWith(respCondMark)) {
            // resp-cond-auth / resp-cond-state / resp-cond-bye
            var responseText = ParseRespText((cond == ImapResponseCondition.Undefined)
                                           ? line.Substring(tagSep + 1)
                                           : line.Substring(respCondSep + 1));

            if (untagged)
              return new ImapUntaggedStatusResponse((ImapResponseCondition)cond,
                                            responseText);
            else
              return new ImapTaggedStatusResponse(line.ToString(0, tagSep),
                                          (ImapResponseCondition)cond,
                                          responseText);
              }

              // mailbox-data / message-data / capability-data etc.
              return ParseDataResponse(line, ref parsingContext);
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:57,代码来源:ImapResponseReceiver.cs

示例6: TestToStringPartial

        public void TestToStringPartial()
        {
            var str = new ByteString("abcdefghi");

              Assert.AreEqual("abcdefghi", str.ToString(0));
              Assert.AreEqual("", str.ToString(0, 0));
              Assert.AreEqual("abc", str.ToString(0, 3));
              Assert.AreEqual("abcdefghi", str.ToString(0, 9));
              Assert.AreEqual("defghi", str.ToString(3));
              Assert.AreEqual("", str.ToString(3, 0));
              Assert.AreEqual("def", str.ToString(3, 3));
              Assert.AreEqual("defghi", str.ToString(3, 6));
              Assert.AreEqual("i", str.ToString(8, 1));
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:14,代码来源:ByteString.cs

示例7: TestToString

        public void TestToString()
        {
            var str = new ByteString(0x61, 0x62, 0x63);

              Assert.AreEqual("abc", str.ToString());
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:6,代码来源:ByteString.cs

示例8: ToString

 public static string ToString(ByteString text)
 {
     return text.ToString();
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:4,代码来源:PopTextConverter.cs

示例9: SubmitTransaction

        private async Task<ByteString> SubmitTransaction(ByteString transaction)
        {
            using (HttpClient client = new HttpClient())
            {
                StringContent content = new StringContent($"\"{transaction.ToString()}\"");
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                HttpResponseMessage response = await client.PostAsync(new Uri(url, "sendrawtransaction"), content);
                response.EnsureSuccessStatusCode();

                JToken result = JToken.Parse(await response.Content.ReadAsStringAsync());
                return ByteString.Parse((string)result);
            }
        }
开发者ID:hellwolf,项目名称:openchain,代码行数:13,代码来源:BlockchainAnchorRecorder.cs


注:本文中的ByteString.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。