当前位置: 首页>>代码示例>>C#>>正文


C# Dictionary.Remove方法代码示例

本文整理汇总了C#中Dictionary.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Remove方法的具体用法?C# Dictionary.Remove怎么用?C# Dictionary.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FilterValidStackLocals

        private static void FilterValidStackLocals(Dictionary<LocalSymbol, LocalDefUseInfo> info)
        {
            // remove fake dummies and variable that cannot be scheduled
            var dummies = ArrayBuilder<LocalDefUseInfo>.GetInstance();

            foreach (var local in info.Keys.ToArray())
            {
                var locInfo = info[local];

                if (local.SynthesizedKind == SynthesizedLocalKind.OptimizerTemp)
                {
                    dummies.Add(locInfo);
                    info.Remove(local);
                }
                else if (locInfo.CannotSchedule)
                {
                    locInfo.LocalDefs.Free();
                    info.Remove(local);
                }
            }

            if (info.Count != 0)
            {
                RemoveIntersectingLocals(info, dummies);
            }

            foreach (var dummy in dummies)
            {
                dummy.LocalDefs.Free();
            }
            dummies.Free();
        }
开发者ID:rosslyn-cuongle,项目名称:roslyn,代码行数:32,代码来源:Optimizer.cs

示例2: AddThreeItems_RemoveMiddleItem_CheckConsistency

        public void AddThreeItems_RemoveMiddleItem_CheckConsistency()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;
            BackingUnknownSize<Customer, string> backingFile = new BackingUnknownSize<Customer, string>(path, 100);
            Dictionary<Customer, string> dict = new Dictionary<Customer, string>(backingFile);

            Customer c1 = new Customer {Name = "Mikael"};
            Customer c2 = new Customer {Name = "Svenson"};
            Customer c3 = new Customer {Name = "Boss"};

            dict.Add(c1, "test");
            dict.Add(c2, "test2");
            dict.Add(c3, "test3");

            var result = dict.Remove(c2);
            Assert.IsTrue(result);
            result = dict.Remove(c2);
            Assert.IsFalse(result);
            dict.Add(c2, "test2");
            result = dict.Remove(c2);
            Assert.IsTrue(result);

            var res2 = dict[c3];
            Assert.AreEqual("test3", res2);
        }
开发者ID:eduardogh,项目名称:MMDataStructures,代码行数:25,代码来源:DictionaryTestUnknownSizeBacking.cs

