小编bit*_*onk的帖子

是否有一个秘密技巧在Windows XP中强制使用Viewport3D内的抗锯齿功能?

在Windows XP WPF下,真正的3D内容(通常使用Viewport3D控件显示)看起来非常难看,因为默认情况下它不像其他WPF图形那样被抗锯齿.特别是在较低分辨率下,体验非常糟糕,因此无法在生产代码中使用.

我已经设法使用驱动程序的设置强制对一些Nvidia显卡进行抗锯齿处理.不幸的是,这有时会产生丑陋的文物,只适用于特定的卡和驱动程序版本.微软在这方面的官方消息是,在Windows XP下通常不支持抗锯齿3D,我看到的工件是由于WPF已经自己进行了抗锯齿(在XP上仅用于2D).

所以我想知道是否有其他一些秘密技巧可以让我在Windows XP下强制对WPF 3D内容进行抗锯齿处理.

3d wpf windows-xp viewport3d antialiasing

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

没有php或asp.net等的blogengine

有没有办法将博客直接集成到我的HTML/javascript网站,而不必像SQL数据库和PHP或MySQL这样的动态引擎?

也许在网络上有一些服务提供这个(希望没有广告:)).或者也许我可以使用完全用javasript编写的博客引擎?

html javascript blogs

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

WPF绘图,伸展而不拉伸笔

我需要在Border控件(或类似)中绘制一些简单的线条,这些线条始终延伸到Border的边界.有没有办法只拉伸线而不是它的笔?没有涉及大量的C#?

在这个版本中,线条伸展:

<Border>
   <Border.Background>
      <DrawingBrush>
         <DrawingBrush.Drawing>
            <DrawingGroup>
               <GeometryDrawing Brush="Red">
                  <GeometryDrawing.Geometry>
                     <GeometryGroup>
                        <RectangleGeometry Rect="0,0 100,1000" />
                        <LineGeometry  StartPoint="0,0" EndPoint="100,1000"/>
                        <LineGeometry  StartPoint="100,0" EndPoint="0,1000"/>
                     </GeometryGroup>
                  </GeometryDrawing.Geometry>
                  <GeometryDrawing.Pen>
                     <Pen Thickness="20" Brush="Black"/>
                  </GeometryDrawing.Pen>
               </GeometryDrawing>
            </DrawingGroup>
         </DrawingBrush.Drawing>
      </DrawingBrush>
   </Border.Background>
</Border>
Run Code Online (Sandbox Code Playgroud)

我提出的最佳解决方案是:

<Border>
   <Grid>
      <Path Stretch="Fill" Fill="Red" Stroke="Black" StrokeThickness="4"  Data="M0,0 L100,0 100,1000 0,1000 z" />
      <Path Stretch="Fill" Stroke="Black" StrokeThickness="4"  Data="M 0,0 L0,0 100,1000" />
      <Path Stretch="Fill" Stroke="Black" StrokeThickness="4"  Data="M 100,0 L100,0 0,1000" />
   </Grid>
</Border>
Run Code Online (Sandbox Code Playgroud)

但是没有更好的解决方案吗?这不涉及额外的网格?

wpf geometry stretch

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

在.NET中序列化数据传输对象

我有一组数据传输对象(例如很多请求,响应消息类,如MainRequest,MainResponse,ShutDownRequest,ShutDownResponse)随着项目的发展,新类不断涌现.这些类必须(使用不同的公共XSD各种XML格式序列化).随着项目的发展,新的XML格式也随之而来.

我的问题是如何围绕这两个要求设计我的类和接口,特别是在我应该放置实际(de)serration逻辑的地方.我应该编写一个可以接受各种DTO实例的静态服务,知道如何序列化它们吗?当新课程出现时,我必须触摸每个FormatXSeriaizer并添加新的覆盖.随着新格式的出现,我只需要编写新的FormatXSerializer类.

FormatASerializer.Serialize(XmlWriter writer, MainResponse r);
FormatASerializer.Serialize(XmlWriter writer, ShutDownResponse r);
FormatBSerializer.Serialize(XmlWriter writer, MainResponse r);
FormatBSerializer.Serialize(XmlWriter writer, ShutDownResponse r);
Run Code Online (Sandbox Code Playgroud)

或者DTO自己应该知道如何去做.所以我把它放在一个地方 - 每个DTO课程.随着新的DTO课程的出现,他们只需要实现各种格式的序列化.随着新格式的出现,我必须触及每个DTO课程.

myMainRequestInstace.Serialize(FormatTypeEnum type, XmlWriter writer);
Run Code Online (Sandbox Code Playgroud)

还是有完全不同的方法?我是否应该为序列化引入一个通用的接口并且有一些控制反转,所以我可以在运行时加载新格式的序列化器?

什么设计模式可以指导我在这里?

我可以研究.NET世界中的哪些开源代码来查看有关此主题的不同方法?

编辑:我知道框架中存在的一般序列化技术.我的问题更侧重于尊重这两个要求的类设计:多个xml格式和多个DTO(消息类型)随着项目的发展而不断涌现.

.net serialization class-design

6
推荐指数
2
解决办法
6708
查看次数

MEF中缺少哪些与IoC容器相同的东西?

MEF 不是 IoC 容器.但它似乎几乎是一个IoC容器.似乎我可以很容易地使MEF表现得像IoC容器(见下面的例子),并且没有太多的缺失使MEF成为一个完整的IoC容器.

MEF中缺少哪些实际功能,StrucureMap,Unity等必须达到标准?

你认为,这个特殊的要求有意义吗?

using System;  
using System.Collections.Generic;  
using System.ComponentModel.Composition;  
using System.ComponentModel.Composition.Hosting;  
using System.ComponentModel.Composition.Primitives;  
using System.Linq;  
...
private CompositionContainer container;
public void Configure()  
{  
    container = CompositionHost.Initialize(  
        new AggregateCatalog(
            AssemblySource.Instance.Select(
              x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()));       
        var batch = new CompositionBatch();        
        batch.AddExportedValue<IWindowManager>(new WindowManager());  
        batch.AddExportedValue<IEventAggregator>(new EventAggregator());  
        batch.AddExportedValue(container);        
        container.Compose(batch);  
 }  
Run Code Online (Sandbox Code Playgroud)

mef ioc-container

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

WPF中的确定性和异步字段验证

在我的基于MVVM的应用程序中,我需要验证数据条目中的字段.如果可能,我想使用与ErrorTemplates的标准WPF验证绑定.

但是我希望验证逻辑的执行完全由ViewModel驱动/触发(推送到View,而不是由View拉动),原因如下:

  1. 它必须异步工作,因为验证逻辑可能需要一段时间才能执行.
  2. 在执行验证逻辑时,我需要更具确定性和细粒度(例如,仅在用户单击"应用"之后或当内部状态以条目突然变为无效的方式更改时)

我知道Silverlight INotifyDataErrorInfo是为了这个目的而引入的,但是WPF没有.我怎样才能确定性和异步地验证我的验证逻辑?

validation wpf binding mvvm

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

在代码中创建一个控件模板的visualtree

这是前一个问题的后续问题,它并没有真正让我到处: WPF中的确定性和异步字段验证

由于WPF似乎不支持INotifyDataErrorInfo,我需要自己实现类似的东西(如果我错了,请纠正我).我需要这个,因为我希望ViewModel触发何时为某些字段显示特殊的ErrorTemplates(例如,在单击按钮之后或在长时间运行异步验证操作结束之后或当内部状态以某些字段突然显示的方式更改时)失效).

我正在考虑为此编写自定义标记扩展或行为.它监听我INotifyDataErrorInfo的ViewModel实现的版本,并在ErrorsChanged引发事件后从XAML中定义的特殊的已知ErrorTemplate创建一个VisualTree .

一旦我在XAML中定义了该模板,我如何从我的行为/表达中找到它,从中实现一个实际的可视化树,然后在我表单上的右侧字段条目中显示它(可能以某种方式在一个装饰层上)?

validation wpf controltemplate

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

为不同的实现重用相同的测试

使用xUnit.net什么是干净的(可读/可理解和可维护的)方法,为同一个接口的多个实现重用相同的测试?

我的测试的行为断言部分始终是相同的(因为接口的所有实现都应该表现相同).对于每次测试运行,SUT都是不同的,对于某些特定测试,排列部分略有不同.

例如,我有以下接口的多个实现(MemoryRepository,FileReposity...).

interface IRepository
{
    object GetById(string id);
    void Set(string id, object value);
}
Run Code Online (Sandbox Code Playgroud)

现在我的测试应该确保所有实现都表现相同:

// all implementations of IRepository must behave like this
// so do this test for all implementations
[Fact]
public void GetRetrievesWhatWasPut()
{
    IRepository sut = new MemoryRepository();
    sut.Set("key", 10);
    var result = sut.Get("key");
    result.Should().Be(10);
}
Run Code Online (Sandbox Code Playgroud)

unit-testing xunit xunit.net

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

从PropertyInfo获取访问器作为Func <object>和Action <object>委托

我需要调用在运行时通过反射确定的属性,并以高频率调用它们.所以我正在寻找具有最佳性能的解决方案,这意味着我可能会避免反思.我在考虑将属性访问器存储为列表中的Func和Action委托,然后调用它们.

private readonly Dictionary<string, Tuple<Func<object>, Action<object>>> dataProperties =
        new Dictionary<string, Tuple<Func<object>, Action<object>>>();

private void BuildDataProperties()
{
    foreach (var keyValuePair in this.GetType()
        .GetProperties(BindingFlags.Instance | BindingFlags.Public)
        .Where(p => p.Name.StartsWith("Data"))
        .Select(
            p =>
                new KeyValuePair<string, Tuple<Func<object>, Action<object>>>(
                    p.Name,
                    Tuple.Create(this.GetGetter(p), this.GetSetter(p)))))
    {
        this.dataProperties.Add(keyValuePair.Key, keyValuePair.Value);
    }
}
Run Code Online (Sandbox Code Playgroud)

现在的问题是,如何将访问器分离为Func和Action为以后的调用进行分类?

仍然使用反射进行调用的天真实现如下所示:

private Func<object> GetGetter(PropertyInfo info)
{
    // 'this' is the owner of the property
    return () => info.GetValue(this);
}

private Action<object> GetSetter(PropertyInfo info)
{
    // 'this' is the owner of the property
    return v => info.SetValue(this, v); …
Run Code Online (Sandbox Code Playgroud)

c# reflection linq-expressions

6
推荐指数
2
解决办法
1873
查看次数

如何使用 dotnet CLI 或 VS Code 将新的 resx 文件添加到我的项目中?

如何使用 dotnet CLI 或 VS Code 将新的 .resx(加上 .Designer.cs)文件添加到我的项目中?

resx visual-studio-code dotnet-new

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