当前位置: 首页>>代码示例>>C#>>正文


C# Project.Add方法代码示例

本文整理汇总了C#中Project.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Project.Add方法的具体用法?C# Project.Add怎么用?C# Project.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project的用法示例。


在下文中一共展示了Project.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddNewSourceToProject

			/// <summary>
			/// Opens a new-source dialog
			/// </summary>
			public static bool AddNewSourceToProject(Project Project, string RelativeDir)
			{
				var sdlg = new NewSrcDlg();
				if (sdlg.ShowDialog().Value)
				{
					var file = (String.IsNullOrEmpty(RelativeDir) ? "" : (RelativeDir + "\\")) + sdlg.FileName;
					var absFile = Project.BaseDirectory + "\\" + file;

					if (File.Exists(absFile))
						return false;

					if (Project.Add(file)!=null)
					{
						// Set standard encoding to UTF8
						File.WriteAllText(absFile, "",Encoding.UTF8);
						Project.Save();
						Instance.UpdateGUI();
						return true;
					}
				}
				return false;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:25,代码来源:FileManagement.cs

示例2: Edit

        public ActionResult Edit([Bind(Include = "ClassroomId,CourseId,DataCenterId,UserId,Start,Name")] Classroom classroom, string sessionId)
        {
            if (ModelState.IsValid)
            {
                DataCenter dc = this.db.Query<DataCenter>().Where(d => d.DataCenterId == classroom.DataCenterId).FirstOrDefault();
                if (dc != null)
                {
                    Course crs = this.db.Query<Course>().Where(c => c.CourseId == classroom.CourseId).FirstOrDefault();
                    if (crs != null)
                    {
                        Project projectObject = new Project(this.st);
                        if (classroom.ClassroomId == 0)
                        {
                            projectObject.name = crs.Name + "-" + classroom.Start.ToShortDateString();
                            projectObject.region = dc.Region;
                            projectObject.Add();
                            if (projectObject.id != null)
                            {
                                classroom.Project = projectObject.id;
                                this.db.Add<Classroom>(classroom);
                                Log.Write(this.db, ControllerContext.HttpContext, new Log() { Message = LogMessages.create, Detail = "Classroom created for " + crs.Name + " on " + classroom.JSDate });
                            }
                        }
                        else
                        {
                            this.db.Update<Classroom>(classroom);
                            Log.Write(this.db, ControllerContext.HttpContext, new Log() { Message = LogMessages.update, Detail = "Classroom updated for  " + crs.Name + " on " + classroom.JSDate });
                        }

                        List<SeatTemp> sts = this.db.Query<SeatTemp>().Where(st => st.SessionId == sessionId).ToList();
                        List<int> stids = sts.Select(s => s.SeatId).ToList();
                        List<Seat> seatsToRemove = this.db.Query<Seat>().Where(s => !stids.Contains(s.SeatId)).ToList();
                        Configuration configuration = new Configuration(this.st);
                        foreach (Seat s in seatsToRemove)
                        {
                            this.db.Remove<Seat>(s);
                            configuration.Id = s.ConfigurationId;
                            configuration.Delete();
                        }

                        foreach (SeatTemp st in sts)
                        {
                            Seat s = st.ToSeat();
                            if (s.SeatId == 0)
                            {
                                if (s.ClassroomId == 0)
                                {
                                    s.ClassroomId = classroom.ClassroomId;
                                }

                                User usr = this.db.Query<User>().Where(u => u.UserId == s.UserId).FirstOrDefault();
                                configuration.Name = usr.EmailAddress + "-" + crs.Name;
                                configuration.Add(classroom.Project, classroom.Course.Template, dc.GateWayBackboneId, dc.Region);
                                if (configuration.Id != null)
                                {
                                    s.ConfigurationId = configuration.Id;
                                    this.db.Add<Seat>(s);
                                }
                            }

                            this.db.Remove<SeatTemp>(st);
                        }

                        this.db.SaveChanges();
                    }
                }

                return this.RedirectToAction("Index", "Home");
            }

            ViewBag.Session = sessionId;
            this.PopulateTemp(classroom.ClassroomId, ViewBag.Session);
            ViewBag.CourseId = new SelectList(this.db.Query<Course>(), "CourseId", "Name", classroom.CourseId);
            ViewBag.UserId = new SelectList(this.db.Query<User>(), "UserId", "EmailAddress", classroom.UserId);
            return this.View(classroom);
        }
开发者ID:Wierdbeard65,项目名称:Labinator2016,代码行数:76,代码来源:ClassroomsController.cs

示例3: AddExistingSourceToProject

			public static void AddExistingSourceToProject(Project Project, string RelativeDir, params string[] Files)
			{
				var absPath = (Project.BaseDirectory + "\\" + RelativeDir).Trim('\\');
				foreach (var FileName in Files)
				{
					/*
					 * - Try to add the new file; if successful:
					 * - Physically copy the file if it's not in the target directory
					 */
					var newFile = absPath + "\\" + Path.GetFileName(FileName);

					if (Project.Add(newFile)!=null)
					{
						try
						{
							if (Path.GetDirectoryName(FileName) != absPath)
								File.Copy(FileName, newFile, true);
						}
						catch (Exception ex) { ErrorLogger.Log(ex); }
					}
				}
				if (Project.Save())
					Instance.UpdateGUI(); ;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:24,代码来源:FileManagement.cs

示例4: RenameFile

			public static bool RenameFile(Project Project, string file, string NewFileName)
			{
				var absPath = Project.ToAbsoluteFileName(file);
				var newFilePath =Path.Combine(Project.BaseDirectory, Path.GetDirectoryName(NewFileName),Util.PurifyFileName(Path.GetFileName(NewFileName)));
				var ret = Util.MoveFile(absPath, newFilePath);
				if (ret)
				{
					Project.Remove(file);
					Project.Add(newFilePath);
					Project.Save();

					foreach (var e in Instance.Editors)
						if (e.AbsoluteFilePath == absPath)
						{
							e.AbsoluteFilePath = newFilePath;
							e.Reload();
						}
				}
				return ret;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:20,代码来源:FileManagement.cs

示例5: AddExistingDirectoryToProject

			public static bool AddExistingDirectoryToProject(string DirectoryPath, Project Project, string RelativeDir)
			{
				/*
				 * - If dir not controlled by prj, add it
				 * - Copy the directory and all its children
				 * - Save project
				 */
				var newDir_rel = Path.Combine(RelativeDir, Path.GetFileName(DirectoryPath));
				var newDir_abs = Project.ToAbsoluteFileName(newDir_rel);

				// If project dir is a subdirectory of DirectoryPath, return false
				if (Project.BaseDirectory.Contains(DirectoryPath) || DirectoryPath == Project.BaseDirectory)
				{
					MessageBox.Show("Project's base directory is part of " + DirectoryPath + " - cannot add it","File addition error");
					return false;
				}

				if (!Project.SubDirectories.Contains(newDir_rel))
					Project.SubDirectories.Add(newDir_rel);

				Util.CreateDirectoryRecursively(newDir_abs);

				foreach (var file in Directory.GetFiles(DirectoryPath, "*", SearchOption.AllDirectories))
				{
					// Note: Empty directories will be ignored.
					var newFile_rel = file.Substring(DirectoryPath.Length).Trim('\\');
					var newFile_abs = newDir_abs + "\\" + newFile_rel;

					if (Project.Add(newFile_abs)!=null)
					{
						try
						{
							if (file != newFile_abs)
								File.Copy(file, newFile_abs, true);
						}
						catch (Exception ex) { 
							ErrorLogger.Log(ex);
							if(MessageBox.Show("Stop adding files?","Error while adding files",MessageBoxButton.YesNo)==MessageBoxResult.Yes)
								return false; 
						}
					}
				}
				Project.Save();
				Instance.UpdateGUI();
				return true;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:46,代码来源:FileManagement.cs

示例6: Connection

 protected Connection(Project project, params Expression<Func<string, object>>[] options)
     : base(options)
 {
     project.Add(this);
     Requests = new List<Request>();
 }
开发者ID:simoneb,项目名称:augen,代码行数:6,代码来源:Connection.cs


注:本文中的Project.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。