Example #1
0
        public int AddFile(Project project, string name, string contents, bool hidden)
        {
            var file = new ProjectFile
            {
                Name = name,
                Contents = contents,
                OwnerProject = project.ID,
                isHidden = hidden
            };

            _db.ProjectFiles.Add(file);
            project.ProjectFiles.Add(file);

            _db.SaveChanges();
            return file.ID;
        }
Example #2
0
 public ProjectStorage(Project project)
 {
     _project = project;
 }
Example #3
0
        private TreeNode projectTree(Project project, IRuntimeProject runtime)
        {
            TreeNode result = new TreeNode
            {
                label   = project.Name,
                icon    = "fa-sitemap",
                actions = new[]
                {
                    new TreeNodeAction { id = "add-class", icon = "fa-plus-circle" }
                } ,
                children = project.ProjectFiles
                    .Where(projectFile => !projectFile.isHidden)
                    .Select<ProjectFile, TreeNode>(projectFile =>
                    {
                        return new TreeNode
                        {
                            label = projectFile.Name,
                            icon = "fa-code",
                            action = "select-file",
                            data = projectFile.Name,
                            actions = new[]
                            {
                                new TreeNodeAction { id = "remove-file", icon = "fa-times-circle-o"       },
                                new TreeNodeAction { id = "open-tab",    icon = "fa-arrow-circle-o-right" },
                            }.Union(runtime.fileActions(projectFile.Name))
                        };
                    })
            };

            return result;
        }
Example #4
0
        public Project CreateProject(string projectType, string projectName, string projectData, string userId)
        {
            var project = new Project
            {
                IsSample    = false,
                Name        = projectName,
                ProjectType = projectType,
                UserID      = userId
            };

            List<ProjectFile> files = new List<ProjectFile>();

            switch (projectType)
            {
                case "console":
                {
                    files.Add(new ProjectFile { Name = "application", Contents = ProjectTemplates.ConsoleApplication });
                    break;
                }

                case "extension":
                {
                    files.Add(new ProjectFile
                    {
                        Name = "plugin",
                        isHidden = true,
                        Contents = ProjectTemplates.ExtensionPlugin
                    });

                    files.Add(new ProjectFile
                    {
                        Name = "extension",
                        Contents = ProjectTemplates.Extension,
                    });

                    files.Add(new ProjectFile
                    {
                        Name = "transform",
                        Contents = ProjectTemplates.Transform,
                    });
                    break;
                }
                //case "dsl":
                //{
                //    DSLConfiguration config = JsonConvert.DeserializeObject<DSLConfiguration>(projectData);

                //    //td: parser and linker types
                //    StringBuilder members = new StringBuilder();
                //    if (config.extendsNamespaces)
                //        members.AppendLine(ProjectTemplates.DSLParseNamespace);
                //    if (config.extendsTypes)
                //        members.AppendLine(ProjectTemplates.DSLParseType);
                //    if (config.extendsMembers)
                //        members.AppendLine(ProjectTemplates.DSLParseMember);
                //    if (config.extendsCode)
                //        members.AppendLine(ProjectTemplates.DSLParseCode);

                //    files.Add(new ProjectFile
                //    {
                //        Name     = "parser",
                //        Contents = string.Format(ProjectTemplates.DSLParser, members.ToString())
                //    });

                //    files.Add(new ProjectFile
                //    {
                //        Name     = "linker",
                //        Contents = ProjectTemplates.DSLLinker
                //    });

                //    files.Add(new ProjectFile
                //    {
                //        Name     = "plugin",
                //        isHidden = true,
                //        Contents = string.Format(ProjectTemplates.DSLPlugin, config.name)
                //    });

                //    dslConfig = new DSLProject
                //    {
                //        Name = config.name,
                //        ParserKind = config.parser,
                //        LinkerKind = config.linker,
                //        ExtendsNamespaces = config.extendsNamespaces,
                //        ExtendsTypes = config.extendsTypes,
                //        ExtendsMembers = config.extendsMembers,
                //        ExtendsCode = config.extendsCode,
                //    };
                //    break;
                //}

                default: throw new InvalidOperationException("Invalid project type: " + projectType);
            }

            _db.Projects.Add(project);
            _db.SaveChanges();

            foreach (var file in files)
            {
                file.OwnerProject = project.ID;
                _db.ProjectFiles.Add(file);
            }

            //if (dslConfig != null)
            //{
            //    dslConfig.ProjectID = project.ID;
            //    _db.DSLProjects.Add(dslConfig);
            //}

            _db.SaveChanges();
            return project;
        }
Example #5
0
 public void SaveProject(Project project)
 {
     _db.SaveChanges();
 }
Example #6
0
        public void LoadProject(Project project)
        {
            var files = from   projectFile in _db.ProjectFiles
                        where  projectFile.OwnerProject == project.ID
                        select projectFile;

            project.ProjectFiles = new List<ProjectFile>(files);
        }