小编Kla*_*Nji的帖子

TypeScript函数重载

TypeScript语言规范的第6.3节讨论了函数重载,并给出了如何实现它的具体示例.但是,如果我尝试这样的事情:

export class LayerFactory { 

    constructor (public styleFactory: Symbology.StyleFactory) { }

    createFeatureLayer (userContext : Model.UserContext, mapWrapperObj : MapWrapperBase) : any {           
         throw "not implemented";
    }                 

    createFeatureLayer(layerName : string, style : any) : any {
        throw "not implemented";
     }        

}
Run Code Online (Sandbox Code Playgroud)

即使函数参数属于不同类型,我也会收到指示重复标识符的编译器错误.即使我在第二个createFeatureLayer函数中添加了一个额外的参数,我仍然会遇到编译器错误.想法,请.

overloading typescript

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

TypeScript或JavaScript类型转换

如何在TypeScript或Javascript中处理类型转换?

假设我有以下TypeScript代码:

module Symbology { 

    export class SymbolFactory { 

        createStyle( symbolInfo : SymbolInfo) : any { 
            if (symbolInfo == null)
            {
                 return null;
            }

            if (symbolInfo.symbolShapeType === "marker") {      

                // how to cast to MarkerSymbolInfo          
                return this.createMarkerStyle((MarkerSymbolInfo) symbolInfo);
            }                                  
        }

        createMarkerStyle(markerSymbol : MarkerSymbolInfo ): any { 
            throw "createMarkerStyle not implemented";
        }              

    }
}
Run Code Online (Sandbox Code Playgroud)

哪里SymbolInfo是基类.如何从处理类型转换SymbolInfoMarkerSymbolInfo以打字稿或Javascript?

casting typescript

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

在哪里可以找到用于升级到System.Web.Http v5.0.0.0的NuGet包?

刚升级ASP.NET MVC4项目以使用Unity.WebApi版本5.0.0.0,它需要System.Web.Http v 5.0.0.0,因为以下错误:

Assembly 'Unity.WebApi, Version=5.1.0.0, Culture=neutral, PublicKeyToken=43da31bc42a85347' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'   
Run Code Online (Sandbox Code Playgroud)

我目前正在引用System.Web.Http v4.0但是将以下NuGet包升级到各自的最新版本:

  • ANTLRv3
  • Microsoft ASP.NET通用提供程序
  • Microsoft.Web.Infrastructure
  • Microsoft ASP.NET MVC
  • Microsoft ASP.NET Razor
  • Microsoft ASP.NET Universal Providers核心库
  • Microsoft ASP.NET通用提供程序
  • Microsoft ASP.NET Web API 2客户端
  • Microsoft ASP.NET Web API 2核心
  • Microsoft ASP.NET Web API 2 Web主机
  • Microsoft ASP.NET Web API 2
  • Microsoft ASP.NET网页
  • Microsoft.Web.Infrastructure
  • WebGrease

    通过NuGet.我没有列出相关的JavaScript库,如Micrososft.jQuery.Unobtrusive Validation等.

什么是升级System.Web.Http的NuGet包,还是我必须手动执行此操作?

.net c# nuget asp.net-mvc-4 asp.net-web-api2

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

TypeScript类型的数组用法

我有一个像这样开始的TypeScript类定义;

module Entities {          

    export class Person {
        private _name: string;
        private _possessions: Thing[];
        private _mostPrecious: Thing;

        constructor (name: string) {
            this._name = name;
            this._possessions = new Thing[100];
        }
Run Code Online (Sandbox Code Playgroud)

看起来像Thing类型的数组无法正确转换为相应的Javascript数组类型.这是生成的JavaScript的一个片段:

function Person(name) {
    this._name = name;
    this._possessions = new Entities.Thing[100]();
}
Run Code Online (Sandbox Code Playgroud)

执行包含Person对象的代码,在尝试初始化_possession字段时抛出异常:

错误是"0x800a138f - Microsoft JScript运行时错误:无法获取属性'100'的值:对象为null或未定义".

如果我将_possession的类型更改为any[] 和初始化_possession new Array()没有抛出异常.我错过了什么?

arrays typescript

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

通过FTP连接到Azure网站

我使用什么登录凭据连接到Azure仪表板上列出的FTP站点?我尝试使用我用于登录Azure的相同凭据,但这是失败的.TIA.

ftp azure azure-web-sites

89
推荐指数
3
解决办法
9万
查看次数

使用数据绑定到图像src属性的Knockout模板不起作用

我看不出这里有什么问题,但使用以下Knockout模板无法显示图像:

<script type="text/html" id="legend-template">       
    <div><input type="checkbox" data-bind="click : doSomething" ></input>
        <img width="16px" height="16px" data-bind="src: 'imagePath'" />          
        <span data-bind="text : label"> </span>
    </div>        
</script>
Run Code Online (Sandbox Code Playgroud)

这个绑定的对象看起来像这样:

tut.myObject= function (imagePath, label) {
    this.label = ko.observable(label);
    this.imagePath = ko.observable(imagePath || liveString + '/Content/images/marker.png');   
};

tut.myObject.prototype = {
    doSomething: function () { alert("do what?");
     }
};
Run Code Online (Sandbox Code Playgroud)

渲染HTML对象时,我看到标签,然后单击复选框调用doSomething.

TIA.

data-binding knockout.js knockout-templating

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

相交LINQ查询

如果我有一个IEnumerable,其中ClassA公开了类型为long的ID属性.是否可以使用Linq查询获取具有属于第二个IEnumerable的ID的ClassA的所有实例?

换句话说,这可以做到吗?

IEnumerable<ClassA> = original.Intersect(idsToFind....)?
Run Code Online (Sandbox Code Playgroud)

原来是IEnumerable<ClassA>和idsToFind的地方IEnumerable<long>.

.net c# linq

48
推荐指数
4
解决办法
8万
查看次数

wPF VisualTreeHelper.GetParent返回错误的类?

我定义了以下XAML.

<Popup x:Class="EMS.Controls.Dictionary.MapTip"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    PopupAnimation="Slide"
     AllowsTransparency="True" Placement="Mouse"       
       x:Name="root"                   
      >

