Example #1
0
        public PartialResultsCollection GetPartialResults(LdapPartialAsyncResult asyncResult)
        {
            lock (this)
            {
                if (!_resultList.Contains(asyncResult))
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.InvalidAsyncResult));
                }

                if (asyncResult.exception != null)
                {
                    // remove this async operation

                    // the async operation basically failed, we won't do it any more, so throw exception to the user and remove it from the list
                    _resultList.Remove(asyncResult);
                    throw asyncResult.exception;
                }

                PartialResultsCollection collection = new PartialResultsCollection();

                if (asyncResult.response != null)
                {
                    if (asyncResult.response.Entries != null)
                    {
                        for (int i = 0; i < asyncResult.response.Entries.Count; i++)
                        {
                            collection.Add(asyncResult.response.Entries[i]);
                        }

                        asyncResult.response.Entries.Clear();
                    }

                    if (asyncResult.response.References != null)
                    {
                        for (int i = 0; i < asyncResult.response.References.Count; i++)
                        {
                            collection.Add(asyncResult.response.References[i]);
                        }

                        asyncResult.response.References.Clear();
                    }
                }

                return(collection);
            }
        }
        public PartialResultsCollection GetPartialResults(LdapPartialAsyncResult asyncResult)
        {
            PartialResultsCollection partialResultsCollection;

            lock (this)
            {
                if (this.resultList.Contains(asyncResult))
                {
                    if (asyncResult.exception == null)
                    {
                        PartialResultsCollection partialResultsCollection1 = new PartialResultsCollection();
                        if (asyncResult.response != null)
                        {
                            if (asyncResult.response.Entries != null)
                            {
                                for (int i = 0; i < asyncResult.response.Entries.Count; i++)
                                {
                                    partialResultsCollection1.Add(asyncResult.response.Entries[i]);
                                }
                                asyncResult.response.Entries.Clear();
                            }
                            if (asyncResult.response.References != null)
                            {
                                for (int j = 0; j < asyncResult.response.References.Count; j++)
                                {
                                    partialResultsCollection1.Add(asyncResult.response.References[j]);
                                }
                                asyncResult.response.References.Clear();
                            }
                        }
                        partialResultsCollection = partialResultsCollection1;
                    }
                    else
                    {
                        this.resultList.Remove(asyncResult);
                        throw asyncResult.exception;
                    }
                }
                else
                {
                    throw new ArgumentException(Res.GetString("InvalidAsyncResult"));
                }
            }
            return(partialResultsCollection);
        }
 public PartialResultsCollection GetPartialResults(LdapPartialAsyncResult asyncResult)
 {
     lock (this)
     {
         if (!this.resultList.Contains(asyncResult))
         {
             throw new ArgumentException(Res.GetString("InvalidAsyncResult"));
         }
         if (asyncResult.exception != null)
         {
             this.resultList.Remove(asyncResult);
             throw asyncResult.exception;
         }
         PartialResultsCollection resultss = new PartialResultsCollection();
         if (asyncResult.response != null)
         {
             if (asyncResult.response.Entries != null)
             {
                 for (int i = 0; i < asyncResult.response.Entries.Count; i++)
                 {
                     resultss.Add(asyncResult.response.Entries[i]);
                 }
                 asyncResult.response.Entries.Clear();
             }
             if (asyncResult.response.References != null)
             {
                 for (int j = 0; j < asyncResult.response.References.Count; j++)
                 {
                     resultss.Add(asyncResult.response.References[j]);
                 }
                 asyncResult.response.References.Clear();
             }
         }
         return resultss;
     }
 }
        public PartialResultsCollection GetPartialResults(LdapPartialAsyncResult asyncResult)
        {
            lock (this)
            {
                if (!_resultList.Contains(asyncResult))
                    throw new ArgumentException(Res.GetString(Res.InvalidAsyncResult));

                if (asyncResult.exception != null)
                {
                    // remove this async operation

                    // the async operation basically failed, we won't do it any more, so throw exception to the user and remove it from the list
                    _resultList.Remove(asyncResult);
                    throw asyncResult.exception;
                }

                PartialResultsCollection collection = new PartialResultsCollection();

                if (asyncResult.response != null)
                {
                    if (asyncResult.response.Entries != null)
                    {
                        for (int i = 0; i < asyncResult.response.Entries.Count; i++)
                            collection.Add(asyncResult.response.Entries[i]);

                        asyncResult.response.Entries.Clear();
                    }

                    if (asyncResult.response.References != null)
                    {
                        for (int i = 0; i < asyncResult.response.References.Count; i++)
                            collection.Add(asyncResult.response.References[i]);

                        asyncResult.response.References.Clear();
                    }
                }

                return collection;
            }
        }