Skip to content

Commit

Permalink
Added missing comments. Release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ezet committed Apr 29, 2016
1 parent 7bfb7a1 commit 3c7756a
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
using System;
// ***********************************************************************
// Assembly : EveLib.Core
// Author : larsd
// Created : 04-28-2016
//
// Last Modified By : larsd
// Last Modified On : 04-29-2016
// ***********************************************************************
// <copyright file="CamelCaseToPascalCaseExpandoObjectConverter.cs" company="Lars Kristian Dahl">
// Copyright © 2016
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using Newtonsoft.Json;

namespace eZet.EveLib.Core.Converters {
/// <summary>
/// Class CamelCaseToPascalCaseExpandoObjectConverter.
/// </summary>
public class CamelCaseToPascalCaseExpandoObjectConverter : JsonConverter {
//CHANGED
//the ExpandoObjectConverter needs this internal method so we have to copy it
//from JsonReader.cs
/// <summary>
/// Determines whether [is primitive token] [the specified token].
/// </summary>
/// <param name="token">The token.</param>
/// <returns><c>true</c> if [is primitive token] [the specified token]; otherwise, <c>false</c>.</returns>
internal static bool IsPrimitiveToken(JsonToken token) {
switch (token) {
case JsonToken.Integer:
Expand All @@ -28,7 +49,7 @@ internal static bool IsPrimitiveToken(JsonToken token) {
/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param>
/// <param name="writer">The <see cref="JsonWriter" /> to write to.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The calling serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
Expand All @@ -38,7 +59,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
/// <param name="reader">The <see cref="JsonReader" /> to read from.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value of object being read.</param>
/// <param name="serializer">The calling serializer.</param>
Expand All @@ -47,6 +68,15 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
return ReadValue(reader);
}

/// <summary>
/// Reads the value.
/// </summary>
/// <param name="reader">The reader.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.Exception">
/// Unexpected end.
/// or
/// </exception>
private object ReadValue(JsonReader reader) {
while (reader.TokenType == JsonToken.Comment) {
if (!reader.Read())
Expand All @@ -70,6 +100,12 @@ private object ReadValue(JsonReader reader) {
}
}

/// <summary>
/// Reads the list.
/// </summary>
/// <param name="reader">The reader.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.Exception">Unexpected end.</exception>
private object ReadList(JsonReader reader) {
IList<object> list = new List<object>();

Expand All @@ -90,6 +126,16 @@ private object ReadList(JsonReader reader) {
throw new Exception("Unexpected end.");
}

/// <summary>
/// Reads the object.
/// </summary>
/// <param name="reader">The reader.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.Exception">
/// Unexpected end.
/// or
/// Unexpected end.
/// </exception>
private object ReadObject(JsonReader reader) {
IDictionary<string, object> expandoObject = new ExpandoObject();

Expand Down Expand Up @@ -121,26 +167,30 @@ private object ReadObject(JsonReader reader) {
/// Determines whether this instance can convert the specified object type.
/// </summary>
/// <param name="objectType">Type of the object.</param>
/// <returns>
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
/// </returns>
/// <returns><c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.</returns>
public override bool CanConvert(Type objectType) {
return objectType == typeof (DynamicObject) || objectType == typeof(ExpandoObject);
}

/// <summary>
/// Gets a value indicating whether this <see cref="JsonConverter"/> can write JSON.
/// Gets a value indicating whether this <see cref="JsonConverter" /> can write JSON.
/// </summary>
/// <value>
/// <c>true</c> if this <see cref="JsonConverter"/> can write JSON; otherwise, <c>false</c>.
/// </value>
/// <value><c>true</c> if this <see cref="JsonConverter" /> can write JSON; otherwise, <c>false</c>.</value>
public override bool CanWrite
{
get { return false; }
}
}

/// <summary>
/// Class StringExtensions.
/// </summary>
public static class StringExtensions {
/// <summary>
/// To the pascal case.
/// </summary>
/// <param name="s">The s.</param>
/// <returns>System.String.</returns>
public static string ToPascalCase(this string s) {
if (string.IsNullOrEmpty(s) || !char.IsLower(s[0]))
return s;
Expand Down
25 changes: 18 additions & 7 deletions EveLib.Core/Serializers/JsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 08-09-2015
//
// Last Modified By : larsd
// Last Modified On : 03-03-2016
// Last Modified On : 04-29-2016
// ***********************************************************************
// <copyright file="JsonSerializer.cs" company="Lars Kristian Dahl">
// Copyright © 2016
Expand All @@ -20,39 +20,50 @@

namespace eZet.EveLib.Core.Serializers {
/// <summary>
/// JSON serializer
/// JSON serializer
/// </summary>
public sealed class JsonSerializer : ISerializer {
/// <summary>
/// The _trace
/// The _trace
/// </summary>
private readonly TraceSource _trace = new TraceSource("EveLib");

/// <summary>
/// The date format
/// The date format
/// </summary>
public string DateFormat = "yyyy-MM-dd HH:mm:ss";

/// <summary>
/// The date format2
/// The date format2
/// </summary>
public string DateFormat2 = "yyyy.MM.dd HH:mm:ss";

/// <summary>
/// Gets the settings.
/// </summary>
/// <value>The settings.</value>
private JsonSerializerSettings Settings { get; }

/// <summary>
/// Initializes a new instance of the <see cref="JsonSerializer"/> class.
/// </summary>
public JsonSerializer() {
Settings = new JsonSerializerSettings();
Settings.Converters.Add(new IsoDateTimeConverter { DateTimeFormat = DateFormat });
Settings.Converters.Add(new CamelCaseToPascalCaseExpandoObjectConverter());
Settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
}

/// <summary>
/// Initializes a new instance of the <see cref="JsonSerializer"/> class.
/// </summary>
/// <param name="dateFormat">The date format.</param>
public JsonSerializer(string dateFormat) : this() {
DateFormat = dateFormat;
}

/// <summary>
/// Deserializes data.
/// Deserializes data.
/// </summary>
/// <typeparam name="T">Type to deserialize to.</typeparam>
/// <param name="data">String of data to deserialize.</param>
Expand All @@ -65,7 +76,7 @@ T ISerializer.Deserialize<T>(string data) {
}

/// <summary>
/// Serializes the specified entity.
/// Serializes the specified entity.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity">The entity.</param>
Expand Down
5 changes: 5 additions & 0 deletions EveLib.EveCrest/EveCrest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,11 @@ public Killmail GetKillmail(long id, string hash) {
return GetKillmailAsync(id, hash).Result;
}

/// <summary>
/// Gets the character stats.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>System.Threading.Tasks.Task&lt;eZet.EveLib.EveCrestModule.Models.CharacterStats&gt;.</returns>
public Task<CharacterStats> GetCharacterStats(long id) {
var uri = "https://characterstats.tech.ccp.is/v1/" + id + "/";
return getAsync<CharacterStats>(uri);
Expand Down
2 changes: 1 addition & 1 deletion EveLib.EveCrest/Models/CharacterStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace eZet.EveLib.EveCrestModule.Models {
public sealed class CharacterStats : CrestResource<CharacterStats> {

public CharacterStats() {
ContentType = "test";
ContentType = "default";
}

[DataMember(Name = "characterID")]
Expand Down
10 changes: 9 additions & 1 deletion EveLib.EveCrest/Models/CollectionResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ public abstract class CollectionResource<TCollection, TItem> : CrestResource<TCo
[DataMember(Name = "next")]
public Href<TCollection> Next { get; set; }

/// <summary>
/// Gets the next resource.
/// </summary>
/// <value>The next resource.</value>
public CollectionResource<TCollection, TItem> NextResource { get; private set; }

/// <summary>
/// <summary>
/// Gets or sets the previous page.
/// </summary>
/// <value>The previous.</value>
Expand Down Expand Up @@ -253,6 +257,10 @@ IEnumerator IEnumerable.GetEnumerator() {

}

/// <summary>
/// To the list asynchronous.
/// </summary>
/// <returns>System.Threading.Tasks.Task&lt;System.Collections.Generic.IList&lt;TItem&gt;&gt;.</returns>
public async Task<IList<TItem>> ToListAsync() {
return (await AllItemsAsync().ConfigureAwait(false)).ToList();
}
Expand Down
4 changes: 4 additions & 0 deletions EveLib.EveCrest/Models/IQueryParameter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace eZet.EveLib.EveCrestModule.Models {
/// <summary>
/// Interface IQueryParameter
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IQueryParameter<out T> : ICrestResource<T> {

}
Expand Down
9 changes: 9 additions & 0 deletions EveLib.EveCrest/Models/Links/ParameterHref.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
namespace eZet.EveLib.EveCrestModule.Models.Links {
/// <summary>
/// Class ParameterHref.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TParam">The type of the t parameter.</typeparam>
public class ParameterHref<T, TParam> : Href<T> {
/// <summary>
/// Initializes a new instance of the <see cref="ParameterHref{T, TParam}" /> class.
/// </summary>
/// <param name="href">The href.</param>
public ParameterHref(string href) : base(href) {

}
Expand Down
4 changes: 4 additions & 0 deletions EveLib.EveCrest/Models/Resources/ItemType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public class DogmaEffect {
public bool IsDefault { get; set; }
}

/// <summary>
/// Gets the name of the parameter.
/// </summary>
/// <value>The name of the parameter.</value>
public string ParameterName { get; }
}
}
13 changes: 12 additions & 1 deletion EveLib.EveCrest/QueryParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,26 @@
using eZet.EveLib.EveCrestModule.Models.Resources.Market;

namespace eZet.EveLib.EveCrestModule {
/// <summary>
/// Class QueryParameters.
/// </summary>
public static class QueryParameters {

/// <summary>
/// The map
/// </summary>
private static Dictionary<Type, string> map = new Dictionary<Type, string> {
{typeof (ItemType), "type"},
{typeof(MarketGroup), "group" }
};

/// <summary>
/// Gets the name of the parameter.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>System.String.</returns>
public static string GetParameterName<T>() {
return map[typeof (T)];
return map[typeof(T)];
}
}
}

0 comments on commit 3c7756a

Please sign in to comment.