public void StripePattern_ShouldBeConstantInY() { var pattern = new Stripe(white, black); Assert.Equal(white, pattern.PatternAt(new Point(0, 0, 0))); Assert.Equal(white, pattern.PatternAt(new Point(0, 1, 0))); Assert.Equal(white, pattern.PatternAt(new Point(0, 2, 0))); }
// Nathan wrote this // sets a stripe's orientation to the lane // parameter stripe is the stripe which we are // setting the orientation of // parameter stripeOrientation is its // new orientation public void setStripeOrientation(GameObject stripe, string stripeOrientation) { Stripe stripeScriptReference = null; // first of all, check for null // if the stripe object is not null, set the stripes accordingly if (stripe != null) { stripeScriptReference = (Stripe)stripe.GetComponent("Stripe"); if (stripeOrientation == "left") { // the stripe is now this lane's "left" stripe leftStripe = stripe; // this lane is now the stripe's "right" lane stripeScriptReference.setLaneOrientation(this.gameObject, "right"); stripeScriptReference.setStripePosition(gameObject.transform.localPosition, -currentLaneWidth / 2); leftStripe.transform.parent = gameObject.transform; } else if (stripeOrientation == "right") { // the stripe is now this lane's "right" stripe rightStripe = stripe; // this lane is now the stripe's "left" lane stripeScriptReference.setLaneOrientation(this.gameObject, "left"); stripeScriptReference.setStripePosition(gameObject.transform.localPosition, currentLaneWidth / 2); rightStripe.transform.parent = gameObject.transform; } // error case else { throw new System.ArgumentException("Invalid stripe orientation."); } } // if the stripe is null, then do one of the following: else { // if left stripe is specified, make it null if (stripeOrientation == "left") { Destroy(leftStripe); leftStripe = null; } // if right stripe is specified, make it null else if (stripeOrientation == "right") { Destroy(rightStripe); rightStripe = null; } // otherwise, make them both null else { Destroy(leftStripe); Destroy(rightStripe); leftStripe = null; rightStripe = null; } } }
public void StripeGatewayCreatesCard() { var paymentGateway = new Stripe(); var card = paymentGateway.CreateCard(1, "alain rex rivas", "4242424242424242", 12.ToString(), 2018.ToString(), 123.ToString()); Assert.IsNotNull(card); Assert.IsNotNull(card["id"]); Assert.IsNull(card["error"]); }
public void StripeGatewayCreatesCustomer() { var paymentGateway = new Stripe(); int Id = 1; var customer = paymentGateway.Customer(Id, "alain rivas", "*****@*****.**"); Assert.IsNotNull(customer); Assert.IsNull(customer["error"]); }
public override void Invoke(Stripe stripe, Dictionary <string, string> matchValues, string zipPath) { var path = _configuration.Path.ReplaceMatchedValues(matchValues); _log.Debug("Extracting {zipFile}, to {path}.", zipPath, path); using (var zip = ZipFile.Read(zipPath)) { zip.ExtractAll(path, ExtractExistingFileAction.OverwriteSilently); } }
public void StripeFileMatches(string filePattern, string fileName, bool expectedResult) { var doc = new XElement("stripe", new XAttribute("file", filePattern)); var config = new StripeConfiguration(doc); var stripe = new Stripe(config); var result = stripe.ExecuteFor(fileName); Assert.AreEqual(expectedResult, result != null); }
public StripeVM(VideoPlayerVM videoPlayerVM, StripeContainerVM stripeContainerVM, Stripe body) { VideoPlayerVM = videoPlayerVM; Body = body; StripeContainerVM = stripeContainerVM; Body.DataContext = this; VideoPlayerVM.SyncronizationShiftVM.PropertyChanged += SyncronizationShiftVM_PropertyChanged; VideoPlayerVM.PropertyChanged += VideoPlayerVM_PropertyChanged; Body.UpFocus += Body_UpFocus; }
public override string GetDescription(Stripe stripe, Dictionary <string, string> matchValues, string zipPath) { var configName = _configuration.Name.ReplaceMatchedValues(matchValues); if (_configuration.Action == "start") { return("Start application pool " + configName); } return("Stop application pool " + configName); }
public void StripePattern_ShouldAlternateInX() { var pattern = new Stripe(white, black); Assert.Equal(white, pattern.PatternAt(new Point(0, 0, 0))); Assert.Equal(white, pattern.PatternAt(new Point(0.9, 0, 0))); Assert.Equal(black, pattern.PatternAt(new Point(1, 0, 0))); Assert.Equal(black, pattern.PatternAt(new Point(-0.1, 0, 0))); Assert.Equal(black, pattern.PatternAt(new Point(-1, 0, 0))); Assert.Equal(white, pattern.PatternAt(new Point(-1.1, 0, 0))); }
// Nathan wrote this // loads a saved lane's data public void loadLaneAtts(LaneData savedLane) { // just need to reassign each of the lane's attributes (position, width, stripes, etc.) // not sure we need position (the lanes will be inserted either way, and should all be // the correct type and in the correct order without resetting this) // also not sure we need to set type, max/min width, or the booleans // as these should all be set properly by inserting the saved lane type // the only true variables are the width and the stripes setLaneWidth(savedLane.loadLaneWidth()); // stripes could be a little more complicated // first, load in the data for both stripes StripeData leftStripeData = savedLane.loadStripeData("left"); StripeData rightStripeData = savedLane.loadStripeData("right"); // if the stripes are not null, load in their data // otherwise, just set their orientation to null if (leftStripeData != null) { // subcase: not sure if we need it, but just in case if (leftStripe != null) { Stripe leftStripeScriptReference = (Stripe)leftStripe.GetComponent("Stripe"); leftStripeScriptReference.loadStripeAtts(leftStripeData); } else { Debug.Log("This almost certainly should never happen. INSIDE WEIRD LOADING CASE."); } } else { setStripeOrientation(null, "left"); } if (rightStripeData != null) { // again, not sure we need this subcase if (rightStripe != null) { Stripe rightStripeScriptReference = (Stripe)rightStripe.GetComponent("Stripe"); rightStripeScriptReference.loadStripeAtts(rightStripeData); } else { Debug.Log("This almost certainly should never happen. INSIDE WEIRD LOADING CASE."); } } else { setStripeOrientation(null, "right"); } }
public StripeDrawing getStripeDrawingForOverTaking(Stripe stripeForOverTaking) { StripeDrawing returnedStripeDrawing = null; foreach (StripeDrawing sd in stripeDrawings) { if (sd.stripe.Equals(stripeForOverTaking)) { returnedStripeDrawing = sd; } } return(returnedStripeDrawing); }
public void StripeExtractsMatchGroups(string filePattern, string fileName, string groupName, string groupValue) { var doc = new XElement("stripe", new XAttribute("file", filePattern)); var config = new StripeConfiguration(doc); var stripe = new Stripe(config); var result = stripe.ExecuteFor(fileName); Assert.IsNotNull(result); var value = result[groupName]; Assert.AreEqual(groupValue, value); }
public override void Invoke(Stripe stripe, string zipName) { var obj = new { color = stripe.Failed ? "red" : "green", message = stripe.Failed ? $"Failed to deploy stripe {zipName} at {Environment.MachineName}. It failed at step \"{stripe.CurrentStep}\"." : $"Successfully deployed stripe {zipName} at {Environment.MachineName}.", notify = stripe.Failed, message_format = "text" }; using (var wc = new WebClient()) { wc.Headers.Add("Content-Type", "application/json"); try { wc.UploadString(_configuration.Room, JsonConvert.SerializeObject(obj)); } catch (Exception e) { _log.Error(e, "Failed to report {file} to HipChat.", zipName); } } }
public void ImportModule(Module module, string content, string version) { List <Stripe> Stripes = null; if (!string.IsNullOrEmpty(content)) { Stripes = JsonSerializer.Deserialize <List <Stripe> >(content); } if (Stripes != null) { foreach (Stripe Stripe in Stripes) { Stripe _Stripe = new Stripe(); _Stripe.ModuleId = module.ModuleId; _Stripe.Name = Stripe.Name; _Stripes.AddStripe(_Stripe); } } }
protected override void OnHandleIntent(Intent intent) { string errorMessage = null; Token token = null; if (intent != null) { string cardNumber = intent.GetStringExtra(EXTRA_CARD_NUMBER); Integer month = (Integer)intent.Extras.Get(EXTRA_MONTH); Integer year = (Integer)intent.Extras.Get(EXTRA_YEAR); string cvc = intent.GetStringExtra(EXTRA_CVC); string publishableKey = intent.GetStringExtra(EXTRA_PUBLISHABLE_KEY); Card card = new Card(cardNumber, month, year, cvc); Stripe stripe = new Stripe(this); try { token = stripe.CreateTokenSynchronous(card, publishableKey); } catch (StripeException stripeEx) { errorMessage = stripeEx.LocalizedMessage; } } Intent localIntent = new Intent(TOKEN_ACTION); if (token != null) { localIntent.PutExtra(STRIPE_CARD_LAST_FOUR, token.Card.Last4); localIntent.PutExtra(STRIPE_CARD_TOKEN_ID, token.Id); } if (errorMessage != null) { localIntent.PutExtra(STRIPE_ERROR_MESSAGE, errorMessage); } // Broadcasts the Intent to receivers in this app. LocalBroadcastManager.GetInstance(this).SendBroadcast(localIntent); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag != "Player") { Stripe stripe = gameObject.GetComponentInParent <Stripe>(); stripe.miniStripes.RemoveFirst(); if (stripe.speed < 0) { transform.position = stripe.miniStripes.Last.Value.position + new Vector3(1.6f, 0, 0); } else { transform.position = stripe.miniStripes.Last.Value.position - new Vector3(1.6f, 0, 0); } stripe.miniStripes.AddLast(transform); } }
private void InitWalletStripe() { try { var stripePublishableKey = ListUtils.SettingsSiteList?.StripeId ?? ""; if (!string.IsNullOrEmpty(stripePublishableKey)) { PaymentConfiguration.Init(stripePublishableKey); Stripe = new Stripe(this, stripePublishableKey); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_ErrorConnectionSystemStripe), ToastLength.Long)?.Show(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public override int ReadFrom(byte[] buffer, int offset) { ChunkSize = EndianUtilities.ToUInt64LittleEndian(buffer, offset); ObjectId = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 0x8); StripeLength = EndianUtilities.ToUInt64LittleEndian(buffer, offset + 0x10); Type = (BlockGroupFlag)EndianUtilities.ToUInt64LittleEndian(buffer, offset + 0x18); OptimalIoAlignment = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x20); OptimalIoWidth = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x24); MinimalIoSize = EndianUtilities.ToUInt32LittleEndian(buffer, offset + 0x28); StripeCount = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 0x2c); SubStripes = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 0x2e); Stripes = new Stripe[StripeCount]; offset += 0x30; for (int i = 0; i < StripeCount; i++) { Stripes[i] = new Stripe(); offset += Stripes[i].ReadFrom(buffer, offset); } return(Size); }
public override void Invoke(Stripe stripe, string zipName) { foreach (var userKey in _configuration.UserKeys) { var values = new NameValueCollection(); values.Add("token", _configuration.ApplicationKey); values.Add("user", userKey); values.Add("title", "Zebra Deploy"); values.Add("message", stripe.Failed ? $"Failed to deploy stripe {zipName} at {Environment.MachineName}. It failed at step \"{stripe.CurrentStep}\"." : $"Successfully deployed stripe {zipName} at {Environment.MachineName}."); values.Add("priority", stripe.Failed ? "0" : "-1"); using (var wc = new WebClient()) { try { wc.UploadValues("https://api.pushover.net/1/messages.json", values); } catch (Exception e) { _log.Error(e, "Failed to report {file} to Pusohver {user}.", zipName, userKey); } } } }
// Nathan wrote this // class constructor // lane is the script of a lane object within the road public LaneData(BasicLane lane) { // store the lane position Vector3 lanePositionVector = lane.getLanePosition(); lanePosition[0] = lanePositionVector.x; lanePosition[1] = lanePositionVector.y; lanePosition[2] = lanePositionVector.z; // store the lane width and the max/min values laneWidth = lane.getLaneWidth(); maxWidth = lane.getMaxWidth(); minWidth = lane.getMinWidth(); // store the lane type laneType = lane.getLaneType(); // store the booleans vehicleLane = lane.isVehicleLane(); nonVehicleAsphalt = lane.isNonVehicleAsphaltLane(); nonAsphalt = lane.isNonAsphaltLane(); // store the stripes' data GameObject leftStripe = lane.getStripe("left"); GameObject rightStripe = lane.getStripe("right"); if (leftStripe != null) { Stripe leftStripeScriptRef = (Stripe)leftStripe.GetComponent("Stripe"); leftStripeData = new StripeData(leftStripeScriptRef); } else { leftStripeData = null; } if (rightStripe != null) { Stripe rightStripeScriptRef = (Stripe)rightStripe.GetComponent("Stripe"); rightStripeData = new StripeData(rightStripeScriptRef); } else { rightStripeData = null; } }
private void SaveCard() { Card cardToSave = mCardInputWidget.Card; if (cardToSave == null) { mErrorDialogHandler.ShowError("Invalid Card Data"); return; } Stripe stripe = new Stripe(mContext); IObservable <Token> tokenObservable = Observable.FromAsync((s) => { return(Task.Run(() => stripe.CreateTokenSynchronous(cardToSave, mPublishableKey))); }); mCompositeSubscription.Add( tokenObservable .SubscribeOn <Token>(Scheduler.Immediate) .ObserveOn <Token>(Scheduler.CurrentThread) .Do <Token>( (token) => { mProgressDialogController.StartProgress(); }, (b) => { mProgressDialogController.FinishProgress(); }) .Subscribe( (token) => { mOutputListController.AddToList(token); }, (throwable) => { mErrorDialogHandler.ShowError(throwable.Message); })); }
private void InitWalletStripe() { try { var stripePublishableKey = ListUtils.SettingsSiteList.FirstOrDefault()?.StripeId ?? ""; if (!string.IsNullOrEmpty(stripePublishableKey)) { PaymentConfiguration.Init(stripePublishableKey); Stripe = new Stripe(this, stripePublishableKey); MPaymentsClient = WalletClass.GetPaymentsClient(this, new WalletClass.WalletOptions.Builder() .SetEnvironment(WalletConstants.EnvironmentTest) .SetTheme(WalletConstants.ThemeLight) .Build()); IsReadyToPay(); } } catch (Exception e) { Console.WriteLine(e); } }
public StripeModel() { Parent = null; Stripe = new Stripe(); Name = String.Empty; }
public override string GetDescription(Stripe stripe, Dictionary <string, string> matchValues, string zipPath) { var path = _configuration.Path.ReplaceMatchedValues(matchValues); return("Clean path " + path); }
public override void Invoke(Stripe stripe, Dictionary <string, string> matchValues, string zipPath) { // Server manager seems to be using some COM behind the scenes // that doesn't like it multithreaded.. lock (_lock) { var configName = _configuration.Name.ReplaceMatchedValues(matchValues); try { var manager = new ServerManager(); var pool = manager.ApplicationPools[configName]; if (pool == null) { throw new InvalidOperationException($"Failed to locate application pool named {configName}."); } var timestamp = DateTime.Now; if (_configuration.Action == "start") { if (pool.State == ObjectState.Started || pool.State == ObjectState.Starting) { return; } _log.Debug("Starting application pool {poolName}", configName); var state = ObjectState.Unknown; while (state != ObjectState.Started) { try { pool.Start(); } catch (Exception) { // Here there be dragons, beware.. } if (timestamp.AddSeconds(20) < DateTime.Now) { break; } Thread.Sleep(200); state = pool.State; } } else { if (pool.State == ObjectState.Stopped || pool.State == ObjectState.Stopping) { return; } _log.Debug("Stopping application pool {poolName}", configName); var state = ObjectState.Unknown; while (state != ObjectState.Stopped) { try { pool.Stop(); } catch (Exception) { // Here there be dragons, beware.. } if (timestamp.AddSeconds(20) < DateTime.Now) { break; } Thread.Sleep(200); state = pool.State; } } } catch (Exception e) { _log.Error(e, "Failed while working with application pool {poolName}", configName); } } }
// Nathan wrote this // constructor for class StripeData // stripe is the script of a stripe object attached to a lane public StripeData(Stripe stripe) { // get the current stripe type stripeType = stripe.getStripeType(); }
public async Task <ActionResult> Register(Stripe model) { if (!ModelState.IsValid) { return(View("Register", model)); } var UserStore = new UserStore <ApplicationUser>(new ApplicationDbContext()); var UserManager = new UserManager <ApplicationUser>(UserStore); var dbUser = await UserManager.FindByNameAsync(model.UserName); if (dbUser != null) { ViewBag.RegisterError = "UserName Already Exists"; return(View("Register", model)); } dbUser = null; dbUser = await UserManager.FindByEmailAsync(model.EmailAddress); if (dbUser != null) { ViewBag.RegisterError = "Email Already Exists"; return(View("Register", model)); } try { var cardToken = gateway.Post(new CreateStripeToken { Card = new StripeCard { Name = model.FirstName + model.LastName, Number = model.CreditCard, Cvc = model.CVC, ExpMonth = Convert.ToInt32(model.ExpMonth), ExpYear = Convert.ToInt32(model.ExpYear), AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, AddressZip = model.ZipCode, AddressState = model.State, AddressCountry = model.Country, }, }); var customer = gateway.Post(new CreateStripeCustomerWithToken { Card = cardToken.Id, Description = "FastFood Items Purchasing", Email = model.EmailAddress, }); var User = new ApplicationUser() { UserName = model.UserName, Email = model.EmailAddress, PhoneNumber = model.PhoneNo, isDisable = false, CustomerId = customer.Id }; IdentityResult result = await UserManager.CreateAsync(User, model.Password); if (result.Succeeded) { //I Created The Role FOr SuperAdmin //var RoleStore = new RoleStore<IdentityRole>(); //var RoleManager = new RoleManager<IdentityRole>(RoleStore); //var Role = new IdentityRole() //{ // Name = "CanManageWebSite" //}; //await RoleManager.CreateAsync(Role); //await UserManager.AddToRoleAsync(User.Id, Role.Name); var AuthenticationManager = System.Web.HttpContext.Current.GetOwinContext().Authentication; var UserIdentity = await UserManager.CreateIdentityAsync(User, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, UserIdentity); return(RedirectToAction("Index", "Items")); } else { ViewBag.RegisterError = "Password Format Is Not Correct"; return(View("Register", model)); } } catch (Exception ety) { ViewBag.RegisterError = " Enter Correct Information Of Credit Card "; return(View("Register", model)); } }
public abstract void Invoke(Stripe stripe, string zipName);
public override void Invoke(Stripe stripe, Dictionary <string, string> matchValues, string zipPath) { var configName = _configuration.Name.ReplaceMatchedValues(matchValues); try { var service = new ServiceController(configName); try { service.Refresh(); } catch (Exception) { throw new InvalidOperationException($"Failed to locate refresh values for service {configName}."); } var timestamp = DateTime.Now; if (_configuration.Action == "start") { if (service.Status == ServiceControllerStatus.Running) { return; } _log.Debug("Starting service {serviceName}", configName); var state = service.Status; while (state != ServiceControllerStatus.Running) { try { service.Start(); } catch (Exception) { // Here there be dragons, beware.. } if (timestamp.AddSeconds(20) < DateTime.Now) { break; } Thread.Sleep(200); service.Refresh(); state = service.Status; } } else { if (service.Status == ServiceControllerStatus.Stopped) { return; } _log.Debug("Stopping service {serviceName}", configName); var state = service.Status; while (state != ServiceControllerStatus.Stopped) { try { service.Stop(); } catch (Exception) { // Here there be dragons, beware.. } if (timestamp.AddSeconds(20) < DateTime.Now) { break; } Thread.Sleep(200); service.Refresh(); state = service.Status; } } } catch (Exception e) { _log.Error(e, "Failed while working with service {serviceName}", configName); } }
public StripeModel(object parent, Stripe obj) { Parent = parent ?? throw new ArgumentNullException(nameof(parent)); Stripe = obj ?? throw new ArgumentNullException(nameof(obj)); Name = DisplayStringFactory.StripeName(Stripe.Name); }