You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

Ma.CustomParser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Ma.CustomParser

Custom parsers to help to parse HTML and JSON content.

9.0.0
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

Ma.CustomParser

Custom parsers to help to parse HTML and JSON content.

Implement your HTML parser classes from IHtmlParser<> or IAsyncHtmlParser<> interface. Implement your Json parser classes from IJsonParser<> or IAsyncJsonParser<> interface.

Add following method to the project where you have html or json parser classes, and call it when program starts to register all parsers:

/// <summary>
/// Register all custom Json and HTML parser classes.
/// </summary>
public static void RegisterCustomParsers(ICustomParser parser)
{
    var customParserInterfaceTypes = new List<Type>
    {
        typeof(IHtmlParser<>),
        typeof(IAsyncHtmlParser<>),
        typeof(IJsonParser<>),
        typeof(IAsyncJsonParser<>)
    };

    // Get all custom parser which implement above interfaces.
    var itemParserTypes = Assembly
        .GetExecutingAssembly()
        .GetTypes()
        .Where(m => m.GetInterfaces().Any(i => i.IsGenericType
            && customParserInterfaceTypes.Contains(i.GetGenericTypeDefinition())));

    foreach (Type itemParserType in itemParserTypes)
    {
    dynamic itemParser = Activator.CreateInstance(itemParserType);
    parser.Configuration.AddParser(itemParser);
    }
}

Keywords

parser

FAQs

Package last updated on 15 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts