Commits

Anonymous committed b649161

Documented Stacky enums and helpers.

Comments (0)

Files changed (20)

trunk/source/Stacky/Enums/BadgeClass.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the badge type.
+    /// </summary>
     public enum BadgeClass
     {
+        /// <summary>
+        /// Gold badge.
+        /// </summary>
         Gold,
+        /// <summary>
+        /// Silver badge.
+        /// </summary>
         Silver,
+        /// <summary>
+        /// Bronze badge.
+        /// </summary>
         Bronze
     }
 }

trunk/source/Stacky/Enums/CommentSort.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies comment sort order.
+    /// </summary>
     public enum CommentSort
     {
+        /// <summary>
+        /// Creation date.
+        /// </summary>
         Creation,
+        /// <summary>
+        /// Vote count.
+        /// </summary>
         Votes
     }
 }

trunk/source/Stacky/Enums/ErrorCode.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies response error codes.
+    /// </summary>
     public enum ErrorCode
     {
+        /// <summary>
+        /// Not found.
+        /// </summary>
         NotFound = 404,
+        /// <summary>
+        /// Internal server error.
+        /// </summary>
         InternalServerError = 500,
+        /// <summary>
+        /// Invalid application public key.
+        /// </summary>
         InvalidApplicationPublicKey = 4000,
+        /// <summary>
+        /// Invalid page size.
+        /// </summary>
         InvalidPageSize = 4001,
+        /// <summary>
+        /// Invalid sort type.
+        /// </summary>
         InvalidSort = 4002,
+        /// <summary>
+        /// Invalid ordering.
+        /// </summary>
         InvalidOrder = 4003,
+        /// <summary>
+        /// Request limit exceeded.
+        /// </summary>
         RequestLimitExceeded = 4004,
+        /// <summary>
+        /// Invalid vector format.
+        /// </summary>
         InvalidVectorFormat = 4005,
+        /// <summary>
+        /// Too many ids.
+        /// </summary>
         TooManyIds = 4006
     }
 }

trunk/source/Stacky/Enums/FavoriteQuestionsSort.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies favorite question sort order.
+    /// </summary>
     public enum FavoriteQuestionsSort
     {
-        Activity, 
-        Views, 
-        Creation, 
-        Added, 
+        /// <summary>
+        /// Activity.
+        /// </summary>
+        Activity,
+        /// <summary>
+        /// View count.
+        /// </summary>
+        Views,
+        /// <summary>
+        /// Creation date.
+        /// </summary>
+        Creation,
+        /// <summary>
+        /// Added date.
+        /// </summary>
+        Added,
+        /// <summary>
+        /// Vote count.
+        /// </summary>
         Votes
     }
 }

trunk/source/Stacky/Enums/HostSite.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the Stack Overflow API endpoints.
+    /// </summary>
     public enum HostSite
     {
+        /// <summary>
+        /// Stack Overflow.
+        /// </summary>
         [SiteAddress("api.stackoverflow.com")]
         StackOverflow,
+        /// <summary>
+        /// Super User.
+        /// </summary>
         [SiteAddress("api.superuser.com")]
         SuperUser,
+        /// <summary>
+        /// Server Fault.
+        /// </summary>
         [SiteAddress("api.serverfault.com")]
         ServerFault,
+        /// <summary>
+        /// Meta Stack Overflow.
+        /// </summary>
         [SiteAddress("api.meta.stackoverflow.com")]
         Meta,
+        /// <summary>
+        /// Stack Apps.
+        /// </summary>
         [SiteAddress("api.stackapps.com")]
         StackApps
     }
 
