Пример #1
0
        /// <summary>
        /// Lädt eine Konfiguration aus einer Datei.
        /// </summary>
        /// <param name="path">Der volle Pfad zur Datei.</param>
        /// <returns>Die rekonstruierte Instanz.</returns>
        /// <exception cref="ArgumentNullException">Es wurde keine Datei angegeben.</exception>
        public static TransitionConfiguration Load(string path)
        {
            // Validate
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            // Open and process
            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                return(TransitionConfiguration.Load(stream));
        }
Пример #2
0
        /// <summary>
        /// Lädt eine Konfiguration aus Ressourcen.
        /// </summary>
        /// <param name="data">Die binär gespeicherten Ressourcen, erwartet wird
        /// letzlich ein Dateiinhalt im UNICODE Format.</param>
        /// <returns>Die gewünschte Instanz.</returns>
        /// <exception cref="ArgumentNullException">Es wurden keinerlei Daten übergeben.</exception>
        public static TransitionConfiguration Load(byte[] data)
        {
            // Validate
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            // Open and process
            using (var stream = new MemoryStream(data, false))
                return(TransitionConfiguration.Load(stream));
        }
Пример #3
0
        /// <summary>
        /// Meldet alle Fehleinträge in der Konfiguration.
        /// </summary>
        /// <param name="configuration">Die zugehörige Konfigration.</param>
        /// <returns>Die gewünschte Liste.</returns>
        internal IEnumerable<Exception> GetValidationExceptions( TransitionConfiguration configuration )
        {
            // State
            if (!string.IsNullOrEmpty( NextState ))
                if (!configuration.HasState( NextState ))
                    yield return new ArgumentException( NextState, "NextState" );

            // All actions
            foreach (var action in Actions)
                if (string.IsNullOrEmpty( action ))
                    yield return new ArgumentNullException( "Actions" );
                else if (configuration.GetSiteMethod( action ) == null)
                    yield return new ArgumentException( action, "Actions" );
        }
Пример #4
0
        /// <summary>
        /// Speichert die Konfiguration in einer Datei.
        /// </summary>
        /// <param name="configuration">Die gewünschte Konfiguration.</param>
        /// <param name="path">Der volle Pfad zur Datei.</param>
        /// <param name="mode">Die Art, wie die Datei zu öffnen ist.</param>
        public static void Save(this TransitionConfiguration configuration, FileInfo path, FileMode mode)
        {
            // Validate
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            // Forward
            configuration.Save(path.FullName, mode);
        }
Пример #5
0
        /// <summary>
        /// Speichert die Konfiguration in einer Datei.
        /// </summary>
        /// <param name="configuration">Die gewünschte Konfiguration.</param>
        /// <param name="path">Der volle Pfad zur Datei.</param>
        /// <param name="mode">Die Art, wie die Datei zu öffnen ist.</param>
        public static void Save(this TransitionConfiguration configuration, string path, FileMode mode)
        {
            // Validate
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            // Just open file and do it
            using (var stream = new FileStream(path, mode, FileAccess.Write, FileShare.None))
                configuration.Save(stream);
        }
Пример #6
0
        /// <summary>
        /// Meldet alle Fehleinträge in der Konfiguration.
        /// </summary>
        /// <param name="configuration">Die zugehörige Konfigration.</param>
        /// <returns>Die gewünschte Liste.</returns>
        internal IEnumerable <Exception> GetValidationExceptions(TransitionConfiguration configuration)
        {
            // State
            if (!string.IsNullOrEmpty(NextState))
            {
                if (!configuration.HasState(NextState))
                {
                    yield return(new ArgumentException(NextState, "NextState"));
                }
            }

            // All actions
            foreach (var action in Actions)
            {
                if (string.IsNullOrEmpty(action))
                {
                    yield return(new ArgumentNullException("Actions"));
                }
                else if (configuration.GetSiteMethod(action) == null)
                {
                    yield return(new ArgumentException(action, "Actions"));
                }
            }
        }
Пример #7
0
 /// <summary>
 /// Speichert die Konfiguration in einer Datei.
 /// </summary>
 /// <param name="configuration">Die gewünschte Konfiguration.</param>
 /// <param name="path">Der volle Pfad zur Datei.</param>
 public static void Save(this TransitionConfiguration configuration, FileInfo path)
 {
     // Forward
     configuration.Save(path, FileMode.Create);
 }