// <copyright file="CronJobSchedular.cs" company="WindSoft">// Copyright (c) WindSoft. All rights reserved.// Licensed under the WindSoft license. See LICENSE file in the project root for full license information.// </copyright>namespace WindSoft.CronScheduler.Services.Repositories;using System;using System.Threading.Tasks;using Cronos;/// <summary>/// Represents a scheduled job based on a Cron expression./// </summary>public class CronJobSchedular{ /// <summary> /// Gets the Cron expression used to schedule the job. /// </summary> public CronExpression CronExpression { get; } // Property declaration /// <summary> /// Gets the task to execute as part of this Cron job. /// </summary> public Func<Task> Task { get; } // Property declaration /// <summary> /// Initializes a new instance of the <see cref="CronJobSchedular"/> class. /// </summary> /// <param name="cronExpression">The Cron expression defining the schedule for the job.</param> /// <param name="task">The task to execute according to the Cron schedule.</param> public CronJobSchedular(string cronExpression, Func<Task> task) // Constructor declaration { this.CronExpression = CronExpression.Parse(cronExpression); this.Task = task; }}
I Have added all the code above.
I am facing issue in this code its showing the A constructor should not follow a propertyBut as per my knowledge i have follow the constructor property if you guys have any solution please let me know. I am stuck in this code from 1-2 hours
/// <summary> /// Initializes a new instance of the <see cref="CronJobSchedular"/> class. /// </summary> /// <param name="cronExpression">The Cron expression defining the schedule for the job.</param> /// <param name="task">The task to execute according to the Cron schedule.</param> public CronJobSchedular(string cronExpression, Func<Task> task) // Constructor declaration { this.CronExpression = CronExpression.Parse(cronExpression); this.Task = task; }
Basically i am tried to implement the cron job using the Cronos package in C# .NET for cronScheduler.
Here is the link of the Cronos - (https://github.com/HangfireIO/Cronos)
I have tried to add the documentation.
/// <summary> /// Initializes a new instance of the <see cref="CronJobSchedular"/> class. /// </summary> /// <param name="cronExpression">The Cron expression defining the schedule for the job.</param> /// <param name="task">The task to execute according to the Cron schedule.</param>
I want to fix the code as soon as possible.