示例3: MapContentType

        static void MapContentType(Dictionary<string, string> headers)
        {
            string contentType;
            if (!headers.TryGetValue("rebus-content-type", out contentType)) return;

            if (contentType == "text/json")
            {
                string contentEncoding;

                if (headers.TryGetValue("rebus-encoding", out contentEncoding))
                {
                    headers.Remove("rebus-content-type");
                    headers.Remove("rebus-encoding");

                    headers[Headers.ContentType] = $"{JsonSerializer.JsonContentType};charset={contentEncoding}";
                }
                else
                {
                    throw new FormatException(
                        "Content type was 'text/json', but the 'rebus-encoding' header was not present!");
                }
            }
            else
            {
                throw new FormatException(
                    $"Sorry, but the '{contentType}' content type is currently not supported by the legacy header mapper");
            }
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:28,代码来源:MapLegacyHeadersIncomingStep.cs

示例4: MergeTasks

        private List<TaskSync> MergeTasks(List<TaskSync> tasksFromDb, List<TaskSync> tasksFromUser)
        {
            Dictionary<string, TaskSync> result = new Dictionary<string, TaskSync>();

            foreach(TaskSync task in tasksFromDb)
            {
                task.Id = 0;
                result.Remove(task.SourceId);
                result.Add(task.SourceId, task);
            }

            foreach(TaskSync task in tasksFromUser)
            {
                task.Id = 0;
                TaskSync tempTask = null;
                result.TryGetValue(task.SourceId, out tempTask);
                if(tempTask != null)
                {
                    DateTime tempTaskDate = tempTask.LastModifyDate;
                    DateTime taskDate = task.LastModifyDate;
                    if(DateTime.Compare(tempTaskDate, taskDate) <= 0)
                    {
                        result.Remove(task.SourceId);
                        result.Add(task.SourceId, task);
                    }
                }
                else
                    result.Add(task.SourceId, task);
            }

            return new List<TaskSync>(result.Values);
        }
开发者ID:povilaspanavas,项目名称:minder,代码行数:32,代码来源:TaskSyncController.cs

示例5: GetAuthorizationUri

        public Uri GetAuthorizationUri(object parameters)
        {
            string queryString = String.Empty;

            if (parameters != null)
            {
                Dictionary<string, string> queryParameters = new Dictionary<string, string>();
#if WINMD
                foreach (var parameter in parameters.GetType().GetTypeInfo().DeclaredProperties)
                {
                    if (queryParameters.ContainsKey(parameter.Name)) queryParameters.Remove(parameter.Name);
                    queryParameters.Add(parameter.Name, parameter.GetValue(parameters).ToString());
                }
#else
                foreach (var parameter in parameters.GetType().GetProperties())
                {
                    if (queryParameters.ContainsKey(parameter.Name)) queryParameters.Remove(parameter.Name);
                    queryParameters.Add(parameter.Name, parameter.GetValue(parameters, null).ToString());
                }
#endif
                foreach (var parameter in queryParameters)
                {
                    queryString = String.Format("{0}&{1}={2}", queryString, parameter.Key, Uri.EscapeDataString(parameter.Value));
                }
            }

            return new Uri(Context.AuthorizationUri.ToString() + "?oauth_token=" + RequestToken.Token + queryString);
        }
开发者ID:kvm,项目名称:Chq.OAuth,代码行数:28,代码来源:Client.cs

示例6: Get_Scheduler

        public static IScheduler Get_Scheduler(string schedule_file)
        {
            // load the schedule file
            Dictionary<string, object> schedule_dict = new Dictionary<string,object>();
            if (File.Exists(schedule_file))
                Inputs_to_Dictionary.Add_Input_Parameters_to_Dictionary(ref schedule_dict, schedule_file);
            else
                schedule_dict.Add("type", "none");

            // get the type of scheduler required and return the scheduler
            switch (((string)schedule_dict["type"]).ToLower())
            {
                case "none":
                    // these are the default values for the mixing scheduler
                    schedule_dict.Add("alpha", 0.01);
                    schedule_dict.Add("zeta", 3.0);
                    schedule_dict.Remove("type");
                    schedule_dict.Add("type", Scheduler_Type.None);
                    return new Constant_Scheduler(schedule_dict);

                case "constant":
                    schedule_dict.Remove("type");
                    schedule_dict.Add("type", Scheduler_Type.Constant);
                    return new Constant_Scheduler(schedule_dict);

                case "file_defined":
                    schedule_dict.Add("filename", schedule_file);
                    schedule_dict.Remove("type");
                    schedule_dict.Add("type", Scheduler_Type.File_Defined);
                    return new File_Defined_Scheduler(schedule_dict);

                default:
                    throw new NotImplementedException("Error - the scheduler type requested is not implemented");
            }
        }
开发者ID:EdmundOwen,项目名称:QuMESHS,代码行数:35,代码来源:Mixing_Scheduler.cs

示例7: UpdateValues

 public Dictionary<SystemMetricTypes, object> UpdateValues(Dictionary<SystemMetricTypes, object> values)
 {
     lock (_milliSeconds)
     {
         long cnt = _milliSeconds.Count;
         double high = 0;
         double tot = 0;
         while (_milliSeconds.Count > 0)
         {
             double tmp = _milliSeconds.Dequeue();
             tot += tmp;
             high = (tmp > high ? tmp : high);
         }
         values.Remove(SystemMetricTypes.Average_Inbound_Connection_Duration);
         values.Add(SystemMetricTypes.Average_Inbound_Connection_Duration, new sSystemMetric(SystemMetricTypes.Average_Inbound_Connection_Duration, MetricUnits.MILLISECONDS, (tot == 0 ? (decimal)0 : (decimal)Math.Round(tot / (double)cnt, 2))));
         if (values.ContainsKey(SystemMetricTypes.Max_Inbound_Connection_Duration))
         {
             if (high>_high){
                 values.Remove(SystemMetricTypes.Max_Inbound_Connection_Duration);
                 values.Add(SystemMetricTypes.Max_Inbound_Connection_Duration, new sSystemMetric(SystemMetricTypes.Max_Inbound_Connection_Duration, MetricUnits.MILLISECONDS, (decimal)high));
                 _high = high;
             }
         }
         else
             values.Add(SystemMetricTypes.Max_Inbound_Connection_Duration, new sSystemMetric(SystemMetricTypes.Max_Inbound_Connection_Duration, MetricUnits.MILLISECONDS, (decimal)high));
     }
     return values;
 }
开发者ID:marquismark,项目名称:freeswitchconfig,代码行数:28,代码来源:ConnectionEventMonitor.cs

示例8: Rename

 public static void Rename(Dictionary<string, string> file_to_new_file)
 {
     var file_to_new_file_copy = new Dictionary<string, string>(file_to_new_file);
     while (file_to_new_file_copy.Count > 0)
     {
         var kvp = file_to_new_file_copy.ElementAt(0);
         Action<string> recursive_rename_delegate = null;
         recursive_rename_delegate = file =>
         {
             if (File.Exists(file_to_new_file_copy[file]))
             {
                 if (file_to_new_file_copy[file] == kvp.Key)
                 {
                     string temp_file = Path.Combine(Path.GetDirectoryName(file) ?? string.Empty, Path.GetRandomFileName());
                     File.Move(file, temp_file);
                     file_to_new_file_copy[temp_file] = file_to_new_file_copy[file];
                     file_to_new_file_copy.Remove(file);
                     return;
                 }
                 else
                 {
                     recursive_rename_delegate(file_to_new_file_copy[file]);
                 }
             }
             File.Move(file, file_to_new_file_copy[file]);
             file_to_new_file_copy.Remove(file);
         };
         recursive_rename_delegate(kvp.Key);
     }
 }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:30,代码来源:Renamer.cs

示例9: CreateForRequest

        public static string CreateForRequest(string callbackURL, string consumerKey, string consumerSecret, string url)
        {
            parameters = new Dictionary<string, string>()
            {
                {"oauth_callback",""},
                {"oauth_consumer_key",""},
                {"oauth_nonce",""},
                {"oauth_signature",""},
                {"oauth_signature_method","HMAC-SHA1"},            
                {"oauth_timestamp",""},
                {"oauth_token",""},
                {"oauth_verifier",""},
                {"oauth_version","1.0"},                        
            };

            OauthConsumerSecret = consumerSecret;

            parameters.Remove("oauth_token");
            parameters.Remove("oauth_verifier");

            parameters["oauth_callback"] = callbackURL;
            parameters["oauth_consumer_key"] = consumerKey;
            parameters["oauth_nonce"] = GenerateNonce();
            parameters["oauth_timestamp"] = GenerateTimeStamp();
            parameters["oauth_signature"] = GenerateSignature(url, "GET");

            return "OAuth " + EncodeRequestParameters();
        }
开发者ID:nagyistge,项目名称:Copy-.Net-SDK,代码行数:28,代码来源:AuthorizationHeader.cs

示例10: FindEndFromDict

        public static bool FindEndFromDict(string[] values, Dictionary<string, string[]> chainDictionary, int length)
        {
            if (values[1] == "END" && chainDictionary.Count == 0)
                return true;

            if (chainDictionary.Count == 0 || length <= 0)
                return false;

            string[] foundItem;
            if(chainDictionary.ContainsKey(values[1]))
                foundItem = chainDictionary[values[1]];
            else
                return false;

            var searchItem = foundItem; // itme to look for again in dict

            // remove begin from Dictionary
            if (chainDictionary.ContainsKey("BEGIN"))
                chainDictionary.Remove("BEGIN");

            chainDictionary.Remove(foundItem[0]);

            length = length - 1;
            return FindEndFromDict(searchItem, chainDictionary, length);
        }
开发者ID:KhatoPito,项目名称:Practice-Code,代码行数:25,代码来源:ChainStatus.cs

示例11: Dictionary_kvp_Remove_checks_key_and_value

 public void Dictionary_kvp_Remove_checks_key_and_value()
 {
     IDictionary<int, string> dictionary = new Dictionary<int, string>();
     dictionary[1] = "foo";
     Assert.IsFalse(dictionary.Remove(new KeyValuePair<int, string>(1, "bar")));
     Assert.IsTrue(dictionary.Remove(new KeyValuePair<int, string>(1, "foo")));
 }
开发者ID:sdether,项目名称:Firkin,代码行数:7,代码来源:TMisc.cs

示例12: CreateAnimation

 public static Storyboard CreateAnimation(this DependencyObject target, Dictionary<string, StoryboardInfo> storyboards, DependencyProperty animatingDependencyProperty, string propertyPath, string propertyKey, object initialValue, object targetValue, TimeSpan timeSpan, IEasingFunction easingFunction, Action releaseAction)
 {
     StoryboardInfo storyboardInfo;
     storyboards.TryGetValue(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey), out storyboardInfo);
     if (storyboardInfo != null)
     {
         DependencyObject storyboardTarget = storyboardInfo.StoryboardTarget;
         storyboardInfo.Storyboard.Stop();
         storyboards.Remove(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey));
         if (storyboardInfo.ReleaseAction != null)
         {
             storyboardInfo.ReleaseAction();
             storyboardInfo.ReleaseAction = (Action)null;
         }
     }
     storyboardInfo = new StoryboardInfo();
     storyboardInfo.Storyboard = DependencyPropertyAnimationHelper.CreateStoryboard(target, animatingDependencyProperty, propertyPath, propertyKey, ref targetValue, timeSpan, easingFunction);
     storyboardInfo.ReleaseAction = releaseAction;
     storyboardInfo.StoryboardTarget = target;
     storyboardInfo.AnimateFrom = initialValue;
     storyboardInfo.Storyboard.Completed += (EventHandler)((source, args) =>
        {
        storyboards.Remove(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey));
        if (storyboardInfo.ReleaseAction == null)
            return;
        storyboardInfo.ReleaseAction();
        storyboardInfo.ReleaseAction = (Action)null;
        });
     storyboards.Add(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey), storyboardInfo);
     return storyboardInfo.Storyboard;
 }
