public static IDev2MethodInfo InvokePlugin(Isolated <PluginRuntimeHandler> appDomain, PluginExecutionDto dto, IDev2MethodInfo dev2MethodInfo, out string objString)
        {
            var invokePlugin = appDomain.Value.Run(dev2MethodInfo, dto, out string objectString);

            objString = objectString;
            return(invokePlugin);
        }
Example #2
0
        private void DealWithMoreItem(int index)
        {
            if (index == -1)
            {
                return;
            }
            switch (index)
            {
            case 0: Isolated.Remove("IsSinaLogin"); Messenger.Default.Send <string>(@"/View/LoginPage.xaml", "NavigateToOtherPage"); break;

            case 1: var result = MessageBox.Show("您确定删除所以数据吗", "提示", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                }
                ;  break;

            case 2: Messenger.Default.Send <string>(@"/View/AboutJobHubPage.xaml", "NavigateToOtherPage"); break;

            case 3: Messenger.Default.Send <string>(@"/View/PrivacyPage.xaml", "NavigateToOtherPage"); break;

            case 4: Messenger.Default.Send <string>(@"/View/FeekBackPage.xaml", "NavigateToOtherPage"); break;

            case 5: UmengAnalytics.update("4fa79487527015184e00003c"); break;
            }
            ;
        }
        void RegularMethodExecution(Isolated <PluginRuntimeHandler> appDomain, PluginExecutionDto pluginExecutionDto, IDev2MethodInfo dev2MethodInfo, int i, int update, IDSFDataObject dataObject)
        {
            var start = DateTime.Now;

            pluginExecutionDto.ObjectString = ObjectResult;
            var result = PluginServiceExecutionFactory.InvokePlugin(appDomain, pluginExecutionDto, dev2MethodInfo, out string objString);

            pluginExecutionDto.ObjectString = objString;
            ObjectResult = objString;
            var pluginAction = MethodsToRun[i];

            pluginAction.MethodResult   = result.MethodResult;
            pluginAction.HasError       = result.HasError;
            pluginAction.ErrorMessage   = result.ErrorMessage;
            dev2MethodInfo.HasError     = result.HasError;
            dev2MethodInfo.ErrorMessage = result.ErrorMessage;
            if (result.HasError)
            {
                DispatchDebugStateForMethod(pluginAction, dataObject, update, false, start);
                return;
            }
            AssignMethodResult(pluginAction, update, dataObject, start);
            if (!string.IsNullOrEmpty(ObjectName) && !pluginExecutionDto.IsStatic)
            {
                var jToken = JToken.Parse(ObjectResult) as JContainer ?? ObjectResult.DeserializeToObject();
                dataObject.Environment.AddToJsonObjects(ObjectName, jToken);
            }
        }
 /// <summary>
 /// Loads specified assembly in separate AppDomain as reflection only and executes specified function
 /// </summary>
 /// <typeparam name="TReturn"></typeparam>
 /// <param name="assemblyPath"></param>
 /// <param name="processorFunc"></param>
 /// <returns></returns>
 public static TReturn ProcessAssembly <TReturn>(string assemblyPath, Func <Assembly, TReturn> processorFunc)
 {
     using (var isolated = new Isolated <IsolatedAssemblyHandler>())
     {
         return(isolated.Value.ProcessAssemblyInternal(assemblyPath, processorFunc));
     }
 }
        /// <summary>
        /// Executes the service
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="theWorkspace">The workspace.</param>
        /// <returns></returns>
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            Dev2Logger.Info("Get COMDll Listings");

            try
            {
                List <DllListing> dllListings;
                using (Isolated <ComDllLoaderHandler> isolated = new Isolated <ComDllLoaderHandler>())
                {
                    var openBaseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32);
                    dllListings = isolated.Value.GetListings(openBaseKey);
                    openBaseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64);
                    dllListings.AddRange(isolated.Value.GetListings(openBaseKey));
                }
                msg.Message = serializer.SerializeToBuilder(dllListings);
            }
            catch (COMException ex)
            {
                msg.HasError = true;
                msg.SetMessage(ex.Message);
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(ex);
                msg.HasError = true;
                msg.SetMessage(ex.Message);
            }

            return(serializer.SerializeToBuilder(msg));
        }
 public void Start() {
     ZMachineHub.RegisterSession(this);
     _engine = new Isolated<ZMachine>();
     _engine.SetData("id", ID);
     _engine.SetData("player", _call.RemoteEndpoint.Participant.UserAtHost);
     _engine.Value.Run();
 }
