我正在测试线程安全性以便更好地掌握,这就是我所做的:
我有一个类型调用ThreadSample,它有两个方法,这里发生锁定:
internal class ThreadTime
{
public void doSomething(string message)
{
lock (this)
{
DialogResult t = MessageBox.Show(message);
Thread.Sleep(2000);
}
}
public void anotherLife(string message)
{
MessageBox.Show("This is coming from anotherLife method and and current threadNumber is " + message);
}
}
Run Code Online (Sandbox Code Playgroud)
基本上这个想法是在doSomething()调用时,它应该锁定整个对象,而其他线程甚至可以调用anotherLife方法,因为它们正在等待其他线程释放锁.
这是模拟锁定释放的逻辑:
public partial class Form1 : Form
{
private ThreadTime time;
private Thread thread;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
thread = new Thread(new ThreadStart(workerThread)); …Run Code Online (Sandbox Code Playgroud) 好的,所以我经历过像"background-clip:padding-box"这样的答案.虽然它使最终产品看起来好一点,但它仍然不能完全解决边界外背景颜色渗出的问题.有没有人真正解决这个问题?
这是该问题的屏幕截图:

用于按钮的CSS
#footer #pager li a {
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
display: block;
float: left;
color: #444 !important;
text-decoration: none !important;
background-clip: padding-box !important;
padding: 8px 12px;
background-color: #ccc;
border: 1px solid #000;
}
Run Code Online (Sandbox Code Playgroud) 我的javascript中有一个CKEditor实例:
var editor = CKEDITOR.instances["id_corpo"];
Run Code Online (Sandbox Code Playgroud)
我需要以编程方式插入一些文本,然后选择一些文本范围.
我已经插入了文本
editor.insertHtml('<h1 id="myheader">This is a foobar header</h1>');
Run Code Online (Sandbox Code Playgroud)
但是我需要通过javascript以编程方式选择(突出显示)"foobar"这个词,以便我可以使用selenium来计算我的CKEditor插件的一些功能测试.
我也试过类似的东西
var selection = editor.getSelection();
var childs = editor.document.getElementsByTag("p");
selection.selectElement(childs);
Run Code Online (Sandbox Code Playgroud)
我觉得
selection.selectRange()
Run Code Online (Sandbox Code Playgroud)
可以做的工作,但我不知道如何使用它.那边没有例子:(
我想在横向和纵向模式下测试我的应用程序的不同行为.我有一个android.test.InstrumentationTestCase的子类,可以很好地测试我的应用程序在纵向模式下的行为,但如果我(手动)在运行测试之前将模拟器置于格局中,它就会失败.那很好 - 横向中的行为不应该通过肖像测试 - 而且我知道如何从我的测试代码中检查方向,所以我可以避免测试失败 - 但我想做的是(来自测试代码)把仿真器进入每个测试的正确状态.我怎样才能做到这一点?
我喜欢构造函数注入依赖注入.它强制从类型中明确声明问题,并有助于可测试性.
我喜欢Constructor注入,在大多数地方......
记录我不喜欢的例子.如果我有一个基类,许多其他类继承,我希望所有这些类都使用我的ILogger(或其他)的实例,我不想要一个静态工厂(Logger.Instance)...我不希望必须在每个采用ILogger的子类上声明构造函数.
所以,我可以让我的基类将logger声明为Property并让它以这种方式注入
public class MyBaseClass
{
public ILogger Logger { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
...但
那么......我还有其他选择吗?(我正在使用Castle Windsor).
我打算制作一个界面
public interface IInitializable<T>
{
void Initialize(T instance);
}
public class MyBaseClass : IInitializable<ILogger>, ...could have other IInitializables too...
{
protected ILogger Logger { get; private set; }
public void Initialize(ILogger instance)
{
Logger = instance;
}
}
Run Code Online (Sandbox Code Playgroud)
然后在我的容器上有一个工具,它自动调用所有IInitializable<T>类型构造的实现......
但在我走这条路之前,我想知道其他人的想法是什么......
.net dependency-injection castle-windsor inversion-of-control
我总是写render_views我的所有控制器规格:
require 'spec_helper'
describe AwesomeController do
render_views
end
Run Code Online (Sandbox Code Playgroud)
有没有办法总是在所有控制器规格上渲染视图?
有什么方法可以模仿这样的东西吗?是不是有用于做"半页卷曲"之类的东西的API?

我听说可以在iPhone(Objective C)项目中使用C++ Code,我想使用一个用C++编写的加密库.但是,该库使用的是一个使用构造函数的C++类型结构,我无法做到这一点.
Struct看起来像这样:
struct SBlock
{
//Constructors
SBlock(unsigned int l=0, unsigned int r=0) : m_uil(l), m_uir(r) {}
//Copy Constructor
SBlock(const SBlock& roBlock) : m_uil(roBlock.m_uil), m_uir(roBlock.m_uir) {}
SBlock& operator^=(SBlock& b) { m_uil ^= b.m_uil; m_uir ^= b.m_uir; return *this; }
unsigned int m_uil, m_uir;
};
Run Code Online (Sandbox Code Playgroud)
完整资源来源:http://www.codeproject.com/KB/security/blowfish.aspx
什么是解决这个问题最简单的方法?我已经阅读了关于在苹果开发者网站上使用c ++代码的文章,但这并没有多大帮助.
我需要从另一个UIImage(不是灰度)获得纯黑白UIImage.有人可以帮帮我吗?
谢谢阅读.
编辑:
这是建议的解决方案.谢谢大家.几乎我知道这不是更好的方法,它工作正常.
// Gets an pure black and white image from an original image.
- (UIImage *)pureBlackAndWhiteImage:(UIImage *)image {
unsigned char *dataBitmap = [self bitmapFromImage:image];
for (int i = 0; i < image.size.width * image.size.height * 4; i += 4) {
if ((dataBitmap[i + 1] + dataBitmap[i + 2] + dataBitmap[i + 3]) < (255 * 3 / 2)) {
dataBitmap[i + 1] = 0;
dataBitmap[i + 2] = 0;
dataBitmap[i + 3] = 0;
} else { …Run Code Online (Sandbox Code Playgroud) 我找到了这个方便的代码来确定我的应用程序是否处于试用模式,还具有能够在模拟器中测试试验行为的额外好处......
public bool IsTrial
{
get
{
#if DEBUG
return true;
#endif
return new LicenseInformation().IsTrial();
}
}
Run Code Online (Sandbox Code Playgroud)
这太好了.我将能够相应地调整行为.
但除此之外,我希望有一些内置的API,我可以在其中获得一个带有按钮的对话框来购买应用程序.理想情况下,按钮应该将用户直接带到市场中的应用程序.
iphone ×2
objective-c ×2
.net ×1
android ×1
animation ×1
c# ×1
c++ ×1
ckeditor ×1
constructor ×1
controller ×1
css ×1
css3 ×1
fckeditor ×1
ios ×1
javascript ×1
rspec2 ×1
selenium ×1
silverlight ×1
struct ×1
trial ×1
uiimage ×1
uiview ×1
unit-testing ×1