• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Amount类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Amount的典型用法代码示例。如果您正苦于以下问题:C# Amount类的具体用法?C# Amount怎么用?C# Amount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Amount类属于命名空间,在下文中一共展示了Amount类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ToString_3

 public void ToString_3()
 {
    var amt = new Amount("usd", -122M);
                          
    Console.WriteLine(amt);    
    Assert.AreEqual("-122:usd", amt.ToString());    
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:7,代码来源:AmountTests.cs


示例2: IngredientUsage

 public IngredientUsage(Ingredient ingredient, IngredientForm form, Amount amount, string prepnote)
 {
     Ingredient = ingredient;
     Form = form;
     Amount = amount;
     PrepNote = prepnote;
 }
开发者ID:TeamSullust,项目名称:Teamwork,代码行数:7,代码来源:IngredientUsage.cs


示例3: RelevantTransaction

        public static bool RelevantTransaction(WalletTransaction tx, Account account, out Amount debit, out Amount credit)
        {
            if (tx == null)
                throw new ArgumentNullException(nameof(tx));

            debit = 0;
            credit = 0;
            var relevant = false;

            foreach (var input in tx.Inputs)
            {
                if (input.PreviousAccount == account)
                {
                    relevant = true;
                    debit -= input.Amount;
                }
            }
            foreach (var output in tx.Outputs)
            {
                var controlledOutput = output as WalletTransaction.Output.ControlledOutput;
                if (controlledOutput?.Account == account)
                {
                    relevant = true;
                    credit += output.Amount;
                }
            }

            return relevant;
        }
开发者ID:btcsuite,项目名称:Paymetheus,代码行数:29,代码来源:Accounting.cs


示例4: IngredientUsage

 public IngredientUsage(Ingredient ingredient, IngredientForm form, Amount amount, string preparationNote)
 {
     this.Ingredient = ingredient;
     this.Form = form;
     this.Amount = amount;
     this.PreparationNote = preparationNote;
 }
开发者ID:Derneuca,项目名称:KitchenPCTeamwork,代码行数:7,代码来源:IngredientUsage.cs


示例5: TestAmounts

        public void TestAmounts()
        {
            var amt1 = new Amount(0.5f, 1f, Units.Teaspoon);
             var amt2 = new Amount(0.75f, Units.Pound);

             //Test equals
             Assert.AreEqual(new Amount(0.5f, 1f, Units.Teaspoon), amt1);
             Assert.AreEqual(new Amount(0.75f, Units.Pound), amt2);

             //Test multiplication
             Assert.AreEqual(new Amount(1f, 2f, Units.Teaspoon), amt1*2);
             Assert.AreEqual(new Amount(1.5f, Units.Pound), amt2*2);

             //Test addition
             Assert.AreEqual(new Amount(2.5f, 3f, Units.Teaspoon), amt1 + 2);
             Assert.AreEqual(new Amount(1f, Units.Pound), amt2 + 0.25f);

             Assert.AreEqual(new Amount(1.5f, 4f, Units.Teaspoon), amt1 + new Amount(1f, 3f, Units.Teaspoon));
             Assert.AreEqual(new Amount(1.5f, 2f, Units.Teaspoon), amt1 + new Amount(1f, Units.Teaspoon));
             Assert.AreEqual(new Amount(1f, Units.Pound), amt2 + new Amount(.25f, Units.Pound));

             //Cross unit addition
             Assert.AreEqual(new Amount(1.5f, 4f, Units.Teaspoon), amt1 + new Amount(.5f, 1f, Units.Tablespoon));
             // Assert.AreEqual(new Amount(3.5f, 4f, Units.Teaspoon), amt1 + new Amount(1f, Units.Tablespoon)); //Adding 3tsp
             Assert.AreEqual(new Amount(1f, Units.Pound), amt2 + new Amount(4f, Units.Ounce));

             //Test division
             Assert.AreEqual(new Amount(.25f, .5f, Units.Teaspoon), amt1/2);
             Assert.AreEqual(new Amount(.25f, Units.Pound), amt2/3);

             //Test subtraction
             Assert.AreEqual(new Amount(.25f, .75f, Units.Teaspoon), amt1 - .25f);
             Assert.AreEqual(new Amount(.25f, Units.Pound), amt2 - 0.50f);
        }
开发者ID:Derneuca,项目名称:KitchenPCTeamwork,代码行数:34,代码来源:Units.cs


示例6: RealExTransactionRequest

 protected RealExTransactionRequest(string secret, string merchantId, string account, string orderId, Amount amount, Card card, Comments comments)
     : base(secret, merchantId, account, orderId, comments)
 {
     SignatureProperties = () => new[] { Amount.Value.ToString(), Amount.Currency.CurrencyName(), Card.Number };
     Amount = amount;
     Card = card;
 }
开发者ID:JonCanning,项目名称:RealEx.NET,代码行数:7,代码来源:RealExTransactionRequest.cs


示例7: AddIngredient

        public IngredientAdder AddIngredient(Ingredient ingredient, Amount amount, string prepNote = null)
        {
            var usage = new IngredientUsage(ingredient, null, amount, prepNote);
            var addedIngredient = this.AddIngredientUsage(usage);

            return addedIngredient;
        }
开发者ID:Team-Makev-High-Quality-Code,项目名称:TEAM--MAKEB--High-Quality-Code-Team-Project,代码行数:7,代码来源:IngredientAdder.cs


示例8: ToString_1

 public void ToString_1()
 {
    var amt = new Amount("usd", 12.45M);
                          
    Console.WriteLine(amt);    
    Assert.AreEqual("12.45:usd", amt.ToString());    
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:7,代码来源:AmountTests.cs


示例9: RealEx3DVerifyRequest

 public RealEx3DVerifyRequest(string secret, string merchantId, string account, string orderId, Amount amount, Card card, string paRes, Comments comments)
     : base(secret, merchantId, account, orderId, amount, card, comments)
 {
     PaRes = paRes;
     Type = "3ds-verifysig";
     IsSecure = true;
 }
开发者ID:JonCanning,项目名称:RealEx.NET,代码行数:7,代码来源:RealEx3DVerifyRequest.cs


示例10: Investment

 public Investment(Investor investor, Venture venture, Amount amount)
 {
     this.investor = investor;
     this.venture = venture;
     this.Value = amount;
     this.venture = venture;
 }
开发者ID:bagheera,项目名称:Gringotts,代码行数:7,代码来源:Investment.cs


示例11: UncontrolledOutput

                public UncontrolledOutput(Amount amount, byte[] pkScript) : base(amount)
                {
                    if (pkScript == null)
                        throw new ArgumentNullException(nameof(pkScript));

                    PkScript = OutputScript.ParseScript(pkScript);
                }
开发者ID:btcsuite,项目名称:Paymetheus,代码行数:7,代码来源:WalletTransaction.cs


示例12: CashWithdrawnEvent

        public CashWithdrawnEvent(Guid id, Balance balance, Amount amount)
        {

            Id = id;
            DateTimeEventOccurred = DateTime.UtcNow;
            Balance = balance;
            Amount = amount;
        }
开发者ID:dpdesi,项目名称:TopmoveApp,代码行数:8,代码来源:CashWithdrawnEvent.cs


示例13: Price

    /// <summary>
    /// Initializes a new instance of the <see cref="Price"/> class.
    /// </summary>
    /// <param name="amount">The amount.</param>
    /// <param name="baseQuantity">The base quantity.</param>
    public Price([NotNull] Amount amount, decimal baseQuantity)
    {
      Assert.ArgumentNotNull(amount, "amount");

      this.amount = amount;
      this.baseQuantity = baseQuantity;
      this.orderableUnitFactorRate = 1;
    }
开发者ID:HydAu,项目名称:sitecore8ecommerce,代码行数:13,代码来源:Price.cs


示例14: ShoppingListItems

 public ShoppingListItems(Guid id, Guid userid, Amount amt, Guid? ingredientId, Guid? recipeId)
 {
     this.ItemId = id;
     this.UserId = userid;
     this.Amount = amt;
     this.Ingredient = ingredientId.HasValue ? Ingredients.FromId(ingredientId.Value) : null;
     this.Recipe = recipeId.HasValue ? Recipes.FromId(recipeId.Value) : null;
 }
开发者ID:Derneuca,项目名称:KitchenPCTeamwork,代码行数:8,代码来源:ShoppingListItems.cs


示例15: UnspentOutput

 public UnspentOutput(Sha256Hash txHash, uint outputIndex, Amount amount, OutputScript pkScript, DateTimeOffset seenTime, bool isFromCoinbase)
 {
     TransactionHash = txHash;
     OutputIndex = outputIndex;
     Amount = amount;
     PkScript = pkScript;
     SeenTime = seenTime;
     IsFromCoinbase = IsFromCoinbase;
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:9,代码来源:UnspentOutput.cs


示例16: DoCalc

 public override ITaxStructured DoCalc(
     TaxSession session,
     IAddress fromAddress, 
     IAddress toAddress, 
     Amount amount, 
     Amount shipping)
 {
   return DoCalc(session as TaxJarSession, fromAddress, toAddress, amount, shipping);
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:9,代码来源:TaxJarCalculator.cs


示例17: WalletTransaction

 public WalletTransaction(Transaction transaction, Sha256Hash hash, Input[] inputs, Output[] outputs, Amount? fee, DateTimeOffset seenTime)
 {
     Hash = hash;
     Inputs = inputs;
     Outputs = outputs;
     Fee = fee;
     Transaction = transaction;
     SeenTime = seenTime;
 }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:9,代码来源:WalletTransaction.cs


示例18: Sum01Test

		public void Sum01Test()
		{
			AmountVector v = new AmountVector(4, LengthUnits.Meter);
			v[0] = new Amount(150m, LengthUnits.Meter);
			v[2] = new Amount(0.2m, LengthUnits.KiloMeter);
			v[3] = new Amount(650m, LengthUnits.Meter);

			Assert.AreEqual(new Amount(1m, LengthUnits.KiloMeter), v.Sum);
		}
开发者ID:codetuner,项目名称:Arebis.Common,代码行数:9,代码来源:UnitAmountVectorTests.cs


示例19: DoCalc

 public override ITaxStructured DoCalc(
     TaxSession session,
     IAddress fromAddress, 
     IAddress toAddress, 
     Amount amount, 
     Amount shipping)
 {
   return TaxStructured.NoneInstance;
 }
开发者ID:PavelTorgashov,项目名称:nfx,代码行数:9,代码来源:NOPTaxCalculator.cs


示例20: BuildUnsignedTransaction

        /// <summary>
        /// Constructs an unsigned transaction by referencing previous unspent outputs.
        /// A change output is added when necessary to return extra value back to the wallet.
        /// </summary>
        /// <param name="outputs">Transaction output array without change.</param>
        /// <param name="changeScript">Output script to pay change to.</param>
        /// <param name="fetchInputsAsync">Input selection source.</param>
        /// <returns>Unsigned transaction and total input amount.</returns>
        /// <exception cref="InsufficientFundsException">Input source was unable to provide enough input value.</exception>
        public static async Task<Tuple<Transaction, Amount>> BuildUnsignedTransaction(Transaction.Output[] outputs,
                                                                                      Amount feePerKb,
                                                                                      InputSource fetchInputsAsync,
                                                                                      ChangeSource fetchChangeAsync)
        {
            if (outputs == null)
                throw new ArgumentNullException(nameof(outputs));
            if (fetchInputsAsync == null)
                throw new ArgumentNullException(nameof(fetchInputsAsync));
            if (fetchChangeAsync == null)
                throw new ArgumentNullException(nameof(fetchChangeAsync));

            var targetAmount = outputs.Sum(o => o.Amount);
            var estimatedSize = Transaction.EstimateSerializeSize(1, outputs, true);
            var targetFee = TransactionFees.FeeForSerializeSize(feePerKb, estimatedSize);

            while (true)
            {
                var funding = await fetchInputsAsync(targetAmount + targetFee);
                var inputAmount = funding.Item1;
                var inputs = funding.Item2;
                if (inputAmount < targetAmount + targetFee)
                {
                    throw new InsufficientFundsException();
                }

                var maxSignedSize = Transaction.EstimateSerializeSize(inputs.Length, outputs, true);
                var maxRequiredFee = TransactionFees.FeeForSerializeSize(feePerKb, maxSignedSize);
                var remainingAmount = inputAmount - targetAmount;
                if (remainingAmount < maxRequiredFee)
                {
                    targetFee = maxRequiredFee;
                    continue;
                }

                var unsignedTransaction = new Transaction(Transaction.SupportedVersion, inputs, outputs, 0, 0);
                var changeAmount = inputAmount - targetAmount - maxRequiredFee;
                if (changeAmount != 0 && !TransactionRules.IsDustAmount(changeAmount, Transaction.PayToPubKeyHashPkScriptSize, feePerKb))
                {
                    var changeScript = await fetchChangeAsync();
                    if (changeScript.Script.Length > Transaction.PayToPubKeyHashPkScriptSize)
                    {
                        throw new Exception("Fee estimation requires change scripts no larger than P2PKH output scripts");
                    }
                    var changeOutput = new Transaction.Output(changeAmount, Transaction.Output.LatestPkScriptVersion, changeScript.Script);

                    var outputList = unsignedTransaction.Outputs.ToList();
                    outputList.Add(changeOutput);
                    var outputsWithChange = outputList.ToArray();

                    unsignedTransaction = new Transaction(unsignedTransaction.Version, unsignedTransaction.Inputs, outputsWithChange,
                        unsignedTransaction.LockTime, unsignedTransaction.Expiry);
                }

                return Tuple.Create(unsignedTransaction, inputAmount);
            }
        }
开发者ID:jrick,项目名称:Paymetheus,代码行数:66,代码来源:TransactionAuthor.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AnItem类代码示例发布时间:2022-05-24
下一篇:
C# AmazonServiceResult类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap