static TItem GetItemCore <TItem>(Visual visual, IsMatch <TItem> isMatch, Next <TItem> next)
     where TItem : Visual
 {
     foreach (var element in VisualTreeUtility.GetChildren(visual))
     {
         Visual o    = element;
         var    item = o as TItem;
         if (item != null)
         {
             if (isMatch(item))
             {
                 return(item);
             }
         }
         else
         {
             var popup = o as Popup;
             if (popup != null)
             {
                 o = popup.Child as Visual;
             }
             var nextItem = next(o);
             if (nextItem != null)
             {
                 return(nextItem);
             }
         }
     }
     return(null);
 }
Example #2
0
        private static RecieveDelegate Receiver(TimeSpan timeout,
                                                IsMatch matcher)
        {
            int to = MessageFactory.TimeSpanToInt32(timeout);

            return(new RecieveDelegateFactory(to, matcher).RecieveDelegate);
        }
Example #3
0
        private IMessage DoReceive(IMessageQueueTransaction transaction,
                                   TimeSpan timeout, IsMatch matcher, bool ack)
        {
            RabbitMQMessageQueueTransaction tx = (RabbitMQMessageQueueTransaction)transaction;

            return(DoReceive((IMessagingContext)tx, timeout, matcher, ack));
        }
Example #4
0
        private IMessage DoReceive(MessageQueueTransactionType transactionType,
                                   TimeSpan timeout, IsMatch matcher, bool ack)
        {
            switch (transactionType)
            {
            case MessageQueueTransactionType.Single:
                using (RabbitMQMessageQueueTransaction tx = NewTx()) {
                    bool success = false;
                    try {
                        IMessage msg = DoReceive((IMessagingContext)tx, timeout, matcher, ack);
                        tx.Commit();
                        success = true;
                        return(msg);
                    } finally {
                        if (!success)
                        {
                            tx.Abort();
                        }
                    }
                }

            case MessageQueueTransactionType.None:
                return(DoReceive(timeout, matcher, true));

            default:
                throw new NotSupportedException(transactionType + " not supported");
            }
        }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = IsMatch.GetHashCode();
         hashCode = (hashCode * 397) ^ (Start != null ? Start.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (End != null ? End.GetHashCode() : 0);
         return(hashCode);
     }
 }
Example #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Part?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ IsMatch.GetHashCode();
         return(hashCode);
     }
 }
Example #7
0
			public RecieveDelegateFactory (int timeout, IsMatch matcher, bool ack)
			{
				if (matcher != null && timeout == -1)
					this.timeout = 500;
				else 
					this.timeout = timeout;
				this.matcher = matcher;
				this.ack = ack;
			}
		static object Find(string name, ICollection items, IsMatch match)
		{
			foreach (object item in items) {
				if (match(item, name)) {
					return item;
				}
			}
			return null;
		}
Example #9
0
 /// <summary>
 /// Returns the hash code for this instance.
 /// </summary>
 /// <returns>
 /// A 32-bit signed integer that is the hash code for this instance.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = IsMatch.GetHashCode();
         hashCode = (hashCode * 397) ^ LengthInCollection1;
         hashCode = (hashCode * 397) ^ LengthInCollection2;
         return(hashCode);
     }
 }
Example #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 13;
         hashCode = (hashCode * 397) ^ Amount.GetHashCode();
         hashCode = (hashCode * 397) ^ IsMatch.GetHashCode();
         return(hashCode);
     }
 }
