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函数中添加了一个额外的参数,我仍然会遇到编译器错误.想法,请.
如何在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是基类.如何从处理类型转换SymbolInfo到MarkerSymbolInfo以打字稿或Javascript?
刚升级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包升级到各自的最新版本:
WebGrease
通过NuGet.我没有列出相关的JavaScript库,如Micrososft.jQuery.Unobtrusive Validation等.
什么是升级System.Web.Http的NuGet包,还是我必须手动执行此操作?
我有一个像这样开始的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()没有抛出异常.我错过了什么?
我使用什么登录凭据连接到Azure仪表板上列出的FTP站点?我尝试使用我用于登录Azure的相同凭据,但这是失败的.TIA.
我看不出这里有什么问题,但使用以下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.
如果我有一个IEnumerable,其中ClassA公开了类型为long的ID属性.是否可以使用Linq查询获取具有属于第二个IEnumerable的ID的ClassA的所有实例?
换句话说,这可以做到吗?
IEnumerable<ClassA> = original.Intersect(idsToFind....)?
Run Code Online (Sandbox Code Playgroud)
原来是IEnumerable<ClassA>和idsToFind的地方IEnumerable<long>.
我定义了以下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.
我有以下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) 我在实现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 ×3
typescript ×3
wpf ×3
c# ×2
data-binding ×2
arrays ×1
azure ×1
casting ×1
ftp ×1
knockout.js ×1
linq ×1
nuget ×1
overloading ×1
xaml ×1