小编yey*_*man的帖子

将Haskell集成到非功能项目中

我在SO中寻找Haskell的问题,并且将我关于函数式编程的大学笔记恢复为业余爱好.但我一直想知道Haskell中的某些事情是如何在Hugs解释器之外进行的,并与C#,C++或Java项目集成.有人这样做过吗?怎么样?

haskell functional-programming

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

由于超时而取消async_read

我正在尝试编写一个包装器同步方法,async_read以允许在套接字上进行非阻塞读取.以下几个关于互联网的例子我已经开发了一个似乎几乎正确的解决方案但是没有用.

该类声明了这些相关的属性和方法:

class communications_client
{
    protected:
        boost::shared_ptr<boost::asio::io_service> _io_service;
        boost::shared_ptr<boost::asio::ip::tcp::socket> _socket;
        boost::array<boost::uint8_t, 128> _data;

        boost::mutex _mutex;
        bool _timeout_triggered;
        bool _message_received;
        boost::system::error_code _error;
        size_t _bytes_transferred;

        void handle_read(const boost::system::error_code & error, size_t bytes_transferred);
        void handle_timeout(const boost::system::error_code & error);
        size_t async_read_helper(unsigned short bytes_to_transfer, const boost::posix_time::time_duration & timeout, boost::system::error_code & error);

        ...
}
Run Code Online (Sandbox Code Playgroud)

该方法async_read_helper是封装了所有复杂的一个,而其他两个handle_readhandle_timeout仅仅是事件处理程序.以下是三种方法的实现:

void communications_client::handle_timeout(const boost::system::error_code & error)
{
    if (!error)
    {
        _mutex.lock();
        _timeout_triggered = true;
        _error.assign(boost::system::errc::timed_out, boost::system::system_category());
        _mutex.unlock();
    }
}

void communications_client::handle_read(const boost::system::error_code & error, …
Run Code Online (Sandbox Code Playgroud)

c++ boost-asio

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

温莎城堡的条件解决

我正在开发 ASP.NET MVC 4 Web 应用程序。默认控制器工厂已替换为 WindsorControllerFactory,如此处建议的那样。这很有用,因为此应用程序中的控制器包含对几个服务的引用,这些服务是使用 Windsor 注入来实例化的。每个服务都有一个代理来包装它。

因此,我们有以下情况:

  • 注册到 Castle 的两个组件(一项服务和一项代理)
  • 其中一个被构建为另一个的依赖项

它看起来像:

// This URL can be resolved at application startup
container.Register(Component.For<ITestService>()
    .UsingFactoryMethod(() => ServiceFactory.CreateService<ITestService>(Settings.Default.ConfigurationProviderUrl))
    .Named(MainServiceComponent)
    .LifeStyle.Transient);

// The URL for this service can be configured during runtime. If it is null or empty it should not be resolved
container.Register(Component.For<ITestService>()
    .UsingFactoryMethod(() => ServiceFactory.CreateService<ITestService>(SiteInformation.PublishUrl))
    .Named(PublicationServiceComponent)
    .LifeStyle.Transient);

// This proxy is necessary
container.Register(Component.For<IConfigurationProxy>()
    .ImplementedBy<ConfigurationProxyWebService>()
    .ServiceOverrides(ServiceOverride.ForKey(typeof(ITestService)).Eq(MainServiceComponent))
    .LifeStyle.Transient);

// This proxy should be created only if SiteInformation.PublishUrl is different …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc castle-windsor asp.net-mvc-4

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

C#中桌面应用程序的数据库引擎

我需要一个桌面应用程序的轻量级数据库引擎.该应用程序不是以数据为中心的,尽管它需要一些持久性数据.您将使用哪个MS SQL Server Express版或SQLite?

编辑

SQL Server Compact版是免费的吗?如果是这样的话,那么SQLite vs SQL Server Compact版开发这种应用程序呢?

c# database desktop-application

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

有没有办法在C#中实现平面TextBox?

我有一个带按钮的平面样式的GUI.我想使用具有相同外观的TextBox控件,但我找不到在哪里可以配置外线.WinForms中是否有任何控件可以给FlatStyle?谢谢!


编辑1

感谢有关FixedSingle边框样式的信息,但是,如何更改行属性?


编辑2

我已经实现了两者兼而有之的解决方案.我想如果你能帮助改进这门课程,因为我不是C#的专家,我发现这段代码有些混乱.这是代码:

class BorderTextBox : UserControl
{
    private TextBox m_textBox;
    private int m_borderSize;

    private void ResizeComponent()
    {
        m_textBox.Size = new Size(Size.Width - 2 * m_borderSize, m_textBox.Size.Height);
        Size = new Size(Size.Width, m_textBox.Size.Height + 2 * m_borderSize);
    }

    protected override void OnResize(EventArgs z_event)
    {
        base.OnResize(z_event);
        ResizeComponent();
    }

    public BorderTextBox()
    {
        SuspendLayout();

        // TextBox
        m_textBox = new TextBox();
        m_textBox.BorderStyle = BorderStyle.None;
        m_textBox.Name = "textBox";
        m_textBox.TabIndex = 0;

        // Body
        BackColor = Color.Black;
        Name = "Body";
        Controls.Add(m_textBox);

        ResumeLayout(false);
        PerformLayout();
    }

    public …
Run Code Online (Sandbox Code Playgroud)

c# winforms

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

在C#中使用using关键字

在我的C++背景中,我是使用范围解析运算符的支持者

class Foo
{
    std::list<int>  m_list;
    ...
}
Run Code Online (Sandbox Code Playgroud)

对于外部库,要清楚说明您正在使用哪个库.

现在在C#中我不知道是否有经验法则或最佳实践知道应该通过using关键字包含哪些包以及哪些类应该是完全限定的.我想这可能是一个主观问题,但想知道最广泛的做法.

c#

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

持续集成始终与测试驱动开发相结合?

我参与了一个项目,我们使用Continuous Integration服务器和NUnit进行单元测试和集成测试.

前几天客户问我们是否在代码之前写了测试......好吧,他们总是不这样做.特别是当我们想要测试复杂的技术问题时,首先要了解问题和可能的解决方案.

我想知道我们是否仍然可以将我们的开发过程视为遵循敏捷开发,对客户说并且不要撒谎.

c# agile continuous-integration

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

是否也可以调试.NET类库方法?

使用.NET Reflector,我们可以看到许多.NET类库方法的实现.

但它也可以调试它们吗?或者,如果我可以在其中设置一个断点?

.net debugging class

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