简体   繁体   中英

Custom Task on WP8

i wanted to make a new Task on my app, for later make a tracking for it... But i think the way i'm trying is not good. This is what i'm trying:

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);
    }

My problem is that i can't use the function CreateDefaultItem... Error on Client() is: Using the generic type Jumper.Core.Client.Client requires 4 type arguments.

Here is the function 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;
    }
}

I have the same problem for function serviceFactory (with the same error).

Can anyone help me please?

Much Thanks!

Well, you need to write something like:

var c = new Jumper.Core.Client.Client<Type1, Type2, Type3, Type4>();

Although I am unfamiliar with that library you are using. Is that the whole listing right there? Are you even supposed to create instances of Client manually?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM