Пример #1
0
 /// <summary>
 /// Find a container by <see cref="ObjectType"/>
 /// </summary>
 /// <param name="name">file extension</param>
 /// <returns>Searched <see cref="ContainerNames"/> or null if thery is no container of that extension</returns>
 public ObjectTypeExtension Find(FileExtensions fileExtension)
 {
     foreach (ContainerNames item in NamesList.Values)
     {
         ObjectTypeExtension result = item.Find(fileExtension);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
Пример #2
0
        /// <summary>
        /// Save an object to a file
        /// </summary>
        /// <remarks>The file name is calculated based on object name and type</remarks>
        public virtual void Save()
        {
            if (String.IsNullOrEmpty(App.WorkingCopyPath))
            {
                throw new InvalidOperationException(Properties.Resources.WorkingCopyMissing);
            }

            string filePath         = null;
            ObjectTypeExtension ote = App.AllowedContainers.Find(ObjectType);
            string fileName         = string.Format("{0}.{1}.txt", NormalizeObjectName(this.Name), ote.FileExtension);

            filePath = System.IO.Path.Combine(App.WorkingCopyPath, String.Concat(ote.Container.InvariantName, System.IO.Path.DirectorySeparatorChar, fileName));
            Save(filePath);
        }