Example #1
0
 private static void ToSTA(ST.ThreadStart code)
 {
     ST.Thread t = new ST.Thread(code);
     t.SetApartmentState(ST.ApartmentState.STA);
     t.Start();
     t.Join();
 }
Example #2
0
        public void QueryResult_Paging_WithInvisibles_OverPaging()
        {
            //                01234 56789 01234 56789 01234 56789 01234 56789 01
            var visibility = "vvvvv v--v- -vvv- ----- ----- --vvv -vvv- v-v-- -v";
            var expected = "----- ----- ----- ----- ----- ----- ----- ----- --";
            EnsureStructure();
            SetBufferedNodeEnumeratorBufferSize(5);
            try
            {
                SetVisibility(visibility);
                User.Current = User.Visitor;

                var qt = String.Format("+ParentId:{0} +Type:Car +Index:[5 TO 37]", TestRoot.Id);
                var sort = new[] { new SortInfo { FieldName = "Index" } };
                var result = ContentQuery.Query(qt, new QuerySettings { Skip = 100, Top = 5, Sort = sort });
                var page = result.Nodes;
                var currentSet = new List<int>();
                foreach (var node in page)
                    currentSet.Add(node.Index);

                var currentString = IndicesToVisibility(currentSet);
                var expectedString = expected.Replace(" ", String.Empty);

                Assert.AreEqual(expectedString, currentString);

            }
            finally
            {
                User.Current = User.Administrator;
            }
        }
Example #3
0
        public void QueryExecutor_ForceTopByConfig()
        {
            StorageContext.Search.DefaultTopAndGrowth = new[] { 10, 30, 80, 0 };
            var qt = "Type:ContentType .AUTOFILTERS:OFF";
            var sort = new[] { new SortInfo { FieldName = "Id" } };
            var result = ContentQuery.Query(qt, new QuerySettings { Skip = 0, Top = 1000, Sort = sort });
            var page = result.Nodes;
            var expectedSet = new List<int>();
            foreach (var node in page)
                expectedSet.Add(node.Id);
            var expectedStr = String.Join(", ", expectedSet);

            result = ContentQuery.Query(qt, new QuerySettings { Skip = 0, Top = 0, Sort = sort });
            page = result.Nodes;
            var currentSet = new List<int>();
            foreach (var node in page)
                currentSet.Add(node.Id);
            var currentStr = String.Join(", ", currentSet);
            
            Assert.AreEqual(expectedStr, currentStr);
            //Assert.IsTrue(currentSet.Except(expectedSet).Count() == 0, "Returned list contains unexpected ids.");
            //Assert.IsTrue(expectedSet.Except(currentSet).Count() == 0, "Expected list contains ids that were not returned.");
        }
        public void PrecedenceTest()
        {
            var precedence = new[]
                                 {
                                     new
                                         {
                                             File = "ConfigFileLocator.exe.config",
                                             Contents = appConfigContents,
                                             Output = appConfigOutput
                                         },
                                     new
                                         {
                                             File = "NLog.config",
                                             Contents = nlogConfigContents,
                                             Output = nlogConfigOutput
                                         },
                                     new
                                         {
                                             File = "ConfigFileLocator.exe.nlog",
                                             Contents = appNLogContents,
                                             Output = appNLogOutput
                                         },
                                     new
                                         {
                                             File = "NLog.dll.nlog",
                                             Contents = nlogDllNLogContents,
                                             Output = nlogDllNLogOutput
                                         },
                                 };
            // deploy all files
            foreach (var p in precedence)
            {
                File.WriteAllText(Path.Combine(_tempDirectory, p.File), p.Contents);
            }

            string output;

            // walk files in precedence order and delete config files
            foreach (var p in precedence)
            {
                output = RunTest();
                Assert.Equal(p.Output, output);
                File.Delete(Path.Combine(_tempDirectory, p.File));
            }

            output = RunTest();
            Assert.Equal(missingConfigOutput, output);

        }
Example #5
0
 public Thread(Threading.Thread t)
 {
     this.t=t;
 }
Example #6
0
 public Thread(SystemThreading.Thread thread)
 {
     m_thread = thread;
 }
Example #7
0
		private Thread (ST.Thread thread)
		{
			this.thread = thread;
		}
		public void AcquirePushChannel(string token)
#endif
        {
            var uri = "";
			
#if WINDOWS_PHONE
            var CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");


            if (CurrentChannel == null)
            {
                CurrentChannel = new HttpNotificationChannel("MyPushChannel");
                CurrentChannel.Open();
                CurrentChannel.BindToShellToast();
            }

            while (CurrentChannel.ChannelUri == null)
            {
                Thread.Sleep(100);
            }

            uri = CurrentChannel.ChannelUri.ToString();
#else
            uri = token;
#endif


            IMobileServiceTable<PushChannel> channelTable = _mobileService.GetTable<PushChannel>();
            var channel = new PushChannel
            {
                Uri = uri,

#if ANDROID
				Platform = "Android",
                DeviceId = Settings.Secure.GetString(Application.Context.ContentResolver, Settings.Secure.AndroidId)

#elif IOS
				Platform = "iOS",
				DeviceId = UIDevice.CurrentDevice.IdentifierForVendor.AsString()
#elif WINDOWS_PHONE
				Platform = "WP8",
				DeviceId = Windows.Phone.System.Analytics.HostInformation.PublisherHostId
#endif
            };
            channelTable.InsertAsync(channel);
        }

    }
		void DispatchEvent (ST.WaitCallback eventCallback)
		{
			lock (eventQueue) {
				eventQueue.Add (eventCallback);
				ST.Monitor.PulseAll (eventQueue);
			}
		}
		void QueueTask (ST.WaitCallback cb)
		{
			lock (debugger) {
				if (stoppedWorkQueue.Count > 0)
					stoppedWorkQueue.Add (cb);
				else
					cb (null);
			}
		}