Пример #1
0
 private static bool Contains(string answerControl, string answerKey, string answerUrl, string command, Form form)
 {
     if (answerCollection == null || answerCollection.Count == 0)
     {
         return(false);
     }
     return(answerCollection.Any(x => x.AnswerControl.Equals(answerControl) && x.AnswerKey.Equals(answerKey) && x.AnswerUrl.Equals(answerUrl) && x.AnswerCommand.Equals(command) && (form == null || form.Equals(x.Form))));
 }
Пример #2
0
        public void FileInfo_NativeWriteOverlapped_Succeeds()
        {
            var bufferSize  = int.Parse((string)TestContext.DataRow["BufferSize"]);
            var fileSize    = int.Parse((string)TestContext.DataRow["FileSize"]);
            var testInput   = Enumerable.Range(0, fileSize).Select(i => (byte)(i % 251 + 1)).ToArray();
            var sutContract = fixture.RootDirectoryItems.OfType <FileInfoContract>().First();
            var differences = new SynchronizedCollection <Tuple <int, int, byte[], byte[]> >();

            fixture.SetupGetRootDirectoryItems();
            var file = fixture.RootDirectoryItems.OfType <FileInfoContract>().First();

            fixture.SetupSetFileContent(file, testInput, differences);

            var root   = fixture.GetDriveInfo().RootDirectory;
            var chunks = Enumerable.Range(0, Fixture.NumberOfChunks(bufferSize, fileSize))
                         .Select(i => new NativeMethods.OverlappedChunk(testInput.Skip(i * bufferSize).Take(NativeMethods.BufferSize(bufferSize, fileSize, i)).ToArray())).ToArray();

            NativeMethods.WriteEx(root.FullName + file.Name, bufferSize, fileSize, chunks);

            Assert.IsTrue(chunks.All(c => c.Win32Error == 0), "Win32Error occured");

            Assert.IsFalse(differences.Any(), "Mismatched data detected");

            fixture.Verify();
        }
Пример #3
0
        public void OnJobReady(ScheduleJob job)
        {
            switch (job.mPriority)
            {
            case ScheduleJob.Priorities.SMALL:
                var existsSmall = mSmallJobs.Any(anyJob => anyJob.Key.mFilePath == job.mFilePath);
                if (!existsSmall)
                {
                    mSmallJobs.TryAdd(job, null);
                }
                break;

            case ScheduleJob.Priorities.MEDIUM:
                var existsMedium = mMediumJobs.Any(anyJob => anyJob.mFilePath == job.mFilePath);
                if (!existsMedium)
                {
                    mMediumJobs.Add(job);
                }
                break;

            case ScheduleJob.Priorities.BIG:
                var existsBig = mBigJobs.Any(anyJob => anyJob.mFilePath == job.mFilePath);
                if (!existsBig)
                {
                    mBigJobs.Add(job);
                }
                break;
            }

            FetchSignal.waitHandle.Set();
        }
Пример #4
0
        private void DownloadFile()
        {
            if (allImages.Any())
            {
                for (int i = 0; i < allImages.Count; i++)
                {
                    WebClient client = new WebClient();
                    client.DownloadFileCompleted += Completed;

                    string FileName = allImages[i].Segments.Last().ToString();

                    //this is here because some images don't have extensions
                    if (FileName.EndsWith(".jpg") || FileName.EndsWith(".png") || FileName.EndsWith(".gif"))
                    {
                        //check to see if the file is already there in the first place
                        //usefull when downloading multiple blogs in the same folder
                        if (!File.Exists(AppSettings.Default.downlaodpath + @"\" + FileName))
                        {
                            client.DownloadFileAsync(allImages[i], AppSettings.Default.downlaodpath + @"\" + FileName, allImages[i]);
                        }
                    }
                    else
                    {
                        if (!File.Exists(AppSettings.Default.downlaodpath + @"\" + FileName + ".jpg"))
                        {
                            client.DownloadFileAsync(allImages[i],
                                                     AppSettings.Default.downlaodpath + @"\" + FileName + ".jpg", allImages[i]);
                        }
                    }
                }
            }
        }
Пример #5
0
 public static bool ContainsKey(IntPtr formHandle)
 {
     try
     {
         return(wndHandleHashtable != null && wndHandleHashtable.Any(x => x.Key.Equals(formHandle)));
     }
     catch (Exception ex)
     {
         Lib.Win.Data.Env.WriteToLog(ex, "Error while trying to find formHandle: " + formHandle.ToString() + ", HashTable is " + (wndHandleHashtable == null ? "" : "NOT ") + "null");
     }
     return(false);
 }
Пример #6
0
 /// <summary>
 /// Tests if an appender with the given name already exixts
 /// </summary>
 /// <param name="list">List of appender</param>
 /// <param name="name">Name of the appender to test</param>
 /// <returns>bool</returns>
 public static bool IsAnAppenderName(this SynchronizedCollection <IAppender> list, string name)
 {
     return(list.Any(li => li.AppenderName == name));
 }