Exemplo n.º 1
0
		public VsShellProvider([Import(typeof(SVsServiceProvider))] IServiceProvider services, IAsyncManager async)
		{
			vsShell = new Lazy<IVsShell>(() => async.Run(async () => {
				await async.SwitchToMainThread();
				return services.GetService<SVsShell, IVsShell>();
			}));
		}
Exemplo n.º 2
0
        public LoginController(IEventAggregator eventAggregator, 
            IRegionManager regionManager, ILoginView view, ILinqApi api, ICredentialsStore store, IAsyncManager manager)
        {
            eventAggregator.GetEvent<InitialViewActivatedEvent>().Subscribe(
                DoLogin);

            this.region = regionManager.Regions[RegionNames.DialogRegion];

            this.eventAggregator = eventAggregator;
            this.view = view;
            this.api = api;
            this.store = store;
            this.manager = manager;
            this.region.Add(this.view);

            this.username = store.Username;
            this.password = store.Password;

            this.view.DataContext = this;

            this.provideCredentialsCommand =
                new DelegateCommand<object>(this.ProvideCredentials,
                                            o =>
                                            !(String.IsNullOrEmpty(this.Username) ||
                                              String.IsNullOrEmpty(this.Password)));
        }
Exemplo n.º 3
0
        public QueryResultsViewModel(string caption, IQueryResultsView view, IEventAggregator aggregator, ITimeLineService service, 
            IAsyncManager asyncManager, ContextMenuRoot menu)
        {
            this._aggregator = aggregator;
            _service = service;
            this._asyncManager = asyncManager;
            Caption = caption;
            View = view;

            View.DataContext = this;

            this.Tweets = new ObservableCollection<TweetViewModel>();

            this._aggregator.GetEvent<RefreshEvent>().Subscribe(Refresh//,
                ,ThreadOption.UIThread, true,
                _ => !this.Editing
                );

            GlobalCommands.UpCommand.RegisterCommand(new DelegateCommand<object>(MoveUp));
            GlobalCommands.DownCommand.RegisterCommand(new DelegateCommand<object>(MoveDown));

            _contextMenu = menu;

            _editCommand = new DelegateCommand<object>(EditSelectedTweet,
                                                       o =>
                                                       this.SelectedTweet !=
                                                       null);

            _cancelEditCommand = new DelegateCommand<object>(CancelEdit,
                o => this.SelectedTweet != null && this.SelectedTweet.Editable);
        }
Exemplo n.º 4
0
		public VsHierarchyItemManagerProvider ([Import (typeof (SVsServiceProvider))] IServiceProvider services, IAsyncManager async)
		{
			hierarchyManager = new Lazy<IVsHierarchyItemManager> (() => async.Run (async () => {
				await async.SwitchToMainThread ();
				return services.GetService<SComponentModel, IComponentModel> ().GetService<IVsHierarchyItemManager> ();
			}));
		}
Exemplo n.º 5
0
        public void Destroy()
        {
            lock (this)
            {
                if (!_isValid)
                {
                    return;
                }
                _isValid = false;
                try
                {
                    OnDestroy?.Invoke(this);
                }
                catch (Exception e)
                {
                    _logger?.WriteException(e);
                }
            }

            _timerManager.Destroy();
            _objectCache.Destroy();
            _typeDB.Destroy();

            GC.Collect();
            GC.WaitForPendingFinalizers();
            ExecutePendingActions();

            // _rwlock.EnterWriteLock();
            for (int i = 0, count = _contextRefs.Count; i < count; i++)
            {
                var contextRef = _contextRefs[i];
                contextRef.target.Destroy();
            }

            _contextRefs.Clear();
            _mainContext = null;
            // _rwlock.ExitWriteLock();


            if (_asyncManager != null)
            {
                _asyncManager.Destroy();
                _asyncManager = null;
            }

            JSApi.JS_FreeRuntime(_rt);
            var id = _runtimeId;

            _runtimeId = -1;
            _rt        = JSRuntime.Null;

            try
            {
                OnAfterDestroy?.Invoke(id);
            }
            catch (Exception e)
            {
                _logger?.WriteException(e);
            }
        }
Exemplo n.º 6
0
 public OAuthLoginViewModel(Func<IOauthSession> sessionCreator, 
     IAsyncManager asyncManager, IProcessLauncher processLauncher)
 {
     _sessionCreator = sessionCreator;
     _asyncManager = asyncManager;
     _processLauncher = processLauncher;
     _getAuthorizationUrlCommand = new DelegateCommand<object>(ExecuteGetAuthorizationUrl);
 }
Exemplo n.º 7
0
		public VsHierarchySelection (
			[Import (typeof (SVsServiceProvider))] IServiceProvider services,
			IAsyncManager asyncManager)
		{
			solution = services.GetService<SVsSolution, IVsHierarchy> ();
			monitorSelection = services.GetService<SVsShellMonitorSelection, IVsMonitorSelection> ();
			this.asyncManager = asyncManager;
		}
Exemplo n.º 8
0
 public VsHierarchySelection(
     [Import(typeof(SVsServiceProvider))] IServiceProvider services,
     IAsyncManager asyncManager)
 {
     solution          = services.GetService <SVsSolution, IVsHierarchy> ();
     monitorSelection  = services.GetService <SVsShellMonitorSelection, IVsMonitorSelection> ();
     this.asyncManager = asyncManager;
 }
Exemplo n.º 9
0
        void Initialize([Inject] IAsyncManager service)
        {
            _service = service;

            this.OnEvent <AddToMainThreadCommand>().Subscribe(e => AddToMainThreadCommandHandler(e)).AddTo(this);
            this.OnEvent <AddToWorkerThreadCommand>().Subscribe(e => AddToWorkerThreadCommandHandler(e)).AddTo(this);
            this.OnEvent <CallCommand>().Subscribe(e => CallCommandHandler(e)).AddTo(this);
            this.OnEvent <DisposeThreadsCommand>().Subscribe(e => DisposeThreadsCommandHandler(e)).AddTo(this);
        }
Exemplo n.º 10
0
 public VsSolutionSelection(
     [Import(ContractNames.Interop.SolutionExplorerWindow)] IVsUIHierarchyWindow hierarchyWindow,
     IVsHierarchyItemManager hierarchyManager,
     IAsyncManager asyncManager)
 {
     this.hierarchyWindow  = hierarchyWindow;
     this.hierarchyManager = hierarchyManager;
     this.asyncManager     = asyncManager;
 }
Exemplo n.º 11
0
		public VsSolutionSelection (
			[Import (ContractNames.Interop.SolutionExplorerWindow)] IVsUIHierarchyWindow hierarchyWindow,
			IVsHierarchyItemManager hierarchyManager,
			IAsyncManager asyncManager)
		{
			this.hierarchyWindow = hierarchyWindow;
			this.hierarchyManager = hierarchyManager;
			this.asyncManager = asyncManager;
		}
Exemplo n.º 12
0
 public TestServerSource(IFingerprintRetriever fingerprintRetriever,
                         IRemoteServerSettings remoteSettings,
                         IServerDialogProvider dialogProvider,
                         IProgress <string> progress,
                         IErrorsManager errorsManager,
                         IAsyncManager asyncManager,
                         IEventStream eventStream)
     : base(fingerprintRetriever, remoteSettings, dialogProvider, progress, errorsManager, asyncManager, eventStream)
 {
 }
Exemplo n.º 13
0
 public VsServicesExports(
     [Import(typeof(SVsServiceProvider))] IServiceProvider services,
     IAsyncManager async)
 {
     vsSolution   = new Lazy <IVsSolution>(() => services.GetService <SVsSolution, IVsSolution>());
     vsStatusBar  = new Lazy <IVsStatusbar>(() => services.GetService <SVsStatusbar, IVsStatusbar>());
     outputWindow = new Lazy <IVsOutputWindow>(() => services.GetService <SVsOutputWindow, IVsOutputWindow>());
     vsShell      = new Lazy <IVsShell>(() => services.GetService <SVsShell, IVsShell>());
     vsUIShell    = new Lazy <IVsUIShell>(() => services.GetService <SVsUIShell, IVsUIShell>());
 }
        public TestServerConnectionManager(
            IRemoteServerSourceManager serverSourceManager,
            IAsyncManager asyncManager,
            IEventStream eventStream)
        {
            this.serverSourceManager = serverSourceManager;
            //this.systemEvents = systemEvents;
            //this.solutionState = solutionState;
            this.asyncManager = asyncManager;
            this.eventStream  = eventStream;

            connectionTypes = new ConcurrentDictionary <RemoteServerPlatform, bool>();

            //systemEvents.PowerModeChanged += OnPowerChange;
            //systemEvents.SessionSwitch += OnSessionSwitch;
            //systemEvents.SessionEnded += OnSessionEnded;

            //this.solutionState.SolutionReady += async (sender, args) => {
            //	await CheckServerSourcesAsync ().ConfigureAwait (continueOnCapturedContext: false);
            //};

            //this.solutionState.SolutionClosed += async (sender, args) => {
            //	await DisconnectAsync (unregisterServerSource: true).ConfigureAwait (continueOnCapturedContext: false);
            //};

            eventStream
            .Of <ProjectChanged>()
            .Subscribe(async ev =>
            {
                if (ev.HasProjects)
                {
                    await CheckServerSourceAsync(ev.Platform)
                    .ConfigureAwait(continueOnCapturedContext: false);
                }
            });

            //eventStream
            //	.Of<StartupProjectsChanged> ()
            //	.Subscribe (async ev => {
            //		foreach (var project in ev.StartupProjects) {
            //			await TryConnectAsync (project.GetPlatform ())
            //				.ConfigureAwait (continueOnCapturedContext: false);
            //		}
            //	});
        }
		public VsBooleanSymbolExpressionEvaluatorProvider([Import(typeof(SVsServiceProvider))] IServiceProvider services, IAsyncManager async)
		{
			expressionEvaluator = new Lazy<IVsBooleanSymbolExpressionEvaluator>(() => async.Run(async () =>
			{
				await async.SwitchToMainThread();

				var registry = services.GetService<SLocalRegistry, ILocalRegistry>();

				// dev14+ should provide the evaluator using the BooleanSymbolExpressionEvaluator interface
				var value = registry.CreateInstance(typeof(BooleanSymbolExpressionEvaluator).GUID) as IVsBooleanSymbolExpressionEvaluator;
				if (value == null)
				{
					// Previous versions of VS provides the service using the VsProjectCapabilityExpressionMatcher interface
					value = registry.CreateInstance(typeof(VsProjectCapabilityExpressionMatcher).GUID) as IVsBooleanSymbolExpressionEvaluator;
				}

				return value;
			}));
		}
