Example #1
0
            public void AddRequest(Node provider, T role)
            {
                var ep = new EndPoint(provider, role);

                if (!Requests.Contains(ep))
                {
                    if (provider == this)
                    {
                        HasLoop = true;
                    }

                    Requests.Add(ep);
                    Owner.Invalidate();
                }
            }
Example #2
0
 public bool HasRequestForFloor(int floor)
 {
     return(Requests.Contains(floor));
 }
Example #3
0
 public bool Contains(Structure s)
 {
     return(Requests.Contains(s));
 }
        private void RemoveDuplicates(Guid sourceId)
        {
            if (!Requests.Contains(sourceId))
            {
                // Should always find this value, but in testing
                // sometimes the mock value uses an empty GUID or
                // something that might not be here. Also, it appears
                // TryGetValue on KeyedCollection<K,V> wasn't added
                // until netstandard2.1, so it causes compiler problems
                // to multitarget netstandard2.0.
                return;
            }

            var source = Requests[sourceId];

            if (!source.Success || source.Instance is null)
            {
                // We can only de-duplicate successful operations because
                // failed operations don't have instances to compare.
                return;
            }

            var duplicates = Requests.Where(dup =>

                                            // Successful requests where IDs are different
                                            dup.Id != sourceId && dup.Success &&

                                            // Instance is exactly the same
                                            dup.Instance is object && object.ReferenceEquals(dup.Instance, source.Instance) &&

                                            // Decorator target must also be the same (otherwise we lose the instance/decorator relationship)
                                            dup.DecoratorTarget == source.DecoratorTarget).ToArray();

            if (duplicates.Length == 0)
            {
                // No duplicates.
                return;
            }

            foreach (var duplicate in duplicates)
            {
                Requests.Remove(duplicate.Id);
                foreach (var request in Requests)
                {
                    var duplicateEdges = request.Edges.Where(e => e.Request == duplicate.Id).ToArray();
                    foreach (var duplicateEdge in duplicateEdges)
                    {
                        // Replace edges pointing to the duplicate so they
                        // point at the new source. HashSet will only keep
                        // unique edges, so if there was already a link to
                        // the source, there won't be duplicate edges.
                        // Also, duplicateEdge will never be null but the
                        // analyzer thinks it could be in that GraphEdge.ctor
                        // call.
                        request.Edges.Remove(duplicateEdge);
                        request.Edges.Add(new GraphEdge(sourceId, duplicateEdge !.Service));
                        if (!source.Services.ContainsKey(duplicateEdge.Service))
                        {
                            source.Services.Add(duplicateEdge.Service, Guid.NewGuid());
                        }
                    }
                }
            }
        }
Example #5
0
 public bool Contains(ResourceRequest.ResourceRequestChanger item) => Requests.Contains(item);
 public bool Contains(EndorsementRequest item)
 {
     return(Requests.Contains(item));
 }