小编dic*_*ice的帖子

SOLR df和qf解释

我无法找到这些查询参数如何相互作用的详尽解释

如果我指定的话,我会感到惊讶(对我而言)

qf=title^20 description^10
Run Code Online (Sandbox Code Playgroud)

然后我没有得到任何结果,如果我然后添加

df=description
Run Code Online (Sandbox Code Playgroud)

我确实得到了结果

df在solrconfig.xml中设置为文本 - 这将改变 - 但我的问题是这个 - df设置是否会覆盖qf设置?这看起来很奇怪

search solr

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

什么是在.net 2中生成唯一集的最快方法

我有一个基本上是锯齿状的名称值对数组 - 我需要从中生成一组唯一的名称值.锯齿状阵列约为86,000 x 11值.对我来说,以何种方式存储名称值对(单个字符串"name = value"或专门的类,例如KeyValuePair)并不重要.
附加信息:有40个不同的名称和更多的不同值 - 可能在10,000个值的区域内.

我正在使用C#和.NET 2.0(并且性能非常差)我认为将整个锯齿状数组推送到sql数据库并从那里做一个不同的选择可能会更好.

以下是当前使用的代码:

List<List<KeyValuePair<string,string>>> vehicleList = retriever.GetVehicles();
this.statsLabel.Text = "Unique Vehicles: " + vehicleList.Count;

Dictionary<KeyValuePair<string, string>, int> uniqueProperties = new Dictionary<KeyValuePair<string, string>, int>();
foreach (List<KeyValuePair<string, string>> vehicle in vehicleList)
{
    foreach (KeyValuePair<string, string> property in vehicle)
    {
        if (!uniqueProperties.ContainsKey(property))
        {
            uniqueProperties.Add(property, 0);
        }
    }
}
this.statsLabel.Text += "\rUnique Properties: " + uniqueProperties.Count;
Run Code Online (Sandbox Code Playgroud)

.net c# collections performance

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

如何创建按钮并从回发中连接事件

我需要最初基于相当多的处理器和磁盘密集型搜索来生成按钮.每个按钮代表一个选择并触发回发.我的问题是回发不会触发命令b_Command.我猜是因为没有重新创建原始按钮.我无法在回发中执行原始搜索以重新创建按钮,因此我想从回发信息生成所需的按钮.

