コード例 #1
0
        /// <summary>
        /// throws ApplicationException if config file corrupt
        /// </summary>
        public bool UpdateHoliday( string oldName, Holiday toAdd )
        {
            if( toAdd.Name != oldName &&
                HolidayElementFromName( toAdd.Name ).Count() > 0 )
                return false;

            IEnumerable<XElement> elementsToEdit = HolidayElementFromName( oldName );
            if( elementsToEdit.Count() != 1 )
                throw new ApplicationException( "Config file corrupted" );

            elementsToEdit.First().ReplaceWith( toAdd.ToXml() );
            this.Save();
            return true;
        }
コード例 #2
0
        /// <summary>
        /// Returns whether the name conflicts
        /// </summary>
        public bool AddHoliday( Holiday h )
        {
            if( HolidayElementFromName( h.Name ).Count() > 0 )
                return false;

            theDoc.Root.Element( "holidays" ).Add( h.ToXml() );
            this.Save();

            return true;
        }