我在Visual Studio 2010中创建了一个控制台应用程序,并为OWIN安装了nuget软件包,如Microsoft.Owin.Hosting和Microsoft.Owin.Host.HttpListener,并配置如下
namespace KatanaIntro
{
class Program
{
static void Main(string[] args)
{
const string uri = "http://localhost:8080";
using (WebApp.Start<Startup>(uri))
{
Console.WriteLine("Started");
Console.ReadKey();
Console.WriteLine("Stopped");
}
}
}
public class Startup
{
public void Configuraion(IAppBuilder app)
{
app.Run(ctx=> ctx.Response.WriteAsync("Welcome to my first katana application"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
运行应用程序后,我得到异常EntryPointNotFoundException *尝试加载应用程序时发生以下错误.- 在类'KatanaIntro.Startup,KatanaIntro,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null*中找不到'配置'方法
我怎么能解决这个问题?我失踪了什么?
我有一个XML文件,如下所示
<Attachment>
<FileName>Perimeter SRS.docx</FileName>
<FileSize>15572</FileSize>
<ActivityName>ActivityNamePerimeter SRS.docx</ActivityName>
<UserAlias>JameelM</UserAlias>
<DocumentTransferId>7123eb83-d768-4a58-be46-0dfaf1297b97</DocumentTransferId>
<EngagementName>EAuditEngagementNameNew</EngagementName>
<Sender>JameelM@orioninc.com</Sender>
</Attachment>
Run Code Online (Sandbox Code Playgroud)
我读了这些xml文件,如下所示
var doc = new XmlDocument();
doc.Load(files);
foreach (XmlElement pointCoord in doc.SelectNodes("/Attachment"))
{
}
Run Code Online (Sandbox Code Playgroud)
我需要在Attachment节点中获取每个子节点值.如何从xml节点列表中获取这些xml元素?
我已经编写了使用Exchange服务器从outlook中读取收件箱消息的代码.以下是阅读代码.
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, itemview);
Run Code Online (Sandbox Code Playgroud)
结果成功.但是没有在结果中获得发件人的电子邮件地址.如何获取发件人的电子邮件地址?
我在嵌套循环中调用异步函数,如下所示
var queue = new Queue<ExchangeEmailInformation>(mailInformation);
var currentQueue = queue.ToList();
foreach (var exchangeEmailInformation in currentQueue)
{
ExchangeEmailInformation information = exchangeEmailInformation;
foreach (var queueList in exchangeEmailInformation.Attachment)
{
Attachment attachment = queueList;
information.FileName = attachment.Name;
var emailId = information.Sender.Split('@');
information.UserAlias = emailId[0];
information.FileSize = attachment.Size;
AddAttachmentAsync(information);
}
}
private static void AddAttachmentAsync(ExchangeEmailInformation information)
{
System.Threading.Tasks.Task.Factory.StartNew(
() =>
AddAttachment(information.UserAlias, information.EngagementName,
information.DocumentTransferId.ToString(), information.FileName,
information.FileSize.ToString(), information.ActivityName)).ContinueWith(
task => OnComplete(task, information), TaskContinuationOptions.None);
}
static void AddAttachment(string userAlias, string engagementName, string documentTranferId, string fileName, string fileSize,string activityName) …Run Code Online (Sandbox Code Playgroud) 我尝试在asp.net mvc中使用jQuery验证下面的电子邮件,如下所示
<script type="text/javascript">
function validateEmail(sEmail) {
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(sEmail)) {
return true;
}
else {
return false;
}
$(document).ready(function() {
$('#create').click(function() {
var sEmail = $('#UserName').val();
if ($.trim(sEmail).length == 0) {
alert('Please enter valid email address');
e.preventDefault();
}
if (validateEmail(sEmail)) {
alert('Email is valid');
}
else {
alert('Invalid Email Address');
e.preventDefault();
}
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
在渲染视图的过程中,我得到了编译错误,在该正则表达式压力下出现意外字符'\'.如何解决此错误?
我试图用两种方式明确地创建依赖.两者几乎相同,但我有点混淆使用反射注射器优于普通注射器的优势以及推荐使用哪一种?
使用注射器
import { Injector } from '@angular/core';
constructor( private injector: Injector) {
this.myService = this.injector.get(MyService);
}
Run Code Online (Sandbox Code Playgroud)
使用反射注射器
import { ReflectiveInjector } from '@angular/core';
constructor() {
var injector= ReflectiveInjector.resolveAndCreate([MyService]);
let myservice=injector.get(MyService);
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个Windows应用程序而没有显示窗口表单.我需要保持我的应用程序运行.现在执行完所有代码后,应用程序就会停止.我尝试下面的方式.
public void RunForm()
{
var frm=new Form();
Application.Run(frm);
}
Run Code Online (Sandbox Code Playgroud)
应用程序没有停止但显示形式.如何在不显示表单的情况下继续运行我的应用程序?
我创建了一个如下所示的宁静网络服务
操作合同
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,ResponseFormat = WebMessageFormat.Json, UriTemplate = "/PushNotification")]
[OperationContract]
void PushNotification(MailInformation mailInformations);
Run Code Online (Sandbox Code Playgroud)
邮件信息类
[DataContract]
public class MailInformation
{
[DataMember]
public List<string> To { get; set; }
[DataMember]
public string SenderEmail { get; set; }
[DataMember]
public string Subject { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如何使用 HttpWebrequest 调用此服务?
我的服务网址
本地主机/聊天/ChatService.svc/PushNotification
你可以看到我有一个方法,它按照我的预期工作得很好
loadTemplates(configUrl: any, templateId: string): Observable<any> {
this.getConfiguration(configUrl)
.pipe(
concatMap(configResponse =>
this.getTemplate(
CONFIGURATION_URL +
"templates/" +
configResponse.TemplateSettings.RootTemplate.Path,
configResponse
)
),
concatMap(rootTemplate =>
this.templateEngine.getAllChildTemplates(rootTemplate)
),
concatMap(childTemplates=>this.templateEngine.createTemplateToRender(childTemplates,""))
)
.subscribe(finalresponse=> {
debugger;
});
}
}
Run Code Online (Sandbox Code Playgroud)
执行
在第 4 个要点中,我将一个空参数传递给createTemplate方法,实际上我必须传递basedntheTemplateresponse(在代码rootTemplate中)。现在我正在通过设置执行getAllChildTemplates时进行调整
getAllChildTemplates(parentTemplate: string) {
this.currentrootTemplate = parentTemplate;
var services = this.getChildTemplateServiceInstance(parentTemplate);
return forkJoin(services);
}
Run Code Online (Sandbox Code Playgroud)
有没有正确的方法将rootTemplate从管道本身传递到下一个concatMap?我不确定这是正确的方法。
var queue = new Queue<ExchangeEmailInformation>(newMails);
Run Code Online (Sandbox Code Playgroud)
如何将上述队列转换为List.
我创建了一个xml文件,如下所示
<Engagements>
<User name ="jjjj">
<Engagement id="1111"/>
</User>
<User name ="kkkk">
<Engagement id="2222"/>
</User>
</Engagements>
Run Code Online (Sandbox Code Playgroud)
我需要从所有Engagement节点获取所有id值.
这就是我目前拥有的:
public static void ParseXml(XmlDocument xmlFile)
{
XmlNodeList nodes = xmlFile.SelectNodes("//Engagement");
foreach (XmlNode node in nodes)
{
// What goes here?
}
}
Run Code Online (Sandbox Code Playgroud)