小编nul*_*ull的帖子

Gulp复制空目录

在我的gulp构建中,我完成了一项任务,在完成所有编译,丑化和缩小之后运行.此任务只是将src中的所有内容复制到以前的任务未触及/处理的dest目录中.我遇到的小问题是这导致dest目录中的空目录.

有没有办法告诉gulp.srcglob只包含模式匹配中的文件(比如提供'is_file'标志)?

谢谢.

glob node.js gulp gulp-glob

8
推荐指数
2
解决办法
2901
查看次数

ItemTemplate:ListBox vs ItemsControl

我对WPF世界很陌生,我在使用ItemsControl模板化项目时遇到了一些问题.我需要的是在ItemsControl(或类似)中模板元素(主要是按钮).

如果我使用以下XAML代码...

<ItemsControl>
    <ItemsControl.ItemTemplate>
        <DataTemplate DataType="{x:Type Button}">
                <Border BorderBrush="AliceBlue" 
                        BorderThickness="3">
                    <TextBlock Text="Templated!"/>        
                </Border>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
    <Button>Not templated</Button>
    <TextBlock>Text not templated</TextBlock>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)

...我得到这个结果:http://img444.imageshack.us/img444/2167/itemscontrolnottemplate.gif

ItemsControl的没有模板套用到按钮也不到TextBlock的控制.如果我将ItemsControl更改为ListBox,如下所示:

<ListBox>
    <ListBox.ItemTemplate>
        <DataTemplate DataType="{x:Type Button}">
                <Border BorderBrush="AliceBlue" 
                        BorderThickness="3">
                    <TextBlock Text="Templated!"/>        
                </Border>
        </DataTemplate>
    </ListBox.ItemTemplate>
    <Button>Not templated</Button>
    <TextBlock>Text not templated</TextBlock>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

...然后我得到了这个结果:img814.imageshack.us/img814/6204/listboxtoomuchtemplatin.gif

现在模板应用于两个子控件(即使我将DataType设置为Button).

wpf listbox itemtemplate itemscontrol

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

rxjs5合并和错误处理

我想合并/合并多个Observable,当每个Observable完成时,执行finally函数。该merge操作似乎在并行执行每个订阅,这正是我需要的,但如果其中任何引发错误的停止执行。

RxJS 版本4具有一个操作符mergeDelayError,该操作符应使所有订阅都一直执行到所有订阅都完成为止,但是该操作符在版本5中未实现。

我应该恢复为其他运营商吗?

var source1 = Rx.Observable.of(1,2,3).delay(3000);
var source2 = Rx.Observable.throw(new Error('woops'));
var source3 = Rx.Observable.of(4,5,6).delay(1000);

// Combine the 3 sources into 1 

var source = Rx.Observable
  .merge(source1, source2, source3)
  .finally(() => {

    // finally is executed before all 
    // subscriptions are completed.

    console.log('finally');

  }); 

var subscription = source.subscribe(
  x => console.log('next:', x),
  e => console.log('error:', e),
  () => console.log('completed'));
Run Code Online (Sandbox Code Playgroud)

联合会

rxjs rxjs5

5
推荐指数
2
解决办法
1722
查看次数

使用StringFormat绑定WPF图像源

我是WPF和MVVM的新手(本周开始尝试它)并尝试在运行时绑定图像资源.我正在尝试显示的项目包含一个枚举属性,指示项目的类型或状态:

public class TraceEvent
{
    /// <summary>
    /// Gets or sets the type of the event.
    /// </summary>
    /// <value>The type of the event.</value>
    public TraceEventType EventType { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

据我所知,Image的Source属性有一个值转换器,它接受字符串并返回Uri对象.

<Image Source="{Binding Path=EventType, StringFormat={}/AssemblyName;component/Images/{0}Icon.ico}" />
Run Code Online (Sandbox Code Playgroud)

那么为什么上面的工作没有呢?如果我直接输入uri(没有绑定),图像就会完美显示.实际上,如果我在TextBlock中进行绑定并在Image中使用该值的结果也没有问题:

<TextBlock Visibility="Collapsed" Name="bindingFix" Text="{Binding Path=EventType, StringFormat={}/AssemblyName;component/Images/{0}Icon.ico}"/>
<Image Source="{Binding ElementName=bindingFix, Path=Text}" />  
Run Code Online (Sandbox Code Playgroud)

我非常肯定我正在做一些与图像这么明显的事情有关的错误.

谢谢.

wpf binding image string-formatting mvvm

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

包含/排除gulp.src的globs

我想设置为我的javascript CONCAT在建任务水珠阵列一饮而尽.目录结构如下所示:

??? about
?   ??? about.js
??? assets
??? contact
??? core
?   ??? navbar
?   ?   ??? navbar.js
?   ?   ??? navbar.test.js
?   ??? routing.js
?   ??? routing.test.js
?   ??? utils.js
?   ??? utils.test.js
??? generated
?   ??? footer.js
?   ??? header.js
?   ??? templates.js
??? home
??? app.js
??? config.js
Run Code Online (Sandbox Code Playgroud)

文件的顺序很重要:

  1. 生成/ header.js
  2. app.js
  3. 任何*.js文件,除了下面的那些
  4. 生成/ templates.js
  5. 生成/ footer.js

我已经疯狂地尝试了各种通配符的组合,但对我来说并不强烈.

var inputFiles = [
  'generated/header.js',
  'app.js',
  '!(generated)**/*.js',    // <=---- ???
  'generated/templates.js',
  'generated/footer.js',
  '!**/*.test.js' …
Run Code Online (Sandbox Code Playgroud)

javascript glob node.js minimatch gulp

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