當前位置: 首頁>>代碼示例>>C#>>正文


C# List.Single方法代碼示例

本文整理匯總了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();
        }
開發者ID:mylgoehy,項目名稱:qlqtpmav10,代碼行數:22,代碼來源:CPronunciation.cs

示例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;
        }
開發者ID:nilavghosh,項目名稱:VChk,代碼行數:14,代碼來源:BusinessUnitServiceAgent.cs

示例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);
            }
        }
開發者ID:ogazitt,項目名稱:TaskStore,代碼行數:45,代碼來源:RequestQueue.cs

示例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);
        }
開發者ID:dewade2003,項目名稱:DSJL,代碼行數:56,代碼來源:ExtractProgressWindow.xaml.cs


注:本文中的System.Windows.Documents.List.Single方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。