示例#1
0
        public void ShowMenu()
        {
            bool showMenu = true;

            while (showMenu)
            {
                PrintMenu();
                bool converted = Int32.TryParse(Console.ReadLine(), out int input);

                if (converted && input <= 0)
                {
                    showMenu = false;
                }
                else if (converted && input <= bankStrings.Count)
                {
                    IBank bankInstance = CreateBank(input);
                    if (bankInstance != null)
                    {
                        ShowInstanceMenu(bankInstance);
                    }
                    else
                    {
                        Console.WriteLine("Bank Account failed to be created");
                    }
                }
            }
        }
示例#2
0
 private Builder(Option <Currency> currency, Option <decimal> distributionUnit, Option <IRoundingStrategy> roundingStrategy, IBank bank)
 {
     _targetCurrency   = currency;
     _distributionUnit = distributionUnit;
     _roundingStrategy = roundingStrategy;
     _bank             = bank;
 }
        public void BankStatementDownload()
        {
            // You need to get your own bank details into an IBank object.
            IBank bank = GetMyBankInfo();
            // You need to get your own account details into an IAccount object.
            IAccount account = GetMyAccountInfo();

            OfxRequestBuilder builder = OfxFactory.Builder.Create();

            builder.BuildOfxRequest(() =>
            {
                builder.Signon.BuildMessageSet(bank);

                builder.Bank.BuildMessageSet(() =>
                {
                    // in your app, you'd have to determine an appropiate date to start with.
                    DateTime fromDate = new DateTime(2018, 1, 1);
                    builder.Bank.BuildStatementRequest(account, fromDate, null, true);
                    // add another statement request if you've got another account at the same bank
                });
            });

            // Send request to the bank and get the response
            string response = GetResponseFromBank(builder.RequestText);

            // Transform response string. Ready to go.
            OfxResponse ofx = OfxFactory.Response.Create(response);
        }
示例#4
0
 private void PrintBankOperations(IBank targetBank)
 {
     Console.WriteLine(targetBank.ToString());
     Console.WriteLine("0. Exit");
     Console.WriteLine("1. Send Money");
     Console.WriteLine("2. Balance");
 }
示例#5
0
        static void Main(string[] args)
        {
            //Account account = new Account();
            //IBank<Account> ordinaryBank = new Bank<Account>();
            //ordinaryBank.DoOperation(account);

            //DepositAccount depositAcc = new DepositAccount();
            //IBank<DepositAccount> depositBank = ordinaryBank;
            //ordinaryBank.DoOperation(depositAcc);

            //Console.ReadLine();

            IBank <DepositAccount> depositBank = new Bank();

            depositBank.DoOperation();

            IBank <Account> ordinaryBank = depositBank;

            ordinaryBank.DoOperation();

            Console.ReadLine();

            Console.WriteLine("GENRIC INTERFACE");

            var driver = DriverFactory.Get(1);

            driver.Do();

            driver = DriverFactory.Get(2);
            driver.Do();

            Console.ReadLine();
        }
示例#6
0
文件: Parcel.cs 项目: uzbekdev1/nfx
        /// <summary>
        /// Seal parcel after modification
        /// May call this method on parcels in either Creating or Modifying states.
        /// Bank is used to create the ReplicationVersionInfo which is depends on store/bank implementation.
        /// Parcels can replicate only within stores/technologies that have sealed them
        /// </summary>
        public void Seal(IBank bank)
        {
            if (bank == null)
            {
                throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR + "Parcel.Seal(bank==null)");
            }

            if (m_State != ParcelState.Creating && m_State != ParcelState.Modifying)
            {
                throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Seal", GetType().FullName, m_State));
            }

            Validate(bank);

            if (ValidationExceptions.Any())
            {
                throw ParcelSealValidationException.ForErrors(GetType().FullName, ValidationExceptions);
            }


            m_ReplicationVersionInfo = bank.GenerateReplicationVersionInfo(this);

            DoSeal(bank);

            m_State       = ParcelState.Sealed;
            m_NewlySealed = true;
        }
