我有一个控制台应用程序试图从web.config文件加载CustomConfigurationSection.
自定义配置部分具有所需的自定义配置元素.这意味着当我加载配置部分时,如果配置中不存在该配置元素,我希望看到异常.问题是.NET框架似乎完全忽略了isRequired属性.因此,当我加载配置部分时,我只创建自定义配置元素的实例并将其设置在配置部分.
我的问题是,为什么会发生这种情况?我希望GetSection()方法触发ConfigurationErrors异常,因为配置中缺少必需的元素.
以下是我的配置部分的外观.
public class MyConfigSection : ConfigurationSection
{
[ConfigurationProperty("MyConfigElement", IsRequired = true)]
public MyConfigElement MyElement
{
get { return (MyConfigElement) this["MyConfigElement"]; }
}
}
public class MyConfigElement : ConfigurationElement
{
[ConfigurationProperty("MyAttribute", IsRequired = true)]
public string MyAttribute
{
get { return this["MyAttribute"].ToString(); }
}
}
Run Code Online (Sandbox Code Playgroud)
这是我加载配置部分的方法.
class Program
{
public static Configuration OpenConfigFile(string configPath)
{
var configFile = new FileInfo(configPath);
var vdm = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
var wcfm = new WebConfigurationFileMap();
wcfm.VirtualDirectories.Add("/", vdm);
return WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/");
} …Run Code Online (Sandbox Code Playgroud) c# configuration configurationsection configurationelement webconfigurationmanager
我理解设置Maven镜像的部分吸引力,如下所示:
<mirror>
<id>nexus</id>
<name>Maven Repository</name>
<mirrorOf>*</mirrorOf>
<url>http://server:8081/nexus/content/groups/public</url>
</mirror>
Run Code Online (Sandbox Code Playgroud)
......是文件说明:
您可以通过使Maven镜像所有存储库请求来强制Maven使用单个存储库.
但是,这是否表明通过*设置镜像必须强制每个工作站通过镜像?
我问,因为我希望每个工作站都能进行故障转移,并在Nexus无法解析依赖关系或插件的情况下直接连接到它知道的任何公共存储库.(在一个完美的世界中,每个开发人员都有必要的访问权限,可以根据需要添加其他代理存储库.但是,有时访问不可用;有时Nexus服务器会关闭;有时它会遇到Java堆错误.)
这是"镜像,但可以直接连接到公共存储库",可以在Maven 2中进行故障转移配置吗?它会在Maven 3中吗?
我想获得修改记录的最后日期.这是一个简单的SELECT示例:
SELECT
t01.name,
t01.last_upd date1,
t02.last_upd date2,
t03.last_upd date3,
'maxof123' maxdate
FROM
s_org_ext t01,
s_org_ext_x t02,
s_addr_org t03
WHERE
t02.par_row_id(+)= t01.row_id and
t03.row_id(+)= t01.pr_addr_id and
t01.int_org_flg = 'n';
Run Code Online (Sandbox Code Playgroud)
如何获取maxdate列以显示三个日期的最大值?
注意:没有UNION或子/嵌套SELECT语句;)
用简单的英语,使用的缺点和优点是什么
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
Run Code Online (Sandbox Code Playgroud)
在查询.NET应用程序和报告服务应用程序?
我在学习PHP时遇到了一些问题,php是否实现了任何内置的插件系统?
所以插件将能够改变核心组件的行为.
例如这样的工作:
include 'core.class.php';
include 'plugin1.class.php';
include 'plugin2.class.php';
new plugin2;
Run Code Online (Sandbox Code Playgroud)
其中core.class.php包含
class core {
public function coremethod1(){
echo 'coremethod1';
}
public function coremethod2(){
echo 'coremethod2';
}
}
Run Code Online (Sandbox Code Playgroud)
plugin1.class.php包含
class plugin1 extends core {
public function coremethod1(){
echo 'plugin1method1';
}
}
Run Code Online (Sandbox Code Playgroud)
plugin2.class.php包含
class plugin2 extends plugin1 {
public function coremethod2(){
echo 'plugin2method2';
}
}
Run Code Online (Sandbox Code Playgroud)
如果不是因为现在插件彼此可靠并且删除其中一个插件的问题,这将是理想的:
include 'core.class.php';
//include 'plugin1.class.php';
include 'plugin2.class.php';
new plugin2;
Run Code Online (Sandbox Code Playgroud)
打破了整个事情......
有没有适当的方法来做到这一点?如果没有,我可以考虑转移到另一个支持这个的语言...
谢谢你的帮助.
编辑: 显然我的理解是缺乏的,所以这里是一个澄清的尝试.
core.class.php包含任何内容......
plugin1.class.php包含任何内容......
plugin2.class.php包含任何内容......
include 'core.class.php';
include 'plugin1.class.php';
include 'plugin2.class.php';
$core = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用希伯来语列名读取.txt文件,但没有成功.
我上传了一个示例文件到:http: //www.talgalili.com/files/aa.txt
我正在尝试这个命令:
read.table("http://www.talgalili.com/files/aa.txt", header = T, sep = "\t")
Run Code Online (Sandbox Code Playgroud)
这让我回头:
X.....ª X...ª...... X...œ....
1 12 97 6
2 123 354 44
3 6 1 3
Run Code Online (Sandbox Code Playgroud)
代替:
??? ????? ????
12 97 6
123 354 44
6 1 3
Run Code Online (Sandbox Code Playgroud)
我的输出:
l10n_info()
Run Code Online (Sandbox Code Playgroud)
方法是:
$MBCS
[1] FALSE
$`UTF-8`
[1] FALSE
$`Latin-1`
[1] TRUE
$codepage
[1] 1252
Run Code Online (Sandbox Code Playgroud)
并为:
Sys.getlocale()
Run Code Online (Sandbox Code Playgroud)
方法是:
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
Run Code Online (Sandbox Code Playgroud)
你能告诉我要尝试改变什么以允许我正确加载文件吗?
更新: 尝试使用:
read.table("http://www.talgalili.com/files/aa.txt",fileEncoding ="iso8859-8")
Run Code Online (Sandbox Code Playgroud)
导致:
V1
1 ?
Warning messages:
1: In read.table("http://www.talgalili.com/files/aa.txt", …Run Code Online (Sandbox Code Playgroud) 是否可以使用PHP函数的正则表达式array_key_exists()?
例如:
$exp = "my regex";
array_key_exists($exp, $array);
Run Code Online (Sandbox Code Playgroud)
谢谢!
我创建了一个XML模式(foo.xsd)并用于xjc为JAXB创建我的绑定类.假设根元素是collection,我正在写N个document对象,它们是复杂的类型.
因为我打算写出大型XML文件,我使用Stax写出collection根元素,而JAXB 使用编写文档子树Marshaller.marshal(JAXBElement, XMLEventWriter).这是jaxb非官方用户指南推荐的方法.
我的问题是,如何在编组时验证XML?如果我将模式绑定到JAXB marshaller(使用Marshaller.setSchema()),我会得到验证错误,因为我只是编组一个子树(它抱怨它没有看到collection根元素").我想我真正想做的是将模式绑定到的Stax XMLEventWriter或类似的东西.
对这种整体方法的任何评论都会有所帮助.基本上我希望能够使用JAXB来编组和解组大型XML文档而不会耗尽内存,所以如果有更好的方法可以让我知道.
目前,我从.ashx处理程序返回XML时,有此版本的自动完成控件.xml看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<States>
<State>
<Code>CA</Code>
<Name>California</Name>
</State>
<State>
<Code>NC</Code>
<Name>North Carolina</Name>
</State>
<State>
<Code>SC</Code>
<Name>South Carolina</Name>
</State>
Run Code Online (Sandbox Code Playgroud)
自动完成代码如下所示:
$('.autocompleteTest').autocomplete(
{
source: function(request, response) {
var list = [];
$.ajax({
url: "http://commonservices.qa.kirkland.com/StateLookup.ashx",
dataType: "xml",
async: false,
data: request,
success: function(xmlResponse) {
list = $("State", xmlResponse).map(function() {
return {
value: $("Code", this).text(),
label: $("Name", this).text()
};
}).get();
}
});
response(list);
},
focus: function(event, ui) {
$('.autocompleteTest').val(ui.item.label);
return false;
},
select: function(event, ui) {
$('.autocompleteTest').val(ui.item.label);
$('.autocompleteValue').val(ui.item.value);
return false;
} …Run Code Online (Sandbox Code Playgroud) 我需要在文件中做一堆单词替换,并希望用vi命令,而不是像EX这样的EX命令:%s///g.我知道这是在当前光标位置替换单词的典型方式:cw<text><esc>但是有没有办法用未命名寄存器的内容作为替换文本并且不覆盖寄存器?