Esempio n. 1
0
        public override IEnumerable <string> GetAssembliesToAdd(IConnectionInfo cxn)
        {
            var assemblies = new List <Assembly>
            {
                typeof(ObservableCollection <>).Assembly, // System
                typeof(Expression).Assembly,              // System.Core
                typeof(ISubject <>).Assembly,             // System.Reactive.Interfaces
                typeof(Observer).Assembly,                // System.Reactive.Core
                typeof(Subject <>).Assembly,              // System.Reactive.Linq
                typeof(ThreadPoolScheduler).Assembly,     // System.Reactive.PlatformServices
                typeof(ControlObservable).Assembly,       // System.Reactive.Windows.Forms
                typeof(Playback).Assembly,                // Tx.Core
            };

            var properties = new TxProperties(cxn);

            assemblies.AddRange(_parserRegistry.GetAssemblies());

            var assemblyNames = new List <string>(from a in assemblies select a.Location);

            _typeCache.Init(properties.ContextName);
            assemblyNames.AddRange(_typeCache.GetAssemblies(properties.ContextName,
                                                            ReplaceSampleTracesDir(properties.Files),
                                                            ReplaceSampleTracesDir(properties.MetadataFiles)));

            return(assemblyNames);
        }
Esempio n. 2
0
        internal ConnectionDialog(TxProperties properties, string filter)
        {
            DataContext = properties;
            _properties = properties;
            _filter     = filter;

            InitializeComponent();

            _files         = new ObservableCollection <string>(_properties.Files);
            _metadataFiles = new ObservableCollection <string>(_properties.MetadataFiles);

            FileList.ItemsSource         = _files;
            MetadataFileList.ItemsSource = _metadataFiles;
            rbLookup.IsChecked           = _properties.IsUsingDirectoryLookup;
            rbRealTime.IsChecked         = _properties.IsRealTime;
        }
Esempio n. 3
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            try
            {
                var properties = new TxProperties(cxInfo);
                return(new ConnectionDialog(properties, _parserRegistry.Filter).ShowDialog() ?? false);
            }
            catch (Exception error)
            {
                TxEventSource.Log.TraceError(error.ToString());

                MessageBox.Show(error.ToString(), "ShowConnectionDialog");

                return(false);
            }
        }
Esempio n. 4
0
        public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
        {
            var playback   = new Playback();
            var properties = new TxProperties(cxInfo);

            if (properties.IsRealTime)
            {
                _parserRegistry.AddSession(playback, properties.SessionName);
            }
            else
            {
                _parserRegistry.AddFiles(playback, ReplaceSampleTracesDir(properties.Files));
            }

            Thread.SetData(_threadStorageSlot, playback);
            return(new[] { playback });
        }
Esempio n. 5
0
        public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo,
                                                                      AssemblyName assemblyToBuild, ref string nameSpace,
                                                                      ref string typeName)
        {
            nameSpace = "System.Reactive.Tx";
            typeName  = "StreamScopeWrapper";

            var allGeneratedSources = new List <string>();
            var sbContextUsings     = new StringBuilder();
            var sbContextProperties = new StringBuilder();

            var properties = new TxProperties(cxInfo);

            _typeCache.Init(properties.ContextName);

            if (properties.IsUsingDirectoryLookup)
            {
                _typeCache.BuildCache(properties.ContextName, properties.Files, properties.MetadataDirectory);
            }
            else
            {
                _typeCache.BuildCache(
                    properties.ContextName,
                    ReplaceSampleTracesDir(properties.Files),
                    ReplaceSampleTracesDir(properties.MetadataFiles));
            }

            string dataContext = DataContextTemplate
                                 .Replace("[usings]", sbContextUsings.ToString())
                                 .Replace("[properties]", sbContextProperties.ToString());

            allGeneratedSources.Add(dataContext);

            CompilerResults results;
            string          outputName = assemblyToBuild.CodeBase;

            using (
                var codeProvider = new CSharpCodeProvider(new Dictionary <string, string> {
                { "CompilerVersion", "v4.0" }
            }))
            {
                string[] assemblies = GetAssembliesToAdd(cxInfo).ToArray();

                var compilerOptions = new CompilerParameters(assemblies, outputName, true);

                results = codeProvider.CompileAssemblyFromSource(compilerOptions, allGeneratedSources.ToArray());

                if (results.Errors.Count > 0)
                {
                    var sbErr = new StringBuilder();
                    foreach (object o in results.Errors)
                    {
                        sbErr.AppendLine(o.ToString());
                    }
                    // Is there any better troubleshooting mechanism?
                    MessageBox.Show(sbErr.ToString(), "Error compiling generated code");
                }
            }

            Dictionary <Type, long> stat = _parserRegistry.GetTypeStatistics(
                _typeCache.GetAvailableTypes(
                    properties.ContextName,
                    ReplaceSampleTracesDir(properties.Files),
                    ReplaceSampleTracesDir(properties.MetadataFiles)),
                ReplaceSampleTracesDir(properties.Files));

            return(CreateTree(stat));
        }
