Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the Settings class.
 /// </summary>
 public Settings()
 {
     settingDirectorys = new DirectoryCollection();
     extensionDirectorys = new DirectoryCollection();
     loadedExtensions = new ExtensionInfoCollection();
     logSettings = new LogHandlerSettingCollection();
 }
Exemplo n.º 2
0
 public void Contains()
 {
     Assert.IsTrue(list.Contains("test"));
     Assert.IsFalse(list.Contains("foo10"));
     list = new DirectoryCollection(dirs2);
     Assert.IsTrue(list.Contains("test1"));
     Assert.IsTrue(list.Contains("foo10"));
     Assert.IsFalse(list.Contains("ding"));
 }
Exemplo n.º 3
0
        //
        // GET: /Directory/

        public ActionResult Index(int p = 0)
        {
            ViewBag.Title             = "Gestion des dossiers";
            ViewBag.Pagination        = true;
            ViewBag.PaginationUrl     = string.Format("{0}?p=", Request.Path);
            ViewBag.PaginationCurrent = p;
            ViewBag.PaginationTotal   = DirectoryCollection.LoadByUserCount(SoftFluent.Samples.GED.Security.User.LoadByUserName(User.Identity.Name)) / 50;

            return(View(DirectoryCollection.PageLoadByUser(0, 50, null, SoftFluent.Samples.GED.Security.User.LoadByUserName(User.Identity.Name))));
        }
Exemplo n.º 4
0
        public void opIndexer_string()
        {
            using (var temp = new TempDirectory())
            {
                const string name = "example";
                var expected = temp.Info.FullName;

                var obj = new DirectoryCollection
                              {
                                  new DirectoryItem
                                      {
                                          Name = name,
                                          Value = temp.Info.FullName
                                      }
                              };

                var actual = obj[name].FullName;

                Assert.Equal(expected, actual);
            }
        }
Exemplo n.º 5
0
 ///<inheritdoc/>
 public override void AddItem(string phrase)
 {
     DirectoryCollection.Add(new Note {
         ActivityId = activityId, Phrase = phrase
     });
 }
Exemplo n.º 6
0
        public void CopyTo()
        {
            string[] result = new string[1];
            list.CopyTo(result, 0);
            Assert.AreEqual("test", result[0]);
            try
            {
                list.CopyTo(result, 1);
                Assert.Fail("Should not copy over the size of the array");
            }
            catch (IndexOutOfRangeException)
            {
            }

            result = new string[6];
            list.CopyTo(result, 2);
            Assert.IsNull(result[0]);
            Assert.IsNull(result[1]);
            Assert.AreEqual("test", result[2]);
            list = new DirectoryCollection(dirs2);
            list.CopyTo(result, 0);
            Assert.AreEqual("test1", result[0]);
            Assert.AreEqual("foo10", result[1]);
            Assert.AreEqual("bar8", result[2]);
            Assert.IsNull(result[3]);
            Assert.IsNull(result[4]);
            Assert.IsNull(result[5]);
            list.CopyTo(result, 2);
            Assert.AreEqual("test1", result[0]);
            Assert.AreEqual("foo10", result[1]);
            Assert.AreEqual("test1", result[2]);
            Assert.AreEqual("foo10", result[3]);
            Assert.AreEqual("bar8", result[4]);
            Assert.IsNull(result[5]);
        }
