小编fer*_*rgs的帖子

C#包装器和回调

我正在为Dallmeier Common API light(相机和监控系统)编写C#包装器,并且之前从未编写过包装器,但是我使用了Canon EDSDK C#包装器。因此,我使用佳能包装纸作为编写Dallmeier包装纸的指南。

我目前在包装回调时遇到问题。在API手册中,它具有以下内容:

dlm_connect

int(unsigned long uLWindowHandle,   
    const char * strIP,  
    const char* strUser1,  
    const char* strPwd1,  
    const char* strUser2,  
    const char* strPwd2,   
    void (*callback)(void *pParameters, void *pResult, void *pInput),   
    void * pInput)  
Run Code Online (Sandbox Code Playgroud)

参数
- ulWindowhandle -传递给ViewerSDK显示视频和消息有窗口的句柄
- strUser1 / 2 -用户的姓名登录如果只使用单一用户登录strUser2是。
-空
- strPwd1 / 2 -密码的两个用户。如果strUser2为NULL,则strPwd2将被忽略。

返回
值此函数创建必须传递的SessionHandle

回调
pParameter的结构如下:
-无符号长ulFunctionID-
无符号长ulSocketHandle,//已建立连接的套接字的句柄
-无符号长ulWindowHandle,-int
SessionHandle,//创建的会话的会话句柄
-const char * strIP,-const
char * strUser1,-const
char * strPwd1,-const char * strUser2,
-const
char * strPWD2
pResult是一个指向整数的指针,表示操作的结果。零成功。负值是错误代码。

因此,从网上和堆栈溢出的内容中我可以读到-C#使用委托进行回调。所以我创建了我的回调函数:

public …
Run Code Online (Sandbox Code Playgroud)

c# callback wrapper

5
推荐指数
1
解决办法
1851
查看次数

使用数据库中的数据填充IAuthSession

所以我根据以下示例使用ServiceStack创建了一个自定义CredentialsAuthProvider:https: //github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization

我有认证方面的工作,但我不知道如何在OnAuthenticated方法中使用数据库中的数据填充会话.在示例中,它们显示以下内容:

     //Fill the IAuthSession with data which you want to retrieve in the app eg:
    session.FirstName = "some_firstname_from_db"; 
Run Code Online (Sandbox Code Playgroud)

在TryAuthenticate方法中,我有用户名/密码,我可以用来根据数据库对用户进行身份验证,但是一旦进入OnAuthenticated方法,我如何/如何使用来从数据库访问/检索用户信息?

servicestack

3
推荐指数
2
解决办法
1442
查看次数

MVVM Light工具包Interaction.Triggers不会在datatemplate中触发

我可以使用Interaction.Triggers来捕获文本框上的textchanged事件,如下所示:

<TextBox  Text="{Binding Title}" Style="{StaticResource GridEditStyle}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="TextChanged">
                            <cmd:EventToCommand Command="{Binding TextChanged}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
Run Code Online (Sandbox Code Playgroud)

但是,当我在listate celltemplate的datatemplate中使用它时,如下所示:

 <ListView  ItemsSource="{Binding LangaugeCollection}" SelectedItem="{Binding SelectedLangauge}" BorderThickness="0" FontFamily="Calibri" FontSize="11">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Width="200">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate >
                                    <Grid>
                                        <TextBlock Text="{Binding Title}" Style="{StaticResource GridBlockStyle}">
                                        </TextBlock>
                                        <TextBox  Text="{Binding Title}" Style="{StaticResource GridEditStyle}">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="TextChanged">
                                                    <cmd:EventToCommand Command="{Binding TextChanged}" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </TextBox>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView> 
                </ListView.View>
            </ListView>
Run Code Online (Sandbox Code Playgroud)

该事件不会触发.

有谁知道为什么这不会触发以及如何解决它?

mvvm-light

2
推荐指数
1
解决办法
2901
查看次数

标签 统计

c# ×1

callback ×1

mvvm-light ×1

servicestack ×1

wrapper ×1