假设我有一个MyClass<T>需要比较两个类型对象的泛型<T>.通常我会做......
void DoSomething(T o1, T o2)
{
if(o1.Equals(o2))
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
现在假设我MyClass<T>有一个支持传递自定义的构造函数IEqualityComparer<T>,类似于Dictionary<T>.在那种情况下,我需要做......
private IEqualityComparer<T> _comparer;
public MyClass() {}
public MyClass(IEqualityComparer<T> comparer)
{
_comparer = comparer;
}
void DoSomething(T o1, T o2)
{
if((_comparer != null && _comparer.Equals(o1, o2)) || (o1.Equals(o2)))
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
要删除这个冗长的if语句,_comparer如果使用常规构造函数,我可以默认使用'default comparer'.我搜索了类似的东西,typeof(T).GetDefaultComparer()却找不到类似的东西.
我找到了EqualityComparer<T>.Default,我可以用它吗?然后这个片段......
public MyClass()
{
_comparer = EqualityComparer<T>.Default;
}
void DoSomething(T o1, T o2)
{
if(_comparer.Equals(o1, o2))
{ …Run Code Online (Sandbox Code Playgroud) 目前我可以想到三个案例:
我是否对这些案件是正确的,还有其他我现在看不到的情况吗?
在我的手机上,在safari中如果我转到我alert("Hello")在身体onload事件上的默认页面,警报显示我的默认页面在后台完全可见.如果我然后转到另一个站点,例如bbc.co.uk,然后在地址栏中键入我的默认页面的网址,则警报会在后台显示BBC内容,就像页面前的警报加载一样装了.
如何在整个页面可见后才显示消息.我已经读过,window.onload等到所有内容都被加载才会触发警报但我必须得到错误,因为行为不会改变.我也尝试过:
$(document).ready(function () {
window.onload= alert('Test');
});
Run Code Online (Sandbox Code Playgroud)
和
<meta http-equiv="Pragma" content="no-cache"/>
Run Code Online (Sandbox Code Playgroud)
如果它与缓存有关,但我不认为这是问题.有任何想法吗 ?
谢谢
我正在尝试将CKEditor添加到我正在开发的页面中但是在获取它来获取我的自定义配置文件时遇到了问题?我在Visual Studio.NET 2008中使用CKEditor.我需要自定义显示的工具栏,因为Basic太小而Full会给用户提供大量的按钮.
我在aspx页面中声明编辑器如下:
<script type="text/javascript">
CKEDITOR.replace(document.getElementById("<%= txtTourItinerary.ClientID %>"),
{ customConfig: 'myconfig.js' }
);
</script>
Run Code Online (Sandbox Code Playgroud)
myconfig.js文件本身位于ckeditor目录的根目录中(config.js所在的位置).
但是,desipite呈现CKEditor本身,似乎完全忽略了我的自定义配置文件.我想知道是否有人有任何建议?
谢谢!
自定义配置文件的内容如下:
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
config.language = 'en';
config.defaultLanguage = 'en';
config.uiColor = '#000000';
};
CKEDITOR.config.toolbar_Full = [['Save', '-', 'Preview', '-' 'Print'],
['Undo', 'Redo'], ['Cut', 'Copy', 'Paste', 'PasteFromWord', 'SelectAll'],
['Find', 'Replace'],
'/',
['Bold', 'Italic', 'Unnderline', 'Strike', '-', 'Subscript', 'Superscript']];
Run Code Online (Sandbox Code Playgroud) 所以我试图绑定到ListView项中的列表,但似乎无法正确绑定。如果有人可以帮助我解决正确的绑定问题,那就太好了!
这是您可能需要的来源:
//class that xaml is initially bound to
public partial class UploadMngPanel : Grid
{
....
//initial list to bind to
public ObservableCollection<FinishedAnimeCollection> UploadedAnime
{
get { return uploadedAnime; }
}
}
public class FinishedAnimeCollection
{
...
//second list to bind to
private ObservableCollection<AnimeEpisodeItem> _episodes = new ObservableCollection<AnimeEpisodeItem>();
public ObservableCollection<AnimeEpisodeItem> Episodes
{
get { return _episodes; }
}
}
public class AnimeEpisodeItem
{
public String Title { get; set; }
public DateTime TimeAdded { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我尝试修复的XAML如下 …
我一直在尝试使用ehcache配置JPA但直到现在都没有成功.我正在做的配置是:
persistence.xml中
<persistence-unit name="customDatabase">
<jta-data-source>jdbc/oracleXE_DS</jta-data-source>
<class>com.td.waw.cse.entities.Product</class>
<properties>
<property name="openjpa.Log" value="DefaultLevel=TRACE, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
<property name="openjpa.QueryCache" value="net.sf.ehcache.openjpa.datacache.EhCacheQueryCache"/>
<property name="openjpa.DataCacheManager" value="net.sf.ehcache.openjpa.datacache.EhCacheDataCacheManager"/>
<property name="openjpa.DataCache" value="net.sf.ehcache.openjpa.datacache.EhCacheDataCache"/>
<property name="openjpa.RemoteCommitProvider" value="net.sf.ehcache.openjpa.datacache.NoOpRemoteCommitProvider"/>
</properties>
Run Code Online (Sandbox Code Playgroud)ehcache.xml中
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true" monitoring="autodetect"
dynamicConfig="true" >
<defaultCache
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="false"
memoryStoreEvictionPolicy="LRU"
/>
<!-- OpenJPA data cache -->
<cache name="openjpa"
maxElementsInMemory="5000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="false"
memoryStoreEvictionPolicy="LRU"
/>
<!-- OpenJPA query cache -->
<cache name="openjpa-querycache"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="false"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
Run Code Online (Sandbox Code Playgroud)Product.java
@Entity
@Table(name="PRODUCT")
@NamedQueries({@NamedQuery(name="getAllProducts", query = "select products from …Run Code Online (Sandbox Code Playgroud)我正在构建一个源自System.Windows.Forms.ContainerControl它的控件,它有一个我需要绘制自己的边框区域.由于没有OnPaintNonClientArea覆盖,我自己就像这样构建它(处理其他消息,例如WM_NCCALCSIZE,WM_NCHITTEST为了简洁而删除):
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCPAINT:
IntPtr hDC = NativeApi.Methods.GetWindowDC(m.HWnd);
if (hDC != IntPtr.Zero)
{
using (Graphics canvas = Graphics.FromHdc(hDC))
{
if (Width > 0 && Height > 0)
using (PaintEventArgs e = new PaintEventArgs(canvas, new Rectangle(0, 0, Width, Height)))
{
OnPaintNonClientArea(e);
}
}
NativeApi.Methods.ReleaseDC(m.HWnd, hDC);
}
m.Result = IntPtr.Zero;
break;
}
base.WndProc(ref m);
}
Run Code Online (Sandbox Code Playgroud)
在内OnPaintNonClientArea,我做了:
private void OnPaintNonClientArea(PaintEventArgs e)
{
if (_ncBuffer …Run Code Online (Sandbox Code Playgroud) 我有一个很好的动画图像.它由180个高质量的图像组成,它可以很好地循环播放.我的问题是,第一次加载包含这些图像的视图时,需要很长时间才能加载.之后的每一次都会立即加载,因为我假设图像已被缓存或预加载!我来自闪光背景,因为我确信你知道预装载器和muck一样普遍,所以我觉得这不应该很难找到但是经过无数的谷歌搜索我找不到任何关于预装的好例子或任何关于为什么有的文章延迟以及如何处理它.
所以我的问题是这样的:
info.plist中是否有一个复选框可以在应用程序开头预加载我的所有图像?
你怎么能预装图像,有没有我可以看到的简单示例项目?
这是实现本质上是视频但是已经输出到png序列的最佳方式吗?
还有另一种方法,因为viewDidLoad不能像我期望的那样工作.它跟踪"完成的加载图像"(参见下面的代码),但视图在图像加载后没有显示一两秒,所以如果视图在图像加载之前没有显示,那么UIActivityIndicatorView也不会相同的观点.
你如何在目标c中进行事件倾听?
下面是viewDidLoad中的代码,我认为它是相当标准的:
我非常感激任何帮助,因为我正在敲打砖墙上看起来在ui开发中看起来非常基本的东西.救命 :)
- (void)viewDidLoad {
[super viewDidLoad];
imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT];
NSLog(@"START LOADING IMAGES");
// Build array of images, cycling through image names
for (int i = 0; i < IMAGE_COUNT; i++){
[imageArray addObject:[UIImage imageNamed: [NSString stringWithFormat:@"Main_%d.png", i]]];
}
animatedImages = [[UIImageView alloc] initWithFrame:CGRectMake(0,20,IMAGE_WIDTH, IMAGE_HEIGHT)];
animatedImages.animationImages = [NSArray arrayWithArray:imageArray];
animatedImages.animationDuration = 6.0;
animatedImages.animationRepeatCount = 0;
[self.view addSubview:animatedImages];
animatedImages.startAnimating;
[animatedImages release];
NSLog(@"FINISH LOADING IMAGES");
}
Run Code Online (Sandbox Code Playgroud)
干杯
中号
c# ×4
.net ×1
asp.net ×1
assemblies ×1
ckeditor ×1
comparison ×1
data-binding ×1
ehcache ×1
gdi ×1
gdi+ ×1
generics ×1
html ×1
ipad ×1
iphone ×1
java ×1
javascript ×1
jpa ×1
listview ×1
objective-c ×1
resources ×1
safari ×1
toolbar ×1
wpf ×1