Exemplo n.º 7
0
        //得到目录下的文件名列表
        public List <string> GetDirFiles(string pictureDirectory)
        {
            this.pictureDirectory = pictureDirectory;
            //
            bool                isDirExist        = false;
            List <string>       pictureFileList   = new List <string>();
            DirectoryCollection pictureCollection = new DirectoryCollection();
            DirectoryFiles      pictureDirFiles   = new DirectoryFiles();

            //
            isDirExist = Directory.Exists(pictureDirectory);
            if (isDirExist == false)
            {
                throw new Exception(string.Format("{0}目录不存在.", pictureDirectory));
            }
            else
            {
                #region

                /*
                 *得到父目录下的所有层级目录列表
                 *例如:目录层级如下
                 * D:\刘亦菲
                 *        |
                 *        --1
                 *        |
                 *        --2
                 * DirectoryCollection pictureCollection = new DirectoryCollection();
                 * List<string> directoryList=pictureCollection.getCollection(@"D:\刘亦菲");
                 *
                 * 返回值:
                 * @"D:\刘亦菲"
                 * @"D:\刘亦菲\1"
                 * @"D:\刘亦菲\2"
                 *
                 */
                #endregion
                pictureDictionary = pictureCollection.getDictionary(pictureDirectory);
                List <string> keyList = new List <string>();
                Dictionary <string, string[]> .Enumerator enumerator = pictureDictionary.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string key = enumerator.Current.Key;
                    keyList.Add(key);
                }
                //如果目录后面没有斜杠:"\\" 则增加
                for (int i = 0; i < keyList.Count; i++)
                {
                    string key = keyList[i];
                    keyList[i] = key.EndsWith("\\") ? key : (Directory.Exists(key) ? key + "\\" : Path.GetDirectoryName(key) + "\\");
                }
                //过滤非目录
                for (int i = 0; i < keyList.Count; i++)
                {
                    string key = keyList[i];
                    keyList[i] = Path.GetDirectoryName(key).EndsWith("\\") ? key : Path.GetDirectoryName(key) + "\\";
                }
                #region

                /*
                 * 遍历列表中的字符串,并按照字符串中路径的目录数量从小到大排序
                 * 举例:列表如下
                 * List<string> testList = new List<string>();
                 * testList.Add(@"D:\test\");
                 * testList.Add(@"D:\test\test1\file.txt");
                 * testList.Add(@"D:\test\test1");
                 * testList.Add(@"D:\test\test1\test0\file.txt");
                 * testList.Add(@"D:\test\");
                 * testList.Add(@"D:\test\test1\test0");
                 *
                 * 片段1:
                 * Path.GetDirectoryName(key).Replace('/', '\\').Split(new char[] {'\\','/'})
                 * 将得到的目录分解成目录
                 * 举例:
                 * key值: D:\test\test1\test0\file.txt
                 * 通过片段1产生临时数组:
                 * {"D:","test","test1","test0",""}
                 *
                 * 片段2:
                 * 去除片段1中产生的临时数组:
                 * Path.GetDirectoryName(key).Replace('/', '\\').Split(new char[] {'\\','/'}).Where(k=>k.Trim()!="")
                 * 通过片段2产生临时数组:
                 * {"D:","test","test1","test0}
                 *
                 * 片段3:计算片段2中临数组的长度
                 * 对于临时数组:{"D:","test","test1","test0}
                 * 此数组的长度为4
                 *
                 * 片段4:遍历List中的字符串,通过片段1,片段2,片段3计算临时数组的长度,并升序排列
                 * keyList.OrderBy(key=>...);
                 * 其中...代码片段2
                 */
                #endregion
                IEnumerable <string> orderKeyList = keyList.OrderBy(key => Path.GetDirectoryName(key).Replace('/', '\\').Split(new char[] { '\\' }).Where(k => k.Trim() != "").Count());
                keyList = orderKeyList.ToList();
                //去重复字符串
                IEnumerable <string> distinctKeyList = keyList.Distinct();
                keyList = distinctKeyList.ToList();
                return(keyList);
            }
        }
Exemplo n.º 8
0
 public void ThisIndex()
 {
     Assert.AreEqual("test", list[0]);
     list = new DirectoryCollection(dirs2);
     Assert.AreEqual("test1", list[0]);
     Assert.AreEqual("foo10", list[1]);
     Assert.AreEqual("bar8", list[2]);
 }
