问题列表 - 第47400页

C#可以从派生类调用基类属性

我有一个基类,其属性具有setter方法.有没有办法从派生类调用基类中的setter,并为其添加更多功能,就像使用base关键字的overriden方法一样.

对不起,我应该添加一个例子.这是一个例子.希望我做对了:

public class A 
{
    public abstract void AProperty 
    {
        set 
        {
            // doing something here
        }
    }
}

public class B : A 
{   
    public override void AProperty 
    {
        set 
        {
            // how to invoke the base class setter here

            // then add some more stuff here
        }
    }   
}
Run Code Online (Sandbox Code Playgroud)

c# setter overriding

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

在android中进行http调用的最佳做法是什么?

所以我需要进行一些http调用,这些调用返回包含单个或一组json对象的JSON响应.我有整个部分的执行http客户端调用和工作,它返回一个带有json响应的字符串.

所以我的问题是:什么是使调用异步的最佳方法.我目前正在使用异步任务调用方法,该方法在后台方法中返回字符串,并通过另一个调用解析用于解析的静态方法解析字符串,该方法返回包含我发送到postExecute部分的所有数据的POJO根据结果​​将结果呈现给ui.这是一个好习惯还是有更好的方法?

我在考虑引入接口来提供数据,例如onSuccess listener和onFail Listener.那有什么建议吗?

谢谢.

multithreading android http

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

wpf VisualState与wpfToolkit冲突?

我正在使用wpfToolkit 3.5作为引用程序集在VS2010中构建应用程序.

我试图从ExpressionBlend 4添加一些VisualStates,当我尝试构建项目时,我收到以下错误.

类型'System.Windows.VisualState'存在于'c:\ Program Files(x86)\ Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\PresentationFramework.dll'和'c:\ Program Files(x86)\ WPF Toolkit\v3.5.50211.1\WPFToolkit.dll'

这是代码

<VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="ShowHideRoomNumber">
            <VisualState x:Name="Show"/>
            <VisualState x:Name="Hide">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="comboBox">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
Run Code Online (Sandbox Code Playgroud)

我也试过了,但发生了同样的错误

xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit"

<vsm:VisualStateManager.VisualStateGroups>
        <vsm:VisualStateGroup x:Name="ShowHideRoomNumber">
            <vsm:VisualState x:Name="Show"/>
            <vsm:VisualState x:Name="Hide">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="comboBox">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </vsm:VisualState>
        </vsm:VisualStateGroup>
    </vsm:VisualStateManager.VisualStateGroups>
Run Code Online (Sandbox Code Playgroud)

有什么建议?

谢谢

wpf expression-blend

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

jQuery - 确定输入元素是文本框还是选择列表

我如何确定jQuery中的:input过滤器返回的元素是文本框还是选择列表?

我希望每个都有不同的行为(文本框返回文本值,选择返回键和文本)

示例设置:

<div id="InputBody">
<div class="box">
    <span id="StartDate">
        <input type="text" id="control1">
    </span>
    <span id="Result">
        <input type="text" id="control2">
    </span>
    <span id="SelectList">
        <select>
            <option value="1">Option 1</option>
            <option value="2">Option 2</option>
            <option value="3">Option 3</option>
        </select>
    </span>
</div>
<div class="box">
    <span id="StartDate">
        <input type="text" id="control1">
    </span>
    <span id="Result">
        <input type="text" id="control2">
    </span>
    <span id="SelectList">
        <select>
            <option value="1">Option 1</option>
            <option value="2">Option 2</option>
            <option value="3">Option 3</option>
        </select>
    </span>
</div>
Run Code Online (Sandbox Code Playgroud)

然后脚本:

$('#InputBody')
    // find all div containers with class = "box"
    .find('.box')
    .each(function () {
        console.log("child: " …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-selectors

84
推荐指数
3
解决办法
10万
查看次数

如何在类定义之外的模板类中定义模板函数?

鉴于:

template <class T>
class Foo
{
public:
    template <class U>
    void bar();
};
Run Code Online (Sandbox Code Playgroud)

如何在仍然可以访问模板参数T和U的同时在类定义之外实现bar?

c++ templates

34
推荐指数
1
解决办法
5666
查看次数

从客户端端点配置获取/修改地址

我想将端点配置存储在.config文件中,但能够在运行时修改基址.EG:这些是我在app.config中的端点定义:

<endpoint address="net.tcp://BASEURI:1001/FooService/"
          binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common"
          contract="ServiceContracts.MyService"
          name="FooService" />

<endpoint address="net.tcp://BASEURI:1002/BarService/"
          binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Special"
          contract="ServiceContracts.MyService"
          name="BarService" />
Run Code Online (Sandbox Code Playgroud)

每个服务使用相同的合同(ServiceContracts.MyService),但生活在不同的端口,不同的路径,有时是不同的绑定配置.

我希望能够以编程方式提取地址"net.tcp:// BASEURI/FooService /",将"BASEURI"替换为服务器的地址,然后在创建客户端连接时将其作为地址传递给DuplexChannelFactory.例如:

string ServiceToUse = "FooService";

var endpointConfig = SomeFunctionThatGetsTheConfig(ServiceToUse);
string trueAddress = endpointConfig.Address.Replace("BASEURI", "192.168.0.1");
DuplexChannelFactory<FooService> client = 
    new DuplexChannelFactory<FooService>(ServiceToUse, new EndpointAddress(trueAddress));
Run Code Online (Sandbox Code Playgroud)

我知道客户端端点不支持服务端点的<baseAddress>功能,但我的目的是以某种方式解决这个问题,以便我不必知道URI的其余部分或绑定是什么.

注意:我没有使用Proxy类,我直接使用DuplexChannelFactory.

wcf .net-3.5

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

如何使用html5 localStorage在iphone Safari上缓存javascript?

我正在构建一个使用主jquery库和我们自己的js的移动网站.我们的网站太大,数据太多,无法成为简单的离线/在线网络应用.我们需要网络连接.

我正在尝试提高缓存性能,以便为移动网站缓存大量的javascript.众所周知,iPhone的Safari上的缓存仅限于15-25kb的文件,而我们的缩小js约为125kb.

我已经考虑过使用缓存清单,但这样做的缺点是浏览器会在每次加载页面时请求缓存清单,而且由于我们没有使用单页面Web应用程序,因此会向服务器添加额外的请求.

我们可以在localStorage中缓存javascript(在移动safari和android浏览器中可用),然后从那里执行它吗?

javascript mobile html5 caching local-storage

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

在c#中的String.indexof之后获取String

我目前正在使用C#开发一个应用程序,我需要在字符串中的某个字符后获取子字符串.

else if (txtPriceLimit.Text.Contains('.') && char.IsNumber(e.KeyChar))
{
    int index = txtPriceLimit.Text.IndexOf('.');
    string pennies = txtPriceLimit.Text.Substring(index, txtPriceLimit.Text.Length);
    Console.WriteLine("Pennies: " + pennies);
}
Run Code Online (Sandbox Code Playgroud)

出于某种原因,它一直在想出一个IndexOutOfRangeException.如何从索引到结尾获取字符串的内容?

感谢您的任何帮助,您可以提供.

编辑: 刚刚发现我已经尝试的各种事情似乎确实有效,除了它没有从最后一个按钮获取值到文本字段.我正在使用KeyPress事件来执行此操作.

例如,如果我输入.123,它将只打印12.然后,如果我在末尾添加4,它将打印123

c# string substring

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

Yahoo Finance所有货币都引用API文档

我已经使用这个feed很长一段时间了,我相信Apple也可以在其中一个mac小部件中使用它.但真正令人好奇的是,我根本找不到任何文档,我已经尝试过谷歌和一切.

http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote

我可以看到人们使用不同的参数,view=basic date=Ymd; currency=true但是可怕的是没有任何正式的.

现在我使用这些参数:

format=jsoncallback=list有时...

但对我来说,这仍然是一个谜.有没有人知道它的真实情况,因为雅虎似乎试图隐藏它在其他地方:)

api yahoo json finance currency

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

我为什么要在List <T>上返回IList <T>?

可能重复:
C# - List <T>或IList <T>

它写的是你应该IList<T>从你的方法返回而不是,List<T>但我找不到任何真正好的理由.我一直在寻找执行此操作的代码,然后调用代码通常执行以下两项操作之一:

  1. 调用new List<T>(returnedIList)它可以使用List上的所有好方法
  2. 强制转换为List<T>可以使用List上的所有好方法

第一个是笨重的,第二个是抛出(运行时), InvalidCastException如果实现实际上已经改变为其他东西(这使得它完全是愚蠢的).

如果我使用List<T>并且由于某种原因必须将其替换为IList<T>我无法继承的实现,List<T>那么我将得到构建错误并且必须更改一些代码.这可能是非常不可能的,如果发生这种情况,修复工作并不是很多.当然,不值得失去List<T>和/或不得不投射/新List<T>(存在,查找等)的好处,以便让他们回到这种不太可能的情况?

那么,还有其他原因可以归还IList<T>吗?

.net c# generics interface

15
推荐指数
2
解决办法
4852
查看次数