Exemplo n.º 16
0
        // this method will be marked as private in the future
        public void Initialize(IFileSystem fileSystem, IPathResolver resolver, IScriptRuntimeListener listener, IAsyncManager asyncManager, IScriptLogger logger, IO.IByteBufferAllocator byteBufferAllocator, bool useReflectBind = true)
        {
            if (fileSystem == null)
            {
                throw new NullReferenceException(nameof(fileSystem));
            }

            MethodInfo bindAll = null;

            if (!isWorker)
            {
                if (listener == null)
                {
                    throw new NullReferenceException(nameof(listener));
                }

#if UNITY_EDITOR
                bindAll        = (useReflectBind ? GetReflectBind(logger) : null) ?? GetStaticBind(logger);
                _isReflectBind = bindAll.Name == "InvokeReflectBinding";
                logger?.Write(LogLevel.Info, _isReflectBind ? "Running in ReflectBind mode" : "Running in StaticBind mode");
#else
                bindAll = GetStaticBind(logger);
#endif
            }

            asyncManager.Initialize(_mainThreadId);

            _isValid   = true;
            _isRunning = true;
            _logger    = logger;
            // _rwlock = new ReaderWriterLockSlim();
            _rt = JSApi.JS_NewRuntime();
            JSApi.JS_SetHostPromiseRejectionTracker(_rt, JSApi.PromiseRejectionTracker, IntPtr.Zero);
#if UNITY_EDITOR
            JSApi.JS_SetInterruptHandler(_rt, _InterruptHandler, IntPtr.Zero);
#else
            if (isWorker)
            {
                JSApi.JS_SetInterruptHandler(_rt, _InterruptHandler, IntPtr.Zero);
            }
#endif
            JSApi.JS_SetRuntimeOpaque(_rt, (IntPtr)_runtimeId);
            JSApi.JS_SetModuleLoaderFunc(_rt, module_normalize, module_loader, IntPtr.Zero);
            CreateContext();
            JSApi.JS_NewClass(_rt, JSApi.JSB_GetBridgeClassID(), "CSharpClass", JSApi.class_finalizer);

            _listener            = listener;
            _pathResolver        = resolver;
            _asyncManager        = asyncManager;
            _byteBufferAllocator = byteBufferAllocator;
            _autorelease         = new Utils.AutoReleasePool();
            _fileSystem          = fileSystem;
            _objectCache         = new ObjectCache(_logger);
            _timerManager        = new TimerManager(_logger);
            _typeDB = new TypeDB(this, _mainContext);
            _typeDB.AddType(typeof(Unity.JSBehaviour), JSApi.JS_UNDEFINED);
#if UNITY_EDITOR
            _typeDB.AddType(typeof(Unity.JSEditorWindow), JSApi.JS_UNDEFINED);
            _typeDB.AddType(typeof(Unity.JSBehaviourInspector), JSApi.JS_UNDEFINED);
#endif
            listener.OnCreate(this);

            // await Task.Run(() => runner.OnBind(this, register));
            if (bindAll != null)
            {
                bindAll.Invoke(null, new object[] { this });
            }

            var register = new TypeRegister(_mainContext);
            listener.OnBind(this, register);
            if (!_isWorker)
            {
                JSWorker.Bind(register);
            }
            TimerManager.Bind(register);
            register.Finish();

            AddStaticModule("jsb", ScriptContext.Bind);
            FindModuleResolver <StaticModuleResolver>().Warmup(_mainContext);

            listener.OnComplete(this);
        }
Exemplo n.º 17
0
        // this method will be marked as private in the future
        public void Initialize(IFileSystem fileSystem, IPathResolver resolver, IAsyncManager asyncManager, IScriptLogger logger, IO.IByteBufferAllocator byteBufferAllocator, IBinder binder)
        {
            if (fileSystem == null)
            {
                throw new NullReferenceException(nameof(fileSystem));
            }

            asyncManager.Initialize(_mainThreadId);

            _isValid   = true;
            _isRunning = true;
            _logger    = logger;
            // _rwlock = new ReaderWriterLockSlim();
            _rt = JSApi.JS_NewRuntime();
            JSApi.JS_SetHostPromiseRejectionTracker(_rt, JSApi.PromiseRejectionTracker, IntPtr.Zero);
#if UNITY_EDITOR
            JSApi.JS_SetInterruptHandler(_rt, _InterruptHandler, IntPtr.Zero);
#else
            if (isWorker)
            {
                JSApi.JS_SetInterruptHandler(_rt, _InterruptHandler, IntPtr.Zero);
            }
#endif
            JSApi.JS_SetRuntimeOpaque(_rt, (IntPtr)_runtimeId);
            JSApi.JS_SetModuleLoaderFunc(_rt, module_normalize, module_loader, IntPtr.Zero);
            CreateContext();
            JSApi.JS_NewClass(_rt, JSApi.JSB_GetBridgeClassID(), "CSharpClass", JSApi.class_finalizer);

            _pathResolver        = resolver;
            _asyncManager        = asyncManager;
            _byteBufferAllocator = byteBufferAllocator;
            _autorelease         = new Utils.AutoReleasePool();
            _fileSystem          = fileSystem;
            _objectCache         = new ObjectCache(_logger);
            _timerManager        = new TimerManager(_logger);
            _typeDB = new TypeDB(this, _mainContext);
#if !JSB_UNITYLESS
            _typeDB.AddType(typeof(Unity.JSBehaviour), JSApi.JS_UNDEFINED);
#endif
#if UNITY_EDITOR
            _typeDB.AddType(Values.FindType("QuickJS.Unity.JSEditorWindow"), JSApi.JS_UNDEFINED);
            _typeDB.AddType(Values.FindType("QuickJS.Unity.JSBehaviourInspector"), JSApi.JS_UNDEFINED);
#endif

            // await Task.Run(() => runner.OnBind(this, register));
            try
            {
                binder?.Bind(this);
            }
            catch (Exception exception)
            {
                _logger?.WriteException(exception);
            }

            var register = new TypeRegister(_mainContext);
            if (!_isWorker)
            {
                JSWorker.Bind(register);
            }
            TimerManager.Bind(register);
            extraBinding?.Invoke(this, register);
            register.Finish();

            AddStaticModule("jsb", ScriptContext.Bind);
            FindModuleResolver <StaticModuleResolver>().Warmup(_mainContext);

            _isInitialized = true;
        }
