Skip to content

Commit

Permalink
EveCore: Cleanup. Release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ezet committed Mar 16, 2016
1 parent 34ff134 commit 32cf71a
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 112 deletions.
26 changes: 21 additions & 5 deletions EveLib.Core/Cache/EveLibFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ namespace eZet.EveLib.Core.Cache {
/// <summary>
/// Simple plain file cache implementation
/// </summary>
public class EveLibFileCache : IEveLibCache {
public class EveLibFileCache : IEveLibCache, IDisposable {
private static readonly SHA1CryptoServiceProvider Sha1 = new SHA1CryptoServiceProvider();

private readonly IDictionary<string, DateTime> _register = new Dictionary<string, DateTime>();

private readonly ReaderWriterLockSlim _registerLock = new ReaderWriterLockSlim();

private readonly TraceSource _trace = new TraceSource("EveLib");

private bool _isInitialized;

private readonly ReaderWriterLockSlim _registerLock = new ReaderWriterLockSlim();

/// <summary>
/// Initializes a new instance of the <see cref="EveLibFileCache" /> class.
/// </summary>
Expand Down Expand Up @@ -96,7 +96,7 @@ public async Task<string> LoadAsync(Uri uri) {
_trace.TraceEvent(TraceEventType.Verbose, 0, "EveLibFileCache:CacheIsValid: {0} ({1})", validCache,
cacheExpirationTime);
if (validCache) {
var filePath = Path.Combine(CachePath , hash);
var filePath = Path.Combine(CachePath, hash);
var fileExist = File.Exists(filePath);
_trace.TraceEvent(TraceEventType.Verbose, 0, "EveLibFileCache:CacheDataFound: {0}", fileExist);
if (File.Exists(filePath)) {
Expand Down Expand Up @@ -132,7 +132,7 @@ public virtual bool TryGetExpirationDate(Uri uri, out DateTime value) {
}

/// <summary>
/// initialize as an asynchronous operation.
/// initialize as an asynchronous operation.
/// </summary>
/// <returns>Task.</returns>
private async Task initAsync() {
Expand Down Expand Up @@ -219,5 +219,21 @@ var file in
if (_registerLock.IsReadLockHeld) _registerLock.ExitReadLock();
}
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="finalize"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool finalize) {
_registerLock.Dispose();
}
}
}
50 changes: 24 additions & 26 deletions EveLib.Core/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,48 @@ namespace eZet.EveLib.Core {
/// Provides configuration and constants for the library.
/// </summary>
public static class Config {
private static string _appData;

/// <summary>
/// UserAgent used for HTTP requests
/// </summary>
public static readonly string UserAgent = ConfigurationManager.AppSettings["eveLib.UserAgent"];

static Config() {
Separator = Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture);
if (IsNullOrEmpty(UserAgent))
UserAgent = "EveLib";
_appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EveLib");
SetConfig();
}

/// <summary>
/// Directory Separator
/// </summary>
public static string Separator { get; set; }

private static string _appData;
/// <summary>
/// Gets or sets the application data.
/// Gets or sets the application data.
/// </summary>
/// <value>The application data.</value>
public static string AppData {
get {
return _appData;
}
get { return _appData; }

set {
_appData = value;
SetConfig();
}
}

static Config() {
Separator = Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture);
if (IsNullOrEmpty(UserAgent))
UserAgent = "EveLib";
_appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EveLib");
SetConfig();
}

private static void SetConfig() {
CachePath = Path.Combine(AppData, "Cache");
ImagePath = Path.Combine(AppData, "Images");
CacheFactory = module => new EveLibFileCache(Path.Combine(CachePath, module), "register");
}


/// <summary>
/// Gets or sets the image path.
/// Gets or sets the image path.
/// </summary>
/// <value>The image path.</value>
public static string ImagePath { get; set; }

/// <summary>
/// Gets or sets the cache path.
/// Gets or sets the cache path.
/// </summary>
/// <value>The cache path.</value>
public static string CachePath { get; set; }
Expand All @@ -63,10 +61,10 @@ private static void SetConfig() {
/// </summary>
public static Func<string, IEveLibCache> CacheFactory { get; set; }

/// <summary>
/// UserAgent used for HTTP requests
/// </summary>
public static readonly string UserAgent = ConfigurationManager.AppSettings["eveLib.UserAgent"];

private static void SetConfig() {
CachePath = Path.Combine(AppData, "Cache");
ImagePath = Path.Combine(AppData, "Images");
CacheFactory = module => new EveLibFileCache(Path.Combine(CachePath, module), "register");
}
}
}
35 changes: 16 additions & 19 deletions EveLib.Core/Converters/BoolConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,39 @@

namespace eZet.EveLib.Core.Converters {
/// <summary>
/// Class BoolConverter.
/// Class BoolConverter.
/// </summary>
public class BoolConverter : JsonConverter
{
public class BoolConverter : JsonConverter {
/// <summary>
/// Writes the json.
/// Writes the json.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(((bool)value) ? 1 : 0);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
writer.WriteValue(((bool) value) ? 1 : 0);
}

/// <summary>
/// Reads the json.
/// Reads the json.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value.</param>
/// <param name="serializer">The serializer.</param>
/// <returns>System.Object.</returns>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return reader.Value.ToString() == "1";
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
JsonSerializer serializer) {
return reader.Value.ToString() == "1";
}

/// <summary>
/// Determines whether this instance can convert the specified object type.
/// 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>
public override bool CanConvert(Type objectType)
{
return objectType == typeof(bool);
public override bool CanConvert(Type objectType) {
return objectType == typeof (bool);
}
}
}
}
}
2 changes: 1 addition & 1 deletion EveLib.Core/EveLib.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl> -->
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>https://github.com/ezet/evelib/releases/tag/Core_v3.0.3</releaseNotes>
<releaseNotes>https://github.com/ezet/evelib/releases/tag/Core_v3.0.4</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>EveLib Core EveOnline Eve Online</tags>
<dependencies>
Expand Down
35 changes: 17 additions & 18 deletions EveLib.Core/Properties/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace eZet.EveLib.Core.Properties {
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter |
AttributeTargets.Property | AttributeTargets.Delegate |
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
AttributeTargets.Field)]
public sealed class CanBeNullAttribute : Attribute {
}

