private CanReuseSnapshotResult(SnapshotState state) { Contract.Requires(state == SnapshotState.NoMatch); SpecsWithTheSamePublicSurface = new List <ISourceFile>(); SpecsWithIncompatiblePublicSurface = new List <ISourceFile>(); State = state; }
public async Task <HttpResponseMessage> Get(string eventName) { eventBitEntities entities = new eventBitEntities(); //Grab my X-AUTH from header. string reqAuth = Request.Headers.GetValues("X-AUTH-CLAIMS").First(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://dev.experienteventbit.com/webapi/API/Event/"); client.DefaultRequestHeaders.Add("X-AUTH-CLAIMS", reqAuth); HttpResponseMessage response = client.GetAsync(eventName + "/TrackingData").Result; string newXAuthHeader = response.Headers.GetValues("X-AUTH-CLAIMS").First(); var data = await response.Content.ReadAsStringAsync(); //Check for error HttpResponseMessage r = new HttpResponseMessage(); if (response.StatusCode == HttpStatusCode.OK) { var d = JsonConvert.DeserializeObject <TrackedData>(data); SnapshotState ssState; //Check my snapshot id. ssState = entities.SnapshotStates.FirstOrDefault(x => x.ShowCode == eventName); if (ssState != null) { if (ssState.UniqueIdentifier == d.UniqueIdentifier) { return(RH.OK(newXAuthHeader, "Snapshot unique identifier matches currently loaded snapshot, no new snapshot available.")); } } else { ssState = new SnapshotState(); ssState.ShowCode = eventName; entities.SnapshotStates.Add(ssState); } ProcessTrackedData(d, eventName); ssState.UniqueIdentifier = d.UniqueIdentifier; entities.SaveChanges(); return(RH.OK(newXAuthHeader, "Snapshot sync complete.")); } else { return(RH.BadRequest(newXAuthHeader, data)); } }
/// <summary> /// Initializes a new instance of the <see cref="SnapshotEnteredErrorStateException"/> class with the /// specified snapshot state. /// </summary> /// <param name="status">The erroneous snapshot state.</param> /// <exception cref="ArgumentNullException">If <paramref name="status"/> is <see langword="null"/>.</exception> public SnapshotEnteredErrorStateException(SnapshotState status) : base(string.Format("The snapshot entered an error state: '{0}'", status)) { if (status == null) throw new ArgumentNullException("status"); _state.Status = status.Name; #if !NET35 SerializeObjectState += (ex, args) => args.AddSerializedState(_state); #endif }
internal override void ResetTransform() { base.ResetTransform(); this.previousPanSign = this.panSign; this.panSign = 0; this.flickSign = 0; this.rotation = 0; this.View.TransitionLayer.Opacity = 0; this.snapshotState = SnapshotState.None; }
/// <summary> /// Initializes a new instance of the <see cref="SnapshotEnteredErrorStateException"/> with the /// specified snapshot state. /// </summary> /// <param name="status">The erroneous snapshot state.</param> /// <exception cref="ArgumentNullException">If <paramref name="status"/> is <see langword="null"/>.</exception> public SnapshotEnteredErrorStateException(SnapshotState status) : base(string.Format("The snapshot entered an error state: '{0}'", status)) { if (status == null) { throw new ArgumentNullException("status"); } _state.Status = status.Name; #if !NET35 SerializeObjectState += (ex, args) => args.AddSerializedState(_state); #endif }
public void GenerateSnapshot_Should_Grab_FromState() { var state = new SnapshotState(); for (int i = 0; i < 10; i++) { state.Apply(new BehaviorEventTest()); } var b = new NumericSnapshotBehavior(10); var events = b.GenerateSnapshot(state); events.Should().HaveCount(10); }
protected void RefreshAllTags(ITextSnapshot snapshot) { Debug.Assert(snapshot != null); if (snapshot == null) { return; } lock (lockObj) { lastSnapshotState?.Cancel(); lastSnapshotState?.FreeRef(); lastSnapshotState = null; cachedTags.Clear(); } TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length))); }
private void OnCompositionTargetRendering(object sender, object e) { CompositionTarget.Rendering -= this.OnCompositionTargetRendering; this.snapshotState = SnapshotState.Ready; if (this.waitingForFlick) { this.waitingForFlick = false; double to = this.panSign == this.flickSign ? this.MaxRotationAngle : 0; this.AnimateRotation(to, SlideViewAnimationState.Flick, 2 * AnimationDiration); } else if (!this.IsManipulating) { this.ResetTransform(); } }
/// <inheritdoc /> public Snapshot WaitForSnapshotState(string snapshotId, SnapshotState expectedState, SnapshotState[] errorStates, int refreshCount = 60, TimeSpan?refreshDelay = null, string region = null, CloudIdentity identity = null) { if (snapshotId == null) { throw new ArgumentNullException("snapshotId"); } if (expectedState == null) { throw new ArgumentNullException("expectedState"); } if (errorStates == null) { throw new ArgumentNullException("errorStates"); } if (string.IsNullOrEmpty(snapshotId)) { throw new ArgumentException("snapshotId cannot be empty"); } if (refreshCount < 0) { throw new ArgumentOutOfRangeException("refreshCount"); } if (refreshDelay < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("refreshDelay"); } CheckIdentity(identity); var snapshotInfo = ShowSnapshot(snapshotId, region, identity); var count = 0; while (!snapshotInfo.Status.Equals(expectedState) && !errorStates.Contains(snapshotInfo.Status) && count < refreshCount) { Thread.Sleep(refreshDelay ?? TimeSpan.FromSeconds(10)); snapshotInfo = ShowSnapshot(snapshotId, region, identity); count++; } if (errorStates.Contains(snapshotInfo.Status)) { throw new SnapshotEnteredErrorStateException(snapshotInfo.Status); } return(snapshotInfo); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void baseNoSendTest(java.util.Map<org.neo4j.cluster.InstanceId,java.net.URI> extraMembers) throws Throwable private void BaseNoSendTest(IDictionary <InstanceId, URI> extraMembers) { URI me = URI.create("cluster://me"); IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId myId = new org.neo4j.cluster.InstanceId(1); InstanceId myId = new InstanceId(1); members[myId] = me; //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method: members.putAll(extraMembers); ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration)); when(clusterConfiguration.Members).thenReturn(members); when(clusterConfiguration.GetElected(ClusterConfiguration.COORDINATOR)).thenReturn(myId); when(clusterConfiguration.GetUriForId(myId)).thenReturn(me); ClusterContext clusterContext = mock(typeof(ClusterContext)); when(clusterContext.Configuration).thenReturn(clusterConfiguration); when(clusterContext.MyId).thenReturn(myId); SnapshotContext context = mock(typeof(SnapshotContext)); when(context.ClusterContext).thenReturn(clusterContext); SnapshotProvider snapshotProvider = mock(typeof(SnapshotProvider)); when(context.SnapshotProvider).thenReturn(snapshotProvider); Message <SnapshotMessage> message = Message.to(SnapshotMessage.RefreshSnapshot, me); MessageHolder outgoing = mock(typeof(MessageHolder)); SnapshotState newState = ( SnapshotState )SnapshotState.Ready.handle(context, message, outgoing); assertThat(newState, equalTo(SnapshotState.Ready)); Mockito.verifyZeroInteractions(outgoing); }
private void PrepareSnapshots() { if (this.snapshotState == SnapshotState.Generating) { return; } this.snapshotState = SnapshotState.Generating; // prepare all snapshots this.PreparePartialSnapshot(); this.PrepareBackSnapshot(); this.PrepareFrontSnapshot(); //// TODO: Revisit this logic for the official Q1 ////if (this.selectionChangedSign == 0) ////{ //// if (this.previousPanSign == this.panSign) //// { //// // we already have generated snapshots for this pan direction //// } //// else //// { //// // prepare all snapshots //// this.PreparePartialSnapshot(); //// this.PrepareBackSnapshot(); //// this.PrepareFrontSnapshot(); //// } ////} ////else ////{ //// Rectangle temp; //// // check which snapshots may be reused //// if (this.selectionChangedSign == this.panSign) //// { //// // we may reuse the partial item - it is currently the Front one //// temp = this.animationFront; //// this.animationFront = this.partialItem; //// this.partialItem = temp; //// this.PrepareBackSnapshot(); //// } //// else //// { //// // we may reuse the front/back snapshots and re-generate only the partial one //// temp = this.animationFront; //// this.animationFront = this.animationBack; //// this.animationBack = temp; //// } //// this.PreparePartialSnapshot(); //// this.selectionChangedSign = 0; ////} this.animationFront.Projection = this.frontProjection = this.CreateProjection(); this.animationBack.Projection = this.backProjection = this.CreateProjection(); this.UpdateProjections(); this.LayoutSnapshots(); this.View.TransitionLayer.Opacity = 1; CompositionTarget.Rendering += this.OnCompositionTargetRendering; }
internal void OnValueChanged(object newValue) { this.State = CheckValueChanged(newValue); }
public IEnumerable <ITagSpan <TTagType> > GetTags(NormalizedSnapshotSpanCollection spans) { if (spans.Count == 0) { return(Enumerable.Empty <ITagSpan <TTagType> >()); } var snapshot = spans[0].Snapshot; // The common case is spans.Count == 1, so try to prevent extra allocations IEnumerable <ITagSpan <TTagType> > singleResult = null; List <ITagSpan <TTagType> > multipleResults = null; SnapshotSpan? singleMissingSpan = null; List <SnapshotSpan> multipleMissingSpans = null; lock (lockObj) { if (lastSnapshotState?.Snapshot != snapshot) { lastSnapshotState?.Cancel(); lastSnapshotState?.FreeRef(); cachedTags.Clear(); lastSnapshotState = new SnapshotState(snapshot); lastSnapshotState.AddRef(); } foreach (var span in spans) { if (cachedTags.TryGetValue(span.Start.Position, out var tags)) { if (singleResult == null) { singleResult = tags; } else { if (multipleResults == null) { multipleResults = new List <ITagSpan <TTagType> >(singleResult); } multipleResults.AddRange(tags); } } else { if (singleMissingSpan == null) { singleMissingSpan = span; } else { if (multipleMissingSpans == null) { multipleMissingSpans = new List <SnapshotSpan>() { singleMissingSpan.Value } } ; multipleMissingSpans.Add(span); } } } } Debug.Assert(multipleResults == null || multipleResults.Count >= 2); Debug.Assert(multipleMissingSpans == null || multipleMissingSpans.Count >= 2); if (singleMissingSpan != null) { if (spans.Count != (multipleMissingSpans?.Count ?? 1)) { spans = multipleMissingSpans != null ? new NormalizedSnapshotSpanCollection(multipleMissingSpans) : new NormalizedSnapshotSpanCollection(singleMissingSpan.Value); } lock (lockObj) { var lastSnapshotStateTmp = lastSnapshotState; lastSnapshotStateTmp.GetTagsStateImpl.AddJob(spans); if (!lastSnapshotStateTmp.TaskStarted) { lastSnapshotStateTmp.TaskStarted = true; lastSnapshotStateTmp.AddRef(); GetTagsAsync(lastSnapshotStateTmp) .ContinueWith(t => { lastSnapshotStateTmp.FreeRef(); var ex = t.Exception; if (t.IsCompleted && !t.IsCanceled && !t.IsFaulted) { SaveResult(t.Result); } }); } } } return(multipleResults ?? singleResult ?? Enumerable.Empty <ITagSpan <TTagType> >()); } void SaveResult(TagsResult[] tagsResultList) { if (tagsResultList.Length == 0) { return; } bool sameSnapshot; lock (lockObj) { sameSnapshot = tagsResultList[0].Span.Snapshot == lastSnapshotState?.Snapshot; if (sameSnapshot) { foreach (var result in tagsResultList) { cachedTags[result.Span.Span.Start] = result.Tags; } } } if (sameSnapshot) { foreach (var result in tagsResultList) { TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(result.Span)); } } } async Task <TagsResult[]> GetTagsAsync(SnapshotState snapshotState) { try { NormalizedSnapshotSpanCollection spans; for (;;) { lock (lockObj) { spans = snapshotState.GetTagsStateImpl.TryGetJob(); if (spans == null) { snapshotState.TaskStarted = false; return(snapshotState.GetTagsStateImpl.GetResult()); } } snapshotState.GetTagsStateImpl.OnStartNewJob(spans); await GetTagsAsync(snapshotState.GetTagsStateImpl, spans).ConfigureAwait(false); snapshotState.GetTagsStateImpl.OnEndNewJob(spans); } } catch (OperationCanceledException) { throw; } catch { return(Array.Empty <TagsResult>()); } }
public SnapshotEnteredErrorStateException(SnapshotState status) : base(string.Format("The snapshot entered an error state: '{0}'", status)) { Status = status; }
public SnapshotInfo(int ssid, SnapshotState state, int parent) { this.SSID = ssid; this.State = state; this.Parent = parent; }