Exemplo n.º 18
0
 public WordLogic(IAsyncManager <Word> wordManager)
 {
     _wordManager = wordManager;
     //UpdateWordList();
 }
Exemplo n.º 19
0
 public VsShellProvider([Import(typeof(SVsServiceProvider))] IServiceProvider services, IAsyncManager async)
 {
     vsShell = new Lazy <IVsShell>(() => async.Run(async() => {
         await async.SwitchToMainThread();
         return(services.GetService <SVsShell, IVsShell>());
     }));
 }
Exemplo n.º 20
0
 public void Init()
 {
     dbName            = "testdb.db";
     PersistentManager = new PersistentWordManager <Word>(dbName);
 }
Exemplo n.º 21
0
        public void Initialize(IFileSystem fileSystem, IPathResolver resolver, IScriptRuntimeListener listener, IAsyncManager asyncManager, IScriptLogger logger, IO.IByteBufferAllocator byteBufferAllocator)
        {
            if (fileSystem == null)
            {
                throw new NullReferenceException(nameof(fileSystem));
            }

            MethodInfo bindAll = null;

            if (!isWorker)
            {
                if (listener == null)
                {
                    throw new NullReferenceException(nameof(listener));
                }

                bindAll = typeof(Values).GetMethod("BindAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (bindAll == null)
                {
#if UNITY_EDITOR
                    var throwError = true;
                    foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                    {
                        var UnityHelper = assembly.GetType("QuickJS.Unity.UnityHelper");
                        if (UnityHelper != null)
                        {
                            var IsReflectBindingSupported = UnityHelper.GetMethod("IsReflectBindingSupported");
                            if (IsReflectBindingSupported != null)
                            {
                                if ((bool)IsReflectBindingSupported.Invoke(null, null))
                                {
                                    var InvokeReflectBinding = UnityHelper.GetMethod("InvokeReflectBinding");
                                    if (InvokeReflectBinding != null)
                                    {
                                        bindAll    = InvokeReflectBinding;
                                        throwError = false;
                                    }
                                }
                            }
                            break;
                        }
                    }

                    if (throwError)
                    {
                        throw new Exception("generate binding code before run");
                    }
#else
                    throw new Exception("generate binding code before run");
#endif
                }
                else
                {
                    var codeGenVersionField = typeof(Values).GetField("CodeGenVersion");
                    if (codeGenVersionField == null || !codeGenVersionField.IsStatic || !codeGenVersionField.IsLiteral || codeGenVersionField.FieldType != typeof(uint))
                    {
                        throw new Exception("binding code version mismatch");
                    }

                    var codeGenVersion = (uint)codeGenVersionField.GetValue(null);
                    if (codeGenVersion != ScriptEngine.VERSION)
                    {
                        if (logger != null)
                        {
                            logger.Write(LogLevel.Warn, "CodeGenVersion: {0} != {1}", codeGenVersion, ScriptEngine.VERSION);
                        }
                    }
                }
            }

            asyncManager.Initialize(_mainThreadId);

            _isValid   = true;
            _isRunning = true;
            // _rwlock = new ReaderWriterLockSlim();
            _rt = JSApi.JS_NewRuntime();
            JSApi.JS_SetHostPromiseRejectionTracker(_rt, JSApi.PromiseRejectionTracker, IntPtr.Zero);
#if UNITY_EDITOR
            JSApi.JS_SetInterruptHandler(_rt, _InterruptHandler, IntPtr.Zero);
#else
            if (isWorker)
            {
                JSApi.JS_SetInterruptHandler(_rt, _InterruptHandler, IntPtr.Zero);
            }
#endif
            JSApi.JS_SetRuntimeOpaque(_rt, (IntPtr)_runtimeId);
            JSApi.JS_SetModuleLoaderFunc(_rt, module_normalize, module_loader, IntPtr.Zero);
            CreateContext();
            JSApi.JS_NewClass(_rt, JSApi.JSB_GetBridgeClassID(), "CSharpClass", JSApi.class_finalizer);

            _listener            = listener;
            _pathResolver        = resolver;
            _asyncManager        = asyncManager;
            _byteBufferAllocator = byteBufferAllocator;
            _autorelease         = new Utils.AutoReleasePool();
            _fileSystem          = fileSystem;
            _logger       = logger;
            _objectCache  = new ObjectCache(_logger);
            _timerManager = new TimerManager(_logger);
            _typeDB       = new TypeDB(this, _mainContext);
            _typeDB.AddType(typeof(Unity.JSBehaviour), JSApi.JS_UNDEFINED);
#if UNITY_EDITOR
            _typeDB.AddType(typeof(Unity.JSEditorWindow), JSApi.JS_UNDEFINED);
            _typeDB.AddType(typeof(Unity.JSBehaviourInspector), JSApi.JS_UNDEFINED);
#endif
            listener.OnCreate(this);

            // await Task.Run(() => runner.OnBind(this, register));
            if (bindAll != null)
            {
                bindAll.Invoke(null, new object[] { this });
            }

            var register = new TypeRegister(_mainContext);
            listener.OnBind(this, register);
            if (!_isWorker)
            {
                JSWorker.Bind(register);
            }
            TimerManager.Bind(register);
            register.Finish();

            AddStaticModule("jsb", ScriptContext.Bind);
            FindModuleResolver <StaticModuleResolver>().Warmup(_mainContext);

            listener.OnComplete(this);
        }
        public VsBooleanSymbolExpressionEvaluatorProvider([Import(typeof(SVsServiceProvider))] IServiceProvider services, IAsyncManager async)
        {
            expressionEvaluator = new Lazy <IVsBooleanSymbolExpressionEvaluator>(() => async.Run(async() =>
            {
                await async.SwitchToMainThread();

                var registry = services.GetService <SLocalRegistry, ILocalRegistry>();

                // dev14+ should provide the evaluator using the BooleanSymbolExpressionEvaluator clsid
                var value = registry.CreateInstance(BooleanSymbolExpressionEvaluatorClsid) as IVsBooleanSymbolExpressionEvaluator;
                if (value == null)
                {
                    // Previous versions of VS provides the service using the VsProjectCapabilityExpressionMatcher interface
                    value = registry.CreateInstance(typeof(VsProjectCapabilityExpressionMatcher).GUID) as IVsBooleanSymbolExpressionEvaluator;
                }

                return(value);
            }));
        }
Exemplo n.º 23
0
 public VsHierarchyItemManagerProvider([Import(typeof(SVsServiceProvider))] IServiceProvider services, IAsyncManager async)
 {
     hierarchyManager = new Lazy <IVsHierarchyItemManager> (() => async.Run(async() => {
         await async.SwitchToMainThread();
         return(services.GetService <SComponentModel, IComponentModel> ().GetService <IVsHierarchyItemManager> ());
     }));
 }