Exemplo n.º 1
0
        /// <summary>
        /// Creates a new stream adapter metadata.
        /// </summary>
        /// <param name="streamAdapterType">The type of the stream adapter.</param>
        /// <param name="logWriter">The log writer where errors should be written to.</param>
        /// <returns>A stream adapter metadata.</returns>
        public static StreamAdapterMetadata Create(Type streamAdapterType, VisualizationLogWriter logWriter)
        {
            if (streamAdapterType == null)
            {
                throw new NullReferenceException(nameof(streamAdapterType));
            }

            // Stream adapter must not be a generic type
            if (streamAdapterType.IsGenericType)
            {
                logWriter.WriteError("StreamAdapter {0} could not be loaded because it is a generic type", streamAdapterType.Name);
                return(null);
            }

            // Find the stream adapter base type
            Type baseStreamAdapterType = streamAdapterType;

            while ((baseStreamAdapterType != null) && (baseStreamAdapterType.Name != typeof(StreamAdapter <,>).Name))
            {
                baseStreamAdapterType = baseStreamAdapterType.BaseType;
            }

            // Make sure ouor type really derives from the base stream adapter type.
            if (baseStreamAdapterType == null)
            {
                logWriter.WriteError("StreamAdapter {0} could not be loaded because it is not derived from StreamAdapter<TSrc, TDest>", streamAdapterType.Name);
                return(null);
            }

            // Create the stream adapter metadata
            return(new StreamAdapterMetadata(baseStreamAdapterType.GenericTypeArguments[0], baseStreamAdapterType.GenericTypeArguments[1], streamAdapterType));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new summarizer metadata.
        /// </summary>
        /// <param name="summarizerType">The type of the summarizer.</param>
        /// <param name="logWriter">The log writer where errors should be written to.</param>
        /// <returns>A summarizer metadata.</returns>
        public static SummarizerMetadata Create(Type summarizerType, VisualizationLogWriter logWriter)
        {
            if (summarizerType == null)
            {
                throw new NullReferenceException(nameof(summarizerType));
            }

            // Summarizer must not be a generic type
            if (summarizerType.IsGenericType)
            {
                logWriter.WriteError("Summarizer {0} could not be loaded because it is a generic type", summarizerType.Name);
                return(null);
            }

            // Summarizers must be directly derived from Summarizer<TSrc, TDest>
            Type baseType = summarizerType.BaseType;

            if (baseType.Name != typeof(Summarizer <,>).Name || baseType.Module.Name != typeof(Summarizer <,>).Module.Name)
            {
                logWriter.WriteError("Summarizer {0} could not be loaded because it is not directly derived from Summarizer<TSrc, TDest>", summarizerType.Name);
                return(null);
            }

            // Create the summarizer metadata
            return(new SummarizerMetadata(summarizerType.BaseType.GenericTypeArguments[0], summarizerType.BaseType.GenericTypeArguments[1], summarizerType));
        }
Exemplo n.º 3
0
        private static BatchProcessingTaskAttribute GetBatchProcessingTaskAttribute(Type taskType, VisualizationLogWriter logWriter)
        {
            var taskAttribute = taskType.GetCustomAttribute <BatchProcessingTaskAttribute>();

            if (taskAttribute == null)
            {
                logWriter.WriteError($"Task {0} could not be loaded because it is not decorated with a {nameof(BatchProcessingTaskAttribute)}", taskType.Name);
                return(null);
            }

            if (string.IsNullOrWhiteSpace(taskAttribute.Name))
            {
                logWriter.WriteError($"Task {0} could not be loaded because its {nameof(BatchProcessingTaskAttribute)} does not specify a Name property", taskType.Name);
                return(null);
            }

            return(taskAttribute);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new batch processing task metadata.
 /// </summary>
 /// <param name="batchProcessingTaskType">The type of the task.</param>
 /// <param name="methodInfo">The method information.</param>
 /// <param name="taskAttribute">The task attribute.</param>
 /// <param name="logWriter">The log writer.</param>
 /// <returns>A task metadata.</returns>
 public static BatchProcessingTaskMetadata Create(Type batchProcessingTaskType, MethodInfo methodInfo, BatchProcessingTaskAttribute taskAttribute, VisualizationLogWriter logWriter)
 {
     // Create the task metadata
     return(new BatchProcessingTaskMetadata(batchProcessingTaskType, methodInfo, taskAttribute.Name, taskAttribute.Description, taskAttribute.IconSourcePath));
 }