Example #7
0
        private void getUserEnd(User user)
        {
            User u = user;

            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                if (string.IsNullOrEmpty(u.Id))
                {
                    MessageBox.Show("用户名或密码错误");
                    return;
                }
                Isolated.Set("IsSinaLogin", true);
                pb_login.Visibility   = Visibility.Collapsed;
                this.IsHitTestVisible = true;
                if (ts_isShare.IsChecked.Value)
                {
                    SinaShareApi _api = new SinaShareApi();

                    _api.LoginShare((s) =>
                    {
                        string ss = s;
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            MessageBox.Show("分享成功");
                        });
                    });
                }
                NavigationService.Navigate(new Uri("/View/MainPage.xaml", UriKind.Relative));
            });
        }
Example #8
0
 private void GetCurrentCityEnd(string city)
 {
     CurrentCity = city;
     Isolated.Set("CurrentCity", CurrentCity);
     JobDal.Instance.GetJobslist(getCurrentTime(), CurrentCity, null
                                 , GetJobListEnd);
     CityDal.Instance.GetCityUniversity(CurrentCity, GetCityUniversityEnd);
 }
 public void ComPluginRuntimeHandler_FetchNamespaceListObject_WhenNullLocationAndInvalidSourceID_ExpectException()
 {
     //------------Setup for test--------------------------
     using (var isolated = new Isolated <ComPluginRuntimeHandler>())
     {
         isolated.Value.FetchNamespaceListObject(new ComPluginSource());
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Isolated isolated = db.isolateds.Find(id);

            db.isolateds.Remove(isolated);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #11
0
 void GetUserEnd(string json)
 {
     if (Callback != null)
     {
         var obj = Utils.JsonToObject <User>(JObject.Parse(json)["val"].ToString());
         Callback(obj);
         Isolated.Set("IsSinaLogin", true);
     }
 }
Example #12
0
 public void Test()
 {
     using(var iso = new Isolated<TE>())
     {
         TE.X = 5;
         Assert.Equal(5, new TE().GetStaticX());
         Assert.Equal(0, iso.Instance.GetStaticX());
     }
 }
 public void ComPluginRuntimeHandler_ListNamespaces_WhenNullLocation_ExpectException()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     using (var isolated = new Isolated <ComPluginRuntimeHandler>())
     {
         isolated.Value.FetchNamespaceListObject(null);
     }
 }
 public void ComPluginRuntimeHandler_FetchNamespaceListObject_WhenNullDll_ExpectException()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     using (Isolated <ComPluginRuntimeHandler> isolated = new Isolated <ComPluginRuntimeHandler>())
     {
         isolated.Value.FetchNamespaceListObject(null);
         //------------Assert Results-------------------------
     }
 }
 public void ComPluginRuntimeHandler_ListMethods_WhenInvalidLocation_ExpectNoResults()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     using (var isolated = new Isolated <ComPluginRuntimeHandler>())
     {
         var result = isolated.Value.ListMethods(string.Empty, false);
         Assert.AreEqual(0, result.Count);
     }
 }
 void RegularConstructorExecution(IDSFDataObject dataObject, Isolated <PluginRuntimeHandler> appDomain, ref PluginExecutionDto pluginExecutionDto)
 {
     pluginExecutionDto = PluginServiceExecutionFactory.ExecuteConstructor(appDomain, pluginExecutionDto);
     ObjectResult       = pluginExecutionDto.ObjectString;
     if (!string.IsNullOrEmpty(ObjectName) && !pluginExecutionDto.IsStatic)
     {
         var jToken = JToken.Parse(ObjectResult) as JContainer ?? ObjectResult.DeserializeToObject();
         dataObject.Environment.AddToJsonObjects(ObjectName, jToken);
     }
 }
Example #17
0
        /// <summary>
        /// 获取
        /// </summary>
        /// <returns></returns>
        public string Get()
        {
            var str = Isolated.Get(IsolatedHelper.TweetDraftKey);

            if (str != null)
            {
                return(str.ToString());
            }
            return("");
        }