示例#7
0
        public override void OnSaved(object sender, EntityAfterEventArgs e)
        {
            base.OnSaved(sender, e);
            Entity entity = (Entity)sender;
            //UserConnection = entity.UserConnection;

            var    amountFC      = entity.GetTypedColumnValue <decimal>("AmountFC");
            var    date          = entity.GetTypedColumnValue <DateTime>("TransactionDate");
            var    currencyId    = entity.GetTypedColumnValue <Guid>("CurrencyId");
            string shortCurrency = entity.FindValueById <string>("Currency", currencyId, "ShortName");

            IBank       ibank  = BankFactory.GetBank(BankFactory.SupportedBanks.BOC);
            IBankResult result = null;

            Task.Run(async() =>
            {
                result = await ibank.GetRateAsync(shortCurrency, date);
            }).Wait();


            entity.SetColumnValue("FxRate", result.ExchangeRate);
            entity.SetColumnValue("AmountHC", amountFC * result.ExchangeRate);
            entity.Save();
            _log.Info($"rate:{result.ExchangeRate} on {result.RateDate:dd-MMM-yyyy}");
        }
示例#8
0
        public void BalanceShowsAllBalances()
        {
            //Arrange
            ICollection <Account> expectedResult = new List <Account>()
            {
                new Account()
                {
                    AccountNumber = 1
                },
                new Account()
                {
                    AccountNumber = 3
                },
                new Account()
                {
                    AccountNumber = 2
                }
            };
            IBank fakeBank = Mock.Create <IBank>();

            Mock.Arrange(() => fakeBank.GetAllAccounts()).Returns(expectedResult).MustBeCalled();

            HomeController controller = new HomeController(fakeBank);

            // Act
            ViewResult result = controller.Balance() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(IEnumerable <Account>));
            Assert.IsTrue((expectedResult as IEnumerable <Account>).SequenceEqual <Account>(result.Model as IEnumerable <Account>));
        }
示例#9
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Bank == null))
                {
                    IBank bankCasted = item.As <IBank>();
                    if ((bankCasted != null))
                    {
                        this._parent.Bank = bankCasted;
                        return;
                    }
                }
                if ((this._parent.ServiceSupplier == null))
                {
                    IServiceSupplier serviceSupplierCasted = item.As <IServiceSupplier>();
                    if ((serviceSupplierCasted != null))
                    {
                        this._parent.ServiceSupplier = serviceSupplierCasted;
                        return;
                    }
                }
                IBankStatement bankStatementsCasted = item.As <IBankStatement>();

                if ((bankStatementsCasted != null))
                {
                    this._parent.BankStatements.Add(bankStatementsCasted);
                }
            }
示例#10
0
        public void WithdrawMoreThanBalanceGivesError()
        {
            //Arrange
            Account testAccount = new Account(new Transaction[] {
                new Transaction()
                {
                    ID = 1, Amount = 100, BalanceAccountNumber = 987654
                },
                new Transaction()
                {
                    ID = 2, Amount = -0.05, BalanceAccountNumber = 123456
                }
            })
            {
                AccountNumber = 7
            };
            IBank fakeBank = Mock.Create <IBank>();

            Mock.Arrange(() => fakeBank.GetAccountByNumber(7)).Returns(testAccount).MustBeCalled();

            HomeController controller     = new HomeController(fakeBank);
            double         expectedResult = testAccount.Balance;

            // Act
            ViewResult result = controller.Withdraw(7, 100) as ViewResult;

            Assert.IsNotNull(result);

            Account account      = result.Model as Account;
            string  actualResult = result.ViewBag.ErrorMessage;

            // Assert
            Assert.IsTrue(actualResult.Contains("Insufficient funds."));
            Assert.AreEqual(expectedResult, account.Balance); //No change done to the account
        }
