public static void PopulateFromRequest(this ITaskParameters task, DashboardRequest request) { foreach (var property in task.GetType().GetProperties().Where(x => x.CanWrite)) { SetProperty(request, property, task); } }
public async Task <bool> Run(ITaskParameters parameters) { if (parameters == null) { throw new NullReferenceException(); } using (var db = new SomeGameDbContext(parameters.GetService <IMetadataProvider>(), string.Empty)) { var created = db.Database.EnsureCreated(); var player = new Player() { ReferencedItem = new ReferencedItem() }; var playerSet = db.Set <Player>(); var entry = playerSet.Add(player); db.SaveChanges(); player = playerSet.FirstOrDefault(); var id = player.Id; var o = id; } return(true); }
private static Job CreateJob(ITaskParameters taskParameters) { var methodInfo = typeof(ITaskDispatcher).GetMethod("Dispatch"); var makeGenericMethod = methodInfo.MakeGenericMethod(taskParameters.GetType()); var job = new Job(typeof(ITaskDispatcher), makeGenericMethod, taskParameters, null, null); return(job); }
/// <summary> /// Initializes a new instance of the <see cref="ConsoleTask"/> class /// with specified task parameters. /// </summary> /// <param name="parameters">An <see cref="ITaskParameters"/> object /// containing essential task informations.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="parameters"/> is null. /// </exception> public ConsoleTask(ITaskParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } this.parameters = parameters; }
protected internal TaskDetailsPage(ITaskParameters taskParameters, TaskDispatcherPagesOptions options, List <Type> genericTypeOptions = null) { _taskParameters = taskParameters; _genericTypeOptions = genericTypeOptions; _options = options; var type = _taskParameters.GetType(); _pageHeader = type.Name.Replace("`1", ""); _displayName = type.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName ?? taskParameters.ToString(); _displayDescription = type.GetCustomAttribute <DescriptionAttribute>()?.Description; _displayErrorDetails = type.GetCustomAttribute <ErrorImplicationDetailsAttribute>()?.Details; }
public async Task <bool> Run(ITaskParameters parameters) { var playerType = parameters.Exports.Get <Player, UnrealMetadataProvider, UnrealTypeInfo>(); var templateFactory = parameters.GetService <UnrealTemplateFactory>(); var template = templateFactory.Create <UnrealClassTemplate>(playerType); template.ModuleName = "SomeGame"; const string filePath = @"C:\Temp\Out.txt"; var fileTemplate = new UnrealHeaderTemplate(template); fileTemplate.AddGeneratedHeaderInclude(filePath); File.WriteAllText(filePath, fileTemplate.Print()); return(true); }
public ITaskResult SetParameters(ITaskParameters taskParameters) { Ensure.That(taskParameters).IsNotNull(); var parameters = (ManufacturingParameters)taskParameters; return SetManufacturingParameters(parameters); }
public async Task PostTask(ITaskParameters parameters) { }
public async Task <bool> Run(ITaskParameters parameters) { return(true); }
public async Task PreTask(ITaskParameters parameters) { }
public bool Authorize(DashboardContext context, ITaskParameters taskParameters) { return(new Random().Next(1) == 1); }
public abstract ITaskResult SetParameters(ITaskParameters taskParameters);
private static void SetProperty(DashboardRequest request, PropertyInfo propertyInfo, ITaskParameters searchObject) { var value = Task.Run(() => request.GetFormValuesAsync(propertyInfo.Name)).Result.FirstOrDefault(); if (value == null) { return; } var propertyType = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType; var propertyValue = ConvertFromInvariantString(propertyType, value); propertyInfo.SetValue(searchObject, propertyValue, null); }