Example #18
0
        private void OnChangeCity(Citys city)
        {
            //JobsList.Clear();
            // UList.Clear();
            Isolated.Set("CurrentCity", city.City);
            JobDal.Instance.GetJobslist(getCurrentTime(), city.City, null, GetJobListEnd);
            CityDal.Instance.GetCityUniversity((string)Isolated.Get("CurrentCity"), GetCityUniversityEnd);

            Messenger.Default.Send <string>(city.City, "ChangeCityComplete");
        }
 public ActionResult Edit([Bind(Include = "IsolatedId,PlaceOfIsolation")] Isolated isolated)
 {
     if (ModelState.IsValid)
     {
         db.Entry(isolated).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(isolated));
 }
 public void ComPluginRuntimeHandler_ListNamespaces_WhenValidClassID_ExpectNamespaces()
 {
     //------------Setup for test--------------------------
     var source = CreateComPluginSource();
     //------------Execute Test---------------------------
     using (var isolated = new Isolated<ComPluginRuntimeHandler>())
     {
         var result = isolated.Value.FetchNamespaceListObject(source);
         Assert.IsNotNull(result);
     }
 }
 public void ComPluginRuntimeHandler_ListMethods_WhenValidLocation_ExpectResults()
 {
     //------------Setup for test--------------------------
     //------------Execute Test---------------------------
     using (var isolated = new Isolated <ComPluginRuntimeHandler>())
     {
         var result = isolated.Value.ListMethods(adodbConnectionClassId, true);
         CollectionAssert.AllItemsAreUnique(result);
         Assert.AreNotEqual(0, result.Count);
     }
 }
Example #22
0
        public void WhenSitecoreIoCApplicationStartsIApplicationPreApplicationStartIsCalled()
        {
            Isolated.Execute(() =>
            {
                //Act
                SitecoreApplication.PreApplicationStart();

                //Assert
                ApplicationSpy.PreApplicationStartWasCalled.Should().BeTrue();
            });
        }
        public ActionResult Create([Bind(Include = "IsolatedId,PlaceOfIsolation")] Isolated isolated)
        {
            if (ModelState.IsValid)
            {
                db.isolateds.Add(isolated);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(isolated));
        }
Example #24
0
        public void WhenSitecoreIoCApplicationShutdownsIApplicationApplicationShutdownIsCalled()
        {
            Isolated.Execute(() =>
            {
                //Act
                SitecoreApplication.ApplicationShutdown();

                //Assert
                ApplicationSpy.ApplicationShutdownWasCalled.Should().BeTrue();
            });
        }
 public void PluginRuntimeHandler_GetNamespaces_WhenValidDll_ExpectNamespaces()
 {
     //------------Setup for test--------------------------
     var source = CreatePluginSource();
     //------------Execute Test---------------------------
     using (Isolated<PluginRuntimeHandler> isolated = new Isolated<PluginRuntimeHandler>())
     {
         var result = PluginServiceExecutionFactory.GetNamespaces(source);
         //------------Assert Results-------------------------
         Assert.IsTrue(result.Count > 0);
     }
 }
 public void ComPluginRuntimeHandler_Run_WhenNullParameters_ExpectException()
 {
     //------------Setup for test--------------------------
     var svc = CreatePluginService();
     var source = CreateComPluginSource();
     //------------Execute Test---------------------------
     using (var isolated = new Isolated<ComPluginRuntimeHandler>())
     {
         var args = new ComPluginInvokeArgs { ClsId = source.ClsId, AssemblyName = "Foo", Fullname = svc.Namespace, Method = svc.Method.Name, Parameters = null };
         isolated.Value.Run(args);
     }
 }
        public void PluginRuntimeHandler_GetNamespaces_WhenValidDll_ExpectNamespaces()
        {
            //------------Setup for test--------------------------
            var source = CreatePluginSource();

            //------------Execute Test---------------------------
            using (Isolated <ComPluginRuntimeHandler> isolated = new Isolated <ComPluginRuntimeHandler>())
            {
                var result = ComPluginServiceExecutionFactory.GetNamespaces(source);
                //------------Assert Results-------------------------
                Assert.IsTrue(result.Count > 0);
            }
        }
        // GET: Isolateds/Edit/5'

        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Isolated isolated = db.isolateds.Find(id);

            if (isolated == null)
            {
                return(HttpNotFound());
            }
            return(View(isolated));
        }
Example #29
0
 private void OnChangeSchool(string city, string university)
 {
     // JobsList.Clear();
     if (university != null && !university.Equals("全部学校"))
     {
         CurrentUniversity = university;
         JobDal.Instance.GetJobslist(getCurrentTime(), city, university, GetJobListEnd);
         Isolated.Set("CurrentUniversity", university);
     }
     else
     {
         JobDal.Instance.GetJobslist(getCurrentTime(), city, null, GetJobListEnd);
     }
 }
