我有以下JSON:
{
"id" : "2"
"categoryId" : "35"
"type" : "item"
"name" : "hamburger"
}
{
"id" : "35"
"type" : "category"
"name" : "drinks"
}
Run Code Online (Sandbox Code Playgroud)
我想将它与此对象匹配:
public class Item
{
[JsonProperty(PropertyName = "categoryId")]
public Category Category { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
Category
是Entity
具有string
Id
我可以访问的属性的类型.我希望JSON反序列化器创建的"35"对象映射到该Category
属性中Item
.
根据文档,我应该使用IReferenceResolver
.我如何实现此接口并将其挂钩到JSON.NET框架中?
可能重复:
如何找出使用.NET锁定文件的进程?
我想复制一个文件,但它被另一个应用程序锁定,因此抛出了FileInUseException.我想告诉用户哪个应用程序正在锁定我正在尝试复制的文件..NET Framework中有没有办法做到这一点?如果没有这方面的知识,我会告诉用户使用Unlocker应用程序.
我使用的是最新的NHibernate 2.1.0Beta2.我正在尝试使用SQLite进行单元测试,并将配置设置为:
Dictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("query.substitutions", "true=1;false=0");
properties.Add("connection.connection_string", "Data Source=test.db;Version=3;New=True;");
properties.Add("proxyfactory.factory_class",
"NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu");
configuration = new Configuration();
configuration.SetProperties(properties);
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我收到以下错误:
NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name …
Run Code Online (Sandbox Code Playgroud) 当我使用我的应用程序的wpf元素时,所有样式都是操作系统的样式,但是当我使用OpenDialog或MessageBox时,它会渲染旧的Windows 9X方式.有没有更简单的方法可以执行Application.EnableVisualStyles()等效调用,使消息框和对话框看起来与应用程序的其余部分相同?
如果我有以下代码:
std::string name = "Michael";
std::string spaces = " ";
Run Code Online (Sandbox Code Playgroud)
我将如何以编程方式创建spaces
字符串(包含所有空格的字符串,长度与name变量匹配)?
我们有一个第三方dll,它在我们的应用程序版本5.0中的1.0版本上.
在我们的应用程序的6.0版本中,我们将第三方dll升级到2.0版.但这导致应用程序出现问题,我们想回滚.
因此,在我们的应用程序的6.1版本中,我们想要回滚到第三方dll的1.0版本.但Windows Installer将该组件视为比MSI中的版本更大且不想更新它的版本.
如何在6.1版本的产品中回滚第三方dll?
我想要一种简单的方法来确保我在xaml文件中声明的所有绑定都转到了真正的属性.更好的是,我想在单元测试中实例化我的wpf窗口并调用方法以确保绑定是正确的.
不幸的是,如果我出错了,wpf甚至不会抛出异常.这使我在QA阶段"发现"问题的负担.
有谁知道我可以更好地验证我的绑定方式?
我编写了一个自定义序列化例程,它不使用ISerializable或SerialzableAttribute将我的对象保存到文件中.
我也远程调用这些相同的对象,并希望使用相同的序列化技术.但是,我不想实现ISerializable,因为我的序列化方法与我的对象完全分离(我希望它保持这种方式).
有没有一种简单的方法(可能有远程接收器),我可以在其中获取流并向其写入字节,另一方面从中读取字节,跳过.NET中的序列化框架?
我可能超出了AutoResetEvent的正确设计,但不太清楚要转向什么.我想要这种行为:
var autoResetEvent = new AutoResetEvent(false);
autoResetEvent.Set();
autoResetEvent.Set();
autoResetEvent.WaitOne();
// since Set was called twice, I don't want to wait here
autoResetEvent.WaitOne();
Run Code Online (Sandbox Code Playgroud)
不幸的是(对于我的问题),这不是AutoResetEvent的行为方式.在这种情况下,最好的课程是什么?
注意:我可以访问.NET Parallel Exensions库.