TuesPechkin icon indicating copy to clipboard operation
TuesPechkin copied to clipboard

Create a TuesPechkin.BlackBox package

Open tuespetre opened this issue 9 years ago • 2 comments

This package would reference the TuesPechkin package as well as the TuesPechkin.Wkhtmltox.AnyCPU package and provide a sort of 'black box' interface to use TuesPeckin a la 1.x.x (think Factory.Create())

tuespetre avatar Mar 10 '15 13:03 tuespetre

Why not to just create a Factory, which will take care about the instance to create? Without AnyCPU package?

Like this:

public static class Factory
{
    private static object _lock = new object();
    private static IConverter _instance = default(IConverter);

    public static IConverter Create()
    {
        if (_instance == null)
        {
            lock (_lock)
            {
                if (_instance == null)
                {

                    IDeployment deployment;
                    IDeployment physical = new TempFolderDeployment();
                    if (IntPtr.Size == 4)
                    {
                        deployment = Deployment32(physical);
                    }
                    else
                    {
                        deployment = Deployment64(physical);
                    }

                    IConverter converter =
     new ThreadSafeConverter(
         new RemotingToolset<PdfToolset>(
             deployment));

                    _instance = converter;
                }
            }
        }

        return _instance;
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static EmbeddedDeployment Deployment32(IDeployment physical)
    {
        return new Win32EmbeddedDeployment(physical);
    }
    [MethodImpl(MethodImplOptions.NoInlining)]
    private static EmbeddedDeployment Deployment64(IDeployment physical)
    {
        return new Win64EmbeddedDeployment(physical);
    }
}

repetantil avatar Jun 16 '15 16:06 repetantil

Thank you, that's exactly what is needed. The package would be for convenience, that way users could just reference the one package directly to bring in all the needed references.

  • Derek Gray

On Jun 16, 2015, at 11:25 AM, Alexei Rebrov [email protected] wrote:

Why not to just create a Factory, which will take care about the instance to create? Without AnyCPU package?

Like this:

public static class Factory { private static object _lock = new object(); private static IConverter _instance = default(IConverter);

public static IConverter Create()
{
    if (_instance == null)
    {
        lock (_lock)
        {
            if (_instance == null)
            {

                IDeployment deployment;
                IDeployment physical = new TempFolderDeployment();
                if (IntPtr.Size == 4)
                {
                    deployment = Deployment32(physical);
                }
                else
                {
                    deployment = Deployment64(physical);
                }

                IConverter converter =
 new ThreadSafeConverter(
     new RemotingToolset<PdfToolset>(
         deployment));

                _instance = converter;
            }
        }
    }

    return _instance;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static EmbeddedDeployment Deployment32(IDeployment physical)
{
    return new Win32EmbeddedDeployment(physical);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static EmbeddedDeployment Deployment64(IDeployment physical)
{
    return new Win64EmbeddedDeployment(physical);
}

} — Reply to this email directly or view it on GitHub.

tuespetre avatar Jun 16 '15 17:06 tuespetre