+    /// <summary>
+    /// Specifies a site address.
+    /// </summary>
     public class SiteAddressAttribute : Attribute
     {
+        /// <summary>
+        /// Gets or sets the address.
+        /// </summary>
+        /// <value>The address.</value>
         public string Address { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SiteAddressAttribute"/> class.
+        /// </summary>
+        /// <param name="address">The address.</param>
         public SiteAddressAttribute(string address)
         {
             Address = address;
         }
     }
 
+    /// <summary>
+    /// <see cref="HostSite"/> extensions.
+    /// </summary>
     public static class HostSiteExtensions
     {
+        /// <summary>
+        /// Gets the address of the specified <see cref="HostSite"/>.
+        /// </summary>
+        /// <param name="site">The site.</param>
+        /// <returns></returns>
         public static string GetAddress(this HostSite site)
         {
             var attribute = site.GetAttribute<SiteAddressAttribute>();

trunk/source/Stacky/Enums/PostEventType.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the post event type.
+    /// </summary>
     public enum PostEventType
     {
+        /// <summary>
+        /// Question.
+        /// </summary>
         Question,
+        /// <summary>
+        /// Answer.
+        /// </summary>
         Answer,
+        /// <summary>
+        /// Summary.
+        /// </summary>
         Comment,
+        /// <summary>
+        /// Revision.
+        /// </summary>
         Revision,
+        /// <summary>
+        /// Votes.
+        /// </summary>
         Votes
     }
 }

trunk/source/Stacky/Enums/PostType.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the post type.
+    /// </summary>
     public enum PostType
     {
+        /// <summary>
+        /// Answer.
+        /// </summary>
         Answer,
+        /// <summary>
+        /// Question.
+        /// </summary>
         Question,
+        /// <summary>
+        /// Comment.
+        /// </summary>
         Comment
     }
 }

trunk/source/Stacky/Enums/QuestionSort.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the sort order for questions.
+    /// </summary>
     public enum QuestionSort
     {
+        /// <summary>
+        /// Activity.
+        /// </summary>
         [SortArgs("activity")]
         Activity,
+        /// <summary>
+        /// Newest.
+        /// </summary>
         [SortArgs("newest")]
         Newest,
+        /// <summary>
+        /// Featured.
+        /// </summary>
         [SortArgs("featured")]
         Featured,
+        /// <summary>
+        /// Hot.
+        /// </summary>
         [SortArgs("hot")]
         Hot,
+        /// <summary>
+        /// Week.
+        /// </summary>
         [SortArgs("week")]
         Week,
+        /// <summary>
+        /// Month.
+        /// </summary>
         [SortArgs("month")]
         Month,
+        /// <summary>
+        /// Vote count.
+        /// </summary>
         [SortArgs("votes")]
         Votes,
+        /// <summary>
+        /// Unanswered.
+        /// </summary>
         [SortArgs(null, "unanswered")]
         Unanswered,
+        /// <summary>
+        /// Newest unanswered.
+        /// </summary>
         [SortArgs("newest", "unanswered")]
         UnansweredNewest,
+        /// <summary>
+        /// Unanswered vote count.
+        /// </summary>
         [SortArgs("votes", "unanswered")]
         UnansweredVotes
     }

trunk/source/Stacky/Enums/QuestionsByUserSort.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the sort order for questions by user.
+    /// </summary>
     public enum QuestionsByUserSort
     {
+        /// <summary>
+        /// Activity.
+        /// </summary>
         Activity,
+        /// <summary>
+        /// View count.
+        /// </summary>
         Views,
+        /// <summary>
+        /// Creation date.
+        /// </summary>
         Creation,
+        /// <summary>
+        /// Vote count.
+        /// </summary>
         Votes
     }
 }

trunk/source/Stacky/Enums/SearchSort.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the search sort order.
+    /// </summary>
     public enum SearchSort
     {
+        /// <summary>
+        /// Activity.
+        /// </summary>
         Activity,
+        /// <summary>
+        /// View count.
+        /// </summary>
         Views,
+        /// <summary>
+        /// Creation date.
+        /// </summary>
         Creation,
+        /// <summary>
+        /// Vote count.
+        /// </summary>
         Votes
     }
 }

trunk/source/Stacky/Enums/SortDirection.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies the sort direction.
+    /// </summary>
     public enum SortDirection
     {
+        /// <summary>
+        /// Ascending.
+        /// </summary>
         Ascending,
+        /// <summary>
+        /// Descending.
+        /// </summary>
         Descending
     }
 }

trunk/source/Stacky/Enums/TagSort.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies tag sort order.
+    /// </summary>
     public enum TagSort
     {
+        /// <summary>
+        /// Popular.
+        /// </summary>
         Popular,
+        /// <summary>
+        /// Name.
+        /// </summary>
         Name,
+        /// <summary>
+        /// Recent.
+        /// </summary>
         Recent
     }
 }

