Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:56:01+00:00 2026-06-17T06:56:01+00:00

I am trying to revise my logging library. Here is where I’m stuck. I

  • 0

I am trying to revise my logging library. Here is where I’m stuck. I use an enumeration, let’s call it ActionType, to identify my operations like UserLogin, PurchaseOrder… hundreds of them. And I use this type in my logger methods. But since I am seperating my logger library from my project specific code in the sake of loose coupling and base library can’t access ActionType defined in a project, how can I achieve this. To clarify it let me explain same case in java. Java allows enums to implement interfaces. So I could write:

In base logger library I could define;

public interface IActionType {}

and in one of my several projects

public enum ActionType implements IActionType {UserLogin, PurchaseOrder, .....}

So when I called my logger.log(ActionType.UserLogin, ....) base library would get the underlying action. This would all be suffice. Is there anyway around it to accomplish this in c#? By the way, I considered using IoC containers, but I want something more elegant.

Many thanks for any help…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:56:02+00:00Added an answer on June 17, 2026 at 6:56 am

    Here is approach log4net uses for Level class (yes, it is class, not enum):

    public class ActionType : IActionType
    {
       public static readonly ActionType UserLogin;
       public static readonly ActionType PurchaseOrder;
    
       static ActionType()
       {
           UserLogin = new ActionType(1, "User Login");
           // ...
       }
    
       public ActionType(int value, string name)
       {           
           // verify arguments values
           Value = value;
           Name = name;
       }
    
       public int Value { get; private set; }
       public string Name { get; private set; }
    }
    

    And interface

    public interface IActionType
    {
        int Value { get; }
        string Name { get; }
    }
    

    Usage:

    logger.Log(ActionType.UserLogin);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code in a function I'm trying to revise. This example works
I am trying to revise my build process to use ant with apache ivy
Trying to figure out how I can do this properly. The print_r looks like
Trying to copy the msdn refernce here doesn't work and gives an error I
Trying to prepare good build environment for my js library. According to reviews on
I'm trying to use git-p4 to clone perforce depot. I keep running into a
I'm trying to make the dynamic select just like this http://railscasts.com/episodes/88-dynamic-select-menus-revised?view=asciicast In my case,
I'm trying to use jQuery Tokeninput as shown in Railscast #258 (revised). When I
I am trying to revise a java code to write something into a txt
Basically I'm trying to call a dll by name, instantiate an object, then call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.