コード例 #1
0
        public void AddTest()
        {
            var customDictionary = new CustomDictionary<string, int>();
            customDictionary.Add("Ivan", 1);
            customDictionary.Add("Stepan", 2);
            customDictionary.Add("Nikolay", 3);

            customDictionary.Invoking(dictionary => dictionary.Add("Nikolay", 4)).ShouldThrow<ArgumentException>();

            customDictionary["Ivan"].Should().Be(1);
            customDictionary["Stepan"].Should().Be(2);
            customDictionary["Nikolay"].Should().Be(3);

            customDictionary.Invoking(dictionary => { int value = customDictionary["Peter"]; }).ShouldThrow<ArgumentException>();

            customDictionary["Nikolay"] = 4;

            customDictionary["Nikolay"].Should().Be(4);

            customDictionary.Remove("Nikolay");
            customDictionary.Contains("Nikolay").Should().BeFalse();

            customDictionary.Add("Nikolay", 3);
            customDictionary.Add("Andrey", 4);
            customDictionary.Add("Sergey", 5);

            customDictionary["Ivan"].Should().Be(1);
            customDictionary["Stepan"].Should().Be(2);
            customDictionary["Nikolay"].Should().Be(3);
            customDictionary["Andrey"].Should().Be(4);
            customDictionary["Sergey"].Should().Be(5);
        }
コード例 #2
0
        static void Main()
        {
            string input = Console.ReadLine();
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentNullException("Input cannot be null or empty.");
            }

            CustomDictionary<char, int> dictionary = new CustomDictionary<char, int>();

            foreach (char c in input)
            {
                if (!dictionary.ContainsKey(c))
                {
                    dictionary.Add(c, 1);
                }
                else
                {
                    dictionary[c]++;
                }
            }

            var chars = dictionary.Keys;
            chars = chars.OrderBy(x => x);

            foreach (var c in chars)
            {
                Console.WriteLine("{0}: {1} time/s", c, dictionary[c]);
            }
        }
コード例 #3
0
ファイル: ValueStack.cs プロジェクト: Fedorm/core-master
 public ValueStack(IExceptionHandler handler, IExpressionContext expressionContext)
 {
     Values = new CustomDictionary();
     _exceptionHandler = handler;
     _evaluator = expressionContext.CreateEvaluator(this);
     Persistables = new Dictionary<string, IPersistable>();
 }
コード例 #4
0
ファイル: SoundExDictionary.cs プロジェクト: rbirkby/soundex
        /// <summary>
        /// Factory method for creating a SoundEx dictonary using any of the
        /// SoundEx implementations available
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="soundex">The type of soundex algorithm.</param>
        /// <returns></returns>
        public static SoundExDictionary CreateCustomDictionary(Stream stream, SoundEx soundex)
        {
            var custom = new CustomDictionary(soundex);
            var reader = new StreamReader(stream);

            Console.Write("Loading");

            string line = reader.ReadLine();

            do
            {
                if (custom.WordCount % 1000 == 0)
                    Console.Write(".");

                custom.AddWord(line);
                line = reader.ReadLine();
            }
            while (line != null);

            Console.WriteLine();

            Console.WriteLine("Number of words loaded: " + custom.WordCount);
            Console.WriteLine("Number of unique SoundEx values: " + custom.SoundExGroups);

            return custom;
        }
        public static void Main()
        {
            string input = Console.ReadLine();
            CustomDictionary<string, string> infoHolder = new CustomDictionary<string, string>();

            bool searchRegime = false;
            do
            {
                if(input.ToLower().Trim() == "search")
                    searchRegime ^= true;

                if(!searchRegime)
                {
                    string[] info = Regex.Split(input, @"\s*\-\s*");
                    infoHolder.AddOrReplace(info[0], info[1]);
                }
                else
                {
                    if (input.ToLower().Trim() == "search")
                        input = Console.ReadLine();
                    string phoneNumber;
                    if(infoHolder.TryGetValue(input.Trim(), out phoneNumber))
                        Console.WriteLine("{0} -> {1}", input.Trim(), phoneNumber);
                    else
                        Console.WriteLine("Contact {0} does not exist.", input);
                }

                input = Console.ReadLine();
            } while(!string.IsNullOrEmpty(input));
        }
        public void Add_EmptyHashTable_Duplicates_ShouldThrowException()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, string>();

            // Act
            customDictionary.Add("Peter", "first");
            customDictionary.Add("Peter", "second");
        }
