public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if MONO AddResource(new JsResource(Constants.kWebRoot, "/js/faqPageCompiled.js", true)); #endif // render head base.Render(ctx, stream, authObj); using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { BaseComponent.SPAN(stream, "Maintenance", HtmlAttributes.@class, "noTopMargin h1"); P("Metaexchange is currently in maintenance mode, please check back soon."); } } } } return null; }
/// <summary> /// Removes the dummy. /// </summary> /// <param name="dummy">The dummy.</param> public virtual void RemoveDummy(IDummy dummy) { if (dummy == null) { ActiveLogger.LogMessage("Cant Remove Null dummy", LogLevel.RecoverableError); return; } bool resp = Dummies.Remove(dummy); if (!resp) { ActiveLogger.LogMessage("Dummy not found: " + dummy.Name, LogLevel.Warning); } }
/// <summary> /// Add a Dummy to the world /// Its like a position, /// usefull to serializable position from a world editor /// </summary> /// <param name="dummy">The dummy.</param> public virtual void AddDummy(IDummy dummy) { if (dummy == null) { ActiveLogger.LogMessage("Cant Add Null dummy", LogLevel.RecoverableError); return; } if (String.IsNullOrEmpty(dummy.Name)) { ActiveLogger.LogMessage("Dummy with no Name", LogLevel.Warning); } Dummies.Add(dummy); }
public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if MONO AddResource(new JsResource(Constants.kWebRoot, "/js/faqPageCompiled.js", true)); #endif // render head base.Render(ctx, stream, authObj); using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { BaseComponent.SPAN(stream, "FAQ", HtmlAttributes.@class, "noTopMargin h1"); } } } } using (new DivContainer(stream, HtmlAttributes.@class, "container", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { P("Q) What happens if I send over the transaction limit?"); P("A) Your full transaction will be refunded"); BR(); P("Q) Where is the transaction limit displayed?"); P("A) In the buy/sell box there is a small tag displaying the transaction limit at the bottom"); BR(); P("Q) Can I send multiple transactions with the same memo?"); P("A) Yes, you can re-use the same memo in multiple different transactions"); BR(); P("Q) What if I forget to include the memo?"); P("A) Your transaction will be automatically refunded"); BR(); P("Q) What is BitShares?"); P("A) You can find out more here: <a href='https://bitshares.org'>bitshares.org</a>"); } } } return null; }
public void TestCommandRegisterEvent1() { IDummy dummy = NSubstitute.Substitute.For <IDummy>(); Command command = new Command(); command.RegisterEvent += (cmd, ret, args) => { NUnit.Framework.Assert.AreEqual("Method3", cmd); NUnit.Framework.Assert.AreEqual(typeof(float), ret.Param); NUnit.Framework.Assert.AreEqual(typeof(int), args[0].Param); NUnit.Framework.Assert.AreEqual(typeof(int), args[1].Param); }; command.RegisterLambda <IDummy, int, int, float>(dummy, (d, i1, i2) => d.Method3(i1, i2), (result) => { }); command.Run("method3", new[] { "3", "9" }); }
public async Task ThenNoInformationMessageShouldBeLogged() { var ts = new CancellationTokenSource(); CancellationToken ct = ts.Token; IDummy dummy = WhenDummyIsResolvedAnd(); // ReSharper disable once ConvertToLocalFunction Func <Task> func = async() => await dummy.ReturnStuffAsync(1, "b"); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(func, ct); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed ts.Cancel(); // ReSharper disable once MethodSupportsCancellation await Task.Delay(500); Log.Count.Should().Be(0); }
public void TestCommandRegisterEvent2() { IDummy dummy = NSubstitute.Substitute.For <IDummy>(); Command command = new Command(); command.RegisterEvent += (cmd, ret, args) => { NUnit.Framework.Assert.AreEqual("Method2", cmd); NUnit.Framework.Assert.AreEqual(typeof(void), ret.Param); NUnit.Framework.Assert.AreEqual(typeof(int), args[0].Param); NUnit.Framework.Assert.AreEqual(typeof(int), args[1].Param); NUnit.Framework.Assert.AreEqual("return_Void", ret.Description); }; command.RegisterLambda <IDummy, int, int>(dummy, (d, i1, i2) => d.Method2(i1, i2)); command.Run("method2", new[] { "3", "9" }); }
public void TestCommandLambdaRegister() { IDummy dummy = NSubstitute.Substitute.For <IDummy>(); Command command = new Command(); command.RegisterLambda(dummy, (d) => d.Method1()); command.Run("method1", new string[] { }); dummy.Received().Method1(); command.RegisterLambda <IDummy, int, int>(dummy, (instance, a1, a2) => instance.Method2(a1, a2)); command.Run("method2", new[] { "1", "2" }); dummy.Received().Method2(1, 2); command.RegisterLambda <IDummy, int, int, float>(dummy, (instance, a1, a2) => instance.Method3(a1, a2), (result) => { }); command.Run("method3", new[] { "3", "4" }); dummy.Received().Method3(3, 4); }
/// <summary> Executes the get statistics action. </summary> /// /// <remarks> Paul, 30/01/2015. </remarks> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> Task OnGetStats(RequestContext ctx, IDummy dummy) { uint sinceTid = RestHelpers.GetPostArg <uint, ApiExceptionMissingParameter>(ctx, WebForms.kLimit); List <TransactionsRow> lastTransactions = m_database.Query <TransactionsRow>("SELECT * FROM transactions WHERE uid>@uid ORDER BY uid;", sinceTid); SiteStatsRow stats = new SiteStatsRow { bid_price = m_bidPrice, ask_price = m_askPrice, max_bitassets = m_bitsharesDepositLimit, max_btc = m_bitcoinDepositLimit }; ctx.Respond <StatsPacket>(new StatsPacket { m_lastTransactions = lastTransactions, m_stats = stats }); return(null); }
static void Main(string[] args) { var dummy = new IDummy(); Savings sav1 = new Savings(); sav1.Number = "SAV001"; sav1.Name = "My Savings Account"; sav1.IntRate = 0.1; MoneyMarket monmar = new MoneyMarket(); monmar.Number = "MM001"; monmar.Name = "My Money Market Account"; monmar.monmarkrate = .03M; Checking chk = new Checking(); chk.Number = "CHK001"; chk.Name = "My checking account"; chk.Deposit(100); chk.Pay(100, 20); sav1.Deposit(5000); sav1.PayInterest(44); sav1.ChangeRate(0.05); monmar.Deposit(4000); monmar.Withdraw(2000); monmar.PayInterest(24); decimal mmbal = monmar.GetBalance(); Account[] accounts = new Account[] { sav1, monmar, chk }; foreach (Account acct in accounts) { Console.WriteLine(acct.Print()); } //bool ItWorked = monmar.TransferTo(sav1, 50); }
public void TestCommandRegisterEvent3() { IDummy dummy = NSubstitute.Substitute.For <IDummy>(); Command command = new Command(); command.RegisterEvent += (cmd, ret, args) => { NUnit.Framework.Assert.AreEqual("m", cmd); NUnit.Framework.Assert.AreEqual(typeof(void), ret.Param); NUnit.Framework.Assert.AreEqual(typeof(int), args[0].Param); NUnit.Framework.Assert.AreEqual(typeof(int), args[1].Param); NUnit.Framework.Assert.AreEqual("", ret.Description); NUnit.Framework.Assert.AreEqual("l1", args[0].Description); NUnit.Framework.Assert.AreEqual("l2", args[1].Description); }; command.Register <int, int>("m [l1 ,l2]", (l1, l2) => { dummy.Method2(l1, l2); }); }
public ClassWithRefConstructorParameter(ref IDummy dependency) { }
public SubForm(IDummy dummy) { this.dummy = dummy; InitializeComponent(); }
// /api/error1 // Throw a framework error because IDummy does not have a concrete type public ApiErrorController(IDummy dummy) { }
public DummyService(IDummy dummy) { _dummy = dummy; }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ctx"></param> /// <param name="stream"></param> /// <param name="authObj"></param> /// <returns></returns> public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if !MONO foreach (string name in m_sharedJsFilenames) { AddResource(new JsResource(Constants.kWebRoot, name, true)); } #endif AddResource(new CssResource(Constants.kWebRoot, "/css/site.css", true)); AddResource(new CssResource(Constants.kWebRoot, "/css/bootstrap.min.css", true)); AddResource(new FavIconResource(Constants.kWebRoot, "/images/favicon.ico")); AddResource(new TitleResource("Metaexchange")); AddResource(new MetaResource("viewport", "width=device-width, initial-scale=1")); ImgResource brand = new ImgResource(Constants.kWebRoot, "/images/brandTitle.png", "", false); AddResource(brand); // render head base.Render(ctx, stream, authObj); m_stream.WriteLine("<!-- Just for debugging purposes. Don't actually copy this line! --> <!--[if lt IE 9]><script src=\"../../assets/js/ie8-responsive-file-warning.js\"></script><![endif]--> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script> <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script><![endif]-->"); // begin body m_stream.WriteLine("<body>"); using (new DivContainer(m_stream, HtmlAttributes.@class, "navbar navbar-default navbar-fixed-top")) { using (new DivContainer(m_stream, HtmlAttributes.@class, "container")) { using (new DivContainer(m_stream, HtmlAttributes.@class, "navbar-header")) { using (new Link(m_stream, HtmlAttributes.@class, "navbar-brand", HtmlAttributes.href, "/")) { brand.Write(m_stream); m_stream.Write(" metaexchange"); } } using (new DivContainer(m_stream, HtmlAttributes.@class, "navbar-collapse collapse")) { string page = ctx.Request.Url.LocalPath.Split('/').Last(); IEnumerable<MarketRow> allMarkets = authObj.m_database.GetAllMarkets().Where(m=>m.visible); using (var ul = new UL(stream, "nav navbar-nav pull-left")) { using (var li = new LI(stream, "dropdown")) { Href(stream, "Markets <span class=\"caret\">", HtmlAttributes.href, "/", HtmlAttributes.@class, "disabled", "data-toggle", "dropdown", "role", "button", "aria-expanded", "false"); using (new UL(stream, HtmlAttributes.@class, "dropdown-menu", "role","menu")) { foreach (MarketRow m in allMarkets.Where(m=>!m.flipped)) { WriteLiHref(stream, CurrencyHelpers.RenameSymbolPair(m.symbol_pair), "", "", HtmlAttributes.href, "/markets/" + CurrencyHelpers.RenameSymbolPair(m.symbol_pair)); } } } //WriteLiHref(stream, "Home", GetLiClass(page, ""), "", HtmlAttributes.href, "/"); WriteLiHref(stream, "Api", GetLiClass(page, "apiDocs"), "", HtmlAttributes.href, "/apiDocs"); WriteLiHref(stream, "Faq", GetLiClass(page, "faq"), "", HtmlAttributes.href, "/faq"); } } } } return null; }
public HelloJob(ILogger logger, IDummy dummy) { this.logger = logger; this.dummy = dummy; }
private static void RunVectorTriad(TriadData data, long vectorLength, long repetitions, IDummy dummy) { fixed(double *ap = data.a) fixed(double *bp = data.b) fixed(double *cp = data.c) fixed(double *dp = data.d) { for (long r = 0; r < repetitions; r++) { if (ap[1] < 1) { dummy.DummyMethod(ap, bp, cp, dp); } for (long i = 0; i < vectorLength; i++) { long j = i;//(i * 1009) % vectorLength; ap[j] = bp[j] + cp[j] * dp[j]; } } } }
public void Attack(IDummy target) { target.TakeAttack(AttackPoints); DurabilityPoints -= 1; }
public HomeController(IDummy dummy) { this.dummy = dummy }
public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if MONO AddResource(new JsResource(Constants.kWebRoot, "/js/marketsPageCompiled.js", true)); #endif AddResource(new CssResource(Constants.kWebRoot, "/css/markets.css", true)); ImgResource logo = CreateLogo(); AddResource(logo); // render head base.Render(ctx, stream, authObj); using (new DivContainer(stream, "ng-app", "myApp", "ng-controller", "MarketsController", HtmlAttributes.id, "rootId")) { using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix no-padding-bottom-top")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { RenderJumbo(stream, logo); } } } } using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12")) { using (new Table(stream, "", 4, 4, "table table-striped table-hover noMargin", new string[] { "", "hidden-sm hidden-xs hidden-md", "", "", "", "hidden-xs", "hidden-xs", "hidden-xs hidden-sm", "hidden-xs hidden-sm" }, "Market", "Currency", "Price", "Volume (BTC)", "Spread %", "Ask", "Bid", "Buy fee (%)", "Sell fee (%)")) { using (var tr = new TR(stream, "ng-if", "!t.flipped", "ng-repeat", "t in allMarkets", HtmlAttributes.@class, "clickable-row", "ng-click", "go(t)")) { tr.TD("{{renameSymbolPair(t.symbol_pair)}}"); tr.TD("{{t.asset_name}}", HtmlAttributes.@class, "hidden-sm hidden-xs hidden-md"); tr.TD("{{t.last_price}} <i class=\"glyphicon glyphicon-arrow-up text-success\"/>", "ng-if", "t.price_delta>0"); tr.TD("{{t.last_price}} <i class=\"glyphicon glyphicon-arrow-down text-danger\"/>", "ng-if", "t.price_delta<0"); tr.TD("{{t.last_price}} <i class=\"glyphicon glyphicon glyphicon-minus text-info\"/>", "ng-if", "t.price_delta==0"); tr.TD("{{t.btc_volume_24h | number:2}}"); tr.TD("{{t.realised_spread_percent | number:2}}"); tr.TD("{{t.ask}}", HtmlAttributes.@class, "hidden-xs"); tr.TD("{{t.bid}}", HtmlAttributes.@class, "hidden-xs"); tr.TD("{{t.ask_fee_percent | number:2}}", HtmlAttributes.@class, "hidden-sm hidden-xs"); tr.TD("{{t.bid_fee_percent | number:2}}", HtmlAttributes.@class, "hidden-sm hidden-xs"); } } } } } // // bullet points // using (new DivContainer(stream, HtmlAttributes.@class, "container", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-ok text-info\"></i> No registration required"); P("There is no need to register an account, just tell us where you'd like to receive the coins that you buy or sell."); } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-flash text-info\"></i> Fast transactions"); P("Only one confirmation is neccessary for buying or selling, which is around 7 minutes for a buy and around 3 seconds for a sell."); } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-lock text-info\"></i> Safe"); P("We don't hold any of our customer's funds, so there is nothing to get lost or stolen."); } } } using (new DivContainer(stream, HtmlAttributes.@class, "bg-primary hidden-xs", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.style, "margin:30px 0px 30px 0px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12")) { H3("Recent transactions"); using (new Table(stream, "", 4, 4, "table noMargin", "Market", "Type", "Price", "Amount", "Fee", "Date")) { using (var tr = new TR(stream, "ng-repeat", "t in transactions")) { tr.TD("{{renameSymbolPair(t.symbol_pair)}}"); tr.TD("{{t.order_type}}"); tr.TD("{{t.price}}"); tr.TD("{{t.amount}}"); tr.TD("{{t.fee}}"); tr.TD("{{t.date*1000 | date:'MMM d, HH:mm'}}"); } } } } } } } } return(null); }
public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if MONO AddResource(new JsResource(Constants.kWebRoot, "/js/apiPageCompiled.js", true)); #endif // render head base.Render(ctx, stream, authObj); using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { BaseComponent.SPAN(stream, "API", HtmlAttributes.@class, "noTopMargin h1"); } } } } using (new DivContainer(stream, HtmlAttributes.@class, "container")) { P("The API allows developers to access the functionality of Metaexchange without needing to use the website."); P("All API requests return data in JSON format."); HR(); H4("API errors"); P("When an API call fails, an error will be returned. The structure of an error is:"); using (new Pre(stream, HtmlAttributes.@class, "prettyprint")) { stream.WriteLine("{<br/>" + "\t\"error\":<error code>,<br/>" + "\t\"message\":<error message>,<br/>" + "}"); } stream.WriteLine(EnumToPrettyTable("Error codes", typeof(ApiErrorCode))); HR(); H4("API summary"); string[] apiEndpointsAndDescriptions = { Routes.kSubmitAddress, "Submit your receiving address and get back deposit details", Routes.kGetOrderStatus, "Get the status of your order by TXID", Routes.kGetMyLastTransactions, "Get a list of your last transactions", Routes.kGetAllMarkets, "Get a list of all supported markets", Routes.kGetMarket, "Get details of a particular market", Routes.kGetLastTransactions, "Get a list of the last transactions" }; for (int i = 0; i < apiEndpointsAndDescriptions.Length; i += 2) { stream.WriteLine("<b>" + apiEndpointsAndDescriptions[i + 1] + "</b><br/>"); stream.WriteLine(DocRefLink(apiEndpointsAndDescriptions[i + 0]) + "<br/><br/>"); } HR(); H4("API detail"); string siteUrl = ctx.Request.Url.AbsoluteUri.TrimEnd(ctx.Request.Url.LocalPath); string market = "bitBTC_BTC"; CodeExample <SubmitAddressResponse>(siteUrl, stream, Routes.kSubmitAddress, WebRequestMethods.Http.Post, "The main function. This will take your supplied receiving address and provide you with a deposit address and a memo (depending on the market).", new List <DocParam> { new DocParam { description = "This is the symbol pair of the market you would like to trade in. Symbol pairs are of the form <b>" + market + "</b> and are case sensitive. Find out what markets are available by calling " + DocRefLink(Routes.kGetAllMarkets), name = WebForms.kSymbolPair, type = DocType.@string }, new DocParam { description = "This is where you would like funds to be forwarded. It could be a bitcoin address or a bitshares account depending on the order type and market.", name = WebForms.kReceivingAddress, type = DocType.@string }, new DocParam { description = "The type of order you want to place. Possible types are <b>" + MetaOrderType.buy + "</b> and <b>" + MetaOrderType.sell + "</b>.", name = WebForms.kOrderType, type = DocType.@string }, }, null, Routes.kSubmitAddress + RestHelpers.BuildArgs(WebForms.kSymbolPair, market, WebForms.kReceivingAddress, "monsterer", WebForms.kOrderType, MetaOrderType.buy), new SubmitAddressResponse { deposit_address = "mrveCRH4nRZDpS7fxgAiLTX7GKvJ1cARY9" }); CodeExample <TransactionsRowNoUid>(siteUrl, stream, Routes.kGetOrderStatus, WebRequestMethods.Http.Post, "Get the status of a particular order when you know the blockchain transaction id. Transaction must be in a block before this function will return a result.", new List <DocParam> { new DocParam { description = "The transaction id of the transaction you sent.", name = WebForms.kTxId, type = DocType.@string }, }, null, Routes.kGetOrderStatus + RestHelpers.BuildArgs(WebForms.kTxId, "ed7364fd1b8ba4cc3428470072300fb88097c3a343c75b6e604c68799a0148cb"), new TransactionsRowNoUid { amount = 0.1M, date = DateTime.UtcNow, deposit_address = "1-n2HPFvf376vxQV1mo", notes = null, order_type = MetaOrderType.sell, sent_txid = "231500b3ecba3bf2ba3db650f5e7565478382c5b", received_txid = "70827daa9f08211491297a5ded2c3f8d7a2b654f1e6f3d4e2ff3ad7e14966a85", status = MetaOrderStatus.completed, symbol_pair = market }); stream.WriteLine(EnumToPrettyTable("Possible order statuses", typeof(MetaOrderStatus))); decimal ask = Numeric.TruncateDecimal(1 / 0.994M, 3); decimal bid = Numeric.TruncateDecimal(0.994M, 3); decimal bq = Numeric.TruncateDecimal(1 / ask, 3); decimal sq = Numeric.TruncateDecimal(1 / bid, 3); CodeExample <MarketRow>(siteUrl, stream, Routes.kGetMarket, WebRequestMethods.Http.Post, "Get details about a particular market, such as bid/ask price and transaction limits.", new List <DocParam> { new DocParam { description = "The symbol pair identifier for the market. Symbol pairs are of the form <b>" + market + "</b>. Use " + DocRefLink(Routes.kGetAllMarkets) + " to query the list of available markets.", name = WebForms.kSymbolPair, type = DocType.@string }, }, null, Routes.kGetMarket + RestHelpers.BuildArgs(WebForms.kSymbolPair, market), new MarketRow { ask = ask, bid = bid, buy_quantity = bq, sell_quantity = sq, ask_max = 1, bid_max = 0.8M, symbol_pair = market, }); P("The values displayed in metaexchange for 1 BTC conversion quantity appear in the fields (1 BTC ->) <b>buy_quantity</b> and <b>sell_quantity</b> (-> 1 BTC)."); CodeExample <List <MarketRow> >(siteUrl, stream, Routes.kGetAllMarkets, WebRequestMethods.Http.Get, "Get a list of all available markets along with the best prices and transaction limits.", null, null, Routes.kGetAllMarkets, new List <MarketRow> { new MarketRow { ask = ask, bid = bid, buy_quantity = bq, sell_quantity = sq, ask_max = 1, bid_max = 0.8M, symbol_pair = market, } }); CodeExample <List <TransactionsRowNoUid> >(siteUrl, stream, Routes.kGetLastTransactions, WebRequestMethods.Http.Post, "Get the most recent transactions, sorted in descending order. This will only show transactions with status " + MetaOrderStatus.completed + ".", new List <DocParam> { new DocParam { description = "The maximum number of results to return.", name = WebForms.kLimit, type = DocType.integer }, }, new List <DocParam> { new DocParam { description = "Market to query.", name = WebForms.kSymbolPair, type = DocType.@string }, }, Routes.kGetLastTransactions + RestHelpers.BuildArgs(WebForms.kSymbolPair, market), new List <TransactionsRowNoUid> { new TransactionsRowNoUid { amount = 0.1M, date = DateTime.UtcNow, deposit_address = "1-n2HPFvf376vxQV1mo", notes = null, order_type = MetaOrderType.sell, sent_txid = "231500b3ecba3bf2ba3db650f5e7565478382c5b", received_txid = "70827daa9f08211491297a5ded2c3f8d7a2b654f1e6f3d4e2ff3ad7e14966a85", status = MetaOrderStatus.completed, symbol_pair = market }, new TransactionsRowNoUid { amount = 0.00010000M, date = DateTime.UtcNow, deposit_address = "mpwPhGCtbe8AeoFq3FWq6ToKbeapL7zM8b", notes = null, order_type = MetaOrderType.buy, sent_txid = "4217b7b0dcb940e5732c977473c8d893f52370c4", received_txid = "70bc0017c21e29738a93b9f4ce21d36814898bf7bcdfc6feba5227e9ab3495d5", status = MetaOrderStatus.completed, symbol_pair = market }, }); CodeExample <List <TransactionsRowNoUid> >(siteUrl, stream, Routes.kGetMyLastTransactions, WebRequestMethods.Http.Post, "Get your most recent transactions, sorted in descending order. Use this when you know the deposit address to which you sent funds, or the transaction memo. This shows transactions with any status.", new List <DocParam> { new DocParam { description = "The maximum number of results to return.", name = WebForms.kLimit, type = DocType.integer }, }, new List <DocParam> { new DocParam { description = "Bitcoin deposit address.", name = WebForms.kDepositAddress, type = DocType.@string }, new DocParam { description = "BitShares transaction memo.", name = WebForms.kMemo, type = DocType.@string }, }, Routes.kGetMyLastTransactions + RestHelpers.BuildArgs(WebForms.kMemo, "1-mqjz4GnADMucWuR4v"), new List <TransactionsRowNoUid> { new TransactionsRowNoUid { amount = 0.700000M, date = DateTime.UtcNow, deposit_address = "1-n2HPFvf376vxQV1mo", notes = "Over 0.2 BTC!", order_type = MetaOrderType.sell, sent_txid = "f94f79e29110107c917ba41fa02fcfc2ccb5e4cc", received_txid = "ab265b51259a651c68b4a82b8bce5c501325d323", status = MetaOrderStatus.refunded, symbol_pair = market }, new TransactionsRowNoUid { amount = 0.0700000M, date = DateTime.UtcNow, deposit_address = "1-n2HPFvf376vxQV1mo", order_type = MetaOrderType.sell, sent_txid = "ed7364fd1b8ba4cc3428470072300fb88097c3a343c75b6e604c68799a0148cb", received_txid = "18159b00b90374cb467a7744a031d84663e92136", status = MetaOrderStatus.completed, symbol_pair = market }, }); } return(null); }
public ClassWithOutConstructorParameter(out IDummy dependency) { dependency = null; }
public static DummySurrogate To(IDummy value) { return value == null ? null : new DummySurrogate { Negative = -value.Positive }; }
public ClassWithOptionalConstructorParameter(IDummy dependency = null) { }
public static void Consume <T> (IDummy <T> obj) { //SOME CODE HERE. }
public AmbiguousConstructorsTestClass(ConcreteClass class1, IDummy dummy1) { }
public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if MONO AddResource(new JsResource(Constants.kWebRoot, "/js/mainPageCompiled.js", true)); #endif IEnumerable <string> markets = ctx.Request.GetWildcardParameters(2); // get any referral partner out of the query args int refid = 0; if (ctx.Request.QueryArgs.Args.ContainsKey(WebForms.kReferralId)) { int.TryParse((string)ctx.Request.QueryArgs.Args[WebForms.kReferralId], out refid); } string @base = "", quote = ""; if (markets.Count() == 2) { @base = markets.First(); quote = markets.Last(); } string market = @base + "_" + quote; if (authObj.m_database.GetMarket(market) == null) { ctx.Respond(System.Net.HttpStatusCode.NotFound); } ImgResource logo = CreateLogo(); AddResource(logo); // render head base.Render(ctx, stream, authObj); using (new DivContainer(stream, "ng-app", "myApp", "ng-controller", "StatsController", HtmlAttributes.id, "rootId")) { using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix no-padding-bottom-top")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { RenderJumbo(stream, logo); using (new DivContainer(stream, HtmlAttributes.id, "serviceStatusId")) { SPAN("Market status: "); SPAN("{{status}}", "", "label label-{{label}}"); } /*using (new DivContainer(stream, HtmlAttributes.id, "serviceStatusId")) * { * SPAN("Market status: "); * SPAN("{{status}}", "", "label label-{{label}}"); * HR(); * * SPAN("Symbol: "); * SPAN("", "assetSymbolId", "label label-success"); * BR(); * * SPAN("Name: "); * SPAN("", "assetNameId", "label label-success"); * BR(); * * SPAN("Description: "); * SPAN("", "assetDescriptionId", "label label-success"); * BR(); * * SPAN("Supply: "); * SPAN("", "assetSupplyId", "label label-success"); * BR(); * * using (new Script(stream, HtmlAttributes.src, "https://api.bitsharesblocks.com/v2/assets/" + @base + "?callback=UpdateAssetDetails")) * { * * } * }*/ } } } } // // buy and sell section // // using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-6")) { Button("Buy {{market.base_symbol}}<br/><span class='badge'>1.00 {{market.quote_symbol}}</span><span class='glyphicon glyphicon-arrow-right arrow'></span><span class='badge'>{{market.buy_quantity | number:3}} {{market.base_symbol}}</span>", HtmlAttributes.@class, "btn btn-success btn-lg btn-block", "data-toggle", "collapse", "aria-expanded", "false", "aria-controls", "buyId", "data-target", "#buyId"); using (new Panel(stream, "Buy {{market.base_symbol}}", "panel panel-success collapse in", false, "buyId")) { P("Once you enter your BitShares account name, we will generate your deposit address and send your {{market.base_symbol}} to you after 1 confirmation."); using (var fm = new FormContainer(stream, HtmlAttributes.method, "post", HtmlAttributes.ajax, true, HtmlAttributes.handler, "OnSubmitAddressBts", HtmlAttributes.action, Routes.kSubmitAddress)) { using (new DivContainer(stream, HtmlAttributes.@class, "form-group")) { fm.Label(stream, "Where shall we send your {{market.base_symbol}}?"); fm.Input(stream, HtmlAttributes.type, InputTypes.hidden, HtmlAttributes.name, WebForms.kOrderType, HtmlAttributes.value, MetaOrderType.buy.ToString()); fm.Input(stream, HtmlAttributes.type, InputTypes.hidden, HtmlAttributes.name, WebForms.kReferralId, HtmlAttributes.value, refid); fm.Input(stream, HtmlAttributes.type, InputTypes.hidden, HtmlAttributes.name, WebForms.kSymbolPair, HtmlAttributes.value, market); using (new DivContainer(stream, HtmlAttributes.@class, "input-group")) { fm.Input(stream, HtmlAttributes.type, InputTypes.text, HtmlAttributes.name, WebForms.kReceivingAddress, HtmlAttributes.minlength, 1, HtmlAttributes.maxlength, 63, HtmlAttributes.required, true, HtmlAttributes.id, "bitsharesBlurId", HtmlAttributes.@class, "form-control submitOnBlur", HtmlAttributes.placeholder, "BitShares account name"); using (new Span(stream, HtmlAttributes.@class, "input-group-btn")) { Button("Submit", HtmlAttributes.@class, "btn btn-info"); } } } Alert("", "alert alert-danger", "bitsharesErrorId", true); } using (var fm = new FormContainer(stream)) { using (new DivContainer(stream, HtmlAttributes.@class, "form-group has-success unhideBtsId")) { fm.Label(stream, "Your bitcoin deposit address"); fm.Input(stream, HtmlAttributes.type, InputTypes.text, HtmlAttributes.id, "bitcoinDespositId", HtmlAttributes.@class, "form-control", HtmlAttributes.@readonly, "readonly", HtmlAttributes.style, "cursor:text;"); } Button("Click to generate QR code", HtmlAttributes.@class, "btn btn-warning btn-xs pull-right unhideBtsId", HtmlAttributes.onclick, "GenerateQrModal()"); SPAN("Maximum {{market.ask_max | number:8}} {{market.quote_symbol}} per transaction", "maxBtcId", "label label-info"); } } } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-6")) { Button("Sell {{market.base_symbol}}<br/><span class='badge'>{{market.sell_quantity | number:3}} {{market.base_symbol}}</span><span class='glyphicon glyphicon-arrow-right arrow'></span><span class='badge'>1.00 {{market.quote_symbol}}</span>", HtmlAttributes.@class, "btn btn-danger btn-lg btn-block", "data-toggle", "collapse", "aria-expanded", "false", "aria-controls", "sellId", "data-target", "#sellId"); using (new Panel(stream, "Sell {{market.base_symbol}}", "panel panel-danger collapse in", false, "sellId")) { P("Once you enter your bitcoin receiving address, we will generate your deposit address and send your bitcoins to you the instant we receive your {{market.base_symbol}}."); using (var fm = new FormContainer(stream, HtmlAttributes.method, "post", HtmlAttributes.ajax, true, HtmlAttributes.action, Routes.kSubmitAddress, HtmlAttributes.handler, "OnSubmitAddressBtc")) { fm.Input(stream, HtmlAttributes.type, InputTypes.hidden, HtmlAttributes.name, WebForms.kOrderType, HtmlAttributes.value, MetaOrderType.sell.ToString()); fm.Input(stream, HtmlAttributes.type, InputTypes.hidden, HtmlAttributes.name, WebForms.kReferralId, HtmlAttributes.value, refid); fm.Input(stream, HtmlAttributes.type, InputTypes.hidden, HtmlAttributes.id, "symbolPairId", HtmlAttributes.name, WebForms.kSymbolPair, HtmlAttributes.value, market); using (new DivContainer(stream, HtmlAttributes.@class, "form-group")) { fm.Label(stream, "Where shall we send your bitcoins?"); using (new DivContainer(stream, HtmlAttributes.@class, "input-group")) { fm.Input(stream, HtmlAttributes.type, InputTypes.text, HtmlAttributes.name, WebForms.kReceivingAddress, HtmlAttributes.minlength, 25, HtmlAttributes.maxlength, 34, HtmlAttributes.required, true, HtmlAttributes.id, "bitcoinBlurId", HtmlAttributes.@class, "form-control submitOnBlur", HtmlAttributes.placeholder, "Bitcoin address from your wallet"); using (new Span(stream, HtmlAttributes.@class, "input-group-btn")) { Button("Submit", HtmlAttributes.@class, "btn btn-info"); } } } Alert("", "alert alert-danger", "bitcoinErrorId", true); } using (var fm = new FormContainer(stream)) { using (new DivContainer(stream, HtmlAttributes.@class, "unhideBtcId")) { using (new DivContainer(stream, HtmlAttributes.@class, "form-group has-success")) { fm.Label(stream, "Your BitShares deposit account"); fm.Input(stream, HtmlAttributes.type, InputTypes.text, HtmlAttributes.id, "bitsharesDespositAccountId", "ng-model", "sell.sendToAccount", HtmlAttributes.@class, "form-control", HtmlAttributes.@readonly, "readonly", HtmlAttributes.style, "cursor:text;"); } using (new DivContainer(stream, HtmlAttributes.@class, "form-group has-success")) { fm.Label(stream, "Your BitShares deposit memo"); fm.Input(stream, HtmlAttributes.type, InputTypes.text, HtmlAttributes.id, "bitsharesMemoId", "ng-model", "sell.memo", HtmlAttributes.@class, "form-control", HtmlAttributes.@readonly, "readonly", HtmlAttributes.style, "cursor:text;"); } } Button("Click to generate transaction", HtmlAttributes.@class, "btn btn-warning btn-xs pull-right unhideBtcId", HtmlAttributes.onclick, "GenerateTransactionModal()"); SPAN("Maximum {{market.bid_max | number:8}} {{market.base_symbol}} per transaction", "maxbitBtcId", "label label-info pull-left"); } } } } } // // bullet points // using (new DivContainer(stream, HtmlAttributes.@class, "container", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-ok text-info\"></i> No registration required"); P("There is no need to register an account, just tell us where you'd like to receive the coins that you buy or sell."); } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-flash text-info\"></i> Fast transactions"); P("Only one confirmation is neccessary for buying or selling, which is around 7 minutes for a buy and around 3 seconds for a sell."); } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-lock text-info\"></i> Safe"); P("We don't hold any of our customer's funds, so there is nothing to get lost or stolen."); } } } using (new DivContainer(stream, HtmlAttributes.@class, "bg-primary hidden-xs", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.style, "margin:30px 0px 30px 0px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row unhideBtsId unhideBtcId", HtmlAttributes.id, "myTransactionsId")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12")) { H3("Your transactions"); using (new Table(stream, "", 4, 4, "table noMargin", "Market", "Type", "Price", "Amount", "Fee", "Date", "Status", "Notes", "Inbound Tx", "Outbound Tx")) { using (var tr = new TR(stream, "ng-repeat", "t in myTransactions")) { tr.TD("{{renameSymbolPair(t.symbol_pair)}}"); tr.TD("{{t.order_type}}"); tr.TD("{{t.price}}"); tr.TD("{{t.amount}}"); tr.TD("{{t.fee}}"); tr.TD("{{t.date*1000 | date:'MMM d, HH:mm'}}"); tr.TD("{{t.status}}"); tr.TD("{{t.notes}}"); tr.TD("<a ng-if=\"t.order_type=='" + MetaOrderType.buy + "'\" target=\"_blank\" ng-href=\"https://blockchain.info/tx/{{t.received_txid}}\">Look up</a>" + "<a ng-if=\"t.order_type=='" + MetaOrderType.sell + "'\" target=\"_blank\" ng-href=\"http://bitsharesblocks.com/blocks/block?trxid={{t.received_txid}}\">Look up</a>"); tr.TD("<a ng-if=\"t.order_type=='" + MetaOrderType.buy + "' && t.status == '" + MetaOrderStatus.completed + "'\" target=\"_blank\" ng-href=\"http://bitsharesblocks.com/blocks/block?trxid={{t.sent_txid}}\">Look up</a>" + "<a ng-if=\"t.order_type=='" + MetaOrderType.buy + "' && t.status == '" + MetaOrderStatus.refunded + "'\" target=\"_blank\" ng-href=\"https://blockchain.info/tx/{{t.sent_txid}}\">Look up</a>" + "<a ng-if=\"t.order_type=='" + MetaOrderType.sell + "' && t.status == '" + MetaOrderStatus.completed + "'\" target=\"_blank\" ng-href=\"https://blockchain.info/tx/{{t.sent_txid}}\">Look up</a>" + "<a ng-if=\"t.order_type=='" + MetaOrderType.sell + "' && t.status == '" + MetaOrderStatus.refunded + "'\" target=\"_blank\" ng-href=\"http://bitsharesblocks.com/blocks/block?trxid={{t.sent_txid}}\">Look up</a>"); } } } } using (new DivContainer(stream, HtmlAttributes.@class, "unhideBtsId unhideBtcId")) { HR(); } using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12")) { H3("Recent {{renameSymbolPair(market.symbol_pair)}} transactions"); using (new Table(stream, "", 4, 4, "table noMargin", "Market", "Type", "Price", "Amount", "Fee", "Date")) { using (var tr = new TR(stream, "ng-repeat", "t in transactions")) { tr.TD("{{renameSymbolPair(t.symbol_pair)}}"); tr.TD("{{t.order_type}}"); tr.TD("{{t.price}}"); tr.TD("{{t.amount}}"); tr.TD("{{t.fee}}"); tr.TD("{{t.date*1000 | date:'MMM d, HH:mm'}}"); } } } } } } } Modal("Generate BitShares transaction", "bitsharesModalId", () => { using (var fm = new FormContainer(stream)) { using (new DivContainer(stream, HtmlAttributes.@class, "form-group")) { fm.Label(stream, "Sending amount"); using (new DivContainer(stream, HtmlAttributes.@class, "input-group")) { fm.Input(stream, HtmlAttributes.type, InputTypes.number, HtmlAttributes.name, "amount", HtmlAttributes.@class, "form-control", HtmlAttributes.required, true, HtmlAttributes.id, "gtxAmountId", "ng-model", "sell.quantity", HtmlAttributes.placeholder, "bitAsset quantity"); SPAN("{{market.base_symbol}}", "", "input-group-addon"); } } using (new DivContainer(stream, HtmlAttributes.@class, "form-group")) { fm.Label(stream, "Account name to send from"); fm.Input(stream, HtmlAttributes.type, InputTypes.text, HtmlAttributes.name, "account", HtmlAttributes.@class, "form-control", HtmlAttributes.required, true, HtmlAttributes.id, "gtxAccountId", "ng-model", "sell.payFrom", HtmlAttributes.placeholder, "Sending acount"); } Href(stream, "Click to open in BitShares", HtmlAttributes.id, "bitsharesLinkId", HtmlAttributes.href, "bts:{{sell.sendToAccount}}/transfer/amount/{{sell.quantity}}/memo/{{sell.memo}}/from/{{sell.payFrom}}/asset/{{(market.base_symbol).TrimStart('bit')}}", HtmlAttributes.style, "display:none", HtmlAttributes.@class, "btn btn-success"); } }, true, "", "modal", "close", false); Modal("Scan for bitcoin address", "qrModalId", () => { using (new DivContainer(stream, "row text-center")) { BaseComponent.IMG(stream, "", HtmlAttributes.@class, "center-block"); } }, true, "", "modal", "close", false); } return(null); }
public ClassWithDependancy(IDummy dependancy) { this.Dependancy = dependancy; }
public static DummySurrogate To(IDummy value) { return(value == null ? null : new DummySurrogate { Negative = -value.Positive }); }
public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if MONO AddResource(new JsResource(Constants.kWebRoot, "/js/marketsPageCompiled.js", true)); #endif AddResource(new CssResource(Constants.kWebRoot, "/css/markets.css", true)); ImgResource logo = CreateLogo(); AddResource(logo); // render head base.Render(ctx, stream, authObj); using (new DivContainer(stream, "ng-app", "myApp", "ng-controller", "MarketsController", HtmlAttributes.id, "rootId")) { using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix no-padding-bottom-top")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12")) { RenderJumbo(stream, logo); } } } } using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12")) { using (new Table(stream, "", 4, 4, "table table-striped table-hover noMargin", new string[] { "", "hidden-sm hidden-xs hidden-md", "", "", "", "hidden-xs", "hidden-xs", "hidden-xs hidden-sm", "hidden-xs hidden-sm" }, "Market", "Currency", "Price", "Volume (BTC)", "Spread %", "Ask", "Bid", "Buy fee (%)", "Sell fee (%)")) { using (var tr = new TR(stream, "ng-if", "!t.flipped", "ng-repeat", "t in allMarkets", HtmlAttributes.@class, "clickable-row", "ng-click", "go(t)")) { tr.TD("{{renameSymbolPair(t.symbol_pair)}}"); tr.TD("{{t.asset_name}}", HtmlAttributes.@class, "hidden-sm hidden-xs hidden-md"); tr.TD("{{t.last_price}} <i class=\"glyphicon glyphicon-arrow-up text-success\"/>", "ng-if", "t.price_delta>0"); tr.TD("{{t.last_price}} <i class=\"glyphicon glyphicon-arrow-down text-danger\"/>", "ng-if", "t.price_delta<0"); tr.TD("{{t.last_price}} <i class=\"glyphicon glyphicon glyphicon-minus text-info\"/>", "ng-if", "t.price_delta==0"); tr.TD("{{t.btc_volume_24h | number:2}}"); tr.TD("{{t.realised_spread_percent | number:2}}"); tr.TD("{{t.ask}}", HtmlAttributes.@class, "hidden-xs"); tr.TD("{{t.bid}}", HtmlAttributes.@class, "hidden-xs"); tr.TD("{{t.ask_fee_percent | number:2}}", HtmlAttributes.@class, "hidden-sm hidden-xs"); tr.TD("{{t.bid_fee_percent | number:2}}", HtmlAttributes.@class, "hidden-sm hidden-xs"); } } } } } // // bullet points // using (new DivContainer(stream, HtmlAttributes.@class, "container", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-ok text-info\"></i> No registration required"); P("There is no need to register an account, just tell us where you'd like to receive the coins that you buy or sell."); } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-flash text-info\"></i> Fast transactions"); P("Only one confirmation is neccessary for buying or selling, which is around 7 minutes for a buy and around 3 seconds for a sell."); } using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4")) { H4("<i class=\"glyphicon glyphicon-lock text-info\"></i> Safe"); P("We don't hold any of our customer's funds, so there is nothing to get lost or stolen."); } } } using (new DivContainer(stream, HtmlAttributes.@class, "bg-primary hidden-xs", HtmlAttributes.style, "margin-top:20px")) { using (new DivContainer(stream, HtmlAttributes.@class, "container")) { using (new DivContainer(stream, HtmlAttributes.style, "margin:30px 0px 30px 0px")) { using (new DivContainer(stream, HtmlAttributes.@class, "row")) { using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12")) { H3("Recent transactions"); using (new Table(stream, "", 4, 4, "table noMargin", "Market", "Type", "Price", "Amount", "Fee", "Date")) { using (var tr = new TR(stream, "ng-repeat", "t in transactions")) { tr.TD("{{renameSymbolPair(t.symbol_pair)}}"); tr.TD("{{t.order_type}}"); tr.TD("{{t.price}}"); tr.TD("{{t.amount}}"); tr.TD("{{t.fee}}"); tr.TD("{{t.date*1000 | date:'MMM d, HH:mm'}}"); } } } } } } } } return null; }
/// <summary> Executes the get statistics action. </summary> /// /// <remarks> Paul, 30/01/2015. </remarks> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> Task OnGetStats(RequestContext ctx, IDummy dummy) { uint sinceTid = RestHelpers.GetPostArg<uint, ApiExceptionMissingParameter>(ctx, WebForms.kLimit); List<TransactionsRow> lastTransactions = m_database.Query<TransactionsRow>("SELECT * FROM transactions WHERE uid>@uid ORDER BY uid;", sinceTid); SiteStatsRow stats = new SiteStatsRow { bid_price = m_bidPrice, ask_price = m_askPrice, max_bitassets = m_bitsharesDepositLimit, max_btc = m_bitcoinDepositLimit }; ctx.Respond<StatsPacket>(new StatsPacket { m_lastTransactions = lastTransactions, m_stats = stats }); return null; }
static void Main(string[] args) { Chart chart = new Chart("Runtime", "Associativity", "Runtime [s]", false); InitializationAndWarmup(); //int cacheSize = (1 << 23) / 4; //Use to provoke cache thrashing. Value must be the L3 cache-size in integer (i.e. cache size in byte divided by sizeof(int)). int cacheSize = 2999999; //Use to avoid cache thrashing. May be larger than the L3 cache-size but should be prime. int cacheLineLength = 64 / 4; int numberOfThreads = 8; long repetitions = 1 << 2; int cnt = 0; IDummy dummy = DummyFactory.Get(); for (int associativity = 1; associativity <= 16; associativity++) { int n = cacheSize * associativity * numberOfThreads; int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = cnt++; fixed(int *a = arr) { Arr array = new Arr() { a = a }; Thread[] threads = new Thread[numberOfThreads]; for (int i = 0; i < numberOfThreads; i++) { int start = associativity * cacheSize * i; int coreIndex = i; threads[i] = new Thread( () => Run(array, start, cacheSize, cacheLineLength, associativity, repetitions, coreIndex, dummy)); } Stopwatch stopwatch = Stopwatch.StartNew(); foreach (Thread thread in threads) { thread.Start(); } for (int i = 0; i < numberOfThreads; i++) { threads[i].Join(); } stopwatch.Stop(); string sumIndicator = totalSum == 42 ? "42" : ""; Console.WriteLine($"associativity={associativity} elapsed={stopwatch.Elapsed} {sumIndicator}"); chart.Add($"{numberOfThreads} threads", associativity, stopwatch.ElapsedMilliseconds); } } chart.Save(typeof(CacheThrashing)); chart.Show(); Console.WriteLine("Finished..."); Console.ReadKey(); }
/// <summary> Executes the submit address action. </summary> /// /// <remarks> Paul, 25/01/2015. </remarks> /// /// <exception cref="ApiExceptionMessage"> Thrown when an API exception message error /// condition occurs. </exception> /// <exception cref="ApiExceptionMissingParameter"> Thrown when an API exception missing /// parameter error condition occurs. </exception> /// /// <param name="ctx"> The context. </param> /// <param name="dummy"> The dummy. </param> /// /// <returns> A Task. </returns> Task OnSubmitAddress(RequestContext ctx, IDummy dummy) { CurrencyTypes fromCurrency = RestHelpers.GetPostArg<CurrencyTypes, ApiExceptionMissingParameter>(ctx, WebForms.kFromCurrency); CurrencyTypes toCurrency = RestHelpers.GetPostArg<CurrencyTypes, ApiExceptionMissingParameter>(ctx, WebForms.kToCurrency); string receivingAddress = RestHelpers.GetPostArg<string, ApiExceptionMissingParameter>(ctx, WebForms.kReceivingAddress); SubmitAddressResponse response; if (fromCurrency == CurrencyTypes.BTC && toCurrency == CurrencyTypes.bitBTC) { string accountName = receivingAddress; // try and retrieve a previous entry SenderToDepositRow senderToDeposit = m_database.Query<SenderToDepositRow>("SELECT * FROM sender_to_deposit WHERE receiving_address=@s;", accountName).FirstOrDefault(); if (senderToDeposit == null || !BitsharesWallet.IsValidAccountName(accountName)) { // no dice, create a new entry // validate bitshares account name try { BitsharesAccount account = m_bitshares.WalletGetAccount(accountName); // generate a new bitcoin address and tie it to this account string depositAdress = m_bitcoin.GetNewAddress(); senderToDeposit = InsertSenderToDeposit(account.name, depositAdress); } catch (BitsharesRpcException) { throw new ApiExceptionMessage(accountName + " is not an existing account! Are you sure it is registered?"); } } response = new SubmitAddressResponse { deposit_address = senderToDeposit.deposit_address }; } else if (fromCurrency == CurrencyTypes.bitBTC && toCurrency == CurrencyTypes.BTC) { string bitcoinAddress = receivingAddress; // try and retrieve a previous entry SenderToDepositRow senderToDeposit = m_database.Query<SenderToDepositRow>("SELECT * FROM sender_to_deposit WHERE receiving_address=@s;", bitcoinAddress).FirstOrDefault(); if (senderToDeposit == null) { // validate bitcoin address byte[] check = Util.Base58CheckToByteArray(bitcoinAddress); if (check == null) { throw new ApiExceptionMessage(bitcoinAddress + " is not a valid bitcoin address!"); } // generate a memo field to use instead string start = "meta-"; string memo = start + bitcoinAddress.Substring(0, BitsharesWallet.kBitsharesMaxMemoLength - start.Length); senderToDeposit = InsertSenderToDeposit(bitcoinAddress, memo); } response = new SubmitAddressResponse { deposit_address = m_bitsharesAccount, memo = senderToDeposit.deposit_address }; } else { throw new ApiExceptionUnsupportedTrade(fromCurrency, toCurrency); } ctx.Respond<SubmitAddressResponse>(response); return null; }
// /error/error1 // Triggers a InvalidOperationException exception public IActionResult Error1(IDummy dummy) { return(View()); }
static void Main(string[] args) { //var acct1 = new Account();//cannot instantiate because it is Abstract var dummy = new IDummy(); Checking chk1 = new Checking(); chk1.Number = "101"; chk1.Name = "My Checking Account"; chk1.Deposit(150); chk1.pay(100, 20); /* * * Savings sav1 = new Savings(); * * sav1.Number = "1005"; * sav1.Name = "My Savings Account"; * sav1.ChangeRate(0.02); * * * MoneyMarket monm = new MoneyMarket(); * monm.Number = "1003"; * monm.Name = "MoneyMarket 1"; * monm.MMRate = .1; * * monm.Deposit(2000); * monm.Withdraw(1000); * //monm.PayInterest(12); */ Account[] accounts = new Account[] { chk1 }; foreach (Account acct in accounts) { Console.WriteLine(acct.Print()); } /* * Console.WriteLine(sav1.Print()); * Console.WriteLine(monm.Print()); * * Console.WriteLine($"MoneyMarket Balance is {monm.GetBalance()}"); * * bool ItWorked = monm.TransferTo(sav1, 1250); * * Console.WriteLine($"MoneyMarket Balance is {monm.GetBalance()}"); * Console.WriteLine($"Saving1 Balance is {sav1.GetBalance()}"); * * * * Savings sav = new Savings(); * sav.Number = "1002";//the .Number is available, but is not in the Savings Class. That is because it is inherited from Account * sav.Name = "Savings 1"; * sav.IntRate = .05; * /* * sav.Deposit(200); * sav.Withdraw(100); * decimal interestTobePaid = sav.CalcInterest(6);//number of months of interest * sav.PayInterest(interestTobePaid); * decimal savbal = sav.GetBalance(); * Console.WriteLine($"Saving balance is {savbal}"); * * sav.Deposit(10);//always begin the line with the variable * sav.Withdraw(10); * decimal balance = sav.GetBalance(); * Console.WriteLine($"Account Balance is {balance} (should be 10)");//added the (should be 10) to verify result * * sav.Deposit(200); * balance = sav.GetBalance(); * Console.WriteLine($"Account Balance is {balance} (should be 10)"); * * sav.Withdraw(100); * balance = sav.GetBalance(); * Console.WriteLine($"Account Balance is {balance} (should be 10)"); * * sav.Withdraw(35); * balance = sav.GetBalance(); * Console.WriteLine($"Account Balance is {balance}"); * * * * /* * Account acct = new Account();// creates a new account instance with Default Constructor * acct.Number = "1001"; //establishes a property as an instance using the 'variable.property name' * acct.Name = "Test Account";//we have just established the three properties * * acct.Deposit(10);//always begin the line with the variable * acct.Withdraw(10); * decimal balance = acct.GetBalance(); * Console.WriteLine($"Account Balance is {balance} (should be 10)");//added the (should be 10) to verify result * * acct.Deposit(-10); * balance = acct.GetBalance(); * Console.WriteLine($"Account Balance is {balance} (should be 10)");*/ }
public Test(IDummy dummy) { Dummy = dummy; }
public DummyNested(IDummy parent) { _parent = parent; }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ctx"></param> /// <param name="stream"></param> /// <param name="authObj"></param> /// <returns></returns> public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj) { #if !MONO foreach (string name in m_sharedJsFilenames) { AddResource(new JsResource(Constants.kWebRoot, name, true)); } #endif AddResource(new CssResource(Constants.kWebRoot, "/css/site.css", true)); AddResource(new CssResource(Constants.kWebRoot, "/css/bootstrap.min.css", true)); AddResource(new FavIconResource(Constants.kWebRoot, "/images/favicon.ico")); AddResource(new TitleResource("Metaexchange")); AddResource(new MetaResource("viewport", "width=device-width, initial-scale=1")); ImgResource brand = new ImgResource(Constants.kWebRoot, "/images/brandTitle.png", "", false); AddResource(brand); // render head base.Render(ctx, stream, authObj); m_stream.WriteLine("<!-- Just for debugging purposes. Don't actually copy this line! --> <!--[if lt IE 9]><script src=\"../../assets/js/ie8-responsive-file-warning.js\"></script><![endif]--> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script> <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script><![endif]-->"); // begin body m_stream.WriteLine("<body>"); using (new DivContainer(m_stream, HtmlAttributes.@class, "navbar navbar-default navbar-fixed-top")) { using (new DivContainer(m_stream, HtmlAttributes.@class, "container")) { using (new DivContainer(m_stream, HtmlAttributes.@class, "navbar-header")) { using (new Link(m_stream, HtmlAttributes.@class, "navbar-brand", HtmlAttributes.href, "/")) { brand.Write(m_stream); m_stream.Write(" metaexchange"); } } using (new DivContainer(m_stream, HtmlAttributes.@class, "navbar-collapse collapse")) { string page = ctx.Request.Url.LocalPath.Split('/').Last(); IEnumerable <MarketRow> allMarkets = authObj.m_database.GetAllMarkets().Where(m => m.visible); using (var ul = new UL(stream, "nav navbar-nav pull-left")) { using (var li = new LI(stream, "dropdown")) { Href(stream, "Markets <span class=\"caret\">", HtmlAttributes.href, "/", HtmlAttributes.@class, "disabled", "data-toggle", "dropdown", "role", "button", "aria-expanded", "false"); using (new UL(stream, HtmlAttributes.@class, "dropdown-menu", "role", "menu")) { foreach (MarketRow m in allMarkets.Where(m => !m.flipped)) { WriteLiHref(stream, CurrencyHelpers.RenameSymbolPair(m.symbol_pair), "", "", HtmlAttributes.href, "/markets/" + CurrencyHelpers.RenameSymbolPair(m.symbol_pair)); } } } //WriteLiHref(stream, "Home", GetLiClass(page, ""), "", HtmlAttributes.href, "/"); WriteLiHref(stream, "Api", GetLiClass(page, "apiDocs"), "", HtmlAttributes.href, "/apiDocs"); WriteLiHref(stream, "Faq", GetLiClass(page, "faq"), "", HtmlAttributes.href, "/faq"); } } } } return(null); }
public SomeContainer(IDummy dummy) { Dummy = dummy; }