我该怎么做以及在哪里做这个?我应该在Page_Load之前做这件事吗?如何从回发中重新构造CommandEventHandler - 如果有的话?

   namespace CloudNavigation
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                // how can I re-generate the button and hook up the event here
                // without executing heavy search 1
            }
            else
            {
                // Execute heavy search 1 to generate buttons
                Button b = new Button();
                b.Text = "Selection 1";
                b.Command += new CommandEventHandler(b_Command);
                Panel1.Controls.Add(b);
            }
        }

        void b_Command(object sender, CommandEventArgs e)
        {
            // Execute heavy search …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net events postback

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

以编程方式设置绑定以要求在iis中进行客户端证书协商

如何实现与使用C#的应用程序中的netsh设置clientcertnegotiation = enable相同(不执行命令行).

netsh http add sslcert ipport=0.0.0.0:8000 certhash=2064a43f429fe97746ce0c1c9adcd4ea93415f6d appid={4dc3e181-e14b-4a21-b022-59fc669b0914} clientcertnegotiation=enable
Run Code Online (Sandbox Code Playgroud)

以下代码成功添加了证书

using (var manager = new ServerManager())
        {
            var siteBindings = from s1 in manager.Sites
                               from b1 in s1.Bindings
                               where b1.Protocol.Equals("https")
                               select new {SiteName = s1.Name, Binding = b1};

            foreach (var siteBinding in siteBindings)
            {
                siteBinding.Binding.CertificateHash = cert.GetCertHash();
            }

            // This is correctly setting the values on the Ssl Cert configuration section in IIS
            var config = manager.GetApplicationHostConfiguration();
            var accessSection = config.GetSection("system.webServer/security/access", "WebActivationService");
            accessSection["sslFlags"] = @"Ssl, SslRequireCert";

            manager.CommitChanges();
        } …
Run Code Online (Sandbox Code Playgroud)

c# iis ssl certificate netsh

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

在回发中重新创建控件后,在命令事件中获取commandeventargs时出现问题

我在使用下面的代码在第二次单击后获取命令事件args时遇到问题.

所以 - 当我处理一个按钮点击,并生成一个新按钮来替换那里的那个按钮时,我会在下一个按钮点击时丢失视图状态.

关于我需要做些什么才能让它发挥作用的任何建议?我无法显着改变结构,因为我必须在命令处理程序中生成可变数量的完全不相关的按钮.

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            LinkButton btn = new LinkButton();
            btn.ID = "btn1";
            this.Panel1.Controls.Add(btn);
            btn.Command += new CommandEventHandler(myLinkButton_Command);          
        }
        else
        {
            LinkButton btn = new LinkButton();
            btn.ID = "btn1";
            this.Panel1.Controls.Add(btn);
            btn.Text = "My Button 1";
            btn.CommandArgument = "1";
            btn.Command += new CommandEventHandler(myLinkButton_Command);
        }
    }

    void myLinkButton_Command(object sender, CommandEventArgs e)
    {
        int newArg = Convert.ToInt32(e.CommandArgument) + 1;// empty string on second mouse click
        this.Panel1.Controls.Clear(); …
Run Code Online (Sandbox Code Playgroud)

asp.net viewstate

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

如何从PInvoke本机回调中返回StringBuilder或其他字符串缓冲区

我想要一个干净的方法来增加StringBuilder()的大小,因为本地代码需要填充,下面的回调方法看起来很干净,但不知怎的,我们得到缓冲区的副本而不是实际的缓冲区 - 我感兴趣的是解释和解决方案(最好坚持回调类型分配,因为只要它可以工作就会很好和干净).

using System;
using System.Runtime.InteropServices;
using System.Text;

namespace csharpapp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var buffer = new StringBuilder(12);
            // straightforward, we can write to the buffer but unfortunately
            // cannot adjust its size to whatever is required
            Native.works(buffer, buffer.Capacity); 
            Console.WriteLine(buffer);

            // try to allocate the size of the buffer in a callback - but now
            // it seems only a copy of the buffer is passed to native code
            Native.foo(size => …
Run Code Online (Sandbox Code Playgroud)

c# pinvoke stringbuilder

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

是否可以注入asp.net web api模型类

我在asp.net web api中的模型类上实现了IValidatableObject.某些对象需要访问数据存储库才能执行完整验证.

如何在调用IValidatableObject.Validate之前解决DAL依赖关系 - 还是有其他方法来解决Validate调用中的依赖关系?

请注意,我正在尝试使用autofac,根据使用autofac 注入到asp.net web api模型中,但它看起来像我没有使用依赖项解析器调用模型.

c# dependencies dependency-injection asp.net-web-api

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

在C++ 11中使用简单范围管理数组的最简洁方法是什么

我正在寻找一种使用C++ 11中引入的新指针模板来管理数组范围的简洁方法,这里的典型场景是调用win32 api函数时.

我在这里发帖是因为虽然对更复杂的事情有很多讨论,但这个相对简单的场景似乎没有被讨论过,我想知道是否有比我现在开始做的更好的选择.

#include <memory>

void Win32ApiFunction(void* arr, int*size)
{
    if(arr==NULL)
        *size = 10;
    else
    {
        memset(arr,'x',10);
        ((char*)arr)[9]='\0';
    }
}

void main(void)
{
    // common to old and new
    int size;
    Win32ApiFunction(NULL,&size);

    // old style - till now I have done this for scope reasons
    if(char* data = new char[size])
    {
        Win32ApiFunction(data,&size);
        // other processing
        delete [] data;
    }

    // new style - note additional braces to approximate
    // the previous scope - is there a better equivalent to …
Run Code Online (Sandbox Code Playgroud)

c++ arrays memory-management unique-ptr c++11

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