小编Bru*_*ton的帖子

什么是__gxx_personality_v0?

这是来自操作系统开发网站的二手问题,但它让我很好奇,因为我无法在任何地方找到合适的解释.

使用gcc编译和链接独立的C++程序时,有时会出现这样的链接器错误:

out/kernel.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
Run Code Online (Sandbox Code Playgroud)

这显然是因为这个符号是在libstdc ++中定义的,它在独立环境中是缺失的.解决问题只需要在某处定义此符号:

void *__gxx_personality_v0;
Run Code Online (Sandbox Code Playgroud)

这很好,但我不喜欢那些神奇地工作的东西......所以问题是,这个符号的目的是什么?

c++ linker gcc kernel

98
推荐指数
5
解决办法
9万
查看次数

什么使语言面向对象?

由于没有有意义的条款的辩论毫无意义,我想我会指出房间里的大象并问:究竟什么语言"面向对象"?我不是在寻找这里的教科书答案,而是根据你在你的领域中运作良好的OO语言的经验,无论它是什么.

一个可能有助于首先回答的相关问题是:面向对象语言的原型是什么?为什么?

language-agnostic oop glossary programming-languages

34
推荐指数
4
解决办法
2万
查看次数

FxCop警告CA1006有什么好的解决方法吗?

我遇到了FxCop警告CA1006,Microsoft.Design"DoNotNestGenericTypesInMemberSignatures"的问题.具体来说,我正在设计一个ReportCollection<T>继承自的类,ReadOnlyCollection<Report<T>>public构造函数将IList<Report<T>>一个参数作为参数.

修复此警告的建议不是很有用:

"要修复违反此规则的行为,请更改设计以删除嵌套类型参数." 到目前为止,我可以通过两种方式来改变设计:

  1. 制作构造函数internal.这在我的情况下不起作用.构造函数必须是public因为此集合类需要通过程序集外部的代码进行实例化.
  2. 使构造函数取代Report<T>[]而不是IList<Report<T>>.这是次优的,因为外部代码应该具有使用动态大小的数据结构的灵活性,List<T>而不是固定大小的数组.

在这一点上,我放弃并压制了这个警告.有更好的解决方案吗?

.net c# fxcop

25
推荐指数
3
解决办法
7133
查看次数

如何使用Microsoft.Azure.Search SearchContinuationToken

有人能指出我如何实现这个的正确方向?

到目前为止,我可以查询我的索引并获得响应

SearchIndexClient indexClient = service.Indexes.GetClient(indexName);
 SearchParameters sp = new SearchParameters()
        {
            Facets = new string[] { "Brand", "Price,values:10|25|100|500|1000|2500" },
            Filter = AzureUtils.BuildFilter(brand, priceFrom, priceTo),
            OrderBy = new string[] { "" },
            IncludeTotalResultCount = true,
            Top = 9,
            SearchMode = SearchMode.Any
        };
        DocumentSearchResponse<MyClass> response = response = indexClient.Documents.Search<MyClass>(searchText, sp);
Run Code Online (Sandbox Code Playgroud)

当结果返回时,response.ContinuationToken为null

如何让我的索引返回response.ContinuationToken属性的值.

另外,如何实现此功能以获取接下来的9个结果?

谢谢

.net c# azure azure-cognitive-search

8
推荐指数
2
解决办法
2279
查看次数

有没有一种简单的方法来模拟C#中的Objective-C类别?

我有一个奇怪的设计情况,我以前从未遇到过......如果我使用Objective-C,我会用类别解决它,但我必须使用C#2.0.

首先,一些背景.我在这个类库中有两个抽象层.底层为扫描内容的组件实现了插件架构(抱歉,不能比这更具体).每个插件都会以一种独特的方式进行扫描,但插件也可能因其接受的内容类型而异.由于与本讨论无关的各种原因,我不想通过插件界面公开泛型.因此,我最终为每种内容类型提供了一个IScanner接口和一个派生接口.

顶层是一个便利包装器,它接受包含各种部分的复合内容格式.不同的扫描程序将需要复合的不同部分,具体取决于它们感兴趣的内容类型.因此,我需要具有特定于每个IScanner派生接口的逻辑,该接口解析复合内容,查找所需的相关部分.