示例#11
0
        public void WithdrawNegGivesError()
        {
            //Arrange
            Account testAccount = new Account(new Transaction[] {
                new Transaction()
                {
                    ID = 1, Amount = 100, BalanceAccountNumber = 987654
                },
                new Transaction()
                {
                    ID = 2, Amount = -0.05, BalanceAccountNumber = 123456
                }
            })
            {
                AccountNumber = 7
            };

            IBank fakeBank = Mock.Create <IBank>();

            Mock.Arrange(() => fakeBank.GetAccountByNumber(7)).Returns(testAccount);

            HomeController controller     = new HomeController(fakeBank);
            double         expectedResult = testAccount.Balance;

            // Act
            ViewResult result       = controller.Withdraw(7, -300.1) as ViewResult;
            Account    account      = result.Model as Account;
            string     actualResult = result.ViewBag.ErrorMessage;

            // Assert
            Assert.IsTrue(actualResult.StartsWith("Cannot withdraw an amount less than or equal 0."));
            Assert.AreEqual(expectedResult, account.Balance); //No change done to the account
        }
示例#12
0
        public void TransactionsGivenValidAccountNrReturnsAccount()
        {
            //Arrange
            Account expectedResult = new Account(new Transaction[] {
                new Transaction()
                {
                    ID = 1, Amount = 100, BalanceAccountNumber = 987654
                },
                new Transaction()
                {
                    ID = 2, Amount = -0.05, BalanceAccountNumber = 123456
                }
            })
            {
                AccountNumber = 7
            };

            IBank fakeBank = Mock.Create <IBank>();

            Mock.Arrange(() => fakeBank.GetAccountByNumber(7)).Returns(expectedResult).MustBeCalled();

            HomeController controller = new HomeController(fakeBank);

            // Act
            ViewResult result       = controller.Transactions(7) as ViewResult;
            Account    actualResult = result.Model as Account;

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
示例#13
0
        public static string GetBankName(string Account)
        {
            if (Account == null)
            {
                return("No data");
            }

            Account = NormalizeNumber(Account);
            if (IsValidNumber(Account))
            {
                IBank bank = GetBank(Account);
                if (bank == null)
                {
                    return("Unknown bank account");
                }
                else
                {
                    return(bank.BankName());
                }
            }
            else
            {
                return("Invalid account number");
            }
        }
示例#14
0
        public async Task BOC_GetRateAsyncShoudReturn(decimal expectedExchangeRate,
                                                      DateTime requestedRateDate, DateTime expectedRateDate, string currency)
        {
            #region Arrange
            IBankResult expected = new BankResult()
            {
                BankName     = "Bank of Canada",
                HomeCurrency = "CAD",
                ExchangeRate = expectedExchangeRate,
                RateDate     = expectedRateDate
            };
            IBank ibank = BankFactory.GetBank(BankFactory.SupportedBanks.BOC);
            #endregion

            #region Act
            IBankResult actual = await ibank.GetRateAsync(currency, requestedRateDate);

            #endregion

            #region Assert
            //Assert.Equal(expected, actual);
            Assert.Equal(expected.RateDate, actual.RateDate);
            Assert.Equal(expected.ExchangeRate, actual.ExchangeRate);
            Assert.Equal(expected.BankName, actual.BankName);
            Assert.Equal(expected.HomeCurrency, actual.HomeCurrency);

            #endregion
        }
示例#15
0
        public void AskCredit_AmountExceeded()
        {
            IClientManager clientManager  = new ClientManager();
            FinanceManager financeManager = new FinanceManager(clientManager, new EmailSenderMock());

            ShoppingClient.Clients.Clear();
            clientManager.RegisterUser("Marko", "Sinisic", "*****@*****.**", "markos123", "Novi Sad", new DateTime(1990, 5, 25), new List <IAccount>());
            IClient client = ShoppingClient.Clients[0];

            financeManager.CreateAccount("f231rf34f34f3f4", new Bank(), 10000, 0, false);
            IAccount account = FinantialDB.Accounts.Values.ToList()[0];

            financeManager.CreateBank("Raiffeisen", "Cara Lazara 55", new List <ICredit>(), "din", new List <IAccount>()
            {
                account
            }, 1000, 10000, 100);
            IBank bank = FinantialDB.Banks.Values.ToList()[0];

            financeManager.CreateCredit("kredit", 0.05, FinantialDB.Currency["EUR"], bank, 10);
            ICredit credit = FinantialDB.Credits.Values.ToList()[0];

            bank.ListOfCredits.Add(credit);

            Assert.Throws <Exception>(() => financeManager.AskCredit(client.ID, credit.ID, 123, 50000), "Credit amount exceeds bank's maximum credit amount.");
        }
示例#16
0
        public void PlatiCommandExecute()
        {
            NalogPrenos nalog = new NalogPrenos(
                -1,
                "test",
                SelektovanaFaktura.NazivKupca,
                "Svrha placanja",
                SelektovanaFaktura.NazivDobavljaca,
                DateTime.Now,
                DateTime.Now,
                racun.BrojRacun,
                97,
                "poziv",
                SelektovanaFaktura.UplataNaRacun,
                97,
                4464,
                SelektovanaFaktura.UkupnoRobeIUsluga,
                "RSD",
                false
                );

            Banka banka = DAO.GetBanka(racun.BrojRacun);

            ChannelFactory <IBank> factory = new ChannelFactory <IBank>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/" + banka.Naziv));
            IBank proxy = factory.CreateChannel();

            try
            {
                proxy.SendNalogPrenos(nalog);
            }
            catch (Exception e)
            { }
        }
示例#17
0
        private static async Task RateBOMX(string Currency, DateTime date)
        {
            IBank       ibank  = BankFactory.GetBank(BankFactory.SupportedBanks.BOMX, Resources.bmxSecret);
            IBankResult result = await ibank.GetRateAsync(Currency, date);

            PrintReSult(Currency, result);
        }
示例#18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="employeeRepository"></param>
 public CommonController(ICommon commonRepository, ILookupDetails lookupDetailsRepository, ICommon CommonRepository, IBank companyRepository)
 {
     _empRepository     = commonRepository;
     _lookUpRepository  = lookupDetailsRepository;
     _CommonRepository  = CommonRepository;
     _companyRepository = companyRepository;
 }
示例#19
0
        private void ShowInstanceMenu(IBank sendingBank)
        {
            bool showMenu = true;

            while (showMenu)
            {
                PrintBankOperations(sendingBank);
                bool converted = Int32.TryParse(Console.ReadLine(), out int input);

                if (converted)
                {
                    switch (input)
                    {
                    case 0:
                        showMenu = false;
                        break;

                    case 1:
                        TransactionResult(SendingMoney(sendingBank).Status);
                        break;

                    case 2:
                        Console.WriteLine(sendingBank.GetBalance());
                        break;
                    }
                }
            }
        }
示例#20
0
        public void MakePayment(Product product, PaymentType type)
        {
            ConcretePaymentFactory factory = new ConcretePaymentFactory();
            IBank bank = factory.PaymentBank(type, product);

            bank.MakePayment(product);
        }
示例#21
0
 private Builder()
 {
     _targetCurrency   = default;
     _roundingStrategy = default;
     _distributionUnit = default;
     _bank             = DefaultBank.Empty;
 }
示例#22
0
        /// <summary>
        /// 1 First search for bytewise duplicate patch, if found -> don't paste.
        /// 2 Than and if 'Equally Named Patches' is selected, search for an equally named patch and reference to that.
        /// 3 Otherwise, if 'Like-Named Pathces' is selected, remove the ignore characters and find a like-named patch and
        ///   reference to that.
        /// For all searches above, if a patch is found on the same location (a), prefer that, otherwise find the first occurence (b).
        /// </summary>
        /// <param name="clipBoardPatch"></param>
        /// <param name="bank"></param>
        /// <returns>True if a duplicate is found.</returns>
        private bool CheckForDuplicate(IClipBoardPatch clipBoardPatch, IBank bank)
        {
            Debug.Assert(!(clipBoardPatch is IClipBoardSetListSlot));

            // If the source patch is present in the source PCG file, check if it is present in the target PCG.
            if (clipBoardPatch.Data.Length != 0)
            {
                IPatch sameLocationPatch;
                if (SearchByteWiseEqualPatchSameLocation(clipBoardPatch, bank, out sameLocationPatch))
                {
                    return(true);
                }

                if (SearchByteWiseEqualPatchFirstOccurence(clipBoardPatch, bank))
                {
                    return(true);
                }

                if (SearchIdenticalNamePatch(clipBoardPatch, bank, sameLocationPatch))
                {
                    return(true);
                }

                if (SearchLikeNamedPatch(clipBoardPatch, bank, sameLocationPatch))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#23
0
        /// <summary>
        /// 3b. Search for a like named patch if Like Named Patches is selected, on same location.
        /// </summary>
        /// <param name="clipBoardPatch"></param>
        /// <param name="bank"></param>
        /// <param name="sameLocationPatch"></param>
        /// <returns></returns>
        private bool SearchLikeNamedPatch(IClipBoardPatch clipBoardPatch, IBank bank, IPatch sameLocationPatch)
        {
            if (Settings.Default.CopyPaste_PatchDuplicationName == (int)CopyPaste.PatchDuplication.LikeNamedNames)
            {
                if (sameLocationPatch != null)
                {
                    if (sameLocationPatch.IsNameLike(clipBoardPatch.OriginalLocation.Name))
                    {
                        clipBoardPatch.PasteDestination = sameLocationPatch;
                        PcgClipBoard.ProtectedPatches.Add(sameLocationPatch);
                        return(true);
                    }
                }

                // 2b. Search for an identical name patch, on first occurence.
                foreach (var patch in bank.Patches.Where(
                             patch => patch.IsNameLike(clipBoardPatch.OriginalLocation.Name)))
                {
                    clipBoardPatch.PasteDestination = patch;
                    PcgClipBoard.ProtectedPatches.Add(patch);
                    return(true);
                }
            }
            return(false);
        }
示例#24
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            IINGExchangeRate iNGExchangeRate2020 = new INGExchangeRate2020();
            IINGExchangeRate iNGExchangeRate2021 = new INGExchangeRate2021();

            IBTExchangeRate bTExchangeRate2020 = new BTExchangeRate2020();
            IBTExchangeRate bTExchangeRate2021 = new BTExchangeRate2021();

            IABExchangeRate aBExchangeRate2020 = new ABExchangeRate2020();
            IABExchangeRate aBExchangeRate2021 = new ABExchangeRate2021();

            IBCRExchangeRate bCRExchangeRate2020 = new BCRExchangeRate2020();
            IBCRExchangeRate bCRExchangeRate2021 = new BCRExchangeRate2021();

            Dictionary <Type, object> dependecyInjectionContainer = new Dictionary <Type, object>();

            dependecyInjectionContainer.Add(typeof(IINGExchangeRate), iNGExchangeRate2020);
            dependecyInjectionContainer.Add(typeof(IBTExchangeRate), bTExchangeRate2020);
            dependecyInjectionContainer.Add(typeof(IABExchangeRate), aBExchangeRate2020);
            dependecyInjectionContainer.Add(typeof(IBCRExchangeRate), bCRExchangeRate2020);

            ConstructorInfo constructorInfo = typeof(ING).GetConstructors().FirstOrDefault();

            List <object> ingParams = new List <object>();

            foreach (ParameterInfo parameterInfo in constructorInfo.GetParameters())
            {
                Console.WriteLine(parameterInfo.ParameterType.ToString());

                ingParams.Add(dependecyInjectionContainer[parameterInfo.ParameterType]);
            }

            //var parameters = new object[1];
            //parameters[0] = ingParams[0];

            //ING ingInstance = Activator.CreateInstance(typeof(ING), parameters) as ING;

            //ING ingInstance = Activator.CreateInstance(typeof(ING), new object[] { ingParams.ToArray() }) as ING;

            var ingCtorParams = ingParams.ToArray();

            ING ingInstance = Activator.CreateInstance(typeof(ING), ingCtorParams) as ING;
            //ING ingInstance = Activator.CreateInstance(typeof(ING), ingParams) as ING;

            //IBank ing = new ING(dependecyInjectionContainer[typeof(IINGExchangeRate)] as IINGExchangeRate);
            IBank ing = Activator.CreateInstance(typeof(ING), ingCtorParams) as ING;
            IBank bt  = new BT(dependecyInjectionContainer[typeof(IBTExchangeRate)] as IBTExchangeRate);
            IBank ab  = new AB(dependecyInjectionContainer[typeof(IABExchangeRate)] as IABExchangeRate);
            IBank bcr = new BCR(dependecyInjectionContainer[typeof(IBCRExchangeRate)] as IBCRExchangeRate);

            Console.WriteLine($"ING converts 100 EUR into {ing.ExchangeInRON(100)}");
            Console.WriteLine($"BT converts 100 EUR into {bt.ExchangeInRON(100)}");
            Console.WriteLine($"AB converts 100 EUR into {ab.ExchangeInRON(100)}");
            Console.WriteLine($"BCR converts 100 EUR into {bcr.ExchangeInRON(100)}");


            Console.ReadKey();
        }
        protected override void RegisterDependencies(IServiceCollection collection)
        {
            collection.AddSingleton <IPaymentTransactionQuery, InMemoryPaymentTransactionQuery>();

            collection.AddTransient(IoC =>
            {
                ObjectCache objectCache = Substitute.For <ObjectCache>();

                objectCache
                .Get(ValidTransactionId, Arg.Any <string>())
                .Returns(new PaymentTransaction(new Card("4916690086480301", 12, 2022), 19.99m, DateTime.Now, true));

                objectCache
                .Get(InvalidTransactionId, Arg.Any <string>())
                .Returns(null);

                return(objectCache);
            });
            collection.AddTransient <IPaymentValidator, PaymentValidator>();
            collection.AddTransient <IPaymentService, PaymentService>();
            collection.AddTransient <IBank>(_ =>
            {
                IBank bank = Substitute.For <IBank>();
                bank.CreatePayment(Arg.Any <Payment>()).Returns(Task.FromResult(new ProcessedPayment()
                {
                    success = true
                }));
                return(bank);
            });
        }
示例#26
0
        static public bool setUp(IBank bank, bool withClean, String server)
        {
            String databaseName = bank.getName().Replace(" ", String.Empty);

            try
            {
                String connectionString = String.Format(connectionTemplate, server, databaseName);
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                    sqlConnection.Open();
                    validateConnection(sqlConnection);

                    validateDatabase(sqlConnection, bank.getTableList());

                    if (withClean)
                    {
                        clearDatabase(sqlConnection, bank.getTableList());
                    }
                    savedConfigurations.Add(bank.getName(), connectionString);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in database connection: Closing program");
                Console.ReadKey();
                System.Environment.Exit(1);
            }
            return(true);
        }
示例#27
0
        public void AskCredit_Success()
        {
            IClientManager clientManager  = new ClientManager();
            FinanceManager financeManager = new FinanceManager(clientManager, new EmailSenderMock());

            ShoppingClient.Clients.Clear();
            clientManager.RegisterUser("Marko", "Sinisic", "*****@*****.**", "markos123", "Novi Sad", new DateTime(1990, 5, 25), new List <IAccount>());
            IClient client = ShoppingClient.Clients[0];

            financeManager.CreateAccount("f231rf34f34f3f4", new Bank(), 10000, 0, true);
            IAccount account = FinantialDB.Accounts.Values.ToList()[0];

            client.ListOfAccounts.Add(account);

            financeManager.CreateBank("Raiffeisen", "Cara Lazara 55", new List <ICredit>(), "din", new List <IAccount>()
            {
                account
            }, 1000, 100000, 100);
            IBank bank = FinantialDB.Banks.Values.ToList()[0];

            financeManager.CreateCredit("kredit", 0.05, FinantialDB.Currency["EUR"], bank, 10);
            ICredit credit = FinantialDB.Credits.Values.ToList()[0];

            bank.ListOfCredits.Add(credit);

            financeManager.AskCredit(client.ID, credit.ID, 20, 50000);

            Assert.IsTrue(account.CreditPayment > 0);
        }
示例#28
0
 protected override void DoValidate(IBank bank)
 {
     if (!Payload.Contains("Aroyan"))
     {
         m_ValidationExceptions.Add(new ParcelValidationException("Aroyan must be present"));
     }
 }
示例#29
0
        private static async Task RateRBA(string Currency, DateTime date)
        {
            IBank       ibank  = BankFactory.GetBank(BankFactory.SupportedBanks.RBA);
            IBankResult result = await ibank.GetRateAsync(Currency, date);

            PrintReSult(Currency, result);
        }
示例#30
0
        /// <summary>
        /// Returns true if timbre should be copied.
        /// </summary>
        /// <param name="timbre"></param>
        /// <param name="usedProgramBank"></param>
        /// <param name="usedProgram"></param>
        /// <returns></returns>
        private bool ShouldTimbreBeCopied(ITimbre timbre, IBank usedProgramBank, IProgram usedProgram)
        {
            // Only copy programs which are audible.
            var copy = !timbre.GetParam(ParameterNames.TimbreParameterName.Status).ToString().Equals("Off");

            // Only copy programs which have a valid reference.
            copy &= (usedProgram != null);
            copy &= (usedProgramBank != null);

            if (copy)
            {
                // Skip GM programs (those are always present on the synth.
                copy &= (usedProgramBank.Type != BankType.EType.Gm);
            }

            if (copy)
            {
                // Copy only filled programs.
                copy &= !usedProgram.IsEmptyOrInit;

                // Copy only programs which are loaded in the file, or otherwise from the master file if configured
                // to be used and also set.
                copy &= (usedProgramBank.IsLoaded ||
                         (Settings.Default.CopyPaste_CopyPatchesFromMasterFile && usedProgram.IsFromMasterFile));
            }
            return(copy);
        }
示例#31
0
文件: BankNetwork.cs 项目: Tolga/Bank
        public void Register(IBank bank)
        {
            if (!Banks.ContainsValue(bank))
            {
                Banks[bank.BankId] = bank;
            }

            bank.BankNetwork = this;
        }
示例#32
0
 public BuyResourceCommand(IPlayer player, IBank bank, MaterialType buy, MaterialType offer)
 {
     if (player == null)
         throw new ArgumentNullException(nameof(player));
     if (bank == null)
         throw new ArgumentNullException(nameof(bank));
     if (buy == offer)
         throw new ArgumentException("Buy and Offer material cant be same type");
     Player = player;
     this.bank = bank;
     this.buy = buy;
     this.offer = offer;
 }
示例#33
0
        public CounterAccount(string number, string accountName, IBank bank, string bankName, Address bankAddress,
            IManagementCompany managementCompany, bool isPublic, Address beneficiaryAddress, bool ByPassValidation)
        {
            this.Number = number;
            this.AccountName = accountName;
            this.Bank = bank;
            this.BankName = bankName;
            this.BankAddress = bankAddress;
            this.ManagementCompany = managementCompany;
            this.IsPublic = isPublic;
            this.BeneficiaryAddress = beneficiaryAddress;

            if (!ByPassValidation && !IsValid)
                throw new ApplicationException("This Counter Account is not valid.");
        }
示例#34
0
文件: Game.cs 项目: Corne/VOC
        public Game(ISet<IPlayer> players, ITurnProvider provider, IBank bank)
        {
            if (players == null)
                throw new ArgumentNullException(nameof(players));
            if (provider == null)
                throw new ArgumentNullException(nameof(provider));
            if (bank == null)
                throw new ArgumentNullException(nameof(bank));
            if (players.Count < 2 || players.Count > 4)
                throw new ArgumentException("Number of players should be between 2 and 4");

            this.players = players;
            this.provider = provider;
            this.bank = bank;
        }
示例#35
0
 public ConsolePlayer(string name, IConsole instance, IBank bank)
     : this(name, new Hand(), instance, bank)
 {
 }
 private static Mock<BettingPlayer> CreateMockPlayer(IHand hand = null, IBank bank = null)
 {
     return new Mock<BettingPlayer>("TEST", hand ?? new Hand(), bank ?? new Bank(1)) { CallBase = true };
 }
 public ProxyBank(Client client)
 {
     this.client = client;
     BankOfWayne = new Bank();
 }
示例#38
0
 private ConsolePlayer(string name, IHand hand, IConsole console, IBank bank)
     : base(name, hand, bank)
 {
     _console = console;
     RegisterPlayerListeners(console);
 }
示例#39
0
 protected BettingPlayer(string name, IHand hand, IBank bank)
     : base(name, hand)
 {
     Bank = bank;
 }
示例#40
0
 public CounterAccount(string number, string accountName, IBank bank, string bankName, Address bankAddress,
         IManagementCompany managementCompany, bool isPublic, Address beneficiaryAddress)
     : this(number, accountName, bank, bankName, bankAddress, managementCompany, isPublic, beneficiaryAddress, false)
 {
 }
示例#41
0
文件: Parcel.cs 项目: kamilkk/nfx
 /// <summary>
 /// Override to perform parcel/payload validation after modification. Add validation exceptions into m_ValidationExceptions field.
 /// Use bank for cross-checks (i.e. may run queries to check consistency)
 /// </summary>
 protected abstract void DoValidate(IBank bank);
示例#42
0
 public Money Reduce(IBank bank, string to)
 {
     var rate = bank.GetRate(Currency, to);
     return new Money(amount / rate, to);
 }
示例#43
0
文件: Parcel.cs 项目: kamilkk/nfx
            /// <summary>
            /// Performs validation of the data. Does not throw but populates validation exceptions if data is not valid.
            /// Bank context may be used to run sub-queries during consistency/crosschecks
            /// May call this method on parcels in either Creating or Modifying states
            /// </summary>
            public void Validate(IBank bank)
            {
                if (m_State!= ParcelState.Creating && m_State!=ParcelState.Modifying) 
                 throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Validate", GetType().FullName, m_State) );

                m_ValidationExceptions = new List<Exception>();
                DoValidate(bank);
            }
示例#44
0
文件: Parcel.cs 项目: kamilkk/nfx
            /// <summary>
            /// Override to seal the parcel instance, i.e. generate some calculated fields.
            /// The version information is already generated by the time this method is called
            /// </summary>
            protected virtual void DoSeal(IBank bank)
            {

            }
示例#45
0
文件: Parcel.cs 项目: kamilkk/nfx
            /// <summary>
            /// Seal parcel after modification
            /// May call this method on parcels in either Creating or Modifying states.
            /// Bank is used to create the ReplicationVersionInfo which is depends on store/bank implementation.
            /// Parcels can replicate only within stores/technologies that have sealed them
            /// </summary>
            public void Seal(IBank bank)
            {
               if (bank==null) 
                 throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+"Parcel.Seal(bank==null)"); 

               if (m_State!= ParcelState.Creating && m_State!=ParcelState.Modifying) 
                 throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Seal", GetType().FullName, m_State) );

               Validate(bank);

               if (ValidationExceptions.Any())
                 throw ParcelSealValidationException.ForErrors(GetType().FullName, ValidationExceptions);


               m_ReplicationVersionInfo = bank.GenerateReplicationVersionInfo(this);

               DoSeal(bank);

               m_State = ParcelState.Sealed;
               m_NewlySealed = true;
            }
示例#46
0
 public static void AddAccount(IBank localBank, IInputOutput io)
 {
     throw new NotImplementedException();
 }
示例#47
0
 public static void Balance(IBank localBank, IInputOutput io)
 {
     throw new NotImplementedException();
 }
示例#48
0
 public static void Withdrawal(IBank localBank, IInputOutput io, ITransactionFactory transactionFactory)
 {
     throw new NotImplementedException();
 }
 public BankAccount(string accountId, ILogging logging, IBank bank)
 {
     m_logging = logging;
     m_bank = bank;
     AccountId = accountId;
 }
示例#50
0
 public void CantConstructWithNullParameter(IPlayer player, IBank bank)
 {
     Assert.Throws<ArgumentNullException>(() => new BuyResourceCommand(player, bank, MaterialType.Grain, MaterialType.Wool));
 }
示例#51
0
 public Money Reduce(IBank bank, string to)
 {
     return new Money(Augend.Reduce(bank, to).amount + Addend.Reduce(bank, to).amount, to);
 }