Expand All @@ -43,7 +43,7 @@ public sealed class CanBeNullAttribute : Attribute {
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter |
AttributeTargets.Property | AttributeTargets.Delegate |
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
AttributeTargets.Field)]
public sealed class NotNullAttribute : Attribute {
}

Expand All @@ -62,8 +62,7 @@ public sealed class NotNullAttribute : Attribute {
/// </code>
/// </example>
[AttributeUsage(
AttributeTargets.Constructor | AttributeTargets.Method,
AllowMultiple = false, Inherited = true)]
AttributeTargets.Constructor | AttributeTargets.Method)]
public sealed class StringFormatMethodAttribute : Attribute {
/// <param name="formatParameterName">
/// Specifies which parameter of an annotated method should be treated as format-string
Expand All @@ -88,7 +87,7 @@ public StringFormatMethodAttribute(string formatParameterName) {
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class InvokerParameterNameAttribute : Attribute {
}

Expand Down Expand Up @@ -147,7 +146,7 @@ public sealed class InvokerParameterNameAttribute : Attribute {
/// </item>
/// </list>
/// </example>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Method)]
public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute {
public NotifyPropertyChangedInvocatorAttribute() {
}
Expand Down Expand Up @@ -213,7 +212,7 @@ public NotifyPropertyChangedInvocatorAttribute(string parameterName) {
/// </item>
/// </list>
/// </examples>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class ContractAnnotationAttribute : Attribute {
public ContractAnnotationAttribute([NotNull] string contract)
: this(contract, false) {
Expand All @@ -239,7 +238,7 @@ public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStat
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.All)]
public sealed class LocalizationRequiredAttribute : Attribute {
public LocalizationRequiredAttribute() : this(true) {
}
Expand Down Expand Up @@ -274,7 +273,7 @@ public LocalizationRequiredAttribute(bool required) {
/// </example>
[AttributeUsage(
AttributeTargets.Interface | AttributeTargets.Class |
AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
AttributeTargets.Struct)]
public sealed class CannotApplyEqualityOperatorAttribute : Attribute {
}

Expand All @@ -290,7 +289,7 @@ public sealed class CannotApplyEqualityOperatorAttribute : Attribute {
/// public class MyComponent : IComponent { }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof (Attribute))]
public sealed class BaseTypeRequiredAttribute : Attribute {
public BaseTypeRequiredAttribute([NotNull] Type baseType) {
Expand All @@ -306,7 +305,7 @@ public BaseTypeRequiredAttribute([NotNull] Type baseType) {
/// (e.g. via reflection, in external library), so this symbol
/// will not be marked as unused (as well as by other usage inspections)
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.All)]
public sealed class UsedImplicitlyAttribute : Attribute {
public UsedImplicitlyAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) {
Expand Down Expand Up @@ -335,7 +334,7 @@ public UsedImplicitlyAttribute(
/// to not mark symbols marked with such attributes as unused
/// (as well as by other usage inspections)
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Class)]
public sealed class MeansImplicitUseAttribute : Attribute {
public MeansImplicitUseAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) {
Expand Down Expand Up @@ -379,7 +378,7 @@ public enum ImplicitUseKindFlags {
InstantiatedWithFixedConstructorSignature = 4,

/// <summary>Indicates implicit instantiation of a type</summary>
InstantiatedNoFixedConstructorSignature = 8,
InstantiatedNoFixedConstructorSignature = 8
}

/// <summary>
Expand Down Expand Up @@ -423,7 +422,7 @@ public PublicAPIAttribute([NotNull] string comment) {
/// If the parameter is an enumerable, indicates that it is enumerated
/// while the method is executed
/// </summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = true)]
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class InstantHandleAttribute : Attribute {
}

Expand All @@ -440,7 +439,7 @@ public sealed class InstantHandleAttribute : Attribute {
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
[AttributeUsage(AttributeTargets.Method)]
public sealed class PureAttribute : Attribute {
}

Expand Down Expand Up @@ -650,7 +649,7 @@ public sealed class AspMvcActionSelectorAttribute : Attribute {

[AttributeUsage(
AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Field, Inherited = true)]
AttributeTargets.Field)]
public sealed class HtmlElementAttributesAttribute : Attribute {
public HtmlElementAttributesAttribute() {
}
Expand All @@ -665,7 +664,7 @@ public HtmlElementAttributesAttribute([NotNull] string name) {

[AttributeUsage(
AttributeTargets.Parameter | AttributeTargets.Field |
AttributeTargets.Property, Inherited = true)]
AttributeTargets.Property)]
public sealed class HtmlAttributeValueAttribute : Attribute {
public HtmlAttributeValueAttribute([NotNull] string name) {
Name = name;
Expand All @@ -682,7 +681,7 @@ public HtmlAttributeValueAttribute([NotNull] string name) {
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, Inherited = true)]
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class RazorSectionAttribute : Attribute {
}
}
3 changes: 0 additions & 3 deletions EveLib.Core/RequestHandlers/IPostRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@

namespace eZet.EveLib.Core.RequestHandlers {
/// <summary>
///
/// </summary>
public interface IPostRequestHandler : IRequestHandler {
/// <summary>
///
/// </summary>
/// <param name="uri"></param>
/// <param name="postData"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
Task<T> PostRequestAsync<T>(Uri uri, string postData);

}
}
1 change: 0 additions & 1 deletion EveLib.Core/RequestHandlers/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public virtual async Task<T> RequestAsync<T>(Uri uri) {
}

/// <summary>
///
/// </summary>
/// <param name="uri"></param>
/// <param name="postData"></param>
Expand Down
Loading

0 comments on commit 32cf71a

Please sign in to comment.