CODEGATOR

.NET info worth sinking your teeth into!
Welcome to CODEGATOR Sign in | Join | Help
in Search

Martin Cook

Yet another C# developer with a blog.

JobAPI - A First Draft

I've been working on an API for my CG.Job library. Here is what I have so far:

 

/// <summary>

/// Represents the public API for the CODEGATOR job library.

/// </summary>

public static class JobApi

{

    /// <summary>

    /// Creates a job entry in the system and schedules the job

    /// for execution.

    /// </summary>

    /// <typeparam name="J">The job type.</typeparam>

    /// <param name="job">The job to be created.</param>

    public static void Create<J>(J job)

        where J : JobBase, new();

 

    // ******************************************************************

 

    /// <summary>

    /// Removes a job from the system.

    /// </summary>

    /// <param name="jobId">The job to be deleted from the system.</param>

    public static void Delete(Guid jobId);

 

    // ******************************************************************

 

    /// <summary>

    /// Saves changes to a job's properties.

    /// </summary>

    /// <typeparam name="J">The job type.</typeparam>

    /// <param name="job">The job to be saved.</param>

    public static void Update<J>(J job)

        where J : JobBase, new();

 

    // ******************************************************************

 

    /// <summary>

    /// Returns a specific job from the system.

    /// </summary>

    /// <typeparam name="J">The job type</typeparam>

    /// <param name="jobId">The identifier for the job.</param>

    /// <returns>A <see cref="JobBase"/> instance.</returns>

    public static J Read<J>(Guid jobId)

        where J : JobBase, new();

 

    // ******************************************************************

 

    /// <summary>

    /// Returns a list of all the jobs in the system.

    /// </summary>

    /// <returns>A list of <see cref="JobBase"/> instances.</returns>

    public static List<JobBase> ReadAll();

 

    // ******************************************************************

 

    /// <summary>

    /// Returns a list of jobs that match a specified type.

    /// </summary>

    /// <typeparam name="J">The job type to search for.</typeparam>

    /// <returns>A list of <see cref="JobBase"/> instances.</returns>

    public static List<J> ReadAll<J>()

        where J : JobBase, new();

}

 

I'll probably modify the way I'm searching for jobs in the future, but for now, I'm keeping things simple. I'll have a better idea of what I'll need when I eventually create a UI for the library.

For now, you can use the JobApi class to manage jobs in the CG.Job library. I intend the JobApi class to be only class that developers will need to deal with in order to use my library.

 

See ya!

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit

About Martin

I work as a software engineer specializing in designing and building object-oriented business solutions for Windows platforms using C#. I have been programming professionally for roughly 20 years.

This Blog

Syndication

Terms of Service | Privacy Statement