解决此问题的一种方法是简单地向IScanner添加另一种方法并在每个插件中实现它.但是,双层设计的重点在于插件本身不需要了解复合格式.解决这个问题的蛮力方法是在上层进行类型测试和向下转换,但是需要谨慎维护这些方法,因为将来会添加对新内容类型的支持.在这种情况下,访客模式也很尴尬,因为实际上只有一个访问者,但不同的可访问类型的数量只会随着时间而增加(即 - 这些是访问者适合的相反条件).而且,当我真正想要的只是劫持IScanner的单一发送时,双重发送感觉就像矫枉过正!

如果我使用的是Objective-C,我只需在每个IScanner派生的接口上定义一个类别,并在那里添加parseContent方法.该类别将在上层定义,因此插件不需要更改,同时避免了类型测试的需要.不幸的是,C#扩展方法不起作用,因为它们基本上是静态的(即 - 与调用站点使用的引用的编译时类型相关联,而不是像Obj-C类别那样挂钩到动态调度).更不用说,我必须使用C#2.0,因此我甚至无法使用扩展方法.:-P

那么在C#中是否有一种简洁的方法来解决这个问题,类似于如何用Objective-C类别解决它?


编辑:一些伪代码,以帮助使当前设计的结构清晰:

interface IScanner
{ // Nothing to see here...
}

interface IContentTypeAScanner : IScanner
{
    void ScanTypeA(TypeA content);
}

interface IContentTypeBScanner : IScanner
{
    void ScanTypeB(TypeB content);
}

class CompositeScanner
{
    private readonly IScanner realScanner;

    // C-tor omitted for brevity... It takes an IScanner that was created
    // from an assembly-qualified type name using dynamic type loading.

    // NOTE: Composite is defined outside my code and completely outside my control. …
Run Code Online (Sandbox Code Playgroud)

c# oop design-patterns objective-c visitor

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

在 Azure 搜索中,如何将日期时间字段与日期时间文字进行比较?

因此,我尝试使用 Azure 搜索对我的表存储进行查询,该表已编入索引。在此处查看表的实体

   [SerializePropertyNamesAsCamelCase]
public class Asset : TableEntity
{
    public Asset(){ }

    public Asset(string name, DateTimeOffset toBePublished)
    {
        Name = name;
        ToBePublishedDate = toBePublished.ToString();
    }

    [System.ComponentModel.DataAnnotations.Key]
    public string Id{ get; set; } = DateTimeOffset.UtcNow.ToString();

    [IsFilterable, IsSortable, IsSearchable]
    public string Name { get; set; }

    [IsFilterable, IsSortable, IsSearchable]
    public string Version { get; set; }

    [IsFilterable, IsSortable, IsSearchable]
    public string ToBePublishedDate { get; set; }

    [IsFilterable, IsSortable, IsSearchable]
    public string ToBeRetiredDate { get; set; }

