아래 코드를 붙여 넣으면 오류가 발생합니다.C#에서 ConfigurationElement를 구현하는 방법은 무엇입니까?
클래스 ZDRCreatorTests.ZDRCreatorTests의 인스턴스를 만들 수 없습니다. 오류 : System.Configuration.ConfigurationErrorsException : 'indexedFolder'속성의 기본값을 파싱 할 수 없습니다. 오류 : 재산 'indexedFolder'유형 '의 DirectoryInfo'에 대한 문자열로/변환을 지원하는 컨버터를 찾을 수 없습니다 ..
namespace ZDRCreator
{
public class ZDRCreatorElement : ConfigurationElement
{
// Create the element.
public ZDRCreatorElement()
{ }
// Get or set the IndexedFolder
[ConfigurationProperty("indexedFolder", DefaultValue = "", IsRequired = true)]
public DirectoryInfo IndexedFolder {
get { return (DirectoryInfo)this["indexedFolder"]; }
set { this["indexedFolder"] = value; }
}
// Get or set the OutputFolder
[ConfigurationProperty("outputFolder", DefaultValue = "", IsRequired = true)]
public DirectoryInfo OutputFolder {
get { return (DirectoryInfo)this["outputFolder"]; }
set { this["outputFolder"] = value; }
}
// Get or set the ZDRFile
[ConfigurationProperty("ZDRFile", DefaultValue = "", IsRequired = true)]
public FileInfo ZDRFile {
get { return (FileInfo)this["ZDRFile"]; }
set { this["ZDRFile"] = value; }
}
// Get or set the overwriteOutput flag
[ConfigurationProperty("overwriteOutput", DefaultValue = "false", IsRequired = true)]
public bool OverwriteOutput {
get { return (bool)this["overwriteOutput"]; }
set { this["overwriteOutput"] = value; }
}
// Get or set the OutputFile
[ConfigurationProperty("outputFile", DefaultValue = "", IsRequired = true)]
public String OutputFile {
get { return (String)this["outputFile"]; }
set { this["outputFile"] = value; }
}
// Get or set the OutputFile
[ConfigurationProperty("pathMask", DefaultValue = "", IsRequired = true)]
public String PathMask {
get { return (String)this["pathMask"]; }
set { this["pathMask"] = value; }
}
}
}
내가 문자열을 넣어려고하기 때문에 오류가 실현 DirectoryInfo 객체에서. 내 질문은 이것입니다 : XML에서 읽은 문자열이나 기본 데이터 형식 만 저장 한 다음 xml을 읽은 다음 다른 개체로 변환한다고 가정합니까? 또는, 내가 내부적으로 사용할 대상으로 그들을 구성 할 수있는 곳이 있습니까? 입력에 대한 유효성 확인은 어디에서 발생합니까?
당신이 말한 것은 모두 사실입니다. CSD는 놀라운 도구이지만 요즘에는 Visual Studio의 정식 버전입니다. 너무 슬다. – QueueHammer