开发者ID:sulerzh,项目名称:chart,代码行数:31,代码来源:DependencyPropertyAnimationHelper.cs

示例13: SplitIntoSpeciallyNamedPictures

		void SplitIntoSpeciallyNamedPictures (Dictionary<String, String> Source)
			{
			BeforeProjekteMaterialien = new Dictionary<string, string> ();
			IntermediateProjekteMaterialien = new Dictionary<string, string> ();
			AfterProjekteMaterialien = new Dictionary<string, string> ();
			int Index = Source.Keys.Count;
			while (Index > 0)
				{
				Index--;
				if (Source.Keys.ElementAt (Index).IndexOf (WordUp23.Basics.BeforeIndicator, StringComparison.CurrentCultureIgnoreCase) != -1)
					{
					BeforeProjekteMaterialien [Source.Keys.ElementAt (Index)]
						= Source [Source.Keys.ElementAt (Index)];
					Source.Remove (Source.Keys.ElementAt (Index));
					continue;
					}
				if (Source.Keys.ElementAt (Index).IndexOf (WordUp23.Basics.IntermediateIndicator, StringComparison.CurrentCultureIgnoreCase) != -1)
					{
					IntermediateProjekteMaterialien [Source.Keys.ElementAt (Index)]
						= Source [Source.Keys.ElementAt (Index)];
					Source.Remove (Source.Keys.ElementAt (Index));
					continue;
					}
				if (Source.Keys.ElementAt (Index).IndexOf (WordUp23.Basics.AfterIndicator, StringComparison.CurrentCultureIgnoreCase) != -1)
					{
					AfterProjekteMaterialien [Source.Keys.ElementAt (Index)]
						= Source [Source.Keys.ElementAt (Index)];
					Source.Remove (Source.Keys.ElementAt (Index));
					continue;
					}
				}
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:32,代码来源:ShowAllPicturesModel.cs

示例14: CreateContext

		private static ServerContext CreateContext(Dictionary<string, Route> scanResult, Http404Behavior http404Behavior, string rootRequestPath)
		{
			var context = new ServerContext
			{
				Http404Behavior = http404Behavior,
				RootRequestPath = rootRequestPath
			};

			var http404 = scanResult.Keys.FirstOrDefault(x => x.EndsWith("/_error/404"));

			if (http404 != null)
			{
				context.Custom404Page = scanResult[http404].Resource;
				scanResult.Remove(http404);
			}

			var http500 = scanResult.Keys.FirstOrDefault(x => x.EndsWith("/_error/500"));

			if (http500 != null)
			{
				context.Custom500Page = scanResult[http500].Resource;
				scanResult.Remove(http500);
			}

			context.Routes = scanResult;

			return context;
		}
开发者ID:wis3guy,项目名称:Markdown.Owin,代码行数:28,代码来源:ServerContext.cs

示例15: GetDataResponseOAuthAsync

        private async static Task<FlickrResult<string>> GetDataResponseOAuthAsync(Twitter flickr, string method, string baseUrl, Dictionary<string, string> parameters)
        {
            if (parameters.ContainsKey("api_key")) parameters.Remove("api_key");

            if (parameters.ContainsKey("api_sig")) parameters.Remove("api_sig");

            if (!String.IsNullOrEmpty(flickr.OAuthAccessToken) && !parameters.ContainsKey("oauth_token"))
            {
                parameters.Add("oauth_token", flickr.OAuthAccessToken);
            }
            if (!String.IsNullOrEmpty(flickr.OAuthAccessTokenSecret) && !parameters.ContainsKey("oauth_signature"))
            {
                string sig = flickr.OAuthCalculateSignatureForCalls(method, baseUrl, parameters, flickr.OAuthAccessTokenSecret);
                parameters.Add("oauth_signature", sig);
            }

            string data = OAuthCalculatePostData(parameters);

            string authHeader = OAuthCalculateAuthHeader(parameters);


            baseUrl = baseUrl.Split("?".ToCharArray())[0];

            if (method == "GET") return await DownloadDataAsync(method, baseUrl, data, GetContentType, authHeader);
            else return await DownloadDataAsync(method, baseUrl, data, PostContentType, authHeader);

        }
开发者ID:liquidboy,项目名称:X,代码行数:27,代码来源:TwitterResponderAsync.cs


注:本文中的Dictionary.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。