小编yve*_*era的帖子

如何使用Unity 2.0注入Log4Net ILog实现

最终这与设置log4Net有关,但一般来说问题不是特定于日志记录.

一般来说,我想弄清楚的是在Microsoft Unity 2.0中,如何做到与Castle.Facilities.Logging.LoggingFacility相同的东西.即能够声明对记录器的依赖性并使用其注入的对象的Type初始化记录器.

本着考试的精神值得千言万语,这就是我所需要的:

class Logger_IOC_Tests
{
    //[Test] 
    public void Logger_should_be_initialized_with_the_type_of_the_object_that_is_using_it()
    {
        var container = new UnityContainer();
        /* Configuration Magic probably involiving registering either 
            * a custom IDependencyResolverPolicy or BuilderStrategy
            * goes here...
            */
        container.RegisterType<LoggerUser>(new ContainerControlledLifetimeManager());

        var user = container.Resolve<LoggerUser>();

        Assert.True(user.Logger.GetUserType() == user.GetType());
    }
}

interface ILogger
{
    Type GetUserType();
}

class Logger : ILogger
{
    private readonly Type _type;

    public Logger(Type type)
    {
        _type = type;
    }

    public Type GetUserType()
    {
        return _type;
    }
}

class LoggerUser
{ …
Run Code Online (Sandbox Code Playgroud)

c# log4net dependency-injection castle-windsor unity-container

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

茉莉花的流星速度没有回归期待的结果?

我正在尝试测试以下手动工作:

  1. 将用户列表返回为<div>s
  2. 单击按钮可将该计数减少<div>一个.

这似乎不起作用:

  it("should show one less person if you tap you liked them", function() {
    var personLength = $('.person').length;
    console.log(personLength); #> 7
    $("[data-action=like]").first().click();
    console.log($('.person').length); #> 7
    console.log(Likes.find().fetch()); #> 1
    expect($('.person').length).toEqual(person-1); #> Fail (expected 7 to equal 6)
  });
Run Code Online (Sandbox Code Playgroud)

我很困惑为什么会这样做.手动测试时,我明显得到了预期的结果.

我想我错过了某种方法来重置该测试以再次查看DOM或其​​他东西?也许有些异步方法可以回调?我不确定,但似乎是一个简单的错误.

javascript velocity jasmine meteor

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

你能通过不安全的方法改变(不可变)字符串的内容吗?

我知道字符串是不可变的,对字符串的任何更改只会在内存中创建一个新字符串(并将旧字符串标记为空闲字符串).但是,我想知道我的下面的逻辑是否合理,你实际上可以以一种循环方式修改字符串的内容.

const string baseString = "The quick brown fox jumps over the lazy dog!";

//initialize a new string
string candidateString = new string('\0', baseString.Length);

//Pin the string
GCHandle gcHandle = GCHandle.Alloc(candidateString, GCHandleType.Pinned);

//Copy the contents of the base string to the candidate string
unsafe
{
    char* cCandidateString = (char*) gcHandle.AddrOfPinnedObject();
    for (int i = 0; i < baseString.Length; i++)
    {
        cCandidateString[i] = baseString[i];
    }
}
Run Code Online (Sandbox Code Playgroud)

这种方法确实改变了内容candidateString(没有在内存中创建新的candidateString),还是运行时通过我的技巧看待它并将其视为普通字符串?

c#

14
推荐指数
2
解决办法
1460
查看次数

Angular Directive使用&不将参数传递给控制器​​来绑定函数

我有一个与Box文件选择器交互的指令.我的指令由2个独立的控制器使用,可能在将来增加更多.

Box文件选择器允许您在用户选择文件/文件夹后设置回调函数,如下所示:

var boxSelect = new BoxSelect();
// Register a success callback handler
boxSelect.success(function(response) {
    console.log(response);
});
Run Code Online (Sandbox Code Playgroud)

我的控制器正在使用该指令,它们将成功的回调逻辑作为范围变量,我将其传递给指令.

我创建了一个plunkr,我在嘲笑Box选择行为

调节器

.controller('myController', function($scope) {
  $scope.onSuccessful = function(message) {
    alert('Success! Message: ' + message);
  };
})
Run Code Online (Sandbox Code Playgroud)

指示

angular.module('myApp', [])
  .controller('myController', function($scope) {
    $scope.onSuccessful = function(message) {
      //message is undefined here
      alert('Success! Message: ' + message);
    };
  })
  .directive('myDirective', function() {
    return {
      restrict: 'A',
      scope: {
        success: '&'
      },
      link: function(scope, element) {

        //third party allows to subscribe …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive

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

如何将不可点击的内容添加到角度引导手风琴标题?

手风琴标题中的默认内容将全部可点击以切换该部分,但现在我需要在标题中添加其他不可点击的内容.怎么办?

<accordion-group is-open="OpenOneAtTime" ng-repeat="destination in mileage.destionations" style='position:relative;'>
    <accordion-heading>
        <!-- All I want is only make "Toggle Me" clickable, and leave other content in the header alone,just like pure text. -->
        <span ng-class="{'fa-chevron-down': OpenOneAtTime, 'fa-chevron-right': !OpenOneAtTime}">Toggle Me</span>
        <span ng-show='!OpenOneAtTime'>{{destination.Total}}+{{destination.To}}</span>
    </accordion-heading>
    <div class='accordion-section'>
        main content
    </div>
    <div class='clear'></div>
</accordion-group>
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-bootstrap

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

防止在 ui-router 中重新加载父控制器

我在 ui-router 中遇到嵌套视图的问题。

我的布局是:

网站搜索
-----------------
site.search.runs
-----------------
site.search.runs.scheme
-----------------
site.search.runs.scheme.payment
-----------------

我不想更改 url,这就是为什么我使用$state.go('', {}, {location:false}); I 也$stage.go('^'...)用于返回父级。

但是当我点击 site.search.runs.scheme.payment 或 site.search.runs.scheme 上的后退按钮时 - site.runs 控制器也会重新加载(我不使用 {reload:true})。
如何防止重新加载顶级父控制器?
我发现了一个像我这样的问题https://github.com/angular-ui/ui-router/issues/2096
有人可以帮我吗?

我的配置是

$stateProvider
        .state('site', {
            abstract: true,
            url: '',
            template: '<ui-view/>'
        })
        .state('site.search', {
            url: '',
            parent: 'site',
            controller: 'SearchController',
            controllerAs: 'search',
            templateUrl: 'js/search/search.tpl.html'
        })
        .state('site.search.runs', {
            url: '',
            parent: 'site.search',
            params: {back: false, timestamp: 0, search: {}},
            controller: 'RunsController as runsCtrl',
            templateUrl: 'js/runs/runs.tpl.html'
        })
        .state('site.search.runs.scheme', { …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui-router

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

RestSharp对Enum类型的属性进行反序列化

我有一个对象

            var testTcc = new TrendingConfigurationConfigDto
            {
                TrendingConfigurationId =1,
                ConfigId = 1,
                DeviceId = 1,
                Selected = true,
                YAxisPosition = YAxisPosition.Left,
                Order = 1,
                Color = "#ffffff",
                Configuration = new BO.Shared.Dtos.List.ConfigurationListDto
                {
                    Id = 1,
                    Name = "configuration",
                    Alias = "configuationAlias",
                    EnableEdit = true,
                    IsBusinessItem = true
                },
                Device = new BO.Shared.Dtos.List.DeviceListDto
                {
                    Id = 1,
                    Name = "Device"
                }
            };
Run Code Online (Sandbox Code Playgroud)

当我将其序列化为json时

var jsonTcc = SimpleJson.SerializeObject(testTcc);
Run Code Online (Sandbox Code Playgroud)

它返回的字符串包含YAxisPosition = 1的json对象,当我尝试使用

testTcc = SimpleJson.DeserializeObject<TrendingConfigurationConfigDto>(jsonTcc);
Run Code Online (Sandbox Code Playgroud)

它给出异常System.InvalidCastException,并显示消息“指定的转换无效”。

我尝试将json字符串中的YAxisPosition值更改为字符串“ 1”或“ Left”,这总是给我相同的错误,直到我从json字符串中删除了属性YAxisPosition。

我可能缺少一些东西(枚举属性上的Attribute或类似的东西)。

请帮助我找到一种方法,以便我可以使用RestSharp对包含Enum类型属性的对象进行序列化和反序列化。

注意:我尝试使用NewtonSoft成功进行序列化和反序列化。但是我不希望Web API客户端依赖NetwonSoft,因为我已经在使用RestSharp。

c# restsharp

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

来自控制器的Console/Symfony Call命令

当我尝试从Controller调用命令时,我在控制台上遇到了一些问题.我在Symfony CookBook中找到了一种方法:http: //symfony.com/doc/current/cookbook/console/command_in_controller.html

它似乎不起作用......也许我忘了一些东西!

命令:

namespace AppBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class GreetCommand extends Command
{
    protected function configure()
    {
        $this
            ->setName('demo:greet')
            ->setDescription('Greet someone')
            ->addArgument(
                'name',
                InputArgument::OPTIONAL,
                'Who do you want to greet?'
            )
            ->addOption(
                'yell',
                null,
                InputOption::VALUE_NONE,
                'If set, the task will yell in uppercase letters'
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name = $input->getArgument('name');
        if ($name) {
            $text = 'Hello '.$name;
        } …
Run Code Online (Sandbox Code Playgroud)

php console symfony

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

使用javascript解析Excel工作表

我正在使用SheetJS来解析Excel工作表但是我遇到了以下错误:

"未捕获的TypeError:jszip不是函数"

执行以下代码时:

var url = "/test-files/test.xlsx";
var oReq = new XMLHttpRequest();
oReq.open("GET", url, true);
oReq.responseType = "arraybuffer";

oReq.onload = function(e) {
  var arraybuffer = oReq.response;

  var data = new Uint8Array(arraybuffer);
  var arr = new Array();
  for(var i = 0; i != data.length; i++) arr[i] = String.fromCharCode(data[i]);
  var bstr = arr.join("");

  var workbook = XLSX.read(bstr, {type: "binary"});
}

oReq.send();
Run Code Online (Sandbox Code Playgroud)

原始代码位于:https://github.com/SheetJS/js-xlsx

是否有任何建议可以更轻松地实现解析Excel文件?

javascript excel parsing

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

ODI studio 11g问题

我在Windows 8上使用JDK 1.8安装了ODI Studio版本11.1.1.9,并连接到位于oracle 11.1.1.6上的远程ODI存储库.

我没有创建接口和几个对象的问题.但是,当我试图使用像ODI工具odisendemail,odiftpget等在ODI包,我第一次看见的属性和使用它们.

后来当我重新打开相同的包时,我无法再选择用于查看属性的ODI工具.

你能帮帮我吗?

oracle-data-integrator

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

量角器3.0.0和黄瓜自动化测试

我目前正在使用量角器,黄瓜和柴/柴作为我的自动化测试.我目前的代码是使用量角器1.8.0,我想将它更新到最新版本.问题是最新版本的量角器不支持黄瓜.

使用黄瓜作为框架,量角器(http://angular.github.io/protractor/#/frameworks)指向您使用量角器 - 黄瓜 - 框架(https://github.com/mattfritz/protractor-cucumber-framework).我已经尝试将它与我当前的代码和一些较小的示例项目集成,但没有运气让它们正常工作.我得到的主要错误是:

错误:在Timer.listOnTimeout(timers.js:92:15)5000毫秒后步进超时

我已尝试全局更改默认超时,因为黄瓜建议:// features/support/env.js

var configure = function () {
  this.setDefaultTimeout(60 * 1000);
};

module.exports = configure;
Run Code Online (Sandbox Code Playgroud)

但我似乎错过了我的设置.

那么,有没有人知道一个很好的例子可以告诉我新的量角器/黄瓜框架的正确设置?如果没有,有没有人知道一个示例,说明如何全局更改默认超时?

javascript automated-tests cucumber angularjs protractor

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