    <Popup.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Popup.Resources>
    <Viewbox x:Name="viewBox" IsHitTestVisible="True">
        <Grid Background="Transparent" Name="mainGrid">

        </Grid>
    </Viewbox>
</Popup>
Run Code Online (Sandbox Code Playgroud)

如果我使用来自"mainGrid"的VisualTreeHelper.GetParent走向可视树,我最终得到System.Windows.Controls.Primitives.PopupRoot,但永远不会获得Popup本身.任何人都有关于为什么会这样做以及我能做些什么的理论?我需要Popup而不是PopupRoot.

TIA.

wpf

13
推荐指数
3
解决办法
9179
查看次数

WPF MenuItem.Command绑定到ElementName结果到System.Windows.Data错误:4:无法找到带引用的绑定源

我有以下XAML:

<UserControl x:Class="EMS.Controls.Dictionary.TOCControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="clr-namespace:EMS.Controls.Dictionary.Models"
    xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
    x:Name="root"  >

    <TreeView                    
        x:Name="TOCTreeView"                    
        Background="White"
         Padding="3,5"      
        ContextMenuOpening="TOCTreeView_ContextMenuOpening"
        ItemsSource="{Binding Children}" BorderBrush="{x:Null}"  >

        <TreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Path=Children, Mode=OneTime}">
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <!--<ColumnDefinition Width="Auto"/>-->                       
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <!--<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsVisible}"/>-->   
                    <ContentPresenter Grid.Column="0" Height="16" Width="20"
                                    Content="{Binding LayerRepresentation}"  />
                    <!--<ContentPresenter Grid.Column="1"      >
                        <ContentPresenter.Content>
                            Test
                        </ContentPresenter.Content>
                    </ContentPresenter>-->
                    <TextBlock Grid.Column="2" FontWeight="Normal" Text="{Binding Path=Alias, Mode=OneWay}" >
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Description}" TextWrapping="Wrap"/>
                        </ToolTipService.ToolTip>
                    </TextBlock>
                </Grid>
                <HierarchicalDataTemplate.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Path=Children, Mode=OneTime}">
                        <!--<DataTemplate>-->
                        <Grid >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>                               
                                <ColumnDefinition …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf xaml

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

.NET暂停调度程序处理时无法执行此操作

我在实现System.ComponentModel.INotifyPropertyChanged的基类中有以下方法:

protected virtual void RaisePropertyChangedEventSynchronous(string propertyName)
{                    
    try
    {
        if (PropertyChanged != null)
        {
            Delegate[] delegates = this.PropertyChanged.GetInvocationList();
            foreach (PropertyChangedEventHandler handler in delegates)
            {                      
                try
                {
                    DispatcherObject dispatcherInvoker = handler.Target 
                        as DispatcherObject;
                    if (dispatcherInvoker != null)
                    {                                
                        dispatcherInvoker.Dispatcher.Invoke(DispatcherPriority.Normal, 
                            new Action(delegate
                        {
                            handler(this, new PropertyChangedEventArgs(propertyName));
                        }));
                    }
                    else
                    {
                        handler(this, new PropertyChangedEventArgs(propertyName));
                    }
                }
                catch (Exception ex)
                {                     
                    ExceptionPolicy.HandleException(ex, 
                        ExceptionHandlingPolicyNames.LogPolicy);
                }
            }
        }
    }
    catch (Exception ex)
    {
         ExceptionPolicy.HandleException(ex, ExceptionHandlingPolicyNames.LogPolicy);
    }
}
Run Code Online (Sandbox Code Playgroud)

有时,我会将以下异常记录到文件中:

类型:System.InvalidOperationException,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089消息:暂停调度程序处理时无法执行此操作.来源:WindowsBase帮助链接:数据:System.Collections.ListDictionaryInternal TargetSite:Void …

.net wpf

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