为了说明这个问题,我创建了一个简单的示例项目,我在 XAML 定义中遇到了编译错误。
这是我的类定义:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MVVMTest.Foo
{
public class FooTestClass
{
public String Name { get; set; }
public String Key { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
需要注意的是 FooTestClass 驻留在 Foo 子文件夹中(MVVMTest 文件夹的)
这是我的 XAML:
<Window x:Class="MVVMTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MVVMTest"
xmlns:mView="clr-namespace:MVVMTest.Foo;assembly=MVVMTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<mView:FooTestClass x:Key="ddd" />
</Window.Resources>
<Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息
XML 命名空间“clr-namespace:MVVMTest.Foo;assembly=MVVMTest”中不存在标记“FooTestClass”。Line 12 Position 10.
MVVMTest C:\Dev Projects\MVVMTest\MVVMTest\MainWindow.xaml
VS 有问题吗?
如何配置 Serilog 以便它在每次程序执行时覆盖文件?
代码
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.ColoredConsole()
.WriteTo.File("c:\\Logs\\myapp.log")
.CreateLogger();
Run Code Online (Sandbox Code Playgroud)
附加新执行的条目日志并没有什么坏处,但在开发过程中只需获取当前日志就很方便。
我正在对日期时间进行单元测试,但它失败了,因为测试名称:
GetDateTime2 结果消息:Assert.AreEqual 失败。预期:<28/05/2017 20:00:00 (System.String)>。实际:<28/05/2017 20:00:00 (System.DateTime)>。
有没有什么方法可以将字符串与日期时间进行比较,我是否必须更改字符串日期和字符串时间的属性?
public void GetDateTime()
{
FootballEvent football = new FootballEvent();
football.Time = "20:00:00";
football.Date = "28/05/2017";
var footballtime = football.GetDateTime();
var expected = "28/05/2017 20:00:00";
Assert.AreEqual(expected, footballtime);
}
Run Code Online (Sandbox Code Playgroud) 我提供了一个文本框,用于输入正则表达式以匹配文件名.我计划使用Regex方法检测它们提供的任何命名捕获组GetGroupNames().
我想得到他们在每个命名捕获组中输入的表达式.
例如,他们可能会输入这样的正则表达式:
December (?<FileYear>\d{4}) Records\.xlsx
Run Code Online (Sandbox Code Playgroud)
\d{4}除了手动解析正则表达式字符串之外,是否有一种方法或手段来获取子表达式?
我有一个这样的字符串:
string myText = "abc def ghi 123 abc def ghi 123 abc def";
Run Code Online (Sandbox Code Playgroud)
我只想abc用空替换最后一个。
这是我的代码:
string pattern2 = "([abc])$";
string replacement2 = "";
Regex regEx = new Regex(pattern2);
var b = Regex.Replace(regEx.Replace(myText, replacement2), @"\s", " ");
Run Code Online (Sandbox Code Playgroud)
它不能正常工作,那么如何才能做到呢?
我在这个主题上搜索了很多,但没有得到任何令人满意的答案.
在Windows Azure中,我们如何从工作者角色中使用外部(第三方)Web服务?是否像在解决方案中使用Web引用一样简单,还是需要使用Azure Service Bus?
我正在写一篇关于我正在写的PowerShell脚本的地方.
基本上我要做的是让它通过目录进行递归,仅包含.pdf文件,并返回最近修改过的3个.pdf,并将每个(完整)文件名粘贴到各自的变量中.
这是我目前的代码 -
$Directory="C:\PDFs"
Get-ChildItem -path $Directory -recurse -include *.pdf | sort-object -Property LastWriteTime -Descending | select-object -First 3 | ForEach-Object
{
Write-Host -FilePath $_.fullname
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行脚本时,它要求我为脚本的ForEach部分提供参数 - 这让我得出结论:命令没有按照它应该的方式进行管道,或者我只是一个白痴而不是使用命令正确.
如何查找/列出全局和用户配置文件?我的意思是“Git 原生功能”,而不是像find.
当我使用多行文本框时,文本框的文本/内容应该对齐到顶部,如果它是单行文本框,那么它的文本对齐方式应该是默认的(居中),我需要在文本框样式中设置它,所以当有一个多行文本框时,我的样式会相应地自动调整内容。
我需要返回一个 json 对象,但出现以下错误:
错误 1 无法将类型“Newtonsoft.Json.Linq.JObject”隐式转换为“System.Collections.Generic.IEnumerable<Newtonsoft.Json.Linq.JObject>”。存在显式转换(您是否缺少演员表?)
谁能帮我解决这个错误?
public static IEnumerable<JObject> GetListOfHotels()
{
const string dataPath = "https://api.eancdn.com/ean-services/rs/hotel/v3/list?minorRev=99&cid=55505&apiKey=key&customerUserAgent=Google&customerIpAddress=123.456&locale=en_US¤cyCode=USD&destinationString=washington,united+kingdom&supplierCacheTolerance=MED&arrivalDate=12/12/2013&departureDate=12/15/2013&room1=2&mberOfResults=1&supplierCacheTolerance=MED_ENHANCED";
var request = WebRequest.Create(dataPath);
request.Method = "POST";
const string postData = dataPath;
var byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
var dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
var response = request.GetResponse();
var responseCode = (((HttpWebResponse) response).StatusDescription);
var responseStream = response.GetResponseStream();
var responseReader = new StreamReader(responseStream, Encoding.UTF8);
var responseString = responseReader.ReadToEnd();
var root = JObject.Parse(responseString);
return root;
}
Run Code Online (Sandbox Code Playgroud)