Example #30
0
        private static void RunDescribedTests(TestDescription testDescription)
        {
            bool exitedInTime;
            int  exitCode;

            using (Isolated <NunitManagedTestRunnerAdaptor> runner = new Isolated <NunitManagedTestRunnerAdaptor>())
            {
                var mutantPath = testDescription.AssemblyPath;
                runner.Instance.Start(mutantPath, testDescription.TestsToRun);
                exitedInTime = runner.Instance.WaitForExit((int)(_killTimeFactor * testDescription.TotalMsBench));
                exitCode     = runner.Instance.ExitCode;
            }
            testDescription.ExitedInTime = exitedInTime;
            testDescription.TestsPass    = (exitCode == 0);
        }
Example #31
0
        private long NoSetBench()
        {
            long elapsedMs = 0;

            using (Isolated <NunitManagedTestRunnerAdaptor> runner = new Isolated <NunitManagedTestRunnerAdaptor>())
            {
                var watch = Stopwatch.StartNew();
                runner.Instance.Start(_testAssemblyLocation);
                runner.Instance.WaitForExit();
                watch.Stop();
                elapsedMs = watch.ElapsedMilliseconds;
                TestsPass = (runner.Instance.ExitCode == 0);
            }
            return(elapsedMs);
        }
Example #32
0
        /// <summary>
        /// 获取我最近输入的话题
        /// </summary>
        /// <param name="count">获取条数</param>
        /// <returns></returns>
        public static List <string> GetRecent(int count = 0)
        {
            var ht = (List <string>)Isolated.Get(IsolatedHelper.HuaTiKey);

            if (ht == null)
            {
                return(new List <string>());
            }
            if (count > 0)
            {
                count = Math.Min(count, ht.Count);
                ht    = ht.Take(count).ToList();
            }
            return(ht);
        }
Example #33
0
        public void Isolated_WhenMoreThanOneApplicationExitsMultipleApplicationFoundThrown()
        {
            //Assign
            var extraAssemblies = new List <Assembly>
            {
                typeof(Application1).Assembly
            };

            //Act
            Action multipleApplications = () =>
                                          Isolated.Execute(SitecoreApplication.PreApplicationStart, extraAssemblies);

            //Assert
            multipleApplications.Should().Throw <MultipleApplicationFound>();
        }
Example #34
0
 private void InitNoticeRenderer()
 {
     logger.Info("Инициализация рендерера");
     if (m_IsolatedNoticeRenderer != null)
     {
         m_IsolatedNoticeRenderer.Dispose();
     }
     m_IsolatedNoticeRenderer = new Isolated<NoticeRenderer>();
 }
        public void PluginRuntimeHandler_InvokePlugin_WhenValidDll_ExpectValidResults()
        {
            //------------Setup for test--------------------------
            var source = CreatePluginSource();
            var svc = CreatePluginService();
                     
            

            //------------Execute Test---------------------------
            using (Isolated<PluginRuntimeHandler> isolated = new Isolated<PluginRuntimeHandler>())
            {
                PluginInvokeArgs args = new PluginInvokeArgs { AssemblyLocation = source.AssemblyLocation, AssemblyName = "Foo", Fullname = svc.Namespace, Method = svc.Method.Name, Parameters = svc.Method.Parameters };
                var result = PluginServiceExecutionFactory.InvokePlugin(args);
                var castResult = result as DummyClassForPluginTest;
                //------------Assert Results-------------------------
                if (castResult != null)
                {
                    StringAssert.Contains(castResult.Name, "test data");
                }
                else
                {
                    Assert.Fail("Failed Conversion for Assert");
                }
            }  
            
        }
Example #36
0
 public Coordinator(CoordinatorCreateOptions options)
 {
     this.isolatedCoordinator = new Isolated<IsolatedSwarmCoordinator>();
     this.CoordinatorValue.Initialize(options);
 }
Example #37
0
        public static int InstallService(string fullFileName,
bool bInstall,
out string strError)
        {
            // http://stackoverflow.com/questions/20938531/managedinstallerclass-installhelper-is-locking-winservice-exe-file
            // ManagedInstallerClass.InstallHelper is locking WinService exe file
            Isolated<InstallServiceWork> isolated = new Isolated<InstallServiceWork>();
            try
            {
                strError = isolated.Value.InstallService(new Parameters { ExePath = fullFileName, Install = bInstall });
                if (string.IsNullOrEmpty(strError) == true)
                    return 0;
                return -1;
            }
            finally
            {
                isolated.Dispose();
            }
        }