コード例 #7
0
ファイル: FileList.cs プロジェクト: pocheptsov/syncsharp
		public FileList(CustomDictionary<string, string, FileUnit> cleanFiles,
		CustomDictionary<string, string, FileUnit> dirtyFiles,
		CustomDictionary<string, string, FileUnit> dirtyDirs,
		CustomDictionary<string, string, FileUnit> cleanDirs)
		{
			this._cleanFiles = cleanFiles;
			this._dirtyFiles = dirtyFiles;
			this._dirtyDirs = dirtyDirs;
			this._cleanDirs = cleanDirs;
		} 
 public static void Main()
 {
     //string input = "SoftUni rocks";
     string input = "Did you know Math.Round rounds to the nearest even integer?";
     var charList = input.ToCharArray();
     var groups = charList.GroupBy(s => s).Select(s => new
         {
             Letter = (char)s.Key,
             Occurrences = s.Count()
         }).ToList();
     CustomDictionary<char, int> infoHolder = new CustomDictionary<char, int>();
     groups.ForEach(g => infoHolder.Add(g.Letter, g.Occurrences));
     PrintLetterOccurrences(infoHolder);
 }
コード例 #9
0
 public FolderDiffForm(CustomDictionary<string,string, PreviewUnit> previewFilesList,
     CustomDictionary<string,string, PreviewUnit> previewFoldersList,
     SyncTask task)
 {
     InitializeComponent();
     _previewFilesList = previewFilesList;
     _previewFoldersList = previewFoldersList;
     _source = task.Source;
     _target = task.Target;
     _sortColumn = -1;
     lblName.Text = task.Name;
     lblSource.Text = _source;
     lblTarget.Text = _target;
     _filter = "";
     this.Text = "[" + lblName.Text + "] Synchronization Preview";
 }
コード例 #10
0
ファイル: SyncMetaData.cs プロジェクト: pocheptsov/syncsharp
		public static void WriteMetaData(string path, CustomDictionary<string, string, FileUnit> metadata)
		{
			try
			{
				if (File.Exists(path))
					File.SetAttributes(path, FileAttributes.Normal);
				FileStream fsMetaFile = null;
				fsMetaFile = new FileStream(path, FileMode.Create);
				var bfMetaFile = new BinaryFormatter();
				bfMetaFile.Serialize(fsMetaFile, metadata);
				fsMetaFile.Close();
			}
			catch
			{
			}
		}
コード例 #11
0
        public static void Main()
        {
            string input = string.Empty;
            var customDictionary = new CustomDictionary<string, string>();

            while (input != "search")
            {
                input = Console.ReadLine();

                if (input != "search")
                {
                    if (input.Contains("-"))
                    {
                        string[] keyValue = input.Split('-');
                        string name = keyValue[0].Trim();
                        string phone = keyValue[1].Trim();

                        bool isExist = customDictionary.AddOrReplace(name, phone);
                        Console.WriteLine(!isExist ? "Successfully add " + name : "Successfully update " + name);
                    }
                    else
                    {
                        Console.WriteLine("Wrong input format!");
                    }
                }
            }

            Console.WriteLine();
            while (input != string.Empty)
            {
                input = Console.ReadLine().Trim();

                if (input != string.Empty)
                {
                    var result = customDictionary.FirstOrDefault(cd => cd.Key == input);
                    if (result != null)
                    {
                        Console.WriteLine("{0} -> {1}", result.Key, result.Value);
                    }
                    else
                    {
                        Console.WriteLine("Contact {0} does not exist.", input);
                    }
                }
            }
        }
        public void Add_1000_Elements_Grow_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, int>(1);

            // Act
            var expectedElements = new List<KeyValue<string, int>>();
            for (int i = 0; i < 1000; i++)
            {
                customDictionary.Add("key" + i, i);
                expectedElements.Add(new KeyValue<string, int>("key" + i, i));
            }

            // Assert
            var actualElements = customDictionary.ToList();
            CollectionAssert.AreEquivalent(expectedElements, actualElements);
        }
