问题列表 - 第19090页

WPF Converter casting causes Visual Studio designer exception

A converter such as what follows will cause the 2008 visual studio designer to not display the xaml, and error out with a "Specified cast is not valid." exception.

public class ItemsVisibilityToGridColumnWidthConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        //THE TWO OFFENDING LINES...
        var itemsVisibility = (Visibility)values[0];
        var orientation = (Orientation)values[1];

        if (orientation == Orientation.Horizontal && itemsVisibility != Visibility.Visible)
        {
            return new GridLength(0);
        }

        return new GridLength(4, GridUnitType.Star);
    }

    public object[] ConvertBack(object value, …
Run Code Online (Sandbox Code Playgroud)

c# wpf visual-studio-2008 visual-studio

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

Logging into facebook with python

If I run the following code 10 times in a row, it will work about half the time and fail the rest. Anyone know why?

import urllib2, cookielib, re, os, sys

class Facebook():
    def __init__(self, email, password):
        self.email = email
        self.password = password

        cj = cookielib.CookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        opener.addheaders = [('Referer', 'http://login.facebook.com/login.php'),
                            ('Content-Type', 'application/x-www-form-urlencoded'),
                            ('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)')]
        self.opener = opener

    def login(self):
        url = 'https://login.facebook.com/login.php?login_attempt=1'
        data = "locale=en_US&non_com_login=&email="+self.email+"&pass="+self.password+"&lsd=20TOl" …
Run Code Online (Sandbox Code Playgroud)

python

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

如何使用 NMS 和 C# 识别 ActiveMQ 断开连接

我有一个 C# 发布者和订阅者,它们使用 ActiveMQ 和 NMS 相互交谈。一切正常,除了我无法知道 ActiveMQ 何时出现故障。这对消费者来说尤其不利。他们停止获取数据,但除了数据停止显示这一事实之外,不会引发任何错误或事件。

有没有办法使用 NMS(特别是 Apache.NMS.IConnection 或 Apache.NMS.ISession 对象)

我从 Spring 下载了我正在使用的实现,但我没有使用任何特定的 spring 实现,我使用的所有内容都在 Apache.NMS 和 Apache.NMS.ActiveMQ 命名空间中。

activemq-classic

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

ActiveRecord - automatically merging model data as an aggregate

Lets say I have two tables.

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string    :type, :default => 'User'
      t.string    :user_name, :null => false
      t.boolean   :is_registered, :default => true
      # ... many more fields
    end
  end
end

class CreateContactInfo < ActiveRecord::Migration
  def self.up
    create_table :contact_info do |t|
      t.integer :resource_id
      t.string :resource_type
      t.string :first_name
      t.string :last_name
      t.string :middle_initial
      t.string :title
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

class ContactInfo < ActiveRecord::Base
  belongs_to :contactable, :polymorphic => true
end

class User < ActiveRecord::Base
  has_one :contact_info, …
Run Code Online (Sandbox Code Playgroud)

activerecord ruby-on-rails

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

使用LINQ2SQL在ASP.NET MVC中跨各种模型存储库共享数据上下文

我的应用程序中有2个存储库,每个存储库都有自己的datacontext对象.

最终结果是我尝试将从一个存储库检索到的对象附加到从不同存储库检索到的对象,从而导致异常.

c# asp.net-mvc linq-to-sql

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

Google Closure minifier在线?

有没有人为Google的Closure minifier 设置在线复制/粘贴实用程序?

我正在开发一个项目,我想手动缩小部分代码,而不必自己设置整个项目.

javascript minify google-closure

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

jquery count属性的元素

我可以计算具有特定属性的元素数量吗?

例如,所有具有src属性test.gif的图像

jquery count

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

有没有什么理由可以解释我是否应该通过GET或POST传递参数?

在我的框架的设计过程中,我想到了将POST和GET参数合并为一个单独的$ parameters变量.

开发人员的优势:框架过滤所有参数值以再次保护XSS攻击(即有趣的孩子插入错误的javascript代码以将访问者重定向到垃圾邮件站点)以及其他类型的有用验证/过滤.

但像往常一样:分离POST和GET是否有任何真正的优势,而不是因为它们来自不同的来源它们只是不同?

我的意思是:那有关系吗?当POST参数与GET参数同名时,两者都真的被使用,它会在任何时候都是"好设计"吗?在我看来这很难看,但也许有人有一个很好的解释为什么我甚至不应该尝试合并POST和GET.

在任何情况下我都会认为POST会覆盖GET.我希望得到诚实的答案:-)

web-applications

7
推荐指数
2
解决办法
224
查看次数

有什么方法可以模拟F5 BIG-IP服务器吗?

我们有一个使用F5 BIG-IP服务器进行负载平衡的潜在客户端.在确定我们是否可以将我们的产品与其负载均衡器完全集成时,我开始查看F5提供的API.问题是,如果没有F5服务器,我无法使用其API运行任何自定义代码.有谁知道是否有相应的软件进行测试?

当我试图了解F5产品如何工作时,创建我自己的模拟并没有帮助.我想点击各种API函数,并了解返回的内容.

big-ip f5

6
推荐指数
1
解决办法
6911
查看次数

用于<label for ="x">的Selenium定位器

使用ASP.NET,标签ID非常不稳定,所以为了使我的测试更加健壮,我想通过标签文本定位元素.我已经和WatiN玩了一些并且完美地做到了这一点但是现在这个项目似乎有点死了所以我认为在决定框架之前我也会考虑Selenium.

我有html看起来像这样

<label for="ctl00_content_loginForm_ctl01_username">Username</label>:
<input type="text" id="ctl00_content_loginForm_ctl01_username" />
Run Code Online (Sandbox Code Playgroud)

我不想输入:

selenium.Type("ctl00_content_loginForm_ctl01_username", "xxx");
Run Code Online (Sandbox Code Playgroud)

这太依赖于身份证.在WatiN我会写:

browser.TextField(Find.ByLabelText("Username")).TypeText("xxx");
Run Code Online (Sandbox Code Playgroud)

有没有办法在Selenium做到这一点?

testing selenium watin web-testing selenium-rc

11
推荐指数
2
解决办法
4万
查看次数