Exemplo n.º 1
0
        /// <summary>
        /// Find first entry in the response list that is not null and didnt timeout.
        /// </summary>
        /// <param name="results">response list</param>
        /// <param name="type">type of response to fetch</param>
        /// <returns>found entry</returns>
        public static Rsp GetFirstNonNullRsp(RspList results, Type type)
        {
            if (results == null)
            {
                return(null);
            }

            Rsp rsp = null;

            for (int i = 0; i < results.size(); i++)
            {
                rsp = (Rsp)results.elementAt(i);

                if (rsp.wasSuspected())
                {
                    results.removeElementAt(i);
                    continue;
                }
                if (!rsp.wasReceived())
                {
                    results.removeElementAt(i);
                    continue;
                }

                if (rsp.Value != null && rsp.Value.GetType().Equals(type))
                {
                    return(rsp);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Find all entries in the response list that are not null and didnt timeout.
        /// </summary>
        /// <param name="results">response list</param>
        /// <param name="type">type of response to fetch</param>
        /// <returns>List of entries found</returns>
        public static ArrayList GetAllNonNullRsp(RspList results, Type type)
        {
            ArrayList list = new ArrayList();

            if (results == null)
            {
                return(null);
            }

            Rsp rsp = null;

            for (int i = 0; i < results.size(); i++)
            {
                rsp = (Rsp)results.elementAt(i);

                if (rsp.wasSuspected())
                {
                    results.removeElementAt(i);
                    continue;
                }
                if (!rsp.wasReceived())
                {
                    results.removeElementAt(i);
                    continue;
                }

                if (rsp.Value != null && rsp.Value.GetType().Equals(type))
                {
                    list.Add(rsp);
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Find first entry in the response list that is not null and didnt timeout.
        /// </summary>
        /// <param name="results">response list</param>
        /// <param name="type">type of response to fetch</param>
        /// <returns>found entry</returns>
        public static Rsp GetFirstNonNullRsp(RspList results, Type type)
        {
            if (results == null)
            {
                return(null);
            }

            Rsp       rsp        = null;
            bool      found      = false;
            ArrayList removeRsps = null;

            for (int i = 0; i < results.size(); i++)
            {
                rsp = (Rsp)results.elementAt(i);

                if (rsp.wasSuspected() || !rsp.wasReceived())
                {
                    if (removeRsps == null)
                    {
                        removeRsps = new ArrayList();
                    }

                    removeRsps.Add(i);
                    continue;
                }

                if (rsp.Value != null && rsp.Value.GetType().Equals(type))
                {
                    found = true;
                    break;
                }
            }


            if (removeRsps != null && removeRsps.Count > 0)
            {
                for (int index = 0; index < removeRsps.Count; index++)
                {
                    int removeAt = (int)removeRsps[index];
                    results.removeElementAt(removeAt);
                }
            }

            if (found)
            {
                return(rsp);
            }

            return(null);
        }