コード例 #13
0
ファイル: Detector.cs プロジェクト: riverstore/syncsharp
 public Detector(String metaDataDir, SyncTask syncTask)
 {
     _sCleanFiles = new CustomDictionary<string, string, FileUnit>();
     _sDirtyFiles = new CustomDictionary<string, string, FileUnit>();
     _tCleanFiles = new CustomDictionary<string, string, FileUnit>();
     _tDirtyFiles = new CustomDictionary<string, string, FileUnit>();
     _sDirtyDirs = new CustomDictionary<string, string, FileUnit>();
     _sCleanDirs = new CustomDictionary<string, string, FileUnit>();
     _tDirtyDirs = new CustomDictionary<string, string, FileUnit>();
     _tCleanDirs = new CustomDictionary<string, string, FileUnit>();
     _backupFiles = new CustomDictionary<string, string, FileUnit>();
     _fileExclusions = new List<string>();
     _task = syncTask;
     _sMetaData = SyncMetaData.ReadMetaData(metaDataDir + @"\" + syncTask.Name + ".meta");
     _tMetaData = SyncMetaData.ReadMetaData(metaDataDir + @"\" + syncTask.Name + ".meta");
     _srcDirtySize = 0;
     _tgtDirtySize = 0;
 }
コード例 #14
0
ファイル: Reconciler.cs プロジェクト: riverstore/syncsharp
        public Reconciler(FileList srcList, FileList tgtList, SyncTask task, String metaDataDir)
        {
            _srcList = srcList;
            _tgtList = tgtList;
            _taskSettings = task.Settings;
            _srcPath = task.Source;
            _tgtPath = task.Target;
            _taskName = task.Name;
            _errorDetected = false;

            _previewFilesList = new CustomDictionary<string, string, PreviewUnit>();
            _previewFoldersList = new CustomDictionary<string, string, PreviewUnit>();
            _updatedList = new CustomDictionary<string, string, FileUnit>();
            _srcRenameList = new CustomDictionary<string, string, FileUnit>();
            _tgtRenameList = new CustomDictionary<string, string, FileUnit>();

            _summary = new SyncSummary();
            _summary.logFile = metaDataDir + @"\" + task.Name + ".log";
        }
        public void AddOrReplace_WithDuplicates_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, int>();

            // Act
            customDictionary.AddOrReplace("Peter", 555);
            customDictionary.AddOrReplace("Maria", 999);
            customDictionary.AddOrReplace("Maria", 123);
            customDictionary.AddOrReplace("Maria", 6);
            customDictionary.AddOrReplace("Peter", 5);

            // Assert
            var expectedElements = new KeyValue<string, int>[]
            {
                new KeyValue<string, int>("Peter", 5),
                new KeyValue<string, int>("Maria", 6)
            };
            var actualElements = customDictionary.ToList();
            CollectionAssert.AreEquivalent(expectedElements, actualElements);
        }
        public void Add_EmptyHashTable_NoDuplicates_ShouldAddElement()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, int>();

            // Act
            var elements = new KeyValue<string, int>[]
            {
                new KeyValue<string, int>("Peter", 5),
                new KeyValue<string, int>("Maria", 6),
                new KeyValue<string, int>("George", 4),
                new KeyValue<string, int>("Kiril", 5)
            };
            foreach (var element in elements)
            {
                customDictionary.Add(element.Key, element.Value);
            }

            // Assert
            var actualElements = customDictionary.ToList();
            CollectionAssert.AreEquivalent(elements, actualElements);
        }
