/// ------------------------------------------------------------------------------------
        public void SaveIdForIndex(int index, string newId)
        {
            if (newId == null || newId.Trim() == string.Empty)
            {
                return;
            }

            newId = GetFieldNameToSerialize(newId);

            if (index == RowData.Count)
            {
                RowData.Add(new FieldInstance(newId));
            }
            else if (RowData[index].FieldId != newId)
            {
                _fieldGatherer.SuspendProcessing();
                _file.RenameId(RowData[index].FieldId, newId);
                RowData[index].FieldId = newId;
                _file.Save();
                _fieldGatherer.GatherFieldsForFileNow(_file.PathToAnnotatedFile);
                _fieldGatherer.ResumeProcessing(true);
            }
        }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        public static ComponentFile CreateComponentFile(TemporaryFolder parentFolder,
                                                        ProjectElement parentElement, string fileName)
        {
            File.WriteAllText(parentFolder.Combine(fileName), @"hello");

            var cf = new ComponentFile(parentElement, parentFolder.Combine(fileName),
                                       new[] { FileType.Create("Text", ".txt"), new UnknownFileType(null, null) },
                                       new ComponentRole[] { }, new XmlFileSerializer(null), null, null, null);

            cf.Save();             //creates the meta file path

            Assert.IsTrue(File.Exists(parentFolder.Combine(fileName)));
            Assert.IsTrue(File.Exists(parentFolder.Combine(fileName + ".meta")));

            return(cf);
        }