小编Ric*_*tte的帖子

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

如何在使用Visual Studio Task Runner Explorer运行时调试gulpfile.js?

如何在使用Visual Studio Task Runner Explorer运行时调试gulpfile.js?或者是否有另一种方式可以使用visual studio启动gulp,以便可以调试gulpfile.js?我知道node-inspector但想看看Visual Studio是否有原生的东西.

visual-studio node.js gulp

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

如何使用服务帐户通过.NET C#访问Google AnalyticsAPI V3?

我意识到这个问题之前已经被问过,但是代码示例的方式很少,所以我再问一次,但至少有一点方向.

经过几个小时的搜索,我得出了以下部分实现.

namespace GoogleAnalyticsAPITest.Console
{
    using System.Security.Cryptography.X509Certificates;
    using DotNetOpenAuth.OAuth2;
    using Google.Apis.Analytics.v3;
    using Google.Apis.Analytics.v3.Data;
    using Google.Apis.Authentication.OAuth2;
    using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;

    class Program
    {
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            string Scope = Google.Apis.Analytics.v3.AnalyticsService.Scopes.Analytics.ToString().ToLower();
            string scopeUrl = "https://www.googleapis.com/auth/" + Scope;
            const string ServiceAccountId = "nnnnnnnnnnn.apps.googleusercontent.com";
            const string ServiceAccountUser = "nnnnnnnnnnn@developer.gserviceaccount.com";
            AssertionFlowClient client = new AssertionFlowClient(
                GoogleAuthenticationServer.Description, new X509Certificate2(@"7039572692013fc5deada350904f55bad2588a2a-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable))
            {
                Scope = scopeUrl,
                ServiceAccountId = ServiceAccountId//,ServiceAccountUser = ServiceAccountUser
            };
            IAuthorizationState state = AssertionFlowClient.GetState(client);
            AnalyticsService service = new AnalyticsService(authenticator);
            string profileId = "ga:xxxxxxxx";
            string …
Run Code Online (Sandbox Code Playgroud)

.net c# dotnetopenauth google-analytics-api oauth-2.0

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

Typescript:如何在子类中使用super关键字调用基类中使用箭头函数定义的方法?

特定

class BaseClass{

  count:number=0;

  public someMethod=():void =>{
      this.count++;
  }
}

class ChildClass extends BaseClass{
  public someMethod=():void=>{
     super.someMethod();
     //Do more work here.
  }
}
Run Code Online (Sandbox Code Playgroud)

我收到错误消息:

只能通过'super'关键字访问基类的公共方法.

@Basarat在这里提供了一些信息,但这似乎是对该语言的真正破解. typescript箭头操作符在原型上定义函数

如何在保留"this"的上下文使用的同时做到这一点?

我是否正确使用箭头函数或者它们是否真的只能用作声明回调之类的方法?

typescript arrow-functions

10
推荐指数
2
解决办法
4239
查看次数

如何将gulp-typescript输出到与源文件相同的目录?

我有以下管道

  function typescripts() {
    return gulp.src(paths.watchedFiles.ts)
        .pipe(cached('typescripts'))
        .pipe(plumber())
        .pipe(addsrc(paths.ts.include))
      //TODO: Need to eliminate the original source path (ex. /users/userName) from the sourcemap file.
        .pipe(sourcemaps.init())
        .pipe(ts(tsProjectMode, undefined, ts.reporter.fullReporter(true))).js
        .pipe(gulpIgnore.exclude(paths.ts.excludeFromPostCompilePipeline))
        .pipe(ngAnnotate({
          remove: false,
          add: true,
          gulpWarnings: false //typescript removes base path for some reason.  Warnings result that we don't want to see.
        }))
        .pipe(sourcemaps.write('.', {includeContent: false}))
        .pipe(gulp.dest(paths.ts.basePath));
  }
Run Code Online (Sandbox Code Playgroud)

我似乎必须根据src路径的根目录制作"硬代码"的dest路径.如果我的src路径是app/modules/**.ts我的dest路径必须app/modules.这限制了我使用单个根src路径,我不能使用兄弟姐妹.

我希望能够创建我的src ['path1/**/*.ts', 'path2/**/*.ts]并将已转换的输出写入源文件所在的同一文件夹.

typescript gulp

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

WCF:如何以声明方式指定AddressFilterMode.Any

我提前为回答我自己的问题而道歉但是我看到很多答案说明当你可以为WCF创建同样的东西时,需要将AddressFilterMode.Any添加为代码属性.在很多地方提出同样的问题,我认为在一个地方回答这个问题会更有益.

.net wcf

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

如何使用ActionResult <T>进行单元测试?

我有一个xUnit测试,例如:

[Fact]
public async void GetLocationsCountAsync_WhenCalled_ReturnsLocationsCount()
{
    _locationsService.Setup(s => s.GetLocationsCountAsync("123")).ReturnsAsync(10);
    var controller = new LocationsController(_locationsService.Object, null)
    {
        ControllerContext = { HttpContext = SetupHttpContext().Object }
    };
    var actionResult = await controller.GetLocationsCountAsync();
    actionResult.Value.Should().Be(10);
    VerifyAll();
}
Run Code Online (Sandbox Code Playgroud)

来源是

/// <summary>
/// Get the current number of locations for a user.
/// </summary>
/// <returns>A <see cref="int"></see>.</returns>
/// <response code="200">The current number of locations.</response>
[HttpGet]
[Route("count")]
public async Task<ActionResult<int>> GetLocationsCountAsync()
{
    return Ok(await _locations.GetLocationsCountAsync(User.APropertyOfTheUser()));
}
Run Code Online (Sandbox Code Playgroud)

结果的值为null,导致我的测试失败,但是如果您查看ActionResult.Result.Value(内部属性),则该结果包含预期的解析值。

请参见以下调试器的屏幕截图。 在此处输入图片说明

如何获取actionResult.Value以在单元测试中填充?

c# unit-testing xunit .net-core asp.net-core

8
推荐指数
5
解决办法
2425
查看次数

如何将 TextWriter 用作 Serilog 的源?

StackExchange.Redis 将日志消息写入 TextWriter。它不使用 ILogger 接口进行日志记录。

我想将写入 TextWriter 的消息转换为 Serilog 调试级别的消息。

想法?

stackexchange.redis serilog

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

Sql Server更改数据捕获:添加列时保留历史记录?

将新列添加到为更改数据捕获(cdc)配置的表时,捕获实例表将不会具有新列,直到禁用cdc并为源表重新启用.在此过程中,将删除现有捕获实例.

我以为我可以将现有数据复制到临时表,然后使用以下SQL复制回来.但是,其他CDC元信息(例如cdc.change_tables.start_lsn)将变为无效.

如果有的话,如何使用相同的捕获实例名称保留捕获实例历史记录?

谢谢,Rich

/*Change Data Capture Test - Alter table definition test */

/*Enter restricted mode so we don't lose data changes during this process*/
alter database ChangeDataCaptureTest set AUTO_UPDATE_STATISTICS_ASYNC OFF
alter database ChangeDataCaptureTest set RESTRICTED_USER with ROLLBACK IMMEDIATE
go

/*Add a column to the table*/
alter table dbo.Table1 add value3 varchar(20) DEFAULT '' not null

/*Copy the existing change tracking into a temp table*/
select * into cdc.dbo_Table1_temp from cdc.dbo_Table1_CT

/*Add the new column to the temp table …
Run Code Online (Sandbox Code Playgroud)

sql-server cdc

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

将Microsoft.SqlServer.Types与Dapper一起使用时的RuntimeBinderInternalCompilerException

使用其目标平台设置为以下之一的Sql Server Data Tools项目:

  • SQL Server 2008
  • SQL Server 2012
  • SQL Server 2014

并部署到(localdb)\ Projects或(localdb)\ ProjectsV12

调用返回Geometry,Geography或HierachyId类型的存储过程,例如:

CREATE PROCEDURE [dbo].[SelectSqlGeometry]
    @x Geometry
AS
    SELECT @x as y
RETURN 0
Run Code Online (Sandbox Code Playgroud)

以下调用代码:

var result = Connection.Query("dbo.SelectSqlGeometry", new { x = geometry }, commandType: CommandType.StoredProcedure).First();
bool isSame = ((bool)geometry.STEquals(result.y));
Run Code Online (Sandbox Code Playgroud)

在STEquals系列中导致以下异常.

Microsoft.CSharp.RuntimeBinder.RuntimeBinderInternalCompilerException未由用户代码处理HResult = -2146233088消息=绑定动态操作时发生意外异常
Source = Microsoft.CSharp StackTrace:at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload,IEnumerable 1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding) at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, IEnumerable1 args,IEnumerable 1 arginfos, DynamicMetaObject onBindingError) at Microsoft.CSharp.RuntimeBinder.CSharpConvertBinder.FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion) at …

.net sql-server dapper

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