瀏覽代碼

add helper methods.

master
yangxiaodong 7 年之前
父節點
當前提交
6541e1aa38
共有 3 個文件被更改,包括 32 次插入0 次删除
  1. +5
    -0
      src/DotNetCore.CAP/IStorage.cs
  2. +10
    -0
      src/DotNetCore.CAP/IStorageConnection.cs
  3. +17
    -0
      src/DotNetCore.CAP/Infrastructure/Helper.cs

+ 5
- 0
src/DotNetCore.CAP/IStorage.cs 查看文件

@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Dashboard;

namespace DotNetCore.CAP
{
@@ -12,5 +13,9 @@ namespace DotNetCore.CAP
/// Initializes the storage. For example, making sure a database is created and migrations are applied.
/// </summary>
Task InitializeAsync(CancellationToken cancellationToken);

IMonitoringApi GetMonitoringApi();

IStorageConnection GetConnection();
}
}

+ 10
- 0
src/DotNetCore.CAP/IStorageConnection.cs 查看文件

@@ -63,5 +63,15 @@ namespace DotNetCore.CAP
/// Creates and returns an <see cref="IStorageTransaction"/>.
/// </summary>
IStorageTransaction CreateTransaction();


//-------------------------------------------
long GetSetCount(string key);

List<string> GetRangeFromSet(string key, int startingFrom, int endingAt);

MessageData GetJobData( string jobId);

StateData GetStateData(string jobId);
}
}

+ 17
- 0
src/DotNetCore.CAP/Infrastructure/Helper.cs 查看文件

@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using Newtonsoft.Json;

@@ -49,6 +50,22 @@ namespace DotNetCore.CAP.Infrastructure
return Epoch.AddSeconds(value);
}

public static string SerializeDateTime(DateTime value)
{
return value.ToString("o", CultureInfo.InvariantCulture);
}

public static DateTime DeserializeDateTime(string value)
{
long timestamp;
if (long.TryParse(value, out timestamp))
{
return FromTimestamp(timestamp);
}

return DateTime.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
}

public static bool IsController(TypeInfo typeInfo)
{
if (!typeInfo.IsClass)


Loading…
取消
儲存