private void EnsureFriends()
 {
     if (m_friends == null ||
         DateTime.Now.Subtract(m_FriendsRetrieved).TotalMinutes > 30)
     {
         try
         {
             m_friends = m_provider.GetFriends();
         }
         catch (COMException cex)
         {
             if (Helpers.IsOSCException(cex))
             {
                 throw;
             }
             else
             {
                 throw new OSCException(@"GetFriends call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, cex);
             }
         }
         catch (ApplicationException ex)
         {
             throw new OSCException(@"GetFriends call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, ex);
         }
         PersonCache.AddRange(m_friends.People);
     }
 }
 private void EnsureFriends()
 {
     if (s_friends == null)
     {
         try
         {
             s_friends = m_provider.GetFriends();
         }
         catch (COMException cex)
         {
             if (Helpers.IsOSCException(cex))
             {
                 throw;
             }
             else
             {
                 throw new OSCException(@"GetFriends call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, cex);
             }
         }
         catch (ApplicationException ex)
         {
             throw new OSCException(@"GetFriends call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, ex);
         }
         PersonCache.AddRange(s_friends.People);
     }
 }
        public ISocialPerson GetPerson(string userID)
        {
            OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Function, @"GetPerson called."));

            Person p;

            p = PersonCache.FindFirst(userID);
            if (p == null)
            {
                try
                {
                    OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Function, @"Calling OSCProvider.GetPerson."));

                    p = m_provider.GetPerson(userID);
                }
                catch (COMException cex)
                {
                    OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Exceptions, cex.Message, cex));

                    if (Helpers.IsOSCException(cex))
                    {
                        throw;
                    }
                    else
                    {
                        throw new OSCException(@"GetPerson call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, cex);
                    }
                }
                catch (ApplicationException ex)
                {
                    OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Exceptions, ex.Message, ex));
                    throw new OSCException(@"GetPerson call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, ex);
                }
                if (p != null)
                {
                    PersonCache.AddPerson(p);
                }
            }
            if (p != null)
            {
                return(new OSCPerson(m_provider, p));
            }
            else
            {
                return(null);//TODO : if p==null, i need to throw OSC_E_NOT_FOUND;
            }
        }
        public string FindPerson(string userID)
        {
            OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Function, @"FindPerson called."));
            Person p;

            p = PersonCache.FindFirst(userID);
            if (p == null)
            {
                try
                {
                    OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Function, @"Calling GetPerson."));

                    p = m_provider.GetPerson(userID);
                }
                catch (COMException cex)
                {
                    OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Exceptions, cex.Message, cex));

                    if (Helpers.IsOSCException(cex))
                    {
                        throw;
                    }
                    else
                    {
                        throw new OSCException(@"GetPerson call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, cex);
                    }
                }
                catch (ApplicationException ex)
                {
                    OSCProvider.OnTraceEvent(this, new OSCEventArgs(TraceType.Exceptions, ex.Message, ex));

                    throw new OSCException(@"GetPerson call failed.", OSCExceptions.OSC_E_INTERNAL_ERROR, ex);
                }
                PersonCache.AddPerson(p);
            }
            p.SchemaVersion = m_provider.ProviderData.SchemaVersion;
            if (p != null)
            {
                return(p.Xml);
            }
            else
            {
                return(string.Empty);
            }
        }
        public Array AreFriendsOrColleagues(Array userIDs)
        {
            List <bool> lFriends = new List <bool>();

            EnsureFriends();

            foreach (string userId in userIDs)
            {
                if (PersonCache.FindFirst(userId) != null)
                {
                    lFriends.Add(true);
                }
                else
                {
                    lFriends.Add(false);
                }
            }

            return(lFriends.ToArray());
        }