trunk/source/Stacky/Enums/UserEventType.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies a user event type.
+    /// </summary>
     public enum UserEventType
     {
+        /// <summary>
+        /// Comment.
+        /// </summary>
         Comment,
+        /// <summary>
+        /// Asked or answered a question.
+        /// </summary>
         AskOrAnswered,
+        /// <summary>
+        /// Badge awarded.
+        /// </summary>
         Badge,
+        /// <summary>
+        /// Revision to a post.
+        /// </summary>
         Revision,
+        /// <summary>
+        /// Accepted an answer.
+        /// </summary>
         Accepted
     }
 }

trunk/source/Stacky/Enums/UserMentionSort.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Specifies user mention sort order.
+    /// </summary>
     public enum UserMentionSort
     {
+        /// <summary>
+        /// Creation date.
+        /// </summary>
         Creation,
+        /// <summary>
+        /// Vote count.
+        /// </summary>
         Votes
     }
 }

trunk/source/Stacky/Enums/UserSort.cs

 namespace Stacky
 {
+    /// <summary>
+    /// Specifies user sort order.
+    /// </summary>
     public enum UserSort
     {
+        /// <summary>
+        /// Reputaion.
+        /// </summary>
         Reputation,
+        /// <summary>
+        /// Creation date.
+        /// </summary>
         Creation,
+        /// <summary>
+        /// Oldest.
+        /// </summary>
         Oldest,
+        /// <summary>
+        /// Name.
+        /// </summary>
         Name
     }
 }

