小编Liv*_* M.的帖子

如何在Visual Studio 2008/2010中注释方法

嗨,我想知道我必须在VS中评论一个方法,当我想选择这些方法时,我在工具提示中看到我的描述?

c# visual-studio

31
推荐指数
2
解决办法
3万
查看次数

允许实现多少个接口?

在C#中:

多少个接口,一个类可以实现在同一时间?

public class MyClass: IInteferface_1, IInterface_2, ... , IInterface_N
{
}
Run Code Online (Sandbox Code Playgroud)

N有限制吗?

不要担心我不想实现或维护这样的对象.我只是想知道是否有限制.

.net c# interface interface-implementation

24
推荐指数
3
解决办法
2万
查看次数

正则表达式和冒号(:)

我有以下代码.这个想法是检测整个单词.

bool contains = Regex.IsMatch("Hello1 Hello2", @"\bHello\b"); // yields false
bool contains = Regex.IsMatch("Hello Hello2", @"\bHello\b"); // yields true
bool contains = Regex.IsMatch("Hello: Hello2", @"\bHello\b"); **// yields true, but should yield false**
Run Code Online (Sandbox Code Playgroud)

似乎正则表达式忽略了冒号.如何修改代码,使最后一行返回false?

c# regex

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

使$ httpBackend忽略对服务器发出的任何请求

我有以下控制器(请注意,在实例化时我进行显式调用$scope.getNotifications()):

bla.controller("myctrl", [
    "$scope", "$http", "configs", function ($scope, $http, configs) {

        $scope.getNotifications = function () {
            $http.get("bla/blabla").success(function (data) {

            });
        };

        $scope.removeNotification = function (notification) {
            var index = $scope.allNotifications.indexOf(notification);
            $scope.allNotifications.splice(index, 1);
        };

        $scope.getNotifications();
    }
]);
Run Code Online (Sandbox Code Playgroud)

然后我做了一些单元测试(注意控制器在每个测试之前被实例化):