コード例 #17
0
ファイル: Reconciler.cs プロジェクト: riverstore/syncsharp
        /// <summary>
        /// Perform restore from target replica to source replica.
        /// </summary>
        /// <param name="srcList"></param>
        public void RestoreSource(CustomDictionary<string, string, FileUnit> srcList)
        {
            _summary.startTime = DateTime.Now;
            foreach (var myRecord in srcList.Primary)
            {
                try
                {
                    String relativePath = myRecord.Key;
                    String srcFile; String tgtFile;

                    srcFile = _srcPath + relativePath; tgtFile = _tgtPath + relativePath;
                    if (Directory.Exists(tgtFile))
                    {
                        if (!Directory.Exists(srcFile))
                        {
                            Directory.CreateDirectory(srcFile);
                            _summary.iSrcFolderCreate++;
                            Logger.WriteLog(Logger.LogType.CreateSRC, srcFile, 0, null, 0);
                        }
                    }
                    else
                    {
                        if (!File.Exists(srcFile))
                        {
                            CheckAndCreateFolder(srcFile);
                            File.Copy(tgtFile, srcFile);
                            _summary.iTgtFileCopy++;
                            long fileSize = new FileInfo(tgtFile).Length;
                            Logger.WriteLog(Logger.LogType.CopyTGT, tgtFile, fileSize, srcFile, fileSize);
                        }
                        else
                        {
                            FileInfo srcFileInfo = new FileInfo(srcFile);
                            FileInfo tgtFileInfo = new FileInfo(tgtFile);

                            if (srcFileInfo.LastWriteTimeUtc != tgtFileInfo.LastWriteTimeUtc)
                            {
                                File.Copy(tgtFile, srcFile, true);
                                _summary.iTgtFileCopy++; _summary.iSrcFileOverwrite++;
                                long fileSize = new FileInfo(tgtFile).Length;
                                Logger.WriteLog(Logger.LogType.CopyTGT, tgtFile, fileSize, srcFile, fileSize);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _errorDetected = true;
                    Logger.WriteErrorLog(e.Message);
                }
            }
            _summary.endTime = DateTime.Now;
        }
 private static void PrintLetterOccurrences(CustomDictionary<char, int> infoHolder)
 {
     infoHolder.OrderBy(ch => ch.Key).ToList().ForEach(i => Console.WriteLine("{0} : {1} time/s", i.Key, i.Value));
 }
コード例 #19
0
        public void Translator_DictionaryTest_InvalidArguments()
        {
            CustomDictionary userCustomDictonaries = null;

            Assert.ThrowsException <ArgumentNullException>(() => new CustomDictionaryPostProcessor(userCustomDictonaries));
        }
コード例 #20
0
ファイル: Query.cs プロジェクト: Fedorm/core-master
 public Query()
 {
     parameters = new CustomDictionary();
 }
コード例 #21
0
 private static void PrintLetterOccurrences(CustomDictionary <char, int> infoHolder)
 {
     infoHolder.OrderBy(ch => ch.Key).ToList().ForEach(i => Console.WriteLine("{0} : {1} time/s", i.Key, i.Value));
 }
        public void Indexer_NonExistingElement_ShouldThrowException()
        {
            // Arrange
            var customDictionary = new CustomDictionary<int, string>();

            // Act
            var value = customDictionary[12345];
        }
コード例 #23
0
ファイル: Query.cs プロジェクト: Fedorm/core-master
 public Query(String text)
 {
     parameters = new CustomDictionary();
     this.text  = text;
 }
コード例 #24
0
ファイル: Tests.cs プロジェクト: ondrejsevcik/PieceOfCake
        public void TryGetIntValueReturnsExpectedValue()
        {
            var dictionary = new CustomDictionary<string, int>();
            dictionary.AddOrSet("A", 1);
            dictionary.AddOrSet("B", 2);

            int value;

            var result = dictionary.TryGetValue("A", out value);

            Assert.AreEqual(1, value);
        }
        public void Keys_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, double>();

            // Assert
            CollectionAssert.AreEquivalent(new string[0], customDictionary.Keys.ToArray());

            // Arrange
            customDictionary.Add("Peter", 12.5);
            customDictionary.Add("Maria", 99.9);
            customDictionary["Peter"] = 123.45;

            // Act
            var keys = customDictionary.Keys;

            // Assert
            var expectedKeys = new string[] { "Peter", "Maria" };
            CollectionAssert.AreEquivalent(expectedKeys, keys.ToArray());
        }
        public void Remove_5000_Elements_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, int>();
            var keys = new List<string>();
            var count = 5000;
            for (int i = 0; i < count; i++)
            {
                var key = Guid.NewGuid().ToString();
                keys.Add(key);
                customDictionary.Add(key, i);
            }

            // Assert
            Assert.AreEqual(count, customDictionary.Count);

            // Act & Assert
            keys.Reverse();
            foreach (var key in keys)
            {
                customDictionary.Remove(key);
                count--;
                Assert.AreEqual(count, customDictionary.Count);
            }

            // Assert
            var expectedElements = new List<KeyValue<string, int>>();
            var actualElements = customDictionary.ToList();
            CollectionAssert.AreEquivalent(expectedElements, actualElements);
        }
コード例 #27
0
 public bool Equals(CustomDictionary <TKey, TValue> other)
 {
     return(true);
 }
コード例 #28
0
        public void CustomDictionaryConstructorTestHelper <K, V>()
        {
            CustomDictionary <K, V> target = new CustomDictionary <K, V>();

            Assert.AreEqual(0, target.Count);
        }
        public void Values_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, double>();

            // Assert
            CollectionAssert.AreEquivalent(new string[0], customDictionary.Values.ToArray());

            // Arrange
            customDictionary.Add("Peter", 12.5);
            customDictionary.Add("Maria", 99.9);
            customDictionary["Peter"] = 123.45;

            // Act
            var values = customDictionary.Values;

            // Assert
            var expectedValues = new double[] { 99.9, 123.45 };
            CollectionAssert.AreEquivalent(expectedValues, values.ToArray());
        }
        public void TryGetValue_NonExistingElement_ShouldReturnFalse()
        {
            // Arrange
            var customDictionary = new CustomDictionary<int, string>();

            // Act
            string value;
            var result = customDictionary.TryGetValue(555, out value);

            // Assert
            Assert.IsFalse(result);
        }
        public void TryGetValue_ExistingElement_ShouldReturnTheValue()
        {
            // Arrange
            var customDictionary = new CustomDictionary<int, string>();

            // Act
            customDictionary.Add(555, "Peter");
            string value;
            var result = customDictionary.TryGetValue(555, out value);

            // Assert
            Assert.AreEqual("Peter", value);
            Assert.IsTrue(result);
        }
        public void Remove_NonExistingElement_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, double>();
            customDictionary.Add("Peter", 12.5);
            customDictionary.Add("Maria", 99.9);

            // Assert
            Assert.AreEqual(2, customDictionary.Count);

            // Act
            var removed = customDictionary.Remove("George");

            // Assert
            Assert.IsFalse(removed);
            Assert.AreEqual(2, customDictionary.Count);
        }
