我有一个Web服务,它将传递一些数据(特别是来自SharePoint文档库的InfoPath xml).我目前正在使用Ninject来处理要加载的数据"策略".这是一些代码(问题如下):
namespace Web.Services
{
public bool AddForm(XmlDocument form, string formName)
{
IKernel kernel = new StandardKernel(new FormsModule());
var ctx = kernel.Get<IPFormDataContext>(formName);
return ctx.DoWork(form);
}
}
Run Code Online (Sandbox Code Playgroud)
namespace Core.Modules
{
public class FormsModule : NinjectModule
{
public override void Load()
{
Bind<IPFormDataContext>().ToSelf().Named("FormA");
Bind<IPFormDataContext>().ToSelf().Named("FormB");
// Snip
Bind<IPFormDataStrategy>().To<FormAStratgey>()
.WhenParentNamed("FormA");
Bind<IPFormDataStrategy>().To<FormBStrategy>()
.WhenParentNamed("FormB");
// Snip
}
}
}
Run Code Online (Sandbox Code Playgroud)
namespace Core.Forms
{
public class IPFormDataContext
{
private IPFormDataStrategy _ipFormDataStrategy;
public IPFormDataContext(IPFormDataStrategy strategy)
{
_ipFormDataStrategy = strategy;
}
public bool DoWork(XmlDocument form)
{
return …Run Code Online (Sandbox Code Playgroud) 我有一个大约1000个对象的ObservableCollection需要由最终用户过滤(搜索).用户必须能够按名称或员工ID进行搜索.列表控件使用FilteredEmployees和Employees在页面加载时加载了所有内容.
我目前设置如下:
public ObservableCollection<EmployeeServicesData> Employees { get; set; }
public ObservableCollection<EmployeeServicesData> FilteredEmployees { get; set; }
internal void FilterEmployee(string searchText, bool isByName)
{
if (searchText.Length > 0)
{
IEnumerabe<EmployeeServicesData> filter;
if (isByName)
filter = Employees.Where(x => x.Name.Length >= searchText.Length).Where(x => x.Name.Substring(0, searchText.Length) == searchText.ToUpper());
else
filter = Employees.Where(x => x.EmployeeNumber.ToString().Length > searchText.Length).Where(x => x.EmployeeNumber.ToString().Substring(0, searchText.Length) == text);
foreach (EmployeeServicesData employee in filter)
FilteredEmployees.Add(employee);
}
}
Run Code Online (Sandbox Code Playgroud)
在此方法之前处理卫生.
这闻起来不是很有效.我应该使用两种方法,还是有更好的方法来处理过滤?
我希望将Employees保持在未更改状态,这样我就可以将FilteredEmployees重新填充到完整列表,而无需再次访问DB.
大约有12人正在使用此应用程序,但我们只想允许4通过传统方法关闭应用程序(Alt + F4,文件>退出,关闭)
如果使用任何其他方法(TaskManager,WindowsShutdown)或其中一个允许的用户关闭应用程序,我们需要执行一些清理(关闭一些连接通道)
private void formClosing(object sender, FormClosingEventArgs e)
{
// If a user is allowed to close the application, an empty file (filename)
// will be in the root directory of the application.
if(e.CloseReason == CloseReason.UserClosing && !File.Exists("filename"))
{
e.Cancel = true;
return;
}
// Cleanup
}
Run Code Online (Sandbox Code Playgroud)
如果用户(不允许关闭)尝试通过传统方法关闭应用程序,则尝试使用任务管理器关闭CloseReason枚举似乎不会自行重置,从而导致任务管理器弹出提示强制关闭,从而阻止清理申请.
这是一个错误,或者我错过了什么,会在FormClosing事件被取消后重置CloseReason.
当我尝试:
using (SPWeb web = site.OpenWeb("/"))
{
SPList list = web.Lists["Blah"];
SPView view = web.GetViewFromUrl("http://foo.com/Lists/Blah/View%20Name.aspx");
foreach (SPListItem item in list.GetItems(view))
{
writer.write(item.Title);
}
}
Run Code Online (Sandbox Code Playgroud)
item.Title让我得到一个ArgumentException.
但是当我使用时
foreach (SPListItem item in list.Items)
{
writer.write(item.Title);
}
Run Code Online (Sandbox Code Playgroud)
它工作得很好.
这里发生了什么?在传递视图时,如何获取列表项的标题?
我正在为一个重大项目研究/设置持续集成服务器,并且需要建议或批评.
Need
CI只是我们道路上的下一步.它是在正确的时间强制执行的,因为一个主要项目正在筹备中.
限制
到目前为止,我把它缩小到目前为止
我正在考虑4种选择:
什么是我真正的问题
根据您对上述任何一项或所有项目的经验,您所看到的任何批评或整洁的事情是什么.在安装过程中需要注意或注意的事项?如果你不得不重新做一遍,你会选择同样的东西吗?