我正在使用youtubes新的iframe代码嵌入视频,但视频质量低于我在youtube上观看时的质量.有没有办法嵌入高质量的视频?
我的代码目前是
<iframe title="YouTube video player" width="650" height="390" src="http://www.youtube.com/embed/6X3zUh8RqbY" frameborder="0" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud) 这是我第一次遇到单元测试,我试图理解如何在简单的日期验证中使用这个概念.
用户可以选择代表日期的ToDate,直到可以进行付款.如果我们的日期无效,则无法付款.
private void CheckToDate(DateTime ToDate)
{
if (Manager.MaxToDate < ToDate.Year)
//show a custom message
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下如何使用单元测试?
问候,
亚历克斯
谢谢你的回答:
正如你们许多人所建议的那样,我将拆分函数并将验证与消息显示分开,并使用单元测试.
public bool IsDateValid(DateTime toDate)
{
return (Manager.MaxToDate < toDate.Year);
}
Run Code Online (Sandbox Code Playgroud) c# unit-testing visual-studio-2010 vs-unit-testing-framework
有没有办法让实体对象通过关系自动提取所有相关数据,而不是必须.包括我想要填充的所有内容?我不能使用延迟加载,因为这需要序列化以通过WCF.让它自动填充相关集合真是太棒了.
我如何使用POST上传一个大字符串(在我的情况下使用BLOB的XML)而不使用GetResponse获取Timeout?
更改超时有帮助,但这不是一个真正的解决方案.如果服务器确实死亡或POST中断,我必须等待极端大超时.
任何的想法?
HttpWebRequest webRequest = null;
string response = "";
byte[] bytes = Encoding.UTF8.GetBytes(xml);
try
{
webRequest = (HttpWebRequest)WebRequest.Create("http://" + this.host + ":" + this.port);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
webRequest.Timeout = 5000;
webRequest.ContentLength = bytes.Length;
using (Stream requeststream = webRequest.GetRequestStream())
{
requeststream.Write(bytes, 0, bytes.Length);
requeststream.Close();
}
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (StreamReader sr = new StreamReader(webResponse.GetResponseStream()))
{
response = sr.ReadToEnd().Trim();
sr.Close();
}
webResponse.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
return response;
Run Code Online (Sandbox Code Playgroud) 基本上,我正在编写一个框架,作为其功能的一部分,它应该为最终开发人员提供一组完善的URI /路径.
这些路径中的两个使用$_SERVER['DOCUMENT_ROOT']:
/**
* Absolute filesystem path to web root install (aka docroot).
* @example "C:/wamp/www" OR "/home/visitgoz/public_html/"
*/
CFG::set('ABS_WWW',
str_replace(
$tmpseps,
DIRECTORY_SEPARATOR,
truepath($_SERVER['DOCUMENT_ROOT']).'/'
)
);
/**
* K2F path relative to web root.
* @example /K2F/
*/
CFG::set('REL_K2F',
str_replace(
array('//','\\'),
'/',
str_replace(CFG::get('ABS_WWW'),'/',CFG::get('ABS_K2F'))
)
);
Run Code Online (Sandbox Code Playgroud)
该代码已经过微调,可以在Linux和Windows上运行.显然,它大部分时间都在Linux上运行,实际上在VPS上非常无缝.
但是,最近,我在HG转销商帐户(共享托管)上试了一下,这一切都破了.我在有问题的机器上打印出$ _SERVER中的数据:
Array
(
** [DOCUMENT_ROOT] => /usr/local/apache/htdocs
[GATEWAY_INTERFACE] => CGI/1.1
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8
[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
[HTTP_ACCEPT_ENCODING] => gzip,deflate
[HTTP_ACCEPT_LANGUAGE] => en-gb,en;q=0.5
[HTTP_CONNECTION] => keep-alive
[HTTP_COOKIE] …Run Code Online (Sandbox Code Playgroud) 我有一个catalog.h文件
typedef struct node* list_node;
struct node
{
operationdesc op_ptr;
list_node next;
};
Run Code Online (Sandbox Code Playgroud)
和一个parser.h
#include "catalog.h"
int parse_query(char *input, list_node operation_list);
Run Code Online (Sandbox Code Playgroud)
两个标题有#ifndef,#define,#endif.编译器给我这个错误:expected declaration specifiers or ‘...’ before ‘list_node’在parse_query行上.怎么了?我试着把typedef放在parser.h中,没关系.当typedef在catalog.h中时,为什么会出现此错误?
我已经开始使用代码契约,并发现它很难立即发现方法的"胆量".
拿这个(非常简单)的例子:
public static void UserAddNew(string domain, string username, string displayName)
{
Contract.Assert(!string.IsNullOrWhiteSpace(domain));
Contract.Assert(!string.IsNullOrWhiteSpace(username));
Contract.Assert(!string.IsNullOrWhiteSpace(displayName));
LinqDal.User.UserAddNew(domain, username, displayName);
}
Run Code Online (Sandbox Code Playgroud)
现在我很想将合同放在一个区域,以便它们可以被隐藏起来,但是我担心我会失去一个很好的优势,能够浏览方法并看到它的期望.
你怎么做才能让你的合同"整洁"?或者我只是太挑剔了?
我有一个PHP项目,我需要显示user1向另一个用户发送消息的时间和日期,user2.当user2打开此消息时,必须根据他的时区显示时间和日期.
由于两个用户都属于不同的时区,因此它显示的是USER1输入的相同日期和时间.
例如:如果User1在2011年2月15日上午11:30在其时区发送消息,并且User2打开此消息,则必须根据其时区显示日期和时间.让我们说User2属于印度(格林尼治标准时间+5:30)然后显示消息发送15-Feb-2011, 04:30 PM.
但它显示2011年2月15日,上午11:30这是错误的.
我正在使用Microsoft提供的WPF功能区控件.
问题在于,当我使用DataTemplate填充a时RibbonApplicationSplitMenuItem,我得到一个额外的嵌套级别,我认为不应该存在.
以下是相关的WPF代码:
<Window.Resources>
<DataTemplate DataType="{x:Type cfg:PluginInfoConfigurationElement}" x:Key="GotoPluginAppMenuItem">
<ribbon:RibbonApplicationMenuItem
Header="{Binding Path=Key}"
ImageSource="{Binding Path=Image}"/>
</DataTemplate>
</Window.Resources>
<ribbon:RibbonApplicationMenu>
<ribbon:RibbonApplicationSplitMenuItem x:Name="LoadPluginMenuItem"
ItemsSource="{Binding Source={StaticResource NlpModel}, Path=AvailablePlugins}"
Header="Plugins"
ItemTemplate="{StaticResource GotoPluginAppMenuItem}">
</ribbon:RibbonApplicationSplitMenuItem>
<ribbon:RibbonApplicationSplitMenuItem x:Name="LoadPluginMenuItem2"
Header="Plugins">
<ribbon:RibbonApplicationMenuItem
Header="FooPlugin"
ImageSource="Images/icon-32.png"/>
<ribbon:RibbonApplicationMenuItem
Header="Invalid"
ImageSource="Images/icon-32.png"/>
</ribbon:RibbonApplicationSplitMenuItem>
<!-- Other items to fill the menu -->
</ribbon:RibbonApplicationMenu>
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:
使用DataTemplate http://img571.imageshack.us/img571/9915/screentemplate.png 使用数据模板.
我想要什么http://img43.imageshack.us/img43/9168/screendesired.png 没有模板.
如您所见,使用DataTemplate时会出现额外的嵌套级别.我怎么能防止这种情况?