Пример #1
0
 /// <summary>
 /// Returns the feed at the end URI specified.
 /// </summary>
 /// <param name="uri">the URI of the feed</param>
 /// <param name="shouldGetAllPages">if true, returns all the pages</param>
 /// <returns></returns>
 public AppsExtendedFeed QueryExtendedFeed(Uri uri, Boolean shouldGetAllPages)
 {
     try
     {
         Stream           feedStream = base.Query(uri);
         AppsExtendedFeed feed       = new AppsExtendedFeed(uri, this);
         feed.Parse(feedStream, AlternativeFormat.Atom);
         feedStream.Close();
         if (shouldGetAllPages)
         {
             if (true)
             {
                 AtomLink next, prev = null;
                 while ((next = feed.Links.FindService("next", null)) != null &&
                        next != prev)
                 {
                     feedStream = base.Query(new Uri(next.HRef.ToString()));
                     feed.Parse(feedStream, AlternativeFormat.Atom);
                     feedStream.Close();
                     prev = next;
                 }
             }
         }
         return(feed);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
        /// <summary>
        /// overwritten Query method
        /// </summary>
        /// <param name="feedQuery">The FeedQuery to use</param>
        /// <returns>the retrieved NicknameFeed</returns>
        public NicknameFeed Query(NicknameQuery feedQuery)
        {
            try
            {
                Stream       feedStream = Query(feedQuery.Uri);
                NicknameFeed feed       = new NicknameFeed(feedQuery.Uri, this);
                feed.Parse(feedStream, AlternativeFormat.Atom);
                feedStream.Close();

                if (feedQuery.RetrieveAllNicknames)
                {
                    AtomLink next, prev = null;
                    while ((next = feed.Links.FindService("next", null)) != null && next != prev)
                    {
                        feedStream = Query(new Uri(next.HRef.ToString()));
                        feed.Parse(feedStream, AlternativeFormat.Atom);
                        feedStream.Close();

                        prev = next;
                    }
                }

                return(feed);
            }
            catch (GDataRequestException e)
            {
                AppsException a = AppsException.ParseAppsException(e);
                throw (a == null ? e : a);
            }
        }
Пример #3
0
 /// <summary>
 /// Inserts a new user account entry into the specified feed.
 /// </summary>
 /// <param name="feed">the feed into which this entry should be inserted</param>
 /// <param name="entry">the entry to insert</param>
 /// <returns>the inserted entry</returns>
 public UserEntry Insert(UserFeed feed, UserEntry entry)
 {
     try {
         return(base.Insert(feed, entry) as UserEntry);
     } catch (GDataRequestException e) {
         AppsException a = AppsException.ParseAppsException(e);
         throw a ?? e;
     }
 }
Пример #4
0
 /// <summary>
 /// Overridden Delete method that throws AppsException
 /// </summary>
 /// <param name="entry">the entry to delete</param>
 public void Delete(UserEntry entry)
 {
     try {
         base.Delete(entry);
     } catch (GDataRequestException e) {
         AppsException a = AppsException.ParseAppsException(e);
         throw a ?? e;
     }
 }
Пример #5
0
 /// <summary>
 /// Overridden Delete method that throws AppsException
 /// </summary>
 /// <param name="uri">the URI to delete</param>
 public new void Delete(Uri uri)
 {
     try {
         base.Delete(uri);
     } catch (GDataRequestException e) {
         AppsException a = AppsException.ParseAppsException(e);
         throw a ?? e;
     }
 }
Пример #6
0
 /// <summary>
 /// Inserts a new nickname entry into the specified feed.
 /// </summary>
 /// <param name="feed">the feed into which this entry should be inserted</param>
 /// <param name="entry">the entry to insert</param>
 /// <returns>the inserted entry</returns>
 public NicknameEntry Insert(NicknameFeed feed, NicknameEntry entry)
 {
     try {
         return(base.Insert(feed, entry) as NicknameEntry);
     } catch (GDataRequestException e) {
         AppsException a = AppsException.ParseAppsException(e);
         throw a ?? e;
     }
 }
Пример #7
0
 /// <summary>
 /// Overridden Delete method that throws AppsException
 /// </summary>
 /// <param name="entry">the NicknameEntry to delete</param>
 public void Delete(NicknameEntry entry)
 {
     try {
         base.Delete(entry);
     } catch (GDataRequestException e) {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
 /// <summary>
 /// Inserts a new nickname entry into the feed at the
 /// specified URI.
 /// </summary>
 /// <param name="feedUri">the URI of the feed into which this entry should be inserted</param>
 /// <param name="entry">the entry to insert</param>
 /// <returns>the inserted entry</returns>
 public NicknameEntry Insert(Uri feedUri, NicknameEntry entry)
 {
     try
     {
         return(base.Insert(feedUri, entry) as NicknameEntry);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
Пример #9
0
 /// <summary>
 /// Updates this AppsExtendedEntry.
 /// </summary>
 /// <returns>the updated GroupsEntry</returns>
 public new AppsExtendedEntry Update()
 {
     try
     {
         return(base.Update() as AppsExtendedEntry);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
 /// <summary>
 /// Inserts a new email list entry into the specified feed.
 /// </summary>
 /// <param name="feed">the feed into which this entry should be inserted</param>
 /// <param name="entry">the entry to insert</param>
 /// <returns>the inserted entry</returns>
 public EmailListEntry Insert(EmailListFeed feed, EmailListEntry entry)
 {
     try
     {
         return(base.Insert(feed, entry) as EmailListEntry);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
Пример #11
0
 /// <summary>
 /// Overridden Delete method that throws AppsException
 /// </summary>
 /// <param name="entry"></param>
 public void Delete(EmailListRecipientEntry entry)
 {
     try
     {
         base.Delete(entry);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
        /// <summary>
        /// Parses a GDataRequestException, which wraps the HTTP
        /// error responses, into an AppsException.
        /// </summary>
        /// <param name="e">the GDataRequestException to parse</param>
        /// <returns>a new AppsException object. The object's ErrorCode,
        /// InvalidInput and Reason properties will be set if the XML
        /// in the HTTP response could be parsed, or null otherwise.</returns>
        public static AppsException ParseAppsException(GDataRequestException e)
        {
            AppsException result = null;

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

            if (e.ResponseString == null)
            {
                return(null);
            }

            try
            {
                XmlReader reader = new XmlTextReader(e.ResponseString, XmlNodeType.Document, null);
                // now find the ErrorElement
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.LocalName == AppsNameTable.AppsError)
                    {
                        result           = new AppsException(e);
                        result.ErrorCode =
                            reader.GetAttribute(AppsNameTable.AppsErrorErrorCode);
                        result.InvalidInput =
                            reader.GetAttribute(AppsNameTable.AppsErrorInvalidInput);
                        result.Reason =
                            reader.GetAttribute(AppsNameTable.AppsErrorReason);
                        break;
                    }
                }
            }
            catch (XmlException)
            {
            }

            return(result);
        }
Пример #13
0
        /// <summary>
        /// Parses a GDataRequestException, which wraps the HTTP
        /// error responses, into an AppsException.
        /// </summary>
        /// <param name="e">the GDataRequestException to parse</param>
        /// <returns>a new AppsException object. The object's ErrorCode,
        /// InvalidInput and Reason properties will be set if the XML
        /// in the HTTP response could be parsed, or null otherwise.</returns>
        public static AppsException ParseAppsException(GDataRequestException e)
        {
            AppsException result = null;

            if (e == null)
                return (null);

            if (e.ResponseString == null)
                return (null);

            try
            {
                XmlReader reader = new XmlTextReader(e.ResponseString, XmlNodeType.Document, null);
                // now find the ErrorElement
                while (reader.Read())
                    if (reader.NodeType == XmlNodeType.Element && reader.LocalName == AppsNameTable.AppsError)
                    {
                        result = new AppsException(e);
                        result.ErrorCode =
                            reader.GetAttribute(AppsNameTable.AppsErrorErrorCode);
                        result.InvalidInput =
                            reader.GetAttribute(AppsNameTable.AppsErrorInvalidInput);
                        result.Reason =
                            reader.GetAttribute(AppsNameTable.AppsErrorReason);
                        break;
                    }
            }
            catch (XmlException)
            {
                    
            }

            return result;
        }
 public void Init()
 {
     exception = new AppsException();
 }