public void DeleteDocument(string parentSubPath, ProjectItemType type, string documentName)
        {
            var fileName = "";

            if (type == ProjectItemType.Page)
            {
                fileName = $"{documentName}.{Constants.ProjectItemFileExtensions.Page}";
            }
            if (type == ProjectItemType.Workflow)
            {
                fileName = $"{documentName}.{Constants.ProjectItemFileExtensions.Workflow}";
            }
            var filePath = Path.Combine(Path.GetDirectoryName(_projectFilePath), parentSubPath, fileName);

            if (!File.Exists(filePath))
            {
                throw new ArgumentException($"A {type.ToString()} named '{fileName}' does not exist in this directory and cannot be deleted!");
            }

            _cmdProcessor.Execute(DeleteDocumentCommand.Create(_outputService, _projectFilePath, parentSubPath, fileName));

            ProjectItemChanged?.Invoke(new ProjectItemChangedArgs
            {
                ItemType      = type,
                Change        = ProjectItemChange.Delete,
                ItemName      = documentName,
                ParentSubPath = parentSubPath
            });
        }
 public ProjectItemExistsEventArgs(string projectName, string itemName, ProjectItemType itemType)
 {
     this.ProjectName = projectName;
     this.ItemName = itemName;
     this.ItemType = itemType;
     this.Exists = false;
 }
Example #3
0
        private static Task <AFileModel> ReadFileModel(ProjectItemType type, string content)
        {
            switch (type)
            {
            case ProjectItemType.Bank:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <BankModel>(content)));

            case ProjectItemType.Character:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <CharacterModel>(content)));

            case ProjectItemType.Map:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <MapModel>(content)));

            case ProjectItemType.TileSet:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <TileSetModel>(content)));

            case ProjectItemType.Palette:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <PaletteModel>(content)));

            case ProjectItemType.World:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <WorldModel>(content)));

            case ProjectItemType.Entity:
                return(Task <AFileModel> .Factory.StartNew(() => Toml.ReadString <EntityModel>(content)));

            case ProjectItemType.None:
            default:
                return(Task.FromResult <AFileModel>(null));
            }
        }
		public ProjectItemExistsEventArgs(string projectName, string itemName, ProjectItemType itemType)
		{
			this.ProjectName = projectName;
			this.ItemName = itemName;
			this.ItemType = itemType;
			this.Exists = false;
		}
        public ActionResult ViewArray(string projectID, ProjectItemType type, string name)
        {
            var project = this.ProjectProvider.FindByID(projectID);
            var role = this.ProjectProvider.GetRole(project.ID, MvcApplication.CurrentUser.ID);

            ProjectItem[] items = null;
            switch (type)
            {
                case ProjectItemType.Actors: items = project.Definition.Actors; break;
                case ProjectItemType.Objetives: items = project.Definition.Objetives; break;
                case ProjectItemType.ReqFunctionals: items = project.Requirements.Functionals; break;
                case ProjectItemType.ReqInformations: items = project.Requirements.Informations; break;
                case ProjectItemType.ReqNotFunctionals: items = project.Requirements.NotFunctionals; break;
            }

            if (role != RoleType.Developer)
            {
                items = (from i in items
                         where i.IsPublic
                         select i).ToArray();
            }

            return View("ViewArray", new Model.Preview
            {
                Project = project,
                Items = items,
                Type = type
            });

        }
Example #6
0
        public static string GetExtensionByType(ProjectItemType type)
        {
            string extensionBanks      = (string)Application.Current.FindResource(_extensionBanksKey);
            string extensionCharacters = (string)Application.Current.FindResource(_extensionCharactersKey);
            string extensionMaps       = (string)Application.Current.FindResource(_extensionMapsKey);
            string extensionTileSets   = (string)Application.Current.FindResource(_extensionTileSetsKey);
            string extensionPalettes   = (string)Application.Current.FindResource(_extensionPalettesKey);
            string extensionWorlds     = (string)Application.Current.FindResource(_extensionWorldsKey);
            string extensionEntities   = (string)Application.Current.FindResource(_extensionEntitiesKey);

            switch (type)
            {
            case ProjectItemType.Bank: return(extensionBanks);

            case ProjectItemType.Character: return(extensionCharacters);

            case ProjectItemType.Map: return(extensionMaps);

            case ProjectItemType.TileSet: return(extensionTileSets);

            case ProjectItemType.Palette: return(extensionPalettes);

            case ProjectItemType.World: return(extensionWorlds);

            case ProjectItemType.Entity: return(extensionEntities);

            case ProjectItemType.None:
            default: return(string.Empty);
            }
        }
Example #7
0
        public void LoadDocument(ProjectItemType type, string documentPath)
        {
            var layout = _projectService.LoadLayoutDocument(documentPath);

            _cmdProcessor.Clear();

            LayoutingCanvas = new LayoutingCanvas(this, this, layout);
            OnPropertyChanged(nameof(LayoutingCanvas));
        }
        public ProjectItemOld GetChild(string id, ProjectItemType itemType)
        {
            if (Children == null)
            {
                return(null);
            }

            return(Children.Where(p => p.Id == id && (p.Type & itemType) != 0).FirstOrDefault());
        }
 public void FindDescendants(List <ProjectItemOld> items, ProjectItemType type)
 {
     Foreach(this, item =>
     {
         if ((item.Type & type) != 0)
         {
             items.Add(item);
         }
     });
 }
 public void Set(ProjectItemType resourceType, Object resource)
 {
     m_resource     = resource;
     m_resrouceType = resourceType;
     IsSelected     = RuntimeSelection.IsSelected(m_resource);
     if (m_started)
     {
         UpdatePreview();
     }
 }
 public ActionResult Preview(Project project, ProjectItem[] items, ProjectItemType type)
 {
     return View(new Model.View
     {
         Project = project,
         Item = items.FirstOrDefault(),
         Type = type,
         Role = this.ProjectProvider.GetRole(project.ID, MvcApplication.CurrentUser.ID)
     });
 }
Example #12
0
        /// <summary>
        /// Builds properties collection for configuration file.
        /// </summary>
        private static Dictionary <string, string> BuildConfigProperties(
            ProjectItemType type,
            CopyToOutputDirectory copyToOutput)
        {
            Dictionary <string, string> properties = new Dictionary <string, string>();

            properties["BuildAction"]  = type.ToString();
            properties["CopyToOutput"] = copyToOutput.ToString();
            return(properties);
        }
 public TestingSortOption(
     string displayName,
     string propertyName,
     ListSortDirection sortDirection,
     ProjectItemType type) : base(
         displayName,
         propertyName,
         sortDirection,
         type)
 {
 }
 public ProjectItemGeneratedEventArgs(string projectItemName, string projectItemContent, string projectName, string parentItemName, ProjectItemType parentItemType, IProjectItemGenerator baseGenerator, bool overwrite)
     : this()
 {
     this.BaseGenerator = baseGenerator;
     this.ProjectItemName = projectItemName;
     this.ProjectItemContent = projectItemContent;
     this.ProjectName = projectName;
     this.ParentItemName = parentItemName;
     this.ParentItemType = parentItemType;
     this.Overwrite = overwrite;
 }
Example #15
0
        private void OnCloseProjectSuccess()
        {
            tbrTileSet.Visibility = Visibility.Collapsed;
            tbrMap.Visibility     = Visibility.Collapsed;
            tbrBanks.Visibility   = Visibility.Collapsed;

            dpItemPanel.Children.Clear();

            _currentViewType = ProjectItemType.None;

            dpItemPanel.UpdateLayout();
        }
        public LayoutingDocumentControl(ProjectItemType type, string documentPath, ILayoutingDocumentViewModel viewModel)
        {
            InitializeComponent();

            this.Loaded += LayoutingDocumentControl_Loaded;
            DataContext  = viewModel;

            if (!string.IsNullOrEmpty(documentPath))
            {
                viewModel.LoadDocument(type, documentPath);
            }
        }
Example #17
0
 protected SortOptionBase(
     string displayName,
     string propertyName,
     ListSortDirection sortDirection,
     ProjectItemType applicableTypes)
 {
     ApplicableType     = applicableTypes;
     DisplayName        = displayName;
     PropertyName       = propertyName;
     SortDirection      = sortDirection;
     HasSortDescription = true;
 }
        public ActionResult View(string projectID, ProjectItemType type, string name)
        {
            var project = this.ProjectProvider.FindByID(projectID);
            var item = this.ProjectProvider.GetItem(projectID, type, name);

            return View(new Model.View
            {
                Project = project,
                Item = item,
                Type = type,
                Role = this.ProjectProvider.GetRole(project.ID, MvcApplication.CurrentUser.ID)
            });
        }
