小编gal*_*nus的帖子

在自定义Visual Studio编辑器中覆盖字体

问题是在VS扩展中使自定义编辑器看起来与当前主题指示不同.编辑器托管在一个对话框中,并且应该具有托管对话框定义的相同字体.

编辑器的内容类型定义如下:

[Export]
[Name("MyContent")]
[BaseDefinition("code")]
public static readonly ContentTypeDefinition ExportContentTypeDefinition = null;
Run Code Online (Sandbox Code Playgroud)

并且有一个分类类型定义:

[Export]
[Name("MyContentText")]
[BaseDefinition("text")]
public static readonly ClassificationTypeDefinition MyTextDefinition = null;
Run Code Online (Sandbox Code Playgroud)

分类器提供程序定义如下:

[Export(typeof(IClassifierProvider))]
[ContentType("MyContent")]
public class ClassifierProvider : IClassifierProvider
{
    [Import]
    public IClassificationTypeRegistryService ClassificationTypesRegistry { get; set; }

    public IClassifier GetClassifier(ITextBuffer textBuffer)
    {
        return new Classifier(
            ClassificationTypesRegistry.GetClassificationType("MyContentText"));
    }
}
Run Code Online (Sandbox Code Playgroud)

虽然分类器只为任何快照提供相同的格式:

public class Classifier : IClassifier
{
    private readonly IClassificationType _classificationType;

    public Classifier(IClassificationType classificationType)
    {
        _classificationType = classificationType;
    }

    public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
    {
        return new [] { new …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio visual-studio-2012

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

Rx for .Net:如何将 Scan 与 Throttle 结合使用

我的问题是:对于给定的事件序列,我想缓存它们的值,直到流中出现暂停。然后,我将批量处理所有缓存数据并清除缓存状态。

一种天真的方法是(不是工作代码,可能存在一些错误):

struct FlaggedData
{
    public EventData Data { get; set; }
    public bool Reset { get; set; }
}

...

IObservable<EventData> eventsStream = GetStream();
var resetSignal = new Subject<FlaggedData>();

var flaggedDataStream = eventsStream
    .Select(data => new FlaggedData { Data = data })
    .Merge(resetSignal)
    .Scan(
        new List<EventData>(),
        (cache, flaggedData) =>
        {
            if (!flaggedData.Reset())
            {
                cache.Add(flaggedData.Data);
                return cache;
            }

            return new List<EventData>();
        })
    .Throttle(SomePeriodOfTime)
    .Subscribe(batch => 
        {
            resetSignal.OnNext(new FlaggedData { Reset = true});
            ProcessBatch(batch);
        });
Run Code Online (Sandbox Code Playgroud)

所以在这里,在收到任何要处理的批处理后,我请求重置缓存。问题是因为Throttle缓存中可能有一些数据(或者我相信),在这种情况下会丢失。

我想要的是一些操作,如:

ScanWithThrottling<TAccumulate, TSource>( …
Run Code Online (Sandbox Code Playgroud)

.net c# events reactive-programming system.reactive

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