Esempio n. 6
0
        public override string GetConnectionDescription(IConnectionInfo cxInfo)
        {
            var properties = new TxProperties(cxInfo);

            return(properties.ContextName);
        }
Esempio n. 7
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            var properties = new TxProperties(cxInfo);

            return(new ConnectionDialog(properties, _parserRegistry.Filter).ShowDialog() ?? false);
        }
Esempio n. 8
0
        public override IEnumerable<string> GetAssembliesToAdd(IConnectionInfo cxn)
        {
            var assemblies = new List<Assembly>
                {
                    typeof (ObservableCollection<>).Assembly, // System
                    typeof (Expression).Assembly, // System.Core
                    typeof (ISubject<>).Assembly, // System.Reactive.Interfaces
                    typeof (Observer).Assembly, // System.Reactive.Core
                    typeof (Subject<>).Assembly, // System.Reactive.Linq
                    typeof (ThreadPoolScheduler).Assembly, // System.Reactive.PlatformServices
                    typeof (ControlObservable).Assembly, // System.Reactive.Windows.Forms
                    typeof (Playback).Assembly, // Tx.Core
                };

            var properties = new TxProperties(cxn);
            assemblies.AddRange(_parserRegistry.GetAssemblies());

            var assemblyNames = new List<string>(from a in assemblies select a.Location);

            _typeCache.Init(properties.ContextName);
            assemblyNames.AddRange(_typeCache.GetAssemblies(properties.ContextName,
                                                         ReplaceSampleTracesDir(properties.Files),
                                                         ReplaceSampleTracesDir(properties.MetadataFiles)));

            return assemblyNames;
        }
Esempio n. 9
0
        public override List<ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo,
                                                                     AssemblyName assemblyToBuild, ref string nameSpace,
                                                                     ref string typeName)
        {
            nameSpace = "System.Reactive.Tx";
            typeName = "StreamScopeWrapper";

            var allGeneratedSources = new List<string>();
            var sbContextUsings = new StringBuilder();
            var sbContextProperties = new StringBuilder();

            var properties = new TxProperties(cxInfo);
            _typeCache.Init(properties.ContextName);

            if (properties.IsUsingDirectoryLookup)
            {
                _typeCache.BuildCache(properties.ContextName, properties.Files, properties.MetadataDirectory);
            }
            else
            {
                _typeCache.BuildCache(
                    properties.ContextName,
                    ReplaceSampleTracesDir(properties.Files),
                    ReplaceSampleTracesDir(properties.MetadataFiles));
            }

            string dataContext = DataContextTemplate
                .Replace("[usings]", sbContextUsings.ToString())
                .Replace("[properties]", sbContextProperties.ToString());
            allGeneratedSources.Add(dataContext);

            CompilerResults results;
            string outputName = assemblyToBuild.CodeBase;
            using (
                var codeProvider = new CSharpCodeProvider(new Dictionary<string, string> {{"CompilerVersion", "v4.0"}}))
            {
                string[] assemblies = GetAssembliesToAdd(cxInfo).ToArray();

                var compilerOptions = new CompilerParameters(assemblies, outputName, true);

                results = codeProvider.CompileAssemblyFromSource(compilerOptions, allGeneratedSources.ToArray());

                if (results.Errors.Count > 0)
                {
                    var sbErr = new StringBuilder();
                    foreach (object o in results.Errors)
                    {
                        sbErr.AppendLine(o.ToString());
                    }
                    // Is there any better troubleshooting mechanism? 
                    MessageBox.Show(sbErr.ToString(), "Error compiling generated code");
                }
            }

            Dictionary<Type, long> stat = _parserRegistry.GetTypeStatistics(
                _typeCache.GetAvailableTypes(
                    properties.ContextName,
                    ReplaceSampleTracesDir(properties.Files),
                    ReplaceSampleTracesDir(properties.MetadataFiles)),
                ReplaceSampleTracesDir(properties.Files));

            return CreateTree(stat);
        }
Esempio n. 10
0
        public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
        {
            var playback = new Playback();
            var properties = new TxProperties(cxInfo);

            if (properties.IsRealTime)
            {
                _parserRegistry.AddSession(playback, properties.SessionName);
            }
            else
            {
                _parserRegistry.AddFiles(playback, ReplaceSampleTracesDir(properties.Files));
            }

            Thread.SetData(_threadStorageSlot, playback);
            return new[] {playback};
        }
Esempio n. 11
0
 public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
 {
     var properties = new TxProperties(cxInfo);
     return new ConnectionDialog(properties, _parserRegistry.Filter).ShowDialog() ?? false;
 }
Esempio n. 12
0
 public override string GetConnectionDescription(IConnectionInfo cxInfo)
 {
     var properties = new TxProperties(cxInfo);
     return properties.ContextName;
 }