trunk/source/Stacky/Helpers/DateHelper.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Unix time helper methods.
+    /// </summary>
     public static class DateHelper
     {
         static DateTime _unixEpoch = new DateTime(1970, 1, 1);
 
+        /// <summary>
+        /// Converts unix time to <see cref="System.DateTime"/>.
+        /// </summary>
+        /// <param name="self">The <see cref="System.DateTime"/>.</param>
+        /// <returns></returns>
         public static DateTime FromUnixTime(this Int64 self)
         {
             return _unixEpoch.AddSeconds(self);
         }
 
+        /// <summary>
+        /// Converts <see cref="System.DateTime"/> to unix time.
+        /// </summary>
+        /// <param name="self">The unix time.</param>
+        /// <returns></returns>
         public static Int64 ToUnixTime(this DateTime self)
         {
             var delta = self - _unixEpoch;

trunk/source/Stacky/Helpers/EnumHelper.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Enum helper methods.
+    /// </summary>
     public static class EnumHelper
     {
+        /// <summary>
+        /// Gets the attribute of the specified type for the provided enum value.
+        /// </summary>
+        /// <typeparam name="T">The attribute type.</typeparam>
+        /// <param name="value">The enum value.</param>
+        /// <returns>The attribute if it exists, otherwise null.</returns>
         public static T GetAttribute<T>(this Enum value)
             where T : Attribute
         {

trunk/source/Stacky/Helpers/SerializationHelper.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Serialization helper methods.
+    /// </summary>
     public static class SerializationHelper
     {
+        /// <summary>
+        /// Deserializes xml into an instance of T.
+        /// </summary>
+        /// <typeparam name="T">The type to be returned.</typeparam>
+        /// <param name="xml">The xml.</param>
+        /// <returns>An instance of T</returns>
         public static T DeserializeXml<T>(string xml)
                where T : new()
         {
             }
         }
 
+        /// <summary>
+        /// Serializes T to xml.
+        /// </summary>
+        /// <typeparam name="T">The type to be serialized.</typeparam>
+        /// <param name="item">The object to be serialized.</param>
+        /// <returns>Xml represntation of item.</returns>
         public static string SerializeXml<T>(T item)
             where T : new()
         {
             return sb.ToString();
         }
 
+        /// <summary>
+        /// Deserializes json into an instance of T.
+        /// </summary>
+        /// <typeparam name="T">The type to be returned.</typeparam>
+        /// <param name="json">The json.</param>
+        /// <returns>An instance of T</returns>
         public static T DeserializeJson<T>(string json)
               where T : new()
         {
             }
         }
 
+        /// <summary>
+        /// Serializes T to json.
+        /// </summary>
+        /// <typeparam name="T">The type to be serialized.</typeparam>
+        /// <param name="item">The object to be serialized.</param>
+        /// <returns>Json represntation of item.</returns>
         public static string SerializeJson<T>(T item)
             where T : new()
         {

trunk/source/Stacky/Helpers/UnixDateTimeConverter.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Class for converting Json unix time to date time.
+    /// </summary>
     public class UnixDateTimeConverter : DateTimeConverterBase
     {
+        /// <summary>
+        /// Reads the JSON representation of the object.
+        /// </summary>
+        /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader"/> to read from.</param>
+        /// <param name="objectType">Type of the object.</param>
+        /// <param name="serializer">The calling serializer.</param>
+        /// <returns>The <see cref="System.DateTime"/>.</returns>
         public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
         {
             if (reader.TokenType != JsonToken.Integer)
             return ticks.FromUnixTime();
         }
 
+        /// <summary>
+        /// Writes the JSON representation of the object.
+        /// </summary>
+        /// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter"/> to write to.</param>
+        /// <param name="value">The <see cref="System.DateTime"/>.</param>
+        /// <param name="serializer">The calling serializer.</param>
         public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
         {
             long val;

trunk/source/Stacky/Helpers/UrlHelper.cs

 
 namespace Stacky
 {
+    /// <summary>
+    /// Stack Overflow API url helper methods.
+    /// </summary>
     public static class UrlHelper
     {
+        /// <summary>
+        /// Builds the Stack Overflow API method <see cref="System.Uri"/>.
+        /// </summary>
+        /// <param name="method">The method.</param>
+        /// <param name="version">The API version.</param>
+        /// <param name="serviceUrl">The service URL.</param>
+        /// <param name="urlParameters">The URL parameters.</param>
+        /// <param name="queryStringParameters">The query string parameters.</param>
+        /// <returns>Stack Overflow method call <see cref="System.Uri"/></returns>
         public static Uri BuildUrl(string method, string version,string serviceUrl, string[] urlParameters, object queryStringParameters)
         {
             return BuildUrl(method, version, serviceUrl, urlParameters, BuildParameters(queryStringParameters));
         }
 
+        /// <summary>
+        /// Builds the Stack Overflow API method <see cref="System.Uri"/>.
+        /// </summary>
+        /// <param name="method">The method.</param>
+        /// <param name="version">The API version.</param>
+        /// <param name="serviceUrl">The service URL.</param>
+        /// <param name="urlParameters">The URL parameters.</param>
+        /// <param name="queryStringParameters">The query string parameters.</param>
+        /// <returns>Stack Overflow method call <see cref="System.Uri"/></returns>
         public static Uri BuildUrl(string method, string version, string serviceUrl, string[] urlParameters, Dictionary<string, string> queryStringParameters)
         {
             return BuildUrl(method, version, serviceUrl, urlParameters, BuildParameters(queryStringParameters));
             return url;
         }
 
+        /// <summary>
+        /// Builds query string parameter from the properties in the provided dictionary.
+        /// </summary>
+        /// <param name="parameters">The property dictionary.</param>
+        /// <returns>"[property0]=[value0]&[property1]=[value1]..."</returns>
         public static string BuildParameters(Dictionary<string, string> parameters)
         {
             if (parameters == null)
             return s.ToString();
         }
 
+        /// <summary>
+        /// Builds query string parameter from the properties in the provided object.
+        /// </summary>
+        /// <param name="parameters">The object.</param>
+        /// <returns>"[property0]=[value0]&[property1]=[value1]..."</returns>
         public static string BuildParameters(object parameters)
         {
             if (parameters == null)
             return BuildParameters(ObjectToDictionary(parameters));
         }
 
+        /// <summary>
+        /// Returns a property dictionary for the provided object.
+        /// </summary>
+        /// <param name="item">The object.</param>
+        /// <returns>Dictionary of propery names and values.</returns>
         public static Dictionary<string, string> ObjectToDictionary(object item)
         {
             Dictionary<string, string> values = new Dictionary<string, string>();
             return String.Join(";", items.Select(i => i.ToString()).ToArray());
         }
 
+        /// <summary>
+        /// Converts an int to int array.
+        /// </summary>
+        /// <param name="item">The int.</param>
+        /// <returns>The int[].</returns>
         public static int[] ToArray(this int item)
         {
             return new int[] { item };