本文整理汇总了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;
}
示例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);
}
示例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(); ;
}
示例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;
}
示例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;
}
示例6: Connection
protected Connection(Project project, params Expression<Func<string, object>>[] options)
: base(options)
{
project.Add(this);
Requests = new List<Request>();
}