コード例 #33
0
ファイル: Reconciler.cs プロジェクト: riverstore/syncsharp
 /// <summary>
 /// Get the list of dirty and clean files and folders.
 /// </summary>
 private void GetFilesFoldersLists()
 {
     _srcDirtyFilesList = _srcList.DirtyFiles;
     _srcCleanFilesList = _srcList.CleanFiles;
     _srcDirtyFoldersList = _srcList.DirtyDirs;
     _srcCleanFoldersList = _srcList.CleanDirs;
     _tgtDirtyFilesList = _tgtList.DirtyFiles;
     _tgtCleanFilesList = _tgtList.CleanFiles;
     _tgtDirtyFoldersList = _tgtList.DirtyDirs;
     _tgtCleanFoldersList = _tgtList.CleanDirs;
 }
        public void Capacity_Grow_ShouldWorkCorrectly()
        {
            // Arrange
            var customDictionary = new CustomDictionary<string, int>(2);

            // Assert
            Assert.AreEqual(2, customDictionary.Capacity);

            // Act
            customDictionary.Add("Peter", 123);
            customDictionary.Add("Maria", 456);

            // Assert
            Assert.AreEqual(4, customDictionary.Capacity);

            // Act
            customDictionary.Add("Tanya", 555);
            customDictionary.Add("George", 777);

            // Assert
            Assert.AreEqual(8, customDictionary.Capacity);
        }
コード例 #35
0
ファイル: Tests.cs プロジェクト: ondrejsevcik/PieceOfCake
        public void TryGetStringValueReturnsExpectedValue()
        {
            var dictionary = new CustomDictionary<string, string>();
            dictionary.AddOrSet("A", "Alpha");
            dictionary.AddOrSet("B", "Bravo");

            string value;

            var result = dictionary.TryGetValue("A", out value);

            Assert.AreEqual("Alpha", value);
        }
コード例 #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomDictionaryPostProcessor"/> class.
 /// </summary>
 /// <param name="userCustomDictionaries">A <see cref="CustomDictionary"/> object that stores all the different languages dictionaries keyed by language id.</param>
 public CustomDictionaryPostProcessor(CustomDictionary userCustomDictionaries)
 {
     this._userCustomDictionaries = userCustomDictionaries ?? throw new ArgumentNullException(nameof(userCustomDictionaries));
 }