    [IsFilterable, IsSortable]
    public bool IsApproved …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-cognitive-search

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

在C#中,有没有办法在实例成员中强制使用"this/base"资格?

有时,在引用同一类(或基类)的其他实例成员的实例成员中读取代码可能会令人困惑:

public void MyMethod()
{
    Where = did + AllTheseWeirdThings(GetDeclared()); // ?
}
Run Code Online (Sandbox Code Playgroud)

具有类似"使用"_"前缀所有私有/受保护成员的编码标准"没有帮助,因为实例成员仍然可以引用公共成员.

读这个会好得多:

public void MyMethod()
{
    this.Where = this.did + base.AllTheseWeirdThings(this.GetDeclared()); // ?
}
Run Code Online (Sandbox Code Playgroud)

有没有办法强制执行此操作,无论是使用编译器选项,StyleCop还是类似的东西?

c# stylecop this

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

为什么分页时可能会从 Azure 搜索中获得重复的结果?

有时,使用Azure 搜索的分页时,结果中可能会出现重复的文档。下面是一个分页请求的示例:

GET /indexes/myindex/docs?search=*$top=15&$skip=15&$orderby=rating desc
Run Code Online (Sandbox Code Playgroud)

为什么这可能?怎么会发生呢?分页时是否有一致性保证?

azure-cognitive-search

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

这个 Azure 搜索索引错误是什么意思?“'search.documentFields' 类型不存在属性 'x'...”

我得到的例外是: The property 'documentType' does not exist on type 'search.documentFields'. Make sure to only use property names that are defined by the type.

我已经用谷歌搜索了这个,但仍然无法弄清楚发生了什么。

这是我们使用的模型:

[SerializePropertyNamesAsCamelCase]
public class WebSearchDocument : SearchDocument, IEventSearchDocument, IResourceSearchDocument
{
    [IsFacetable]
    public string DocumentType { get; set; }
    [IsSearchable]
    public string Title { get; set; }
    [IsSearchable]
    public string Description { get; set; }
    [IsFilterable]
    public DateTime? PublishedDate { get; set; }
    public DateTime? LastUpdatedDate { get; set; }
    public string ImageUrl { get; set; } …
Run Code Online (Sandbox Code Playgroud)

azure azure-cognitive-search azure-search-.net-sdk

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

如何在Azure搜索中过滤数组

我在索引中有以下数据,

{
"name" : "The 100",
"lists" : [
                "2c8540ee-85df-4f1a-b35f-00124e1d3c4a;Bellamy",
                "2c8540ee-85df-4f1a-b35f-00155c40f11c;Pike",
                "2c8540ee-85df-4f1a-b35f-00155c02e581;Clark"
          ]

}
Run Code Online (Sandbox Code Playgroud)

我必须得到列表中有Pike的所有文档.

虽然完整的搜索查询适用于任何我无法得到包含工作.

$filter=lists/any(t: t eq '2c8540ee-85df-4f1a-b35f-00155c40f11c;Pike')
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何只用Pike搜索.

$filter=lists/any(t: t eq 'Pike')

我想eq寻找全文搜索,有没有任何方式使用给定的数据结构我应该使这个查询工作.

目前,字段列表没有可搜索的属性,只有可过滤的属性.

azure-cognitive-search azure-search-.net-sdk

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

如何在 Azure Search REST API 上使用“id”删除特定文档?

我想知道如何删除 Azure 搜索索引中的特定文档。

我想通过使用 REST API 使用“id”来删除文档。我已经搜索过,但找不到方法。

{
    "@odata.context": "https://xxxx/$metadata#docs(*)",
    "value": [
        {
            "@search.score": 1,
            "id": "16",
            "questions": [
                "Question"
            ],
            "answer": "Answer",
            "source": "https://azure.microsoft.com/ja-jp/support/faq/",
            "keywords": [],
            "alternateQuestions": null
 },
Run Code Online (Sandbox Code Playgroud)

例如,我只想删除id为16的文档。我不想删除整个索引,只想删除文档。

如果有人知道怎么做,请提供一个 REST API 示例。

azure azure-cognitive-search

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

Azure搜索-在“包含”一词中查找匹配项

我使用Azure搜索,而Azure搜索又使用Lucene。有什么方法可以使搜索不那么严格。我需要的是在搜索“ term ”时应将文档与包含“ term ”的术语匹配。

狐狸搜索字词应与“前缀字词 ”,“ 字词后缀”,“前缀字词后缀” 匹配

狐狸的第2 部分应该与“第1部分第2 部分 ”,“第2 部分第3部分”,“第1 部分第2部分第3部分”匹配

我需要运行具有多个术语的搜索查询,例如

"term part2"
Run Code Online (Sandbox Code Playgroud)

匹配如下文件:

{ someField:"... PrefixTermSuffix ... part1part2part3 ..." }
{ someField:"... PrefixTerm ... part2part3 ..." }
etc
Run Code Online (Sandbox Code Playgroud)

lucene search-engine azure azure-cognitive-search

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

'ConfigurationBuilder'不包含'AddJsonFile'的定义

我有以下错误:

Program.cs(15,72):错误CS1061:'ConfigurationBuilder'不包含'AddJsonFile'的定义,并且找不到可访问的扩展方法'AddJsonFile'接受类型为“ ConfigurationBuilder”的第一个参数(您是否缺少使用指令或汇编

该项目是一个使用Azure Search SDK的dotnet核心应用程序,控制台应用程序

错误行如下:

using System;
using System.Linq;
using System.Threading;
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Spatial;

namespace DemoSearchIndexer
{
    class Program
    {
        static void Main(string[] args)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
            IConfigurationRoot configuration = builder.Build();
Run Code Online (Sandbox Code Playgroud)

c# .net-core

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