<commit_before>﻿namespace Nessos.MBrace.Runtime

[<AutoOpen>]
module private ResourceUtils =
        
    let inline key<'T> = typeof<'T>.AssemblyQualifiedName

/// Exception raised on missing resource resolution
type ResourceNotFoundException internal (message : string) = 
    inherit System.Exception(message)

/// Cloud resource runtime dependency resolver
type ResourceRegistry private (index : Map<string, obj>) =

    /// Try Resolving resource of given type
    member __.TryResolve<'TResource> () = index.TryFind key<'TResource> |> Option.map unbox<'TResource>

    /// Resolves resource of given type
    member __.Resolve<'TResource> () =
        match index.TryFind key<'TResource> with
        | Some boxedResource -> unbox<'TResource> boxedResource
        | None -> raise <| ResourceNotFoundException (sprintf "Resource '%s' not installed in this context." typeof<'TResource>.Name)

    /// Creates an empty resource resolver
    static member Empty = new ResourceRegistry(Map.empty)<commit_msg>add resource registry attributes<commit_after>﻿namespace Nessos.MBrace.Runtime

[<AutoOpen>]
module private ResourceUtils =
        
    let inline key<'T> = typeof<'T>.AssemblyQualifiedName

/// Exception raised on missing resource resolution
type ResourceNotFoundException internal (message : string) = 
    inherit System.Exception(message)

/// Cloud resource runtime dependency resolver
[<Sealed ; AutoSerializable(false)>]
type ResourceRegistry private (index : Map<string, obj>) =

    /// Try Resolving resource of given type
    member __.TryResolve<'TResource> () = index.TryFind key<'TResource> |> Option.map unbox<'TResource>

    /// Resolves resource of given type
    member __.Resolve<'TResource> () =
        match index.TryFind key<'TResource> with
        | Some boxedResource -> unbox<'TResource> boxedResource
        | None -> raise <| ResourceNotFoundException (sprintf "Resource '%s' not installed in this context." typeof<'TResource>.Name)

    /// Creates an empty resource resolver
    static member Empty = new ResourceRegistry(Map.empty)
{'fraction_non_alphanumeric': 0.10260115606936417, 'fraction_numerical': 0.0, 'mean_word_length': 3.9808153477218227, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1363264', 'n_tokens_mistral': 532, 'n_tokens_neox': 545, 'n_words': 170}