我已经开始围绕整个MVP模式,尽管我对单个对象做得很好,但是当涉及到集合时,它开始变得困难.
所以我们假设我们正在构建一个简单的WinForms应用程序,它由一个Form中的DataGrid组成,数据Model是一个简单的东西集合,其中这些东西有很多属性,而View实际上会显示它们:
模型
public class Person
{
public string Name { get; set; }
public DateTime Birth { get; set; }
public bool IsCool { get; set; }
}
public class People
{
public List<Person> Persons { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图
public interface IPeopleView
{
List<People> ListOfPeople { get; set; }
}
public partial class PeopleViewImpl : Form, IPeopleView
{
private DataGridView _grid = new DataGridView();
public PeopleViewImpl()
{
InitializeComponent();
}
// Implementation of IPeopleView
public List<People> …Run Code Online (Sandbox Code Playgroud) 我试图理解最简单的背景转换可能只 使用HTML5和CSS3.通过stackoverflow搜索我已经知道它可以使用外部库轻松实现,jQuery但是对于这个项目,我决定不依赖于任何这些.
标记
<nav>
<ul>
<li><a id="foobar" href="http://www.google.com/search?q=foobar">Foobar</a></li>
</ul>
</nav>
Run Code Online (Sandbox Code Playgroud)
样式
body {
background: url('background-default.png'), no-repeat;
}
#foobar a:hover {
background: url('background-hover.png'), no-repeat;
-webkit-transition: // TODO;
-moz-transition: // TODO;
-o-transition: // TODO;
-ms-transition: // TODO;
transition: // TODO;
}
Run Code Online (Sandbox Code Playgroud) 我一直试图开始OutputDebugString工作,但没有用.我的代码如下:
int main(int argc, char* argv[])
{
OutputDebugStringA("asd");
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我在没有调试的情况下运行应用程序时,DebugView显示asd但是当我调试我的应用程序(F5)时,它不会在输出或中间窗口中打印我的字符串.
我尝试过OutputDebugString asd但没有改变.可能是什么问题?
这个问题有点轶事,但对我来说仍然很有趣; 我想知道为什么Visual Studio 2008不喜欢以下常量使用:
public class Service101 : ServiceBase
{
/// <remarks>
/// Shown at Start -> Settings -> Control Panel -> Administrative Tools -> Services
/// </remarks>
internal const string SERVICE_NAME = "WinSvc101";
/// <remarks>
/// Shown at Start -> Settings -> Control Panel -> Administrative Tools -> Services
/// </remarks>
internal const string DISPLAY_NAME = "Windows Service 101";
/// <summary>
/// Public constructor for Service101.
/// </summary>
public Service101()
{
InitializeComponent();
}
private void InitializeComponent()
{ …Run Code Online (Sandbox Code Playgroud) 我真的非常高兴我的第一次体验Knockout.js,非常棒的图书馆,但我仍然试图围绕它的模板功能,例如这个非常简单的联系人应用程序,我想为每个创建一个表格行新联系人:
<h3>Contact</h3>
<p>First Name: <input data-bind="value: contactFirstName" /></p>
<p>Last Name: <input data-bind="value: contactLastName" /></p>
<p>Email Address: <input data-bind="value: contactEmailAddress" /></p>
<button data-bind="click: addContact">Add</button>
<table>
<thead>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Email Address</td>
</tr>
</thead>
<tbody data-bind="template: {name: 'contactsTemplate', foreach: contacts}" />
</table>
<script id="contactsTemplate" type="text/html">
<tr>
<td>${ $data.firstName }</td>
<td>${ $data.lastName }</td>
<td>${ $data.emailAddress }</td>
</tr>
</script>
<script type="text/javascript">
function contact(firstName, lastName, emailAddress) {
return {
firstName: ko.observable(firstName),
lastName : ko.observable(lastName),
emailAddress: ko.observable(emailAddress)
};
}
var viewModel = …Run Code Online (Sandbox Code Playgroud) 几乎没有架构经验,我正在尝试为.NET 4平台设计一个DRY KISS解决方案,采用MVP方法,最终将实现为桌面(WinForms)和Web(ASP.NET或Silverlight)产品.我曾经做过一些MVC,MVVM的工作,但由于某种原因,我很难绕过这个特定的一个,所以为了抓住模式,我决定从最简单的样本开始问你们一些帮助.
所以假设一个非常简单的模型如下(在实践中它绝对是一个WCF调用):
internal class Person
{
internal string FirstName { get; set; }
internal string LastName { get; set; }
internal DateTime Born { get; set; }
}
public class People
{
private readonly List<Person> _people = new List<Person>();
public List<Person> People { get { return _people; } }
}
Run Code Online (Sandbox Code Playgroud)
我在想:
最后:任何机会都有一个完善的,可测试的,轻量级的框架来实现这一目标吗?
目前我使用简单的shell one-liner监视特定文件:
filesize=$(ls -lah somefile | awk '{print $5}')
Run Code Online (Sandbox Code Playgroud)
我知道Perl有一些很好的模块可以处理Excel文件所以我们的想法就是每天运行那个检查,也许用cron,然后将结果写在电子表格上以供进一步统计使用.
无论是命令行还是GUI,我都有兴趣测试它们.
我有一个配置和工作的角色层次结构:
<beans:bean id="roleHierarchy"
class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
<beans:property name="hierarchy">
<beans:value>
ROLE_ADMIN > ROLE_PRIVILEGED
ROLE_PRIVILEGED > ROLE_USER
ROLE_USER > ROLE_ANONYMOUS
</beans:value>
</beans:property>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
对于用户角色设置,我需要访问我定义的角色。我怎样才能实现它?可能与roleHierarchy.getReachableGrantedAuthorities但我不知道,给它什么作为参数。提前致谢。
我用一种方法编写一个简单的小班,发送电子邮件.我的目标是在遗留的Visual Basic 6项目中实现它,通过COM Interop工具将其公开为COM对象.
有一个细节我发现很难解决,我应该在多大程度上验证参数.从那个角度来看,我真的不高兴,而且根本不是一个细节,就是我实际处理异常的方式:
public class MyMailerClass
{
#region Creation
public void SendMail(string from, string subject, string to, string body)
{
if (this.IsValidMessage(from, subject, to, body)) // CS1501
{
MailMessage msg = new MailMessage();
msg.IsBodyHtml = true;
msg.From = new MailAddress(from);
msg.To.Add(to);
msg.Subject = subject;
msg.Body = body;
SmtpClient srv = new SmtpClient("SOME-SMTP-HOST.COM");
srv.Send(msg);
}
else
{
throw new ApplicationException("Invalid message format.");
}
}
#endregion Creation
#region Validation
private bool IsValidMessage(string from, string subject, string to, string body)
{ …Run Code Online (Sandbox Code Playgroud) c# ×2
mvp ×2
asp.net ×1
biztalk ×1
c#-4.0 ×1
com-interop ×1
command-line ×1
css3 ×1
designer ×1
html5 ×1
jquery ×1
knockout.js ×1
ksh ×1
markup ×1
monitoring ×1
passive-view ×1
perl ×1
shell ×1
stylesheet ×1
transitions ×1
unix ×1
vb6 ×1
winforms ×1