Example #1
0
        /// <summary>
        /// Changes the extension of a path atom.
        /// </summary>
        /// <param name="table">The string table holding the strings for the path atoms.</param>
        /// <param name="extension">The new file extension. If this is PathAtom.Invalid, this method removes any existing extension.</param>
        /// <returns>A new path atom with the applied extension.</returns>
        public PathAtom ChangeExtension(StringTable table, PathAtom extension)
        {
            Contract.RequiresNotNull(table);
            Contract.Requires(IsValid);

            if (extension.IsValid)
            {
                StringId newId = table.ChangeExtension(StringId, extension.StringId);
                return(new PathAtom(newId));
            }

            return(RemoveExtension(table));
        }
Example #2
0
        /// <summary>
        /// Changes the extension of a path atom.
        /// </summary>
        /// <param name="table">The string table holding the strings for the path atoms.</param>
        /// <param name="extension">The new file extension. If this is PathAtom.Invalid, this method removes any existing extension.</param>
        /// <returns>A new path atom with the applied extension.</returns>
        public PathAtom ChangeExtension(StringTable table, PathAtom extension)
        {
            Contract.Requires(table != null);
            Contract.Requires(IsValid);
            Contract.Ensures(Contract.Result <PathAtom>().IsValid);

            if (extension.IsValid)
            {
                StringId newId = table.ChangeExtension(StringId, extension.StringId);
                return(new PathAtom(newId));
            }

            return(RemoveExtension(table));
        }