我有一个带App.Config
文件的exe .现在我想在exe周围创建一个包装器dll,以便消耗一些功能.
问题是如何从包装器DLL访问exe中的app.config属性?
也许我应该在我的问题中多一点,我有以下app.config内容与exe:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myKey" value="myValue"/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
问题是如何从包装器dll中取出"myValue"?
谢谢你的解决方案.
实际上我最初的概念是避免使用XML文件读取方法或LINQ或其他任何方法.我首选的解决方案是使用配置管理器库等.
我将非常感谢使用通常与访问app.config属性相关联的类的任何帮助.
.net c# system.configuration configuration-files appsettings
.NET开发人员在那里!需要你的意见!
我现在正在使用Visual Assist X,这是一个不错的软件.但.NET博客似乎更喜欢Resharper.我可能想考虑转换,但在此之前,我希望你的家伙先发表意见.
关于如何在ASP.NET MVC中单元测试视图的任何想法?
当我启动我的MVC项目时,我厌倦了遇到死亡的黄色屏幕,因为当Action
我的控制器的一个方法更改名称时,我忘记更新视图.
什么是SQL选择的Big-O,对于一个包含n
行的表,我想要返回m
结果?
什么是一个Update
,或delete
,或Create
操作的大O ?
我一般都在谈论mysql和sqlite.
我PDOStatement
用来查询数据库.每当我得到一个返回的行时,我希望将它$row[0]
作为键提取到数组中,并将行中的后续元素作为值.
当然,我可以编写一个foreach
循环和if
条件组合来完成这项工作,如下所示:
private static function GetMySQLResult($dbname, $sqlString) {
$dbh = self::ConstructPDOObject($dbname);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result=array();
foreach ($dbh->query($sqlString) as $row)
{
$result[$row[0]][]=$row[1]; // the simplest case for 2 columns, should add more to handle more columns
}
return $result;
}
Run Code Online (Sandbox Code Playgroud)
但我正在寻找一种现有的方法; 有没有这样的方法已经存在?
我想在NUnit中使用一个内联器来断言两个字典是否相同.即,我想要以下代码的简洁版本:
public static void DictionaryAssert<T, U>(Dictionary<T, U> dictionaryResult, Dictionary<T, U> expectedResult)
{
Assert.AreEqual(dictionaryResult.Count, expectedResult.Count);
foreach (var aKey in expectedResult.Keys)
{
Assert.AreEqual(expectedResult[aKey], dictionaryResult[aKey]);
}
}
Run Code Online (Sandbox Code Playgroud)
当然不是那么困难,但我找不到参考,任何想法?
我有一个简单的类XmlFileHelper如下:
public class XmlFileHelper
{
#region Private Members
private XmlDocument xmlDoc = new XmlDocument();
private string xmlFilePath;
#endregion
#region Constructor
public XmlFileHelper(string xmlFilePath)
{
this.xmlFilePath = xmlFilePath;
xmlDoc.Load(xmlFilePath);
}
#endregion
#region Public Methods
public XmlNode SelectSingleNode(string xPathQuery)
{
return xmlDoc.SelectSingleNode(xPathQuery);
}
public string GetAttributeValueByName(XmlNode node, string attributeName)
{
return node.Attributes.GetNamedItem(attributeName).Value;
}
#endregion
#region Public Properties
public string XmlFilePath
{
get
{
return xmlFilePath;
}
}
#endregion
}
Run Code Online (Sandbox Code Playgroud)
问题是我在加载时收到以下错误:
System.IO.IOException: The process cannot access the file ''C:\CvarUAT\ReportWriterSettings.xml'' **because it is being …
Run Code Online (Sandbox Code Playgroud) 如何使用LINQ为下表创建嵌套分组?我想分组Code
,然后分组Mktcode
.
Code Mktcode Id
==== ======= ====
1 10 0001
2 20 0010
1 10 0012
1 20 0010
1 20 0014
2 20 0001
2 30 0002
1 30 0002
1 30 0005
Run Code Online (Sandbox Code Playgroud)
我最喜欢的是字典
Dictionary<Code, List<Dictionary<Mktcode, List<Id>>>>
Run Code Online (Sandbox Code Playgroud)
所以这本词典的价值就是
{1, ({10,(0001,0012)}, {20,(0010,0014)}, {30, (0002, 0005)})},
{2, ({20,(0001, 0010)}, {30, (0020)} )}
Run Code Online (Sandbox Code Playgroud) 给出这样一个清单:
List<int> intList = new List<int>();
intList.Add(5);
intList.Add(10);
intList.Add(15);
intList.Add(46);
Run Code Online (Sandbox Code Playgroud)
你如何获得列表中最大元素的索引?在这种情况下,它在索引3处.
编辑:遗憾的是标准LINQ没有提供这些功能.
c# ×4
.net ×2
linq ×2
appsettings ×1
asp.net-mvc ×1
big-o ×1
dictionary ×1
load ×1
locking ×1
mysql ×1
nunit ×1
orm ×1
pdostatement ×1
php ×1
resharper ×1
sql ×1
unit-testing ×1
xml ×1