是否可以使用Visual Studio 2012创建XNA游戏?
在Web应用程序中,我希望能够使用如下配置部分定义一些映射:
<configuration>
<configSections>
<sectionGroup name="MyCustomer">
<section name="CatalogMappings" type="MyCustom.MyConfigSection" />
</sectionGroup>
</configSections>
<MyCustomer>
<catalogMappings>
<catalog name="toto">
<mapping value="1" displayText="titi" />
<mapping value="2" displayText="tata" />
</catalog>
<catalog name="toto2">
<mapping value="1" displayText="titi2" />
<mapping value="2" displayText="tata2" />
</catalog>
</catalogMappings>
</MyCustomer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我正在努力实现这一目标,特别是在定义我的集合集合时.为实现这一目标,我需要实现哪些类?
目前,我有:
public class CatalogMappingSection : System.Configuration.ConfigurationSection
{
public class Mapping : ConfigurationElement
{
[ConfigurationProperty("externalKey")]
public string ExternalKey { get; set; }
[ConfigurationProperty("displayText", IsRequired=true)]
public string DisplayText { get; set; }
[ConfigurationProperty("value", IsRequired=true, IsKey=true)]
public int Value { get; set; }
} …
Run Code Online (Sandbox Code Playgroud) 在商务舱我有:
class Employee{
public Employee() {
m_Manager = new Lazy<Manager>( () => return myRepository.GetManager(ManagerId); );
}
public int ManagerId { get; set;}
private Lazy<Manager> m_Manager;
public Manager Manager {
get {
return m_Manager.Value;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,仅在访问Manager属性时才调用自定义存储库.现在我想在ManagerId发生变化时"重置"我的经理属性.怎么做 ?
我可以 :
class Employee{
public Employee() {
m_Manager = new Lazy<Manager>( () => return myRepository.GetManager(ManagerId); );
}
private int m_ManagerId;
public int ManagerId {
get { return m_ManagerId;}
set {
if(m_ManagerId != value)
{
m_ManagerId = value;
m_Manager = new Lazy<Manager>( () …
Run Code Online (Sandbox Code Playgroud) 如果我宣布这样的枚举......
public enum MyEnum : byte {
Val1,
Val2
}
Run Code Online (Sandbox Code Playgroud)
......它正在发挥作用.
如果我宣布这样的枚举......
public enum MyEnum : System.Byte {
Val1,
Val2
}
Run Code Online (Sandbox Code Playgroud)
......它不起作用.编译抛出:
错误CS1008:键入byte,sbyte,short,ushort,int,uint,long或ulong expected
由于byte是实际类型的别名System.Byte
,为什么我不能使用第二个声明?
我正在创建一个Windows应用程序(WPF)和C#.在我看来,我必须添加一些布局,如浏览文件夹,在列表视图中显示文件夹中的文件等
我的要求是:上面提到的面板应该是可折叠的面板,我想,我们在wpf中没有可折叠面板的选项.
我必须为此创建一个自定义控件?如果是这样,请建议我怎么做?
我正在构建一个必须处理大量数据的控制台应用程序.
基本上,应用程序从数据库中获取引用.对于每个引用,解析文件的内容并进行一些更改.这些文件是HTML文件,并且该过程正在使用RegEx替换进行繁重的工作(查找引用并将它们转换为链接).然后将结果存储在文件系统中并发送到外部系统.
如果我按顺序恢复该过程:
var refs = GetReferencesFromDB(); // ~5000 Datarow returned
foreach(var ref in refs)
{
var filePath = GetFilePath(ref); // This method looks up in a previously loaded file list
var html = File.ReadAllText(filePath); // Read html locally, or from a network drive
var convertedHtml = ParseHtml(html);
File.WriteAllText(destinationFilePath); // Copy the result locally, or a network drive
SendToWs(ref, convertedHtml);
}
Run Code Online (Sandbox Code Playgroud)
我的程序工作正常,但速度很慢.这就是为什么我想要并行化这个过程.
到现在为止,我做了一个简单的并行化添加AsParallel:
var refs = GetReferencesFromDB().AsParallel();
refs.ForAll(ref=>
{
var filePath = GetFilePath(ref);
var html = File.ReadAllText(filePath);
var convertedHtml = …
Run Code Online (Sandbox Code Playgroud) c# parallel-processing multithreading plinq task-parallel-library
如果我从Git Extention(CTRL+ G)运行Git bash ,我的主目录是%USERPROFILE%,这没关系.
如果我从git repo文件夹的上下文菜单中运行Git bash,或者如果我从开始菜单运行Git bash,我的主目录是%HOME%,这是不同的.
如何设置git bash以始终使用%USERPROFILE%作为主目录(我有.ssh文件夹)?
如果它可以帮助,从Git Ext运行git bash,我有:
$ echo $HOME
/c/Users/mylogin
Run Code Online (Sandbox Code Playgroud)
git bash上的相同命令直接运行:
$ echo $HOME
/h
Run Code Online (Sandbox Code Playgroud)
h:
是我的公司主目录
我能做什么 ?
我有一个场景,我有一个类资源,其中有两个嵌套在其中的类; Action和ResourceURL.我需要为Resource和Action编写自定义xmlserializer,而不是为ResourceURL编写.我为它们实现了IXmlSerializable.
问题是,当Resource被序列化时,我调用Action.WriteXML(XmlWriter)来获取Action的序列化形式,但是我无法获得ResourceURL的序列化形式.标签变得混乱,它还添加了一个标签.
那么我如何序列化一个对某些嵌套对象进行客户seril化的对象,而不是其他对象呢?
我有一个自定义类(简单):
using System;
using System.ComponentModel.DataAnnotations;
public class MyClass {
[Required]
public string Title { get; set;}
[Required]
public string Description { get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我想验证这个对象,并获得一个不正确的异常.
如果我做 :
void Validate() {
var objectToValidate = new MyClass { }; // Both properties are null at this time
var ctx = new ValidationContext(objectToValidate, null, null);
Validator.ValidateObject(objectToValidate, ctx, true);
}
Run Code Online (Sandbox Code Playgroud)
抛出ValidationException但它只显示第一个错误,即使我为validateAllProperties
参数指定了true .
如果我重构我的代码:
void Validate() {
var objectToValidate = new MyClass { }; // Both properties are null at this time
var …
Run Code Online (Sandbox Code Playgroud) 使用分布式和可扩展的体系结构时,通常需要最终的一致性.
从图形上看,如何处理这种最终的一致性?
用户习惯于单击保存,并立即查看结果...最终的一致性是不可能的.
如何处理这种场景的GUI?
请注意,该问题适用于桌面应用程序和Web应用程序.
PS:我正在使用微软平台,但我想这个问题适用于任何技术......