describe("blaController", function () {

    var scope, $httpBackend;

    beforeEach(module('bla'));

    beforeEach(inject(function ($controller, $rootScope, _$httpBackend_) {
        scope = $rootScope.$new();
        $httpBackend = _$httpBackend_;
        $controller('blaCtrl', { $scope: scope });
    }));

 afterEach(function(){
    //assert
    $httpBackend.verifyNoOutstandingExpectation();
    $httpBackend.verifyNoOutstandingRequest();
 });

 it("should get all notifications from server when instantiated", function () { …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing jasmine angularjs httpbackend

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

如何对使用FederatedAuthentication.SessionAuthenticationModule的代码进行单元测试

如何测试此代码(ASP.NET MVC 4,.NET 4.5 Web应用程序中的登录方法):

public ActionResult Login(LoginModel model, string returnUrl)
{
            if (ModelState.IsValid && _userCredentialsService.ValidateUser(model.UserName, model.Password))
            {
                SessionAuthentication.SetAuthCookie(model.UserName, _userCredentialsService.GetUserGroups(model.UserName), model.RememberMe);

                return RedirectToLocal(returnUrl);
            }
}
Run Code Online (Sandbox Code Playgroud)

使用此SetAuthCookie方法:

public static void SetAuthCookie(IEnumerable<Claim> claims, bool isPersistent)
{
            if (!HttpContext.Current.Request.IsSecureConnection && FormsAuthentication.RequireSSL)
            {
                throw new HttpException(500, "Connection is not secured with SSL");
            }

            var sessionToken = CreateSessionSecurityToken(CreatePrincipal(claims.ToList()), isPersistent);
            FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(sessionToken);
}
Run Code Online (Sandbox Code Playgroud)

我在访问时得到一个空引用异常SessionAuthenticationModule(在尝试获取HttpContext时提到的属性在内部抛出异常).这是堆栈跟踪:

   at System.IdentityModel.Services.FederatedAuthentication.GetHttpContextModule[T]()
   at System.IdentityModel.Services.FederatedAuthentication.GetHttpModule[T]()
   at System.IdentityModel.Services.FederatedAuthentication.get_SessionAuthenticationModule()
Run Code Online (Sandbox Code Playgroud)

我在位于测试程序集中的app.config中制作了我的web.config的精确副本,代码在应用程序的正常运行时中运行.

我已经使用了HttpSimulator和MvcContrib测试助手,以便HttpContext得到设置,但仍然抛出异常.有没有人有如何测试它的解决方案或解决方法?

.net c# unit-testing claims-based-identity asp.net-mvc-4

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

询问Microsoft的功能

如何向Microsoft提出Visual Studio功能请求?

request visual-studio

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

NSIS中的字符串解析函数

除了StrCpy和StrLen之外,NSIS中是否有任何字符串解析函数?

或者是一个插件,它有strstr,strcmp,find,contains等方法.

string nsis

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

MemoryCache和每次调用多个WCF服务

MemoryCache如果我希望缓存数据在多个WCF服务中可见(使用PerCall实例模式),那么使用该类是一个有效的选项吗?

有两种情况:

  1. 这些服务都托管在IIS中的同一个应用程序中
  2. 服务托管在同一服务器上的不同IIS应用程序中

c# iis wcf caching memorycache

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

运行时以静默方式更新应用程序

我的应用程序最初将与Windows Installer一起部署.

我正在寻找的解决方案的主要特点包括:

  • 在应用程序运行时支持静默更新(或自动重启客户端)

  • 易于维护和管理包装过程

  • 避免复杂的自定义或安装脚本

你有什么想法我怎么能实现这个目标?即使它意味着修改应用程序代码以支持任何想法.

应用程序是.net 2.0

.net c# patch silent

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

从休眠状态唤醒C#时的通知

当系统从休眠状态唤醒时,有没有办法在我的C#2.0应用程序中获取通知(事件)?

我的应用程序在系统进入休眠状态时在系统托盘中运行.

.net c# hibernation

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

单元测试框架 - 解析实体名时发生错误

我创建了简单的MS单元测试项目.Assert.Equal(true, true).当我想运行测试时,我收到来自Resharper和Visual Studio的错误.

"单元测试Runner未能运行测试

System.Xml.XmlException:解析EnityName时发生错误.第1行,第17位."

我错过了什么吗

编辑:我无法添加屏幕截图,我无法选择要复制的文本.好的,我会尽我所能写出来的.

at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.xml.XmlTextReaderImpl.Throw(String res,String arg)
at System.Xml.XmlText.ParseEnityName()
at System.Xml.XmlTextReaderImplparseEnityReference
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextLoader.ParsePartialContent(XmlNode parentNode,String innerxmltext, xmlNodeType nt)
at System.Xml.XmlElement.set_InnerXml(string value)
at Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingHelper.AppendOrModifyChild(XpathNavigator,String nodePatH,String nodeNAME,sTRING INNERxML)
at Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.UpdatedRunConfiguration(XPathNavigator, ArchitectureeffectivePlatform,FrameworkVersion effectiveFramework,String resultsDirectory,String solutionDirectory,String binariesRootDirectory)
Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.MergeRunSettingsAndFindCompatibleSource()
at JetBrains.ReSharper.UnitTestProvider.MSTest11.MsTest11Runner.Run(IRemoteTaskServer server,String assemblyLocation,String runConfigurationFilename,IUnitTestRun run)
Run Code Online (Sandbox Code Playgroud)

unit-testing vs-unit-testing-framework

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

什么是通过线路发送大数据的有效方法?

我有一个字符串列表List<string>.实际上是文件路径列表.我需要将它发送到网络服务.该清单可包含大量物品(1 000 - 10 000).

实现这一目标的最有效方法是什么?考虑到消息有效载荷将非常高.

我在寻求想法和原则,而不是代码示例.

非常感谢.

c#

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