OleViewDotNet.COMRegistryViewer.CreatePythonFilter C# (CSharp) Method

CreatePythonFilter() private static method

private static CreatePythonFilter ( string filter ) : bool>.Func
filter string
return bool>.Func
        private static Func<object, bool> CreatePythonFilter(string filter)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("def run_filter(entry):");
            builder.AppendFormat("  return {0}", filter);
            builder.AppendLine();
            
            ScriptEngine engine = Python.CreateEngine();
            ScriptSource source = engine.CreateScriptSourceFromString(builder.ToString(), SourceCodeKind.File);
            ScriptScope scope = engine.CreateScope();
            source.Execute(scope);
            return scope.GetVariable<Func<object, bool>>("run_filter");            
        }