本文整理汇总了C#中System.Windows.Documents.List.Single方法的典型用法代码示例。如果您正苦于以下问题:C# List.Single方法的具体用法?C# List.Single怎么用?C# List.Single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Single方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXML
public void ReadXML(string pathfile)
{
if (ListWord.Count() > 0)
ListWord.Clear();
if (ListSentence.Count() > 0)
ListSentence.Clear();
XDocument myXML = XDocument.Load(pathfile);
Noidung = (from s in myXML.Descendants("Content") select s.Value).ToList();
Noidung.Single();
ListWord = (from s in myXML.Descendants("Item")
select new CItem()
{
type = s.Attribute("type").Value,
soundPath = s.Attribute("soundPath").Value,
word = s.Value
}
).ToList();
ListSentence = (from s in myXML.Descendants("Sentence") select s.Value).ToList();
}
示例2: GetMandatoryStatusForBusinessUnit
public bool GetMandatoryStatusForBusinessUnit(string businessUnit,List<BusinessUnit> units)
{
bool result = false;
if (!string.IsNullOrEmpty(businessUnit))
{
var unit = units.Single(b => b.Title == businessUnit);
if (unit != null)
result = unit.LinkToMandatory;
else
result = false;
}
return result;
}
示例3: OptimizeQueue
/// <summary>
/// Helper method to optimize the queue
/// </summary>
/// <param name="newRecord"></param>
/// <param name="requests"></param>
private static void OptimizeQueue(RequestRecord newRecord, List<RequestRecord> requests)
{
// try to find a record for the same entity by the local ID
try
{
var existingRecord = requests.Single(r => r.ID == newRecord.ID);
existingRecord.DeserializeBody();
UpdateExistingRecord(requests, existingRecord, newRecord);
}
catch (Exception)
{
// this is a new record so add the new record at the end
requests.Add(newRecord);
}
// if this is a request to remove a tasklist, need to also remove all the manipulations to tasks inside that list
if (newRecord.ReqType == RequestRecord.RequestType.Delete &&
newRecord.BodyTypeName == "TaskList")
{
// create a list that holds the task references to delete
List<RequestRecord> deleteList = new List<RequestRecord>();
// deserialize the bodies for all the tasks (need TaskListID for all the tasks)
foreach (var r in requests)
{
if (r.BodyTypeName == "Task")
{
r.DeserializeBody();
Task t;
if (r.ReqType == RequestRecord.RequestType.Update)
t = ((List<Task>)r.Body)[0];
else
t = (Task)r.Body;
if (t.TaskListID == newRecord.ID)
deleteList.Add(r);
}
}
foreach (var r in deleteList)
requests.Remove(r);
}
}
示例4: Restore
//还原文件
private void Restore()
{
//检查解压到文件中是否有mdb数据库文件
List<string> tempFileNames = new List<string>();
tempFileNames.AddRange(Directory.GetFiles(tempExtrctorPath));
string mdbFile = "";
try
{
mdbFile = tempFileNames.Single(x => x.Substring(x.LastIndexOf(".")) == ".mdb");
tempFileNames.Remove(mdbFile);
}
catch (Exception ee)
{
Directory.Delete(tempExtrctorPath, true);
MessageBox.Show("没有找到数据库文件,该文件不是软件的备份文件!", "系统信息");
this.Close();
}
//还原数据库文件
File.Copy(mdbFile, Model.AppPath.RootPath + "\\AppData\\DSJLDB.mdb", true);
//删除旧文件
if (Directory.Exists(Model.AppPath.XmlDataDirPath))
{
string[] oldFileNames = Directory.GetFiles(Model.AppPath.XmlDataDirPath);
foreach (string oldFileName in oldFileNames)
{
File.Delete(oldFileName);
}
//复制新文件
for (int i = 0; i < tempFileNames.Count; i++) {
string xmlFile = tempFileNames[i];
string name = xmlFile.Substring(xmlFile.LastIndexOf("\\"));
File.Copy(xmlFile, Model.AppPath.XmlDataDirPath + name);
this.Dispatcher.Invoke(rui, (double)(i + 1), (double)tempFileNames.Count, "正在还原数据文件...");
}
}
else
{
Directory.CreateDirectory(Model.AppPath.XmlDataDirPath);
//复制新文件
for (int i = 0; i < tempFileNames.Count; i++)
{
string xmlFile = tempFileNames[i];
string name = xmlFile.Substring(xmlFile.LastIndexOf("\\"));
File.Copy(xmlFile, Model.AppPath.XmlDataDirPath + name);
this.Dispatcher.Invoke(rui, (double)(i + 1), (double)tempFileNames.Count, "正在还原数据文件...");
}
}
Directory.Delete(tempExtrctorPath, true);
this.Dispatcher.Invoke(rui, 1,1, "还原完成!");
this.Dispatcher.Invoke(closeWindow);
}