コード例 #37
0
        private T DoExecute <T>(CustomRequest <T> request, string session) where T : CustomResponse
        {
            long start = DateTime.Now.Ticks;

            // 添加协议级请求参数
            CustomDictionary parameters = new CustomDictionary();

            if (request.GetQueryParameters() != null)
            {
                parameters.AddAll(request.GetQueryParameters());
            }

            if (string.IsNullOrEmpty(appKey) && string.IsNullOrEmpty(appSecret))
            {
                //parameters.Add("accept", "application/json");
                //parameters.Add("content-type", "application/json");
                //request.AddHeaderParameter("accept", "application/json");
                //request.AddHeaderParameter("content-type", "application/json");
            }
            else
            {
                //parameters.Add(Constants.METHOD, request.GetApiName());
                //parameters.Add(Constants.VERSION, request.Version);
                //parameters.Add(Constants.APP_KEY, appKey);
                //parameters.Add(Constants.TIMESTAMP, request.Timestamp);
                //parameters.Add(Constants.FORMAT, format);
                //parameters.Add(Constants.SIGN_METHOD, signMethod);
                //parameters.Add(Constants.SESSION, session);
                //parameters.Add(Constants.PARTNER_ID, Constants.SDK_VERSION);
                //parameters.Add(Constants.QM_CUSTOMER_ID, request.CustomerId);
                //request.AddHeaderParameter("accept", "application/xml");
                //request.AddHeaderParameter("content-type", "application/xml");
            }

            //json
            //parameters.Add();

            // 添加头部参数
            if (this.useGzipEncoding)
            {
                request.AddHeaderParameter(Constants.ACCEPT_ENCODING, Constants.CONTENT_ENCODING_GZIP);
            }

            try
            {
                string reqBody = request.Body;
                if (string.IsNullOrEmpty(reqBody))
                {
                    //XmlWriter writer = new XmlWriter(Constants.QM_ROOT_TAG_REQ, typeof(QimenRequest<T>));
                    //reqBody = writer.Write(request);
                    if (string.IsNullOrEmpty(appKey) && string.IsNullOrEmpty(appSecret))
                    {
                        reqBody = JsonConvert.SerializeObject(request);
                    }
                    else
                    {
                        reqBody = XmlSerializeHelper.XmlSerialize(request);
                    }
                }

                // 添加签名参数

                string fullUrl = WebUtils.BuildRequestUrl(serverUrl, parameters);
                string rspBody = webUtils.DoPost(fullUrl, Encoding.UTF8.GetBytes(reqBody), Constants.QM_CONTENT_TYPE, request.GetHeaderParameters());

                // 解释响应结果
                T rsp = null;
                if (disableParser)
                {
                    rsp      = Activator.CreateInstance <T>();
                    rsp.Body = rspBody;
                }
                else
                {
                    if (string.IsNullOrEmpty(appKey) && string.IsNullOrEmpty(appSecret))
                    {
                        rsp = JsonConvert.DeserializeObject <T>(rspBody);
                    }
                    else
                    {
                        if (Constants.FORMAT_XML.Equals(format, StringComparison.OrdinalIgnoreCase))
                        {
                            XmlDeserializeHelper <T> helper = new XmlDeserializeHelper <T>();
                            rsp = helper.Parse(rspBody);
                        }
                    }
                }

                // 追踪错误的请求
                if (rsp != null && rsp.IsError)
                {
                    TimeSpan latency = new TimeSpan(DateTime.Now.Ticks - start);
                    TraceApiError(appKey, request.GetApiName(), serverUrl, parameters, latency.TotalMilliseconds, rspBody);
                }
                return(rsp);
            }
            catch (Exception e)
            {
                TimeSpan latency = new TimeSpan(DateTime.Now.Ticks - start);
                TraceApiError(appKey, request.GetApiName(), serverUrl, parameters, latency.TotalMilliseconds, e.GetType() + ": " + e.Message);
                throw e;
            }
        }
コード例 #38
0
 public Example()
 {
     Data = new CustomDictionary();
 }
コード例 #39
0
 private void SetDictionary(string name, CustomDictionary dictionary)
 {
     _settings.SetIndexedValue <CustomDictionarySettings, string, CustomDictionary>(
         x => x.CustomDictionaries, name, dictionary);
 }
コード例 #40
0
        private void ReadFromPreviewList(CustomDictionary<string, string, PreviewUnit> previewList)
        {
            foreach (var item in previewList.PriSub)
            {
                string srcRelativePath = item.Key;
                string tgtRelativePath = item.Value;
                PreviewUnit unit = previewList.GetByPrimary(srcRelativePath);

                if (unit.sAction != SyncAction.NoAction)
                {
                    FileUnit u = null;
                    if (!unit.srcFlag.Equals("D"))
                    {
                        u = new FileUnit(_source + srcRelativePath);
                        u.MatchingPath = tgtRelativePath;

                        if (!unit.tgtFlag.Equals("D"))
                            u.Match = new FileUnit(_target + tgtRelativePath);
                    }
                    else
                    {
                        if (!unit.tgtFlag.Equals("D"))
                        {
                            u = new FileUnit(_target + tgtRelativePath);
                            u.MatchingPath = srcRelativePath;
                        }
                    }
                    if (u == null) continue;
                    ComputeStatisticsResult(u, unit.sAction);
                    AddDataRow(u, unit.sAction);
                }
            }
        }