Example #11
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (IsMatch.IsIPv4("127.0.0.1"))
     {
         MessageBox.Show("符合");
     }
     else
     {
         MessageBox.Show("不符合");
     }
 }
		public IMessage Receive (QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
		{
			lock (syncObj) {
				ValidateHost (qRef);
					
				Model.TxSelect ();
				isActive = true;
				
				return Context.Receive (qRef, timeout, matcher, ack);
			}
		}	
Example #13
0
 public IMessage Receive(QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
 {
     if (matcher == null)
     {
         return(Receive(qRef, MessageFactory.TimeSpanToMillis(timeout), ack));
     }
     else
     {
         return(ReceiveWithMatcher(qRef, MessageFactory.TimeSpanToMillis(timeout), matcher, ack));
     }
 }
Example #14
0
        public IMessage Receive(QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
        {
            lock (syncObj) {
                ValidateHost(qRef);

                Model.TxSelect();
                isActive = true;

                return(Context.Receive(qRef, timeout, matcher, ack));
            }
        }
 static object Find(string name, ICollection items, IsMatch match)
 {
     foreach (object item in items)
     {
         if (match(item, name))
         {
             return(item);
         }
     }
     return(null);
 }
Example #16
0
 private static bool ForAny(List <DBState> states, List <bool> nonfatal, IsMatch pred)
 {
     for (int i = 0; i < states.Count; i++)
     {
         if (pred(states [i], nonfatal [i]))
         {
             return(true);
         }
     }
     return(false);
 }
Example #17
0
        public override int GetHashCode()
        {
            var hashCode = 977042922;

            hashCode = hashCode * -1521134295 + IsMatch.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(TrimmedRoute);

            hashCode = hashCode * -1521134295 + EqualityComparer <IEnumerable <KeyValuePair <string, string> > > .Default.GetHashCode(RouteParameters);

            return(hashCode);
        }
Example #18
0
 public List<Student> FindStudent(IsMatch isMatch)
 {
     List<Student> returnList = new List<Student>();
     foreach (var student in students)
     {
        if(isMatch(student))
        {
            returnList.Add(student);
        }
     }
     return returnList;
 }
Example #19
0
        private IEnumerable<INativeElement> GetArrayElements(IsMatch constraint)
        {
            Initialize();

            var ffElements = JSUtils.ElementArrayEnumerator(GetCommand, ClientPort);

            foreach (var ffElement in ffElements)
            {
                if (constraint.Invoke(ffElement))
                    yield return ffElement;
            }
        }
Example #20
0
        //TODO: Inject a windows API abstraction here for unit testing purposes

        public WindowsDeviceEnumerator(
            ILogger logger,
            Guid classGuid,
            GetDeviceDefinition getDeviceDefinition,
            IsMatch isMatch
            )
        {
            Logger               = logger ?? NullLogger.Instance;
            _classGuid           = classGuid;
            _getDeviceDefinition = getDeviceDefinition;
            _isMatch             = isMatch;
        }
        internal static TItem GetItem <TItem>(Visual parent, string[] headerTexts, ShowNextItem <TItem> showNextItem) where TItem : Visual
        {
            GetItemDelegate <TItem, string> getItem = (visual, headerText) =>
            {
                IsMatch <TItem> isMatch = (item) => (GetItemText(item) == headerText);
                Next <TItem>    next    = null;
                next = (v) => GetItemCore(v, isMatch, next);
                return(GetItemCore(visual, isMatch, next));
            };

            return(GetItem <TItem, string>(parent, headerTexts, getItem, showNextItem));
        }
        internal static TItem GetItem <TItem>(Visual parent, int[] indices, ShowNextItem <TItem> showNextItem) where TItem : Visual
        {
            GetItemDelegate <TItem, int> getItem = (visual, index) =>
            {
                int             currentIndex = 0;
                IsMatch <TItem> isMatch      = (v) => (currentIndex++ == index);
                Next <TItem>    next         = null;
                next = (v) => GetItemCore(v, isMatch, next);
                return(GetItemCore(visual, isMatch, next));
            };

            return(GetItem <TItem, int>(parent, indices, getItem, showNextItem));
        }
Example #23
0
        private IEnumerable<INativeElement> GetArrayElements(IsMatch constraint)
        {
            this.Initialize();

            var ffElements = JSUtils.ElementArrayEnumerator(this.GetCommand, this.ClientPort);

            foreach (var ffElement in ffElements)
            {
                if (!constraint.Invoke(ffElement)) continue;

                ffElement.Pin();
                yield return ffElement;
            }
        }
        public IEnumerable <INativeElement> GetArrayElements(IsMatch constraint)
        {
            Initialize();

            var ffElements = JSUtils.ElementArrayEnumerator(GetCommand, ClientPort);

            foreach (var ffElement in ffElements)
            {
                if (constraint.Invoke(ffElement))
                {
                    yield return(ffElement);
                }
            }
        }
Example #25
0
        private IEnumerable <INativeElement> GetArrayElements(IsMatch constraint)
        {
            this.Initialize();

            var ffElements = JSUtils.ElementArrayEnumerator(this.GetCommand, this.ClientPort);

            foreach (var ffElement in ffElements)
            {
                if (!constraint.Invoke(ffElement))
                {
                    continue;
                }

                ffElement.Pin();
                yield return(ffElement);
            }
        }
Example #26
0
		private IMessage Receive (IModel model, int timeout, 
		                          bool doAck, IsMatch matcher)
		{
			string finalName = model.QueueDeclare (QRef.Queue, false);
			
			using (Subscription sub = new Subscription (model, finalName)) {
				BasicDeliverEventArgs result;
				while (sub.Next (timeout, out result)) {
					
					if (matcher (result)) {
						IMessage m = helper.ReadMessage (QRef, result);
						if (doAck)
							sub.Ack (result);
						return m;
					}
				}
				
				throw new MessageUnavailableException ("Message not available");
			}
		}
Example #27
0
        internal static TItem GetItem <TItem>(Visual parent, object[] indices, ShowNextItem <TItem> showNextItem) where TItem : Visual
        {
            GetItemDelegate <TItem, object> getItem = (visual, obj) =>
            {
                int             currentIndex = 0;
                IsMatch <TItem> isMatch      = (v) =>
                {
                    if (obj is int)
                    {
                        return(currentIndex++ == (int)obj);
                    }
                    else if (obj is string)
                    {
                        return(GetItemText(v) == (string)obj);
                    }
                    throw new NotSupportedException();
                };
                Next <TItem> next = null;
                next = (v) => GetItemCore(v, isMatch, next);
                return(GetItemCore(visual, isMatch, next));
            };

            return(GetItem <TItem, object>(parent, indices, getItem, showNextItem));
        }
Example #28
0
        private IMessage ReceiveWithMatcher(QueueReference qRef, int timeout, IsMatch matcher, bool ack)
        {
            IModel _model = Model;

            string finalName = _model.QueueDeclare(qRef.Queue, false);

            using (Subscription sub = new Subscription(_model, finalName)) {
                BasicDeliverEventArgs result;
                while (sub.Next(timeout, out result))
                {
                    if (matcher(result))
                    {
                        IMessage m = helper.ReadMessage(qRef, result);
                        if (ack)
                        {
                            sub.Ack(result);
                        }
                        return(m);
                    }
                }

                throw new MessageUnavailableException("Message not available");
            }
        }
Example #29
0
		private RecieveDelegate Peeker (IsMatch matcher)
		{
			return new RecieveDelegateFactory (-1, matcher, false).RecieveDelegate;
		}		
Example #30
0
		private static RecieveDelegate Receiver (IsMatch matcher)
		{
			return new RecieveDelegateFactory (-1, matcher).RecieveDelegate;
		}
		private static RecieveDelegate Receiver (TimeSpan timeout,
		                                         IsMatch matcher)
		{
			int to = MessageFactory.TimeSpanToInt32 (timeout);
			return new RecieveDelegateFactory (to, matcher).RecieveDelegate;
		}
Example #32
0
			public RecieveDelegateFactory (int timeout, IsMatch matcher)
				: this (timeout, matcher, true)
			{
			}
Example #33
0
 public override string ToString()
 {
     return($"{{{nameof(Owner)}={Owner}, {nameof(Request)}={Request}, {nameof(IsMatch)}={IsMatch.ToString()}, {nameof(BusinessEx)}={BusinessEx}, {nameof(DeTime)}={DeTime.ToString()}, {nameof(EnTime)}={EnTime.ToString()}}}");
 }
Example #34
0
		private IMessage DoReceive (IMessagingContext context, TimeSpan timeout,
									IsMatch matcher, bool ack)
		{
			return context.Receive (QRef, timeout, matcher, ack);
		}
Example #35
0
		private IMessage DoReceive (TimeSpan timeout, IsMatch matcher, bool ack)
		{
			using (IMessagingContext context = CurrentContext) {
				return DoReceive (context, timeout, matcher, ack);
			}
		}
Example #36
0
		private IMessage DoReceive (IMessageQueueTransaction transaction,
									TimeSpan timeout, IsMatch matcher, bool ack)
		{
			RabbitMQMessageQueueTransaction tx = (RabbitMQMessageQueueTransaction) transaction;
			return DoReceive ((IMessagingContext) tx, timeout, matcher, ack);
		}
Example #37
0
		private IMessage DoReceive (MessageQueueTransactionType transactionType,
									TimeSpan timeout, IsMatch matcher, bool ack)
		{
			switch (transactionType) {
			case MessageQueueTransactionType.Single:
				using (RabbitMQMessageQueueTransaction tx = NewTx ()) {
					bool success = false;
					try {
						IMessage msg = DoReceive ((IMessagingContext) tx, timeout, matcher, ack);
						tx.Commit ();
						success = true;
						return msg;
					} finally {
						if (!success)
							tx.Abort ();
					}
				}

			case MessageQueueTransactionType.None:
				return DoReceive (timeout, matcher, true);

			default:
				throw new NotSupportedException (transactionType + " not supported");
			}
		}
Example #38
0
 static extern void StoreMatch(IsMatch match);
Example #39
0
		public IMessage Receive (QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
		{
			if (matcher == null)
			{
				return Receive (qRef, MessageFactory.TimeSpanToMillis (timeout), ack);
			}
			else
			{
				return ReceiveWithMatcher (qRef, MessageFactory.TimeSpanToMillis (timeout), matcher, ack);
			}
		}
        public List <JNPWorkflowStatus> FindFiltered(IsMatch match)
        {
            Predicate <JNPWorkflowStatus> predicate = new Predicate <JNPWorkflowStatus>(match);

            return(base.FindAll(predicate));
        }
Example #41
0
		private RecieveDelegate Peeker (TimeSpan timeout, IsMatch matcher)
		{
			int to = MessageFactory.TimeSpanToInt32 (timeout);
			return new RecieveDelegateFactory (to, matcher, false).RecieveDelegate;
		}
Example #42
0
 static extern int FindMatch(IsMatch match);
		private static bool ForAny (List<DBState> states, List<bool> nonfatal, IsMatch pred)
		{
			for (int i = 0; i < states.Count; i++) {
				if (pred (states [i], nonfatal [i]))
					return true;
			}
			return false;
		}
Example #44
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (ExternalId.Length != 0)
            {
                hash ^= ExternalId.GetHashCode();
            }
            if (Profile.Length != 0)
            {
                hash ^= Profile.GetHashCode();
            }
            if (Job.Length != 0)
            {
                hash ^= Job.GetHashCode();
            }
            if (Company.Length != 0)
            {
                hash ^= Company.GetHashCode();
            }
            if (applicationDate_ != null)
            {
                hash ^= ApplicationDate.GetHashCode();
            }
            if (Stage != global::Google.Cloud.Talent.V4Beta1.Application.Types.ApplicationStage.Unspecified)
            {
                hash ^= Stage.GetHashCode();
            }
            if (State != global::Google.Cloud.Talent.V4Beta1.Application.Types.ApplicationState.Unspecified)
            {
                hash ^= State.GetHashCode();
            }
            hash ^= interviews_.GetHashCode();
            if (referral_ != null)
            {
                hash ^= Referral.GetHashCode();
            }
            if (createTime_ != null)
            {
                hash ^= CreateTime.GetHashCode();
            }
            if (updateTime_ != null)
            {
                hash ^= UpdateTime.GetHashCode();
            }
            if (OutcomeNotes.Length != 0)
            {
                hash ^= OutcomeNotes.GetHashCode();
            }
            if (Outcome != global::Google.Cloud.Talent.V4Beta1.Outcome.Unspecified)
            {
                hash ^= Outcome.GetHashCode();
            }
            if (isMatch_ != null)
            {
                hash ^= IsMatch.GetHashCode();
            }
            if (JobTitleSnippet.Length != 0)
            {
                hash ^= JobTitleSnippet.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #45
0
		private IMessage ReceiveWithMatcher (QueueReference qRef, int timeout, IsMatch matcher, bool ack)
		{
			IModel _model = Model;
			
			string finalName = _model.QueueDeclare (qRef.Queue, false);
			using (Subscription sub = new Subscription (_model, finalName)) {
				BasicDeliverEventArgs result;
				while (sub.Next (timeout, out result)) {
					
					if (matcher (result)) {
						IMessage m = helper.ReadMessage (qRef, result);
						if (ack)
							sub.Ack (result);
						return m;
					}
				}
				
				throw new MessageUnavailableException ("Message not available");
			}
		}