Exemplo n.º 9
0
        protected CProject(SerializationInfo info, StreamingContext context)
        {
            //this.FileList = (ArrayList)info.GetValue("FileList", typeof(ArrayList));
            //this.DirList = (ArrayList)info.GetValue("DirList", typeof(ArrayList));

            g.LogDebug("CPROJECT::ctor: Enter (Deserialization)");

            try {
                g.LogDebug("CPROJECT::ctor: Trying to get file version");
                int proj_filever = (int)info.GetValue("___PROJECT_FILE_VERSION", typeof(int));

                if (proj_filever != 1) {
                    g.LogDebug("CPROJECT::ctor: Failed");
                    throw new Exception("The project is from an older version of TorqueDev / Codeweaver that is completely incompatible with the current version.");
                }

            } catch {
                g.LogDebug("CPROJECT::ctor: Failed");
                throw new Exception("The project is from an older version of TorqueDev / Codeweaver that is completely incompatible with the current version.");
            }

            /* Try to load the new file collection data; if not, we need to convert */
            try {
                g.LogDebug("CPROJECT::ctor: Load directory and file information");
                this.FileList = (FileCollection)info.GetValue("FileList_V2", typeof(FileCollection));
                this.DirList = (DirectoryCollection)info.GetValue("DirList_V2", typeof(DirectoryCollection));
            } catch {
                g.LogDebug("CPROJECT::ctor: Failed; need to update project file");
                DialogResult result = MessageBox.Show("This project contains data from an older version of TorqueDev / Codewaver (namely, the " +
                    "way projects store file and directory data has changed).  Do you want to update your project file to the latest version? " +
                    "(Note: Selecting 'no' will leave you with a blank project)", "Project Conversion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                this.FileList = new FileCollection();
                this.DirList = new DirectoryCollection();

                if (result == DialogResult.Yes) {
                    // Convert the old data
                    ArrayList oldfiles = (ArrayList)info.GetValue("FileList", typeof(ArrayList));
                    ArrayList olddirs = (ArrayList)info.GetValue("DirList", typeof(ArrayList));

                    foreach (CProject.File oldfile in oldfiles)
                        this.FileList.Add(oldfile);

                    foreach (CProject.Directory olddir in olddirs)
                        this.DirList.Add(olddir);
                }
            }

            g.LogDebug("CPROJECT::ctor: Loading project properties");
            //this._TokenObjList = (Hashtable)info.GetValue("TokenObject", typeof(Hashtable));
            this.ProjectName = (string)info.GetValue("#ProjectName#", typeof(string));
            //this.ProjectPath = (string)info.GetValue("#FullRootPath#", typeof(string));
            this.ProjectPath = System.IO.Directory.GetCurrentDirectory();

            // Try to load the debugger data; if nothing, just quit
            try {
                g.LogDebug("CPROJECT::ctor: Loading debugger properties");
                this.DebugEnabled = (bool)info.GetValue("DebugEn", typeof(bool));
                this.DebugExe = (string)info.GetValue("DebugExe", typeof(string));
                this.DebugParams = (string)info.GetValue("DebugParams", typeof(string));
                this.DebugPasswd = (string)info.GetValue("DebugPasswd", typeof(string));
                this.DebugPort = (int)info.GetValue("DebugPort", typeof(int));
            } catch {}

            // Try to load the last open file list; if not, just quit
            try {
                g.LogDebug("CPROJECT::ctor: Loading previous state");
                this.OpenFiles = (FileCollection)info.GetValue("OpenFiles", typeof(FileCollection));
                this.OpenFilesState = (byte[])info.GetValue("OpenFilesState", typeof(byte[]));
            } catch {}

            // Deserialize the macro list
            try {
                g.LogDebug("CPROJECT::ctor: Reloading macros");
                ArrayList macrolist = new ArrayList();
                this.MacroList = new Hashtable();
                macrolist = (ArrayList)info.GetValue("SerializedMacroList", typeof(ArrayList));

                foreach(CProject.SerializedMacro sermac in macrolist) {
                    MemoryStream mem = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(sermac.MacroXML));
                    System.Xml.XmlTextReader xmlread = new System.Xml.XmlTextReader(mem);

                    ActiproSoftware.SyntaxEditor.Commands.MacroCommand newcmd = new ActiproSoftware.SyntaxEditor.Commands.MacroCommand();
                    newcmd.ReadFromXml(xmlread);

                    xmlread.Close();
                    mem.Close();

                    CProject.Macro newmac = new CProject.Macro(sermac.MacroName, newcmd);
                    newmac.MacroNum = sermac.MacroNum;

                    this.MacroList.Add(newmac.MacroName, newmac);
                }
            } catch (Exception exc) {
                g.LogDebug("CPROJECT::ctor: Failed");
                MessageBox.Show("Error in loading saved macros.  Some macros may not be available.\n\n" + exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // Try to see if the project type is set
            try {
                g.LogDebug("CPROJECT::ctor: Loading project type");
                this.ProjectType = Convert.ToInt16(info.GetValue("#ProjectType#", typeof(short)));
            } catch {
                g.LogDebug("CPROJECT::ctor: Failed");
                MessageBox.Show("This project is from an older version of TorqueDev / Codeweaver and does not include a project type definition.  It has automatically been set to \"TGE\".  You will need to edit the project properties to change the project type to the appropriate value.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.ProjectType = 0;
            }

            // Grab the variable watch list if we can
            try {
                g.LogDebug("CPROJECT::ctor: Loading watch list");
                this.VarWatchList = (ArrayList)info.GetValue("WatchVars", typeof(ArrayList));
            } catch {}

            // Take care of the new debug options
            try {
                g.LogDebug("CPROJECT::ctor: Loading debug auto insert info");
                this.DebugAutoInsert = Convert.ToBoolean(info.GetValue("DebugAutoInsert", typeof(bool)));
                this.DebugMainCs = (string)(info.GetValue("DebugMainCs", typeof(string)));
            } catch {
                // Reset the debugging info if we've failed to
                // convert the new debug settings
                MessageBox.Show("This project does not contain extended debug information (due to conversion from an older version of TorqueDev). " +
                    "The project's debug information will be cleared.  You can run the new Debug Wizard available from the \"Debug\" menu to " +
                    "define the debugger settings.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DebugExe = "";
                this.DebugEnabled = false;
                this.DebugParams = "";
                this.DebugPasswd = "";
                this.DebugPort = 8777;
                this.DebugAutoInsert = false;
                this.DebugMainCs = "";
            }

            // See if we can get the last project finds/replaces
            try {
                g.LogDebug("CPROJECT::ctor: Loading finds/replaces");
                this.Finds = (ArrayList)info.GetValue("RecentFinds", typeof(ArrayList));
                this.Replaces = (ArrayList)info.GetValue("RecentReplaces", typeof(ArrayList));
            } catch { }

            // Clean up any foreign files that are left in the project
            g.LogDebug("CPROJECT::ctor: Remove foreign files");
            FileList.CleanUpForeigns();
        }
Exemplo n.º 10
0
 public void Default()
 {
     Assert.AreEqual("test", list.Default);
     list = new DirectoryCollection(dirs2);
     Assert.AreEqual("test1", list.Default);
     dirs1.Add("blubb");
     Assert.AreEqual("test1", list.Default);
 }
Exemplo n.º 11
0
 public void SetUp()
 {
     dirs1 = new List<string>();
     dirs1.Add("test");
     dirs2 = new List<string>();
     dirs2.Add("test1");
     dirs2.Add("foo10");
     dirs2.Add("bar8");
     list = new DirectoryCollection(dirs1);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Get index of the selected record.
 /// </summary>
 protected int GetIndex()
 {
     return(DirectoryCollection.IndexOf(SelectedValue));
 }
Exemplo n.º 13
0
 public void Count()
 {
     Assert.AreEqual(1, list.Count);
     list = new DirectoryCollection(dirs2);
     Assert.AreEqual(3, list.Count);
     list.Add("foobar");
     Assert.AreEqual(4, list.Count);
 }
Exemplo n.º 14
0
 public object Clone()
 {
     g.LogDebug("CPROJECT::DirectoryCollection::Clone: Enter");
     DirectoryCollection clonedCollection = new DirectoryCollection();
     clonedCollection.InnerList.AddRange((ICollection)this.InnerList.Clone());
     return clonedCollection;
 }
Exemplo n.º 15
0
        private static void WriteDirectoryList(XmlWriter writer, string tag, DirectoryCollection dirs)
        {
            if (dirs.Count > 0)
            {
                writer.WriteStartElement(tag);
                foreach (string dir in dirs)
                {
                    writer.WriteElementString("directory", dir);
                }

                writer.WriteEndElement();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Reads a list of directorys.
        /// </summary>
        /// <param name="reader">Thre reader to read from.</param>
        /// <param name="dirs">The directory list to add the readed directorys to.</param>
        private static void ReadDirectoryList(XmlReader reader, DirectoryCollection dirs)
        {
            reader.Read();
            while (true)
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    switch (reader.Name)
                    {
                        case "directory":
                            dirs.Add(reader.ReadString());
                            reader.Read();
                            break;
                        default:
                            reader.Skip();
                            break;
                    }

                    break;
                case XmlNodeType.EndElement:
                    reader.Read();
                    return;
                default:
                    if (!reader.Read())
                    {
                        return;
                    }

                    break;
                }
            }
        }
Exemplo n.º 17
0
 ///<inheritdoc/>
 public override void AddItem(string item)
 {
     DirectoryCollection.Add(new Activity {
         Name = item, Type = item
     });
 }
Exemplo n.º 18
0
 ///<inheritdoc/>
 public override void RemoveItem()
 {
     DirectoryCollection.Remove(SelectedValue);
 }