我目前正在建立一个新项目,我遇到了一些问题,我需要一点点输入.
这就是我在考虑的问题:
我想要一个通用的存储库
我不想从我的存储库返回IQueryable.
我想将我的查询封装在规范中.
我已经实现了规范模式
它需要易于测试
现在这是我陷入困境的地方,我的问题是哪种方式是使用一个或多个规范调用find方法的最优雅方式:
(流利): bannerRepository.Find().IsAvailableForFrontend().IsSmallMediaBanner()
或者用我的规范将查询表达为lambdas
(波长): bannerRepository.Find.Where(banner => banner.IsFrontendCampaignBanner && banner.IsSmallMediaBanner)
或者可能是其他一些方式?最重要的是,实现MVC前端的人应该具有良好的存储库直观体验.
我希望实现的是保持som灵活性,以便能够结合规范,并提供"过滤"的经验与规范,但不会泄漏IQueryable到控制器,但更像是一个ISpecifiable,只允许使用规范而不是Linq修改查询.但我是否只是以这种方式将查询逻辑泄漏给控制器?
我在里面有几个.screen文件/xxx/documentation,它的子目录已经被Git跟踪了.
在修改了许多这些屏幕文件之后,我运行git add documentation/\\*.screen-as git-add文档中的第一个示例所示- 来暂存这些文件,但命令失败:
fatal: pathspec 'documentation/\*.screen' did not match any files
我的命令不好,还是git有bug?
我喜欢将字符串的java映射编码为单个基本64位编码字符串.编码的字符串将被传输到远程端点,并且可能由不好的人操纵.因此,应该发生的最糟糕的事情是invaild key,value-tuples,但不应该带来任何其他安全风险.
例:
Map<String,String> map = ...
String encoded = Base64.encode(map);
// somewhere else
Map<String,String> map = Base64.decode(encoded);
Run Code Online (Sandbox Code Playgroud)
是的,必须是Base64.不喜欢那个 或那个 或任何其他这些.是否有现有的轻量级解决方案(Single Utils-Class首选)?或者我必须创建自己的?
有什么比这更好的?
// marshalling
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(map);
oos.close();
String encoded = new String(Base64.encodeBase64(baos.toByteArray()));
// unmarshalling
byte[] decoded = Base64.decodeBase64(encoded.getBytes());
ByteArrayInputStream bais = new ByteArrayInputStream(decoded);
ObjectInputStream ois = new ObjectInputStream(bais);
map = (Map<String,String>) ois.readObject();
ois.close();
Run Code Online (Sandbox Code Playgroud)
谢谢,
与PHP中的三等号匹配相反的是什么?
$mail_01 = filter_var($mail_01, FILTER_VALIDATE_EMAIL);
if($mail !== false){
echo "Email address required";
}
Run Code Online (Sandbox Code Playgroud)
是!==使用正确的吗?谢谢你的帮助.
我正在尝试创建一个Eclipse Form,它有三个可折叠部分,一个固定大小,另外两个应该抓住编辑器窗口中所有剩余的垂直空间,这样,当其中一个底部折叠时,另一个将填充所有可用空间.
我已阅读形式的文章,尝试了许多变化grabExcessVerticalSpace和SWT.FILL的和几乎一切的GridData的部分所提供的,但没有运气.我也试图在复合材料中嵌套部分客户端grabExcess...Space,但这也无济于事.调用layout()没有帮助,折叠部分时形式回流,折叠第一部分工作正常.
这是一个包含三个部分的表单的代码,但是其中两个底部部分在折叠时只放弃了它们的一小部分空间,而不是我想要的所有部分:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
public class SectionFormPage extends FormPage {
private IManagedForm managedForm;
public SectionFormPage(FormEditor editor) {
super(editor, "sectionEditor", "title");
}
protected void createFormContent(IManagedForm managedForm) {
this.managedForm = managedForm;
FormToolkit toolkit = managedForm.getToolkit();
Composite body = managedForm.getForm().getBody();
body.setLayout(new GridLayout());
createSectionWithButton(toolkit, body, new GridData(SWT.FILL, SWT.FILL, true, false)); …Run Code Online (Sandbox Code Playgroud) 一旦iTunes Store中有我的应用程序的新版本,是否可以强制用户升级?
我目前正在申请一个申请.但是,我想在上传新版本时强制升级,因为升级会有更多功能,我想放弃以前的版本.这是默认使用iPhone的可能吗?还是我必须编写自己的实现来检查当前版本并将其与商店进行比较?
我创建了一个带有NSOpenGLView的窗口,我正在将OpenGL内容渲染到其中.
我想在视图中添加一些按钮和文本字段:我可以使用界面构建器(或代码)添加NSTextFields和NSButton,但它们不会出现.
NSOpenGLView被记录为无法拥有子视图,因此我通过直接从NSView派生并实现代码来创建和使用NSOpenGLContext来创建我自己的CustomGLView.但是子视图仍然没有出现: - OpenGL上下文描绘了它们.
在Windows上,这个问题不存在: - 用于托管OpenGL的Windows必须设置WS_CLIPCHILDREN和WS_CHIPSIBLINGS设置样式,以确保OpenGL表面不会遮挡任何对等体或子子视图(视图).
如何在使用OpenGL绘制的NSView上显示子视图?
以下C代码说明了我在Linux 2.6.30.5-43.fc11.x86_64上看到的问题:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main() {
char buf[1024];
void *base;
int fd;
size_t pagesz = sysconf(_SC_PAGE_SIZE);
fd = open("<some file, at least 4*pagesz in length>", O_RDONLY);
if (fd < 0) {
perror("open");
return 1;
}
base = mmap(0, 4*pagesz, PROT_READ, MAP_SHARED, fd, 0);
if (base < 0) {
perror("mmap");
close(fd);
return 1;
}
memcpy(buf, (char*)base + 2*pagesz, 1024);
if (remap_file_pages(base, pagesz, 0, 2, 0) < …Run Code Online (Sandbox Code Playgroud) 我正在使用C#进行编程.
我面临的问题是,我的隐藏变量值在更新面板中时没有更新.请参阅下面的aspx代码:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">
</asp:Timer>
<input type="hidden" runat="server" id="hidCurrentDate" value="" />
<input type="hidden" runat="server" id="hidTripIds" value="" />
<input type="hidden" runat="server" id="hidTripDetails" value="" />
<asp:UpdateProgress ID="uprogTrips" runat="server">
<ProgressTemplate>
<span style="display: block; text-align: center">
<p style="font-family: Verdana; font-size: larger; font-weight: bold;">
<img src="../../Images/ajax-loader.gif" alt="Processing..." /><br />
<br />
Processing...</p>
</span>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upTripsGrid" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="gvAllTrips" runat="server" OnRowDataBound="gvAllTrips_RowDataBound"
OnPageIndexChanging="gvAllTrips_PageIndexChanging" AllowPaging="true" AutoGenerateColumns="false">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="35" Position="TopAndBottom" />
<PagerStyle CssClass="GridPager" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger …Run Code Online (Sandbox Code Playgroud) 我正在测试一个包含Firefox扩展作为一个组件的应用程序.它最初是在FF3.5.5是最新版本时部署的,并且在3.5.6和3.5.7中幸存下来.但是在FF3.6上我在我的错误控制台中得到以下内容:
Warning: reference to undefined property Components.interfaces.nsIProcess2
Source file: chrome://overthewall/content/otwhelper.js
Line: 55
Error: Component returned failure code: 0x80570018 (NS_ERROR_XPC_BAD_IID)
[nsIJSCID.createInstance]
Source file: chrome://overthewall/content/otwhelper.js
Line: 55
Run Code Online (Sandbox Code Playgroud)
抛出错误的函数是:
48 function otwRunHelper(cmd, aCallback) {
49 var file =
50 Components.classes["@mozilla.org/file/local;1"].
51 createInstance(Components.interfaces.nsILocalFile);
52 file.initWithPath(otwRegInstallDir+'otwhelper.exe');
53
54 otwProcess = Components.classes["@mozilla.org/process/util;1"]
55 .createInstance(Components.interfaces.nsIProcess2);
56
57 otwProcess.init(file);
58 var params = new Array();
59 params = cmd.split(' ');
60
61 otwNextCallback = aCallback;
62 otwObserver = new otwHelperProcess();
63 otwProcess.runAsync(params, params.length, otwObserver, false);
64 }
Run Code Online (Sandbox Code Playgroud)
如您所见,所有这些函数都运行一个外部EXE帮助文件(由注册表项定位)和一些命令行参数,并设置一个Observer以异步等待响应并处理Exit代码. …