如何创建包装CloudTable的自定义绑定?

时间:2020-04-23 07:34:37

标签: c# azure azure-functions azure-durable-functions

问题:如何创建包装云表的蔚蓝自定义绑定?

我的希望是创建一种用于包装云表的存储库,以便可以从业务逻辑中消除对CloudTable的关注。

到目前为止,我已经尝试使用转换器将其嵌入,但是我不确定在那儿是否走错了路。

[Extension( "TheThingProvider" )]
public class TheThingProvider : IExtensionConfigProvider
{
    public void Initialize( ExtensionConfigContext context )
    {
        context.AddConverter<CloudTable, TheThingThatDoesThings>( ConvertToItem);

        var rule = context.AddBindingRule<TheThingAttribute>( );

        rule.BindToInput<TheThingThatDoesThings>( BuildItemFromAttr );
    }

    private TheThingThatDoesThings ConvertToItem(CloudTable arg)
    {
        return new TheThingThatDoesThings(arg);
    }

    private TheThingThatDoesThings BuildItemFromAttr( TheThingAttribute attribute )
    {
        return new TheThingThatDoesThings( null );
    }
}
public class TheThingThatDoesThings
{
    private readonly CloudTable _table;

    public TheThingThatDoesThings(CloudTable table)
    {
        _table = table;
    }
    public void DoSomething( )
    {
        // _table.DoSomething();
    }
}

0 个答案:

没有答案
相关问题