我想在我的应用程序上创建一个新任务,以便稍后对其进行跟踪...但我认为我尝试的方式并不好。 这就是我正在尝试的:
public async Task NombreEvento(string json)
{
var c = new Jumper.Core.Client.Client();
var item2 = await c.CreateDefaultItem();
Jumper.Core.Model.TrackingItem item = item2;
item.Type = Jumper.Core.Model.TrackingTypeEnum.Custom;
item.Json = json;
item.RunningSeconds = 0;
var t = new Jumper.Core.Services.ServiceFactory();
var service = await t.serviceFactory.TrackingService.AddItem(item);
}
我的问题是我无法使用CreateDefaultItem函数... Client()上的错误是:使用泛型类型Jumper.Core.Client.Client需要4个类型参数。
这是函数CreateDefaultItem:
namespace Jumper.Core.Client
{
public sealed class Client
<TBaseSaveData,
TDeviceServiceHelper,
TGeoLocationService,
TNetworkService>
where TBaseSaveData : BaseSaveDataService, new()
where TDeviceServiceHelper : IDeviceServiceHelper, new()
where TGeoLocationService : IGeoLocationService, new()
where TNetworkService : INetworkService, new()
{
private readonly int appId;
private readonly string appVersion;
private readonly ServiceFactory<TBaseSaveData,
TDeviceServiceHelper,
TGeoLocationService,
TNetworkService> serviceFactory;
#region Constructors
internal Client
(int appId, string appVersion)
{
this.appId = appId;
this.appVersion = appVersion;
this.serviceFactory = new ServiceFactory<TBaseSaveData,
TDeviceServiceHelper,
TGeoLocationService,
TNetworkService>();
}
#endregion
#region Private Methods
public async Task SendItem(TrackingTypeEnum trackingType, bool flush)
{
TrackingItem item = await CreateDefaultItem();
item.Type = trackingType;
if (trackingType != TrackingTypeEnum.Background)
{
item.RunningSeconds = 0;
}
await this.serviceFactory.TrackingService.AddItem(item, flush);
}
public async Task<TrackingItem> CreateDefaultItem()
{
Tuple<double, double> location = await this.serviceFactory.GeoLocationService
.GetUnifiedGeoLocation();
var assemblyService = this.serviceFactory.AssemblyInfoService;
var deviceService = this.serviceFactory.DeviceServiceHelper;
var seconds = (DateTime.UtcNow - this.serviceFactory.TrackingService.StartTime).TotalSeconds;
TrackingItem item = new TrackingItem()
{
//APP
AppId = this.appId,
RunningSeconds = (int)seconds,
AppVersion = this.appVersion,
Language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName,
Country = CultureInfo.CurrentCulture.Name.Substring(3, 2),
//Navigation
Json = TrackingItem.NULL
};
return item;
}
}
我对函数serviceFactory有同样的问题(具有相同的错误)。
有人可以帮我吗?
非常感谢!
答案 0 :(得分:0)
嗯,你需要写一些类似的东西:
var c = new Jumper.Core.Client.Client<Type1, Type2, Type3, Type4>();
虽然我不熟悉你正在使用的那个库。
整个上市就在那里吗?您是否应该手动创建Client
的实例?