我创建了一个带有节点的XElement,其中包含XML,如下所示.
我想删除所有" 规则 "节点,如果它们包含" 条件 "节点.
我创建一个for循环,如下所示,但它不会删除我的节点
foreach (XElement xx in xRelation.Elements())
{
if (xx.Element("Conditions") != null)
{
xx.Remove();
}
}
Run Code Online (Sandbox Code Playgroud)
样品:
<Rules effectNode="2" attribute="ability" iteration="1">
<Rule cause="Cause1" effect="I">
<Conditions>
<Condition node="1" type="Internal" />
</Conditions>
</Rule>
<Rule cause="cause2" effect="I">
<Conditions>
<Condition node="1" type="External" />
</Conditions>
</Rule>
</Rules>
Run Code Online (Sandbox Code Playgroud)
如果它们包含" 条件 "节点,如何删除所有" 规则 "节点?
如何使用 Moq for 编写单元测试DirectoryInfo?我的班级如下:
public class DataProcessor : IDataProcessor, IDisposable
{
private ILogger _logger;
DataProcessor(ILogger logger)
{
_logger = logger;
}
public async Task Run(string filePath)
{
var dir = new DirectoryInfo( filePath);
var filesInDir = dir.GetFiles("*.xml");
foreach(var filePath in filesInDir)
{
// process file
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用 System.IO.Abstractions 并按如下方式更改了我的类,但DirectoryInfo不适用于 System.IO.Abstractions
public class DataProcessor : IDataProcessor, IDisposable
{
private readonly IFileSystem _fileSystem;
private ILogger _logger;
DataProcessor(ILogger logger) : this(new FileSystem())
{
_logger = logger;
} …Run Code Online (Sandbox Code Playgroud) 我已经使用chracterset POLISH_POLAND.EE8MSWIN1250安装了oracle。我可以从nls_database_parameters中的select *中检查值,它们是NLS_CHARACTERSET = EE8MSWIN1250和NLS_NCHAR_CHARACTERSET = AL16UTF16
对于sqlplus,我将NLS_LANG设置为POLISH_POLAND.EE8PC852。现在,我从sqlplus命令提示符处运行一个sql文件,该文件保存在“无BOM的UTF-8”中,因为它具有波兰语字符并且工作正常。但是,如何检查数据库中的值是否合适?
我已经签入SQL Developer(将NLS_LANG设置为抛光后),但它们看起来不正确。请帮忙。
我的类有一个我的viewmodel类的ObservableCollection,我在xaml中设置Itemcontrol的itemsource,如下所示
<ItemsControl ItemsSource="{Binding ConditionItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Background="#FFD0D7EB">
<StackPanel>
<Button Content="Delete" HorizontalAlignment="Right" Width="180" Margin="0,0,12,10" Command="{Binding DeleteItem}" CommandParameter="{Binding}">
</Button> </StackPanel>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我的DeleteItem永远不会被调用.
private RelayCommand _DeleteRule;
private void DoDeleteRule(object item)
{
if (item != null)
{
MessageBox.Show("in del");
}
}
public ICommand DeleteItem
{
get
{
if (_DeleteRule == null)
_DeleteRule = new RelayCommand(o => DoDeleteRule(o));
return _DeleteRule;
}
}
Run Code Online (Sandbox Code Playgroud)
我在xaml做错了吗?
我正在创建一个动态二维数组并分配它.我的for循环在10-15次运行后出错(每次都不是相同的值),分配错误.任何帮助,将不胜感激.
__int32 aLarge = 8121432;
__int32 bLarge = 8121784;
ActualPosition** myPositions;
myPositions = new ActualPosition*[aLarge];
for (int x = 0; x < aLarge; x++)
{
try
{
myPositions[x] = new ActualPosition[bLarge];
}
catch (bad_alloc& ba)
{
// Error here
}
}
Run Code Online (Sandbox Code Playgroud) 我最近将我的 VS2015 项目升级到了 VS2017。我将 .NET 框架升级到 4.7.2,但现在出现以下问题
using (IDataReader rd = ExecuteCmdAndGetReader(myssqlstring))
{
MyList = rd.Select<myObject>(myObject.Load).ToList();
}
internal SqlDataReader ExecuteCmdAndGetReader(string sql)
{
SqlCommand cmd;
cmd = new SqlCommand(sql, connection);
SqlDataReader reader = cmd.ExecuteReader();
return reader;
}
Run Code Online (Sandbox Code Playgroud)
错误是
“IDataReader”不包含“Select”的定义,并且找不到接受“IDataReader”类型的第一个参数的可访问扩展方法“Select”(您是否缺少 using 指令或程序集引用?)
我确实在使用中使用了 System.Linq,在参考中使用了 System.Core。请问有什么想法吗?