小编Muh*_*adY的帖子

c#generic Delegate Error无法绑定到目标方法,因为它的签名

我有一个泛型委托,它在像这样的单例类中实现;

public class BBCacheMethods
{
    private static BBCacheMethods instance;

    private BBCacheMethods() { }

    public static BBCacheMethods Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new BBCacheMethods();
            }

            return instance;
        }
    }

    public T GetResUstPolitikaBelgeTurlerisForCache<T>() where T:class
    {
        return null;
    }

    public delegate T MethodToInvokeDelegate<T>();
    public static MethodToInvokeDelegate<T> MethodToInvoke<T>() where T : class
    {  
        MethodInfo method = Instance
            .GetType()
            .GetMethod("GetResUstPolitikaBelgeTurlerisForCache");

        if (null != method)
        {
            return (MethodToInvokeDelegate<T>)Delegate.CreateDelegate(
                typeof(MethodToInvokeDelegate<T>),
                Instance,
                method);
        }
        else
            throw new FaultException("");
    }
Run Code Online (Sandbox Code Playgroud)

我调用委托时收到此错误的一点:

无法绑定到目标方法,因为其签名或安全透明性与委托类型的签名或安全透明性不兼容. …

c# generics delegates

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

Dapper Reader处理异常

我确实用下面的代码扩展了GridReader;

 /// <summary>
/// 
/// </summary>
public static class Extentions
{
    /// <summary>
    /// Maps the specified reader.
    /// </summary>
    /// <typeparam name="TFirst">The type of the first.</typeparam>
    /// <typeparam name="TSecond">The type of the second.</typeparam>
    /// <typeparam name="TKey">The type of the key.</typeparam>
    /// <param name="reader">The reader.</param>
    /// <param name="firstKey">The first key.</param>
    /// <param name="secondKey">The second key.</param>
    /// <param name="addChildren">The add children.</param>
    /// <returns></returns>
    public static IEnumerable<TFirst> Map<TFirst, TSecond, TKey>
 (
 this Dapper.SqlMapper.GridReader reader,
 Func<TFirst, TKey> firstKey,
 Func<TSecond, TKey> secondKey,
 Action<TFirst, IEnumerable<TSecond>> …
Run Code Online (Sandbox Code Playgroud)

c# dapper

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

Angular 6"工作区需要在使用前加载." 在尝试生成新组件时

当我使用angular dotnet创建asp.net核心项目时,new命令不会将angular.json文件(角度6)添加到项目中,因此我们无法使用angular cli.如果我手动添加angular.json文件,项目将在下面给出例外!?

Workspace needs to be loaded before it is used. Error: Workspace needs to be loaded before it is used. at Workspace._assertLoaded (D:\NetAngular\node_modules\@angular-devkit\core\src\workspace\workspace.js:59:19) at Workspace.getProjectByPath (D:\NetAngular\node_modules\@angular-devkit\core\src\workspace\workspace.js:103:14) at Object.getPackageManager (D:\NetAngular\node_modules\@angular\cli\utilities\config.js:97:35) at UpdateCommand.runSchematic (D:\NetAngular\node_modules\@angular\cli\models\schematic-command.js:74:38) at UpdateCommand.<anonymous> (D:\NetAngular\node_modules\@angular\cli\commands\update.js:70:25) at Generator.next (<anonymous>) at D:\NetAngular\node_modules\@angular\cli\commands\update.js:7:71 at new Promise (<anonymous>) at __awaiter (D:\NetAngular\node_modules\@angular\cli\commands\update.js:3:12) at UpdateCommand.run (D:\NetAngular\node_modules\@angular\cli\commands\update.js:69:16)
Run Code Online (Sandbox Code Playgroud)

asp.net-core angular angular6

5
推荐指数
3
解决办法
5834
查看次数

T4嵌套模板,具有多个文件输出

我有一个模板,从数据库中读取需要生成的表和对象.没有问题,模板确实在cs文件中单独生成相关文件(很棒)我使用TemplateFileManager2.1来实现它.在这个表循环中,我想调用另一个模板,使用循环中的tablename创建该表所需的接口,并将该接口放在另一个文件中.

foreach (var table in tables)
    {  
        if(table.name !="sysdiagrams")
        {
        var manager2 = TemplateFileManager.Create(this);
            manager2.StartNewFile(table.name+"mm.cs","Generator","Deneme"); 
            InterfaceGeneratora(table.name);
            manager2.Process();
            manager2=null;


        manager.StartNewFile(table.name+".cs","Generator","GeneratedTables"); 
Run Code Online (Sandbox Code Playgroud)

这里manager对象用于输出表类,manager2用于接口.这里的poit是在调用manager2和InterfaceGeneratora(table.name)时; 运行manager2开始用新表intefarce替换创建的表接口,最后我创建了所有表类,但我手头上只有最后一个表接口.任何帮助表示赞赏.

c# t4

3
推荐指数
1
解决办法
3433
查看次数

标签 统计

c# ×3

angular ×1

angular6 ×1

asp.net-core ×1

dapper ×1

delegates ×1

generics ×1

t4 ×1