示例#1
0
        private static TypeContainer GetTypeContainerFromCode()
        {
            TypeContainer tc = TypeContainer.Instance;

            ////register PlugIn libraries

            //register OPC receivers, converters
            tc.Register <ILogger, ConsoleLogger>();
            tc.Register <IReceiver, OpcReceiver <IMessage> >(TELEMETRY_NAMESPACE);
            tc.Register <IConverter <object, Tag>, OpcTagToTagStateConverter>(TELEMETRY_NAMESPACE);

            //register IotHub sender
            tc.Register <IConverter <Tag, object>, ToIotHubMessageConverter>(TELEMETRY_NAMESPACE);
            tc.Register <ISender, IoTHubTelemetrySender <Tag> >(TELEMETRY_NAMESPACE);

            //register additional libraries from Azure Connector; we don't have to Dictionary<string, object>ally load them
            //  as there are not expected to be changed by the PlugIn writers
            tc.Register <IServiceHost, TelemetryHost>(TELEMETRY_NAMESPACE);

            //Register IotHub command receiver
            tc.Register <IReceiver, IotHubCommandReceiver <Command> >(COMMAND_NAMESPACE);
            tc.Register <IConverter <string, Command>, FromIotHubCommandConverter>(COMMAND_NAMESPACE);
            tc.Register <ICommandExecutor <Command>, OpcUaCommandExecutor> (COMMAND_NAMESPACE);
            tc.Register <IServiceHost, CommandHost>(COMMAND_NAMESPACE);
            //the following generates XML to be used in reflection based ConsoleRunner.
            string xml = tc.GetRegistryAsXml();

            return(tc);
        }