小编piu*_*ius的帖子

方法C旁边的加号和减号是什么意思?

我在目标c和xcode中都很新.我想知道方法定义旁边的符号+-符号是什么意思.

- (void)loadPluginsAtPath:(NSString*)pluginPath errors:(NSArray **)errors;
Run Code Online (Sandbox Code Playgroud)

syntax objective-c method-declaration

176
推荐指数
4
解决办法
6万
查看次数

Sublime Text转到字符编号

如何转到文件中的第N个字符.忽略所有换行符,整个文件中的第N个字符.

此vim命令类似,但在崇高文本中

sublimetext sublimetext3

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

通过cython从c调用python代码

所以我想通过cython从c调用一些python代码.我设法从c调用cython代码.我也可以从cython中调用python代码.但是当我把它们全部加在一起时,有些东西会丢失.

这是我的python代码(quacker.pyx):

def quack():
    print "Quack!"
Run Code Online (Sandbox Code Playgroud)

这是我的cython"bridge"(caller.pyx):

from quacker import quack

cdef public void call_quack():
    quack()
Run Code Online (Sandbox Code Playgroud)

这是c代码(main.c):

#include <Python.h>
#include "caller.h"

int main() {
  Py_Initialize();
  initcaller();
  call_quack();
  Py_Finalize();
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我运行这个时,我得到了这个例外:

Exception NameError: "name 'quack' is not defined" in 'caller.call_quack' ignored

我怀疑的遗失的部分:

  • 我没有打过电话 initquacker()
  • 我没有包括在内 quacker.h
  • Cython没有产生任何quacker.h-only quacker.c
  • caller.c不导入quacker.h或调用initquacker()

我不太确定它甚至可以做我想做的事情,但在我看来它应该是.我很想听听你的任何意见.

编辑:

这是我cythonize/compile/link/run的方式:

$ cython *.pyx
$ cc -c *.c -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
$ cc -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -ldl …
Run Code Online (Sandbox Code Playgroud)

c python cython

19
推荐指数
2
解决办法
6548
查看次数

如何配置omnisharp syntastic语法检查器更宽松?

我已按照本指南设置我的v#c#.我工作得很漂亮,但我有一个烦恼:合成检查对我来说有点过于苛刻.具体来说,它建议我改变这一行:

var parser = new Parser(configuration, findReservations: true);
Run Code Online (Sandbox Code Playgroud)

消息"冗余参数名称规范".当然我可以像它说的那样做,但我碰巧喜欢我的冗余参数规范.我的代码的读者可能不记得该布尔值是什么.所以...我怎么能告诉syntastic(或omnisharp)放松这种警告?

c# vim syntastic omnisharp

6
推荐指数
1
解决办法
2505
查看次数

尝试将ef核心迁移用于迁移到.net核心2的项目

我正在尝试添加我的第一个EF Core 2迁移.我为解决方案运行了EF6迁移,但现在我已迁移到EF Core 2和.Net Core 2.0.当我运行此命令时:

dotnet ef migrations add InitialMigration
Run Code Online (Sandbox Code Playgroud)

我得到这个例外:

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
    at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
    at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
    at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String contentRootPath, String dataDirectory, String rootNamespace, String environment)
    at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()
    at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsListCommand.Execute()
    at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
    at …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core .net-core

6
推荐指数
1
解决办法
742
查看次数

如何让NHibernate在数据库停机时幸存?

我有一个C#控制台应用程序,我想继续运行,即使它的数据库崩溃.在这种情况下,它应该轮询数据库以查看它何时重新联机,然后恢复操作.我有这个代码,我不喜欢:

    public static T Robust<T>(Func<T> function)
    {
        while (true)
        {
            try
            {
                return function();
            }
            catch (GenericADOException e)
            {
                Console.WriteLine("SQL Exception. Retrying in 10 seconds");
                Thread.Sleep(10000);
            }
        }
    }
    [...]
    N.Robust(() => Session.CreateCriteria(typeof(MyEntity)).List());
Run Code Online (Sandbox Code Playgroud)

问题是我必须在N.Robust任何地方插入那个令人讨厌的构造混乱的代码.此外,我冒着忘记它的风险.我一直在研究使用NHibernate的EventListeners或Inceptors,但还是无法使它工作.我是否真的需要使用NHibernate来实现这项功能?

更新 好了,所以我已经克服了我的两个问题之一.通过注入我自己的事件监听器,我至少可以确保对数据库的所有调用都通过上述方法.

        _configuration.EventListeners.LoadEventListeners
         = new ILoadEventListener[] { new RobustEventListener() };
        [...]
        public class RobustEventListener : ILoadEventListener
        {
            public void OnLoad(LoadEvent e, LoadType type)
            {
                if (!RobustMode)
                    throw new ApplicationException("Not allowed");
            }
        }
Run Code Online (Sandbox Code Playgroud)

我仍然有一个杂乱的代码库,但我认为这是一个合理的价格,以支付增加服务正常运行时间.

c# nhibernate

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