示例#1
0
 public void AddVisualizer(IVisualizer Visualizer)
 {
     if (Visualizer != null)
     {
         System.Reflection.Assembly info = Visualizer.GetType().Assembly;
         info.GetCustomAttributes(Visualizer.GetType(), false);
         // var attribute =  (VisualizerAttribute) Attribute.GetCustomAttribute(info., typeof (VisualizerAttribute));
         //switch (attribute.Category)
         //{
         //    case VisualizerCategory.Database:
         //        break;
         //    case  VisualizerCategory.General:
         //        break;
         //    case VisualizerCategory.Profling:
         //        break;
         //    case VisualizerCategory.Slotworker:
         //        break;
         //}
     }
     StackPanelHost.Children.Add(Visualizer as UIElement);
 }
        private ISensor WrapSensorIfNecessary(ISensor sensor, IVisualizer visualizer)
        {
            var sensorCharacteristic = GetSensorCharacteristic(sensor);
            var visualizerAttribute  = (MeasureCharacteristic)Attribute.GetCustomAttribute(visualizer.GetType(), typeof(MeasureCharacteristic));

            if (visualizerAttribute.unit != sensorCharacteristic.unit)
            {
                var converter = _converters[sensorCharacteristic.unit];
                sensor = (Converter)Activator.CreateInstance(converter, sensor);
                Console.WriteLine($"Apply converter : {converter}");
            }
            return(sensor);
        }