Example #19
0
        public bool DeleteProjectFileItems(ProjectItemType itemType, [NotNull] IEnumerable <string> filesPath)
        {
            ProjectFileRepository fileRepo = InitRepository(itemType);

            if (fileRepo != null)
            {
                foreach (var path in filesPath)
                {
                    fileRepo.Delete(path);
                }
                return(true);
            }
            return(false);
        }
Example #20
0
        public void ProjectTypeIsIndependentOfDocumentType()
        {
            // Arrange

            const ProjectItemType type = ProjectItemType.Project;

            // Act

            var hasFlag = type.HasFlag(ProjectItemType.Document);

            // Assert

            Assert.IsFalse(hasFlag);
        }
        /// <summary>
        /// Ve el concepto en vista previa
        /// </summary>
        /// <param name="project">Proyecto</param>
        /// <param name="items">Elemento</param>
        /// <param name="type">Tipo de elemento</param>
        /// <returns></returns>
        public ActionResult Preview(Project project, ProjectItem[] items, ProjectItemType type)
        {
            if (this.GetRole(project.ID) != RoleType.Developer && !items.FirstOrDefault().IsPublic)
                return null;


            return View(new Model.View
            {
                Project = project,
                Item = items.FirstOrDefault(),
                Type = type,
                Role = this.ProjectProvider.GetRole(project.ID, MvcApplication.CurrentUser.ID)
            });
        }
 public void FindChildren(List <ProjectItemOld> items, ProjectItemType type)
 {
     if (Children != null)
     {
         for (int i = 0; i < Children.Count; ++i)
         {
             ProjectItemOld child = Children[i];
             if ((child.Type & type) != 0)
             {
                 items.Add(Children[i]);
             }
         }
     }
 }
Example #23
0
        public void AddItem(string safeFileName, string filePath, ProjectItemType projectItemType)
        {
            //
            // TODO: Add robust "Would you like to overwrite existing?" IO logic
            //       Right now, we simply bulldoze through and overwrite existing
            //       files without asking.
            //
            string fileDest = this.ProjectLocation + "\\" + safeFileName;

            if ("JetCanvas.xml" != safeFileName)
            {
                File.Copy(filePath, fileDest, true);
            }
            this.listProjectItems.Add(new ProjectItem(safeFileName, projectItemType));
        }
Example #24
0
        private ProjectFileRepository InitRepository(ProjectItemType itemType)
        {
            ProjectFileRepository repo;

            switch (itemType)
            {
            case ProjectItemType.WorkListDefinition:
                repo = new ProjectWorkListFileRepository(Project.Current);
                break;

            default:
                repo = new ProjectFileRepository(Project.Current);
                break;
            }
            return(repo);
        }
Example #25
0
        /// <summary>
        /// Checks properties for configuration file.
        /// </summary>
        private static void CheckConfigProperties(
            string configFileName,
            ProjectItemType type,
            CopyToOutputDirectory copyToOutput)
        {
            IEnumerable <ProjectItem> items = ProjectHelper.GetProjectItems()
                                              .Where(item => Path.GetFileName(item.FullName) == configFileName);

            if (items.Count() != 1)
            {
                bool ignore = false;

                if (configFileName == "Web.config" &&
                    items.Count() > 0)
                {
                    ignore = true;
                }

                if (!ignore)
                {
                    RaiseError.WrongConfigFileLocation(configFileName);
                }
            }

            foreach (ProjectItem config in items)
            {
                StringBuilder message = new StringBuilder();

                string description;
                if (!ValidationHelper.CheckProperties(
                        BuildConfigProperties(config.Type, config.CopyToOutput),
                        BuildConfigProperties(type, copyToOutput),
                        new Dictionary <string, string>(),
                        out description))
                {
                    message.Append(description);
                }

                if (message.Length == 0)
                {
                    continue;
                }

                RaiseError.WrongFileProperties(configFileName, message.ToString());
            }
        }
        public ActionResult PreviewResume(Project project, ProjectItem[] items, ProjectItemType type)
        {
            var role = this.ProjectProvider.GetRole(project.ID, MvcApplication.CurrentUser.ID);
            if (role != RoleType.Developer)
            {
                items = (from i in items
                         where i.IsPublic
                         select i).ToArray();
            }

            return View(new Model.Preview
            {
                Project = project,
                Items = items,
                Type = type,
                
            });
        }
Example #27
0
        public static void Seed(this ModelBuilder modelBuilder)
        {
            var now          = DateTime.UtcNow;
            var userName     = Environment.UserName;
            var rootItemType = new ProjectItemType
            {
                Id         = 1,
                Name       = ProjectItemTypeEnum.Root,
                CreatedBy  = userName,
                CreatedOn  = now,
                ModifiedBy = userName,
                ModifiedOn = now
            };

            modelBuilder.Entity <ProjectItemType>().HasData(
                new ProjectItemType {
                Id = 2, Name = ProjectItemTypeEnum.Application, CreatedBy = userName, CreatedOn = now, ModifiedBy = userName, ModifiedOn = now
            },
                new ProjectItemType {
                Id = 3, Name = ProjectItemTypeEnum.Document, CreatedBy = userName, CreatedOn = now, ModifiedBy = userName, ModifiedOn = now
            },
                new ProjectItemType {
                Id = 4, Name = ProjectItemTypeEnum.New, CreatedBy = userName, CreatedOn = now, ModifiedBy = userName, ModifiedOn = now
            },
                new ProjectItemType {
                Id = 5, Name = ProjectItemTypeEnum.Project, CreatedBy = userName, CreatedOn = now, ModifiedOn = now, ModifiedBy = userName
            },
                rootItemType
                );
            modelBuilder.Entity <ProjectItem>().HasData(
                new ProjectItem
            {
                Id         = 1,
                Name       = "Root",
                ItemTypeId = rootItemType.Id,
                CreatedBy  = userName,
                CreatedOn  = now,
                ModifiedBy = userName,
                ModifiedOn = now
            }
                );
        }
Example #28
0
 public ProjectItemBuilder SetType(ProjectItemType projectItemType)
 {
     if (projectItemType == ProjectItemType.Folder)
     {
         _projectItem.Items = new ObservableCollection <ProjectItem>();
         _projectItem.ItemsOperation[0].IsEnabled = true;
         _projectItem.ItemsOperation[1].IsEnabled = false;
         _projectItem.ItemsOperation[2].IsEnabled = false;
         SetImage("/Resources/Images/folder.png");
     }
     else
     {
         _projectItem.ItemsOperation[0].IsEnabled = false;
         _projectItem.ItemsOperation[1].IsEnabled = true;
         _projectItem.ItemsOperation[2].IsEnabled = true;
         _projectItem.Items = null;
         SetImage("/Resources/Images/file.png");
     }
     return(this);
 }
Example #29
0
        private void OnDeleteElement(ProjectItem item)
        {
            if (_currentViewType == item.Type)
            {
                if (dpItemPanel.Children.Count > 0)
                {
                    if (dpItemPanel.Children[0] is UserControl oldGui)
                    {
                        if (oldGui.DataContext is ItemViewModel oldModel)
                        {
                            oldModel.OnDeactivate();
                        }
                    }

                    dpItemPanel.Children.Clear();
                }

                _currentViewType = ProjectItemType.None;

                dpItemPanel.UpdateLayout();
            }
        }
        private async Task <SourceFilesWithConfiguration> getAllSupportedFilesFromProjectAsync(Project project)
        {
            var sourceFiles = new SourceFilesWithConfiguration();

            sourceFiles.Configuration = await getConfigurationAsync(project);

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            foreach (ProjectItem item in project.ProjectItems)
            {
                ProjectItemType itemType = await getTypeOfProjectItemAsync(item);

                if (itemType == ProjectItemType.cFile || itemType == ProjectItemType.cppFile || itemType == ProjectItemType.headerFile)
                {
                    //List<SourceFile> projectSourceFileList = await getProjectFilesAsync(project, configuration);
                    //foreach (SourceFile projectSourceFile in projectSourceFileList)
                    //	addEntry(currentConfiguredFiles, projectSourceFileList, project);
                }
            }

            return(sourceFiles);
        }
Example #31
0
        public static AFileModel FileModelFactory(ProjectItemType type)
        {
            switch (type)
            {
            case ProjectItemType.Bank: return(new BankModel());

            case ProjectItemType.Character: return(new CharacterModel());

            case ProjectItemType.Map: return(new MapModel());

            case ProjectItemType.TileSet: return(new TileSetModel());

            case ProjectItemType.Palette: return(new PaletteModel());

            case ProjectItemType.World: return(new WorldModel());

            case ProjectItemType.Entity: return(new EntityModel());

            case ProjectItemType.None:
            default: return(null);
            }
        }
        /// <summary>
        /// Gets names of files matching specified criteria
        /// </summary>
        /// <param name="types">Project item type(s)</param>
        /// <param name="matchString">Regex string</param>
        /// <returns></returns>
        public IEnumerable <string> GetSourceFiles(ProjectItemType types, string matchString)
        {
            var regex = new Regex(matchString);

            foreach (var xItemGroupElement in _projectElement.Elements(Namespace + ItemGroupString))
            {
                foreach (ProjectItemType type in Enum.GetValues(typeof(ProjectItemType)))
                {
                    if ((type & types) == type && type != ProjectItemType.All)
                    {
                        foreach (var elementOfType in xItemGroupElement.Elements(Namespace + ProjectItemTypesDictionary[type]))
                        {
                            var fileName = elementOfType.Attribute(IncludeString)?.Value;
                            if (fileName != null && (string.IsNullOrEmpty(matchString) || regex.IsMatch(fileName)))
                            {
                                yield return(Path.GetFullPath(Path.Combine(Directory, fileName)));
                            }
                        }
                    }
                }
            }
        }
Example #33
0
        /// <summary>
        /// Finds the project item within the current project heirarchy
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="name"></param>
        /// <param name="itemType"></param>
        /// <returns></returns>
        private static ProjectItem FindItemByName(ProjectItems projectItems, string itemPath,
                                                  ProjectItemType itemType)
        {
            //Get list of file parts
            List <string> partNames = GetPathParts(itemPath);

            //Locate matching file
            ProjectItems currentProjectItems = projectItems;
            ProjectItem  subItem             = null;

            foreach (string partName in partNames)
            {
                //Find sub item
                subItem = GATLib.DteHelper.FindItemByName(currentProjectItems, partName, false);
                if (null == subItem)
                {
                    return(null);
                }

                //Ensure only folders (if we want only folders)
                if ((ProjectItemType.Folder == itemType) &&
                    (VSConstants.vsProjectItemKindPhysicalFolder != subItem.Kind))
                {
                    return(null);
                }

                //Iterate to sub item
                currentProjectItems = subItem.ProjectItems;
            }

            //Ensure we got a file (if we wanted files)
            if ((ProjectItemType.File == itemType) &&
                (VSConstants.vsProjectItemKindPhysicalFile != subItem.Kind))
            {
                return(null);
            }

            return(subItem);
        }
Example #34
0
        public void AddItem(string safeFileName, FileStream sourceFileStream, ProjectItemType projectItemType)
        {
            //
            // Not setting FileStream.Position to 0 will bite you in the ass (FileStream.Read will
            // fail without throwing any exception).
            // Passing this stream to a New Bitmap() constructor is what dirties the object
            //
            sourceFileStream.Position = 0;
            string     fileDest       = this.ProjectLocation + "\\" + safeFileName;
            FileStream destFileStream = File.Create(fileDest, (int)sourceFileStream.Length);

            byte[] buffer = new byte[sourceFileStream.Length];
            int    read   = 0;

            while ((read = sourceFileStream.Read(buffer, 0, buffer.Length)) > 0)
            {
                destFileStream.Write(buffer, 0, read);
            }
            sourceFileStream.Position = 0;
            destFileStream.Position   = 0;
            destFileStream.Close();
            this.listProjectItems.Add(new ProjectItem(safeFileName, projectItemType));
        }
        public ProjectItemOld(string id, ProjectItemType type, ProjectItemOld parent = null, KnownResourceType[] resourceTypes = null)
        {
            if (!IsValidId(id))
            {
                throw new System.FormatException("id has invalid characters");
            }
            if (id != null)
            {
                if (type != ProjectItemType.Resource)
                {
                    if (id[0] == '-' || char.IsDigit(id[0]))
                    {
                        throw new System.FormatException("id should start with character");
                    }
                }
            }


            Parent        = parent;
            Id            = id;
            Type          = type;
            ResourceTypes = resourceTypes;
        }
 public ActionResult AddComment(string projectID, ProjectItemType type, string name, string message)
 {
     this.ProjectProvider.AddComment(projectID, type, name, message, MvcApplication.CurrentUser);
     return null;
 }
 public ActionResult ViewComment(string projectID, ProjectItemType type, string name, long timeTicks)
 {
     var item = this.ProjectProvider.GetItem(projectID, type, name);
     var project = this.ProjectProvider.FindByID(projectID);
     var actors = project.Actors.Concat(
                 this.UserProvider.ListByIDs(
                     item.Comments.Where(c => !project.Actors.Any(a => a.ID == c.UserID))
                     .Select(c => c.UserID).ToArray()
                     ).Select(u => new Actor
                     {
                         ID = u.ID,
                         Email = u.Email,
                         Name = u.Email,
                         Role = (u.ID == project.Owner.ID) ? RoleType.Developer : RoleType.Stakeholder
                     })
                     ).ToArray();
     var comment = item.Comments.Where(c => c.Time.Ticks == timeTicks).FirstOrDefault();
     var model = new Model.ViewComment
     {
         Project = project,
         Item = item,
         Comment = comment,
         Type = type,
         Actors = actors,
         Actor = actors.FirstOrDefault(a => a.ID == comment.UserID)
     };
     return View(model);
 }
 public ActionResult NewComment(string projectID, ProjectItemType type, string name)
 {
     var model = new Model.View {
         Item = this.ProjectProvider.GetItem(projectID, type, name),
         Type = type,
         Project = this.ProjectProvider.FindByID(projectID)
     };
     return View(model);
 }
 public ActionResult ListComments(string projectID, ProjectItemType type, string name)
 {
     var item = this.ProjectProvider.GetItem(projectID, type, name);
     var project = this.ProjectProvider.FindByID(projectID);
     return View(
         new Model.ListComments
         {
             Comments = item.Comments,
             ProjectID = project.ID,
             Type = type,
             ItemName = name,
             Actors = project.Actors.Concat(
                 this.UserProvider.ListByIDs(
                     item.Comments.Where(c => !project.Actors.Any(a => a.ID == c.UserID))
                     .Select(c => c.UserID).ToArray()
                     ).Select(u => new Actor
                     {
                         ID = u.ID,
                         Email = u.Email,
                         Name = u.Email,
                         Role = (u.ID == project.Owner.ID) ? RoleType.Developer : RoleType.Stakeholder
                     })
                     ).ToArray()
         }
         );
 }
Example #40
0
        public ProjectItem(string name, ProjectItemType projectItemType, IProjectItem parent = null)
        {
            Argument.IsNotNullOrWhitespace("name", name);

            Initialize(name, projectItemType, parent);
        }
Example #41
0
		/// <summary>
		/// Builds properties collection for configuration file.
		/// </summary>
		private static Dictionary<string, string> BuildConfigProperties(
			ProjectItemType type,
			CopyToOutputDirectory copyToOutput)
		{
			Dictionary<string, string> properties = new Dictionary<string, string>();
			properties["BuildAction"] = type.ToString();
			properties["CopyToOutput"] = copyToOutput.ToString();
			return properties;
		}
Example #42
0
 public static string GetName(PackageBase package, ProjectItemType type, string initName)
 {
     string n = initName;
     int i = 1;
     do
     {
         if (CheckName(package, type, n))
             return n;
         n = initName + i++;
     }
     while (true);
 }
Example #43
0
 public static bool CheckName(PackageBase package, ProjectItemType type, string name)
 {
     if (package == null) return true;
     foreach (var i in package.Items)
     {
         if (i.ItemType == type && i.Name == name)
             return false;
     }
     return true;
 }
 public ActionResult AllowEdit(string projectID, ProjectItemType type, string name)
 {
     var item = this.ProjectProvider.BlockItem(projectID, type, name, MvcApplication.CurrentUser);
     return Json(item, JsonRequestBehavior.AllowGet);
 }
 public ActionResult SaveItem(string projectID, ProjectItemType type,string name, ProjectItem item)
 {
     var oldItem = this.ProjectProvider.GetItem(projectID, type, name);
     if (string.IsNullOrEmpty(item.Name))
         oldItem.Name = item.Name;
     oldItem.Data = item.Data;
     return Json(this.ProjectProvider.SaveItem(projectID, type, oldItem), JsonRequestBehavior.AllowGet);
 }
 public ActionResult New(string projectID, ProjectItemType type, string name)
 {
     var project = this.ProjectProvider.FindByID(projectID);
     this.ProjectProvider.SaveItem(projectID, type, new ProjectItem
     {
         Name = name
     });
     return Json(true, JsonRequestBehavior.AllowGet);
 }
 public ActionResult Publish(string projectID, ProjectItemType type, string name, bool publish)
 {
     return Json(this.ProjectProvider.PublishItem(projectID, type, name, publish), JsonRequestBehavior.AllowGet);
 }
Example #48
0
 public ProjectItem(int i, ProjectItemType t, String n, String d, bool c)
 {
     this.id = i;
     this.name = n;
     this.description = d;
     this.complete = c;
     this.Type = t;
 }
Example #49
0
        private void Initialize(string name, ProjectItemType projectItemType, IProjectItem parent = null)
        {
            if (parent == null)
            {
                Argument.IsNotNull("name", name);
            }
            else
            {
                Argument.IsNotNullOrWhitespace("name", name);
            }

            Name = name;
            Type = projectItemType;
            Parent = parent;
        }
Example #50
0
 public static IEnumerable <ProjectItem> OfType(this IEnumerable <ProjectItem> that, ProjectItemType type)
 {
     return(that.Where(item => item.ItemType == type));
 }
        public ProjectItem GetProjectItem(string projectName, string parentRelativeName, ProjectItemType parentItemType)
        {
            var relativeFolder = string.Empty;
            var parentFileName = string.Empty;
            if (parentItemType == ProjectItemType.File)
            {
                var folders = parentRelativeName.Split(new char[] {'\\'});
                for (var ii = 0; ii < folders.Length - 1; ii++)
                {
                    relativeFolder = relativeFolder + @"\" + folders[ii];
                }
                parentFileName = folders[folders.Length - 1];
            }
            else
            {
                relativeFolder = parentRelativeName;
            }

            if (relativeFolder != string.Empty && relativeFolder != "\\")
            {
                var folder = this.GetProjectItem(GetProject(projectName), relativeFolder);
                if (parentItemType == ProjectItemType.File)
                {
                    foreach (ProjectItem subItem in folder.ProjectItems)
                    {
                        if (subItem.Kind == Constants.vsProjectItemKindPhysicalFile && StringHelper.Match(subItem.Name, parentFileName, true))
                        {
                            return subItem;
                        }
                    }
                    return null;
                }
                return folder;
            }
            else
            {
                var projectToAddTo = this.GetProject(projectName);
                foreach (ProjectItem projectItem in projectToAddTo.ProjectItems)
                {
                    if (projectItem.Kind == Constants.vsProjectItemKindPhysicalFile && StringHelper.Match(projectItem.Name, parentFileName, true))
                    {
                        return projectItem;
                    }
                }
                return null;
            }
        }
 public ProjectItemGeneratedEventArgs(string projectItemName, string projectItemContent, string projectName, string parentItemName, ProjectItemType parentItemType, IProjectItemGenerator baseGenerator, bool overwrite)
     : this()
 {
     this.BaseGenerator      = baseGenerator;
     this.ProjectItemName    = projectItemName;
     this.ProjectItemContent = projectItemContent;
     this.ProjectName        = projectName;
     this.ParentItemName     = parentItemName;
     this.ParentItemType     = parentItemType;
     this.Overwrite          = overwrite;
 }
Example #53
0
		/// <summary>
		/// Checks properties for configuration file.
		/// </summary>
		private static void CheckConfigProperties(
			string configFileName,
			ProjectItemType type,
			CopyToOutputDirectory copyToOutput)
		{
			IEnumerable<ProjectItem> items = ProjectHelper.GetProjectItems()
				.Where(item => Path.GetFileName(item.FullName) == configFileName);

			if (items.Count() != 1)
			{
				bool ignore = false;

				if (configFileName == "Web.config"
					&& items.Count() > 0)
					ignore = true;

				if (!ignore)
					RaiseError.WrongConfigFileLocation(configFileName);
			}

			foreach (ProjectItem config in items)
			{
				StringBuilder message = new StringBuilder();

				string description;
				if (!ValidationHelper.CheckProperties(
					BuildConfigProperties(config.Type, config.CopyToOutput),
					BuildConfigProperties(type, copyToOutput),
					new Dictionary<string, string>(),
					out description))
				{
					message.Append(description);
				}

				if (message.Length == 0)
					continue;

				RaiseError.WrongFileProperties(configFileName, message.ToString());
			}
		}