小编Jör*_*ann的帖子

用于解析源代码文件的.Net 库?

有谁知道一个好的 .NET 库可以让我解析源代码文件,而不仅仅是 .NET 源代码文件(如 java、perl、ruby 等)?

我需要以编程方式访问各种源代码文件的内容(例如类/方法/参数名称、类型等)。

有人遇到过这样的事情吗?我知道在 .NET 中这是相当可能的,并且有一些库,但我需要将其抽象为更多类型的编程语言。

.net parsing

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

DataContractSerializer 将接口属性序列化为 System.Object / anyType

在应用程序中,我具有以下接口/实现结构:

public interface IMyInterface
{
  IMyOtherInterface InstanceOfMyOtherInterface { get; }
}

public interface IMyOtherInterface
{
  string SomeValue { get; }
}

[DataContract(Name = "MyInterfaceImplementation", Namespace = "")]
public class MyInterfaceImplementation : IMyInterface
{
  [DataMember(EmitDefaultValue = false), XmlAttribute(Namespace = "")]
  public IMyOtherInterface InstanceOfMyOtherInterface { get; private set; }

  public MyInterfaceImplementation()
  {
    this.InstanceOfMyOtherInterface = new MyOtherInterfaceImplementation("Hello World");
  }
}

[DataContract(Name = "MyOtherInterfaceImplementation", Namespace = "")]
public class MyOtherInterfaceImplementation : IMyOtherInterface
{
  [DataMember]
  public string SomeValue { get; private set; }

  public MyOtherInterfaceImplementation(string …
Run Code Online (Sandbox Code Playgroud)

.net serialization xml-serialization datacontract datacontractserializer

5
推荐指数
0
解决办法
1430
查看次数

System.Web.HttpUtility.HtmlEncode/Decode的替代品?

.net 3.5(sp1)中的System.Web.HttpUtility.HtmlEncode/.Decode函数是否有"更瘦"的替代方案?一个单独的库是好的...甚至是"想要的",至少是一些不会引入System.Web所需的"全新"依赖关系的东西.

我只想将普通字符串转换为符合xml/xhtml的等效字符串(&back).

.net entities html-entities

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

获取Word中的当前光标位置(VSTO)

Word Add-In是否有办法在文档/屏幕上获取当前光标位置(例如,在其旁边显示我自己的控件)?

.net interop ms-word ms-office

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

Azure云服务项目在调试时在启动时打开两个浏览器Windows

我有一个VS2013(更新3)解决方案,其中一个Azure云服务项目有一个Web角色/ ASP.Net项目,后者有"不要打开页面".在其Propers> Web选项卡下面选择,但每当我启动Azure CS .ccproj进行调试(后者设置为启动项目)时,每次都会打开两个(不是一个)浏览器Windows.

有谁知道我可以在哪里禁用它或至少将它设置为一个窗口?它与Azure SDK 2.4一起运行,我正在使用IIS Express和(Azure)Emulator Express.

c# asp.net azure

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

Nancy将(404)JsonResponse转换为Html

我有一个Nancy Fx应用程序,它充当一个纯API端点(仅限application/json,没有文本/ html或浏览器等访问)和一个返回例如以下内容的模块:

return
    userExists
        ? Negotiate.WithStatusCode(HttpStatusCode.OK)
        : Negotiate.WithStatusCode(HttpStatusCode.NotFound);
Run Code Online (Sandbox Code Playgroud)

但是,我注意到一个特殊性 - 客户端将Accept-Header设置为'application/json'并在此处执行GET请求,确实得到文本/ html响应,更糟糕的是 - 在.NotFound情况下是Nancy特定的/返回自己的404错误,如果是.OK,则由于缺少视图而发生异常.

让我更奇怪的是,在我的自定义IStatusCodeHandler中,我"看到"context.Response 一个JsonResponse,在管道的某个地方,它被处理并(试图)以某种方式进一步转换为text/html,而且我想知道为什么.

有什么方法可以阻止转换为text/html吗?

nancy

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

.NET TIFF文件:没有第三方库可以转换RGB到CMYK?

继我之前的问题:是否以及如何使用基于RGB的TIFF文件并将其转换为具有标准.NET(3.5)功能的CMYK?

这有可能吗?

c# tiff image

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

Xunit:在一种测试方法中执行所有'断言'?

有可能告诉xUnit.net Assert.True()在一个测试方法中执行所有操作吗?基本上在我们的一些use/testcases中,所有断言在逻辑上都属于同一个"范围"的测试,我有这样的东西:

    [Fact(DisplayName = "Tr-MissImpl")]
    public void MissingImplementationTest()
    {
        // parse export.xml file
        var exportXml = Libraries.Utilities.XML.GenericClassDeserializer.DeserializeXmlFile<Libraries.MedTrace.ExportXml>(
                ExportXmlFile);

        // compare parsed results with expected ones
        Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_154163", "E0032A"));
        Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_155763", "E0032A"));
        Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_155931", "E0032A"));
        Assert.True(exportXml.ContainsRequirementKeyWithError("PERS_157145", "E0032A"));

        Assert.True(exportXml.ContainsRequirementKeyWithError("s_sw_ers_req_A", "E0032A"));
        Assert.True(exportXml.ContainsRequirementKeyWithError("s_sw_ers_req_C", "E0032A"));
        Assert.True(exportXml.ContainsRequirementKeyWithError("s_sw_ers_req_D", "E0032A"));       
    }
Run Code Online (Sandbox Code Playgroud)

现在,如果第一个Assert.True(...)失败,则不执行/检查其他的.我宁愿不将这七个断言分解为单独的方法,因为它们确实在逻辑上属于一起(如果所有七个都通过一起,则TC仅被'完全传递'.

.net xunit.net assertions arrange-act-assert

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

指定double.TryParse(..)数字格式?

我从API中获取lat/lon字符串,格式为'37 .766713'或'-122.428938'(请参阅http://en.wikipedia.org/wiki/Decimal_degrees),并希望将这些字符串分解为双,但是, double.TryParse(string,out doubleInstance)给了我'37766713,0'的两倍.有没有优雅的方法来指定解析的输入格式?执行string.Replace(".",",")会有点伤害.

.net double formatting parsing

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

.Net Regex for Comma用严格格式分隔字符串

我有一个字符串,我需要验证有效性,后来是如此:

  • 它完全是空的
  • 或者包含一个逗号分隔的字符串,必须如下所示:'abc,def,ghi,jkl'.

这些逗号分隔值中有多少并不重要,但如果字符串不为空,则必须遵循以逗号(并且只有逗号)分隔的格式,并且它们周围没有空格,并且每个值可能只包含ascii az/Az ..没有特殊字符或任何东西.

我如何验证字符串是否符合规则?

.net c# regex

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

“无止境” TakeWhile,BufferWhile和SkipWhile RX.Net序列

我想知道是否存在一种方法来获取可观察的流并使用* While运算符,尤其是TakeWhile,SkipWhile和BufferWhile,以便在满足bool“ while”条件时,它们的订阅者不会收到.OnComplete?

当我开始使用.TakeWhile / SkipWhile和BufferWhile运算符时,我假定它们不会终止/ .OnComplete(),而只是在满足布尔条件时才发出/不发出。

举个例子可能更有意义:

我有一个bool标志,指示一个实例是否忙,以及一个可观察的数据流:

private bool IsBusy { get;set; }
private bool IgnoreChanges { get;set; }

private IObservable<int> Producer { get;set; }
private IDisposable ConsumerSubscription { get;set; }
Run Code Online (Sandbox Code Playgroud)

..并像这样(简化)使用/设置RX流

private void SetupRx()
{
    ConsumerSubscription = Producer
        .SkipWhile(_ => IgnoreChanges == true) // Drop the producer's stream of ints whenever the IgnoreChanges flag is set to true, but forward them whenever the IgnoreChanges flag is set to false
        .BufferWhile(_ => IsBusy == true) // for all …
Run Code Online (Sandbox Code Playgroud)

.net reactive-programming system.reactive

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