Exemplo n.º 1
0
        /// <summary>
        /// Creates a contextual picture holding given configuration and its
        /// analytic representation in possibly more pictures.
        /// </summary>
        /// <param name="configuration">The configuration to be represented.</param>
        /// <param name="allObjects">The analytic representation of the configuration.</returns>
        /// <returns>The contextual picture.</returns>
        private static ContextualPicture CreatePicture(Configuration configuration, IAnalyticObject[][] allObjects)
        {
            // Create pictures
            var pictures = new PicturesOfConfiguration(configuration, allObjects.Length);

            // Add all objects to them. For a current picture
            pictures.ForEach((picture, pictureIndex) =>
            {
                // Get the objects
                var objects = allObjects[pictureIndex].ToArray();

                // Add all of them to it
                for (var i = 0; i < objects.Length; i++)
                {
                    // Get the current object
                    var analyticObject = objects[i];

                    // Add it to the picture
                    picture.TryAdd(configuration.AllObjects[i], analyticObject, out var _);
                }
            });

            // Return the result
            return(new ContextualPicture(pictures));
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public void InconstructiblePicturesByCloning(PicturesOfConfiguration previousPictures, Configuration newConfiguration, InconsistentPicturesException exception)
        {
            // Prepare the initial information string
            var infoString = $"Undrawable object into pictures.";

            // If logging is allowed, log it with the reference to more detail in the file
            if (_settings.LogFailures)
            {
                Log.Warning("Object generation: {info} See {path} for more detail.", infoString, _settings.FailureFilePath);
            }

            // Prepare the formatter for the configuration
            var formatter = new OutputFormatter(newConfiguration.AllObjects);

            // Add the data about how the object can be drawn
            infoString += $"\n\nThe object is the last object of the following defining configuration:\n\n{formatter.FormatConfiguration(newConfiguration).Indent(2)}";

            // Add the exception
            infoString += $"\n\nThe details of the exception: {exception.Format(formatter)}\n";

            // Open the stream writer for the file
            using var streamWriter = new StreamWriter(_settings.FailureFilePath, append: true);

            // Write indented message to the file
            streamWriter.WriteLine($"- {infoString.Indent(3).TrimStart()}");
        }
 /// <inheritdoc/>
 public void InconstructibleContextualPictureByCloning(ContextualPicture previousContextualPicture, PicturesOfConfiguration newConfigurationPictures, InconsistentPicturesException exception)
 {
 }
 /// <inheritdoc/>
 public void InconstructiblePicturesByCloning(PicturesOfConfiguration previousPictures, Configuration newConfiguration, InconsistentPicturesException exception)
 {
 }