コード例 #1
0
        public ScriptedSubsystem(string filePath, string className, Dependencies dependencies, Type collectorType)
        {
            Name          = className;
            CollectorType = collectorType;
            var engine = Python.CreateEngine();
            var scope  = engine.CreateScope();
            var ops    = engine.Operations;

            engine.ExecuteFile(filePath, scope);
            var pythonType = scope.GetVariable(className);

            PythonInstance = ops.CreateInstance(pythonType);
            Dictionary <string, Delegate> newDependencies = PythonInstance.getDependencyDictionary();

            dependencies.Append(newDependencies);
            SubsystemDependencyFunctions = PythonInstance.getDependencyDictionary();
        }
コード例 #2
0
        public ScriptedSubsystem(XmlNode scriptedSubXmlNode, Dependencies dependencies)
        {
            Name = scriptedSubXmlNode.Attributes["Name"].Value.ToString();
            string pythonFilePath = scriptedSubXmlNode.Attributes["src"].Value.ToString();

            CollectorType = Type.GetType(scriptedSubXmlNode.Attributes["CollectorType"].Value.ToString());
            var engine = Python.CreateEngine();
            var scope  = engine.CreateScope();
            var ops    = engine.Operations;

            engine.ExecuteFile(pythonFilePath, scope);
            var pythonType = scope.GetVariable(Name);

            PythonInstance = ops.CreateInstance(pythonType);
            Dictionary <string, Delegate> newDependencies = PythonInstance.getDependencyDictionary();

            dependencies.Append(newDependencies);
            SubsystemDependencyFunctions = PythonInstance.getDependencyDictionary();
        }