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


C# SafeDictionary.Remove方法代码示例

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


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

示例1: CancelExtracted

 private void CancelExtracted(bool throwOnFirstException, SafeDictionary<CancellationTokenRegistration, Action> callbacks)
 {
     if (Interlocked.CompareExchange(ref _cancelRequested, 1, 0) == 0)
     {
         _handle.Set();
         UnregisterLinkedTokens();
         List<Exception> exceptions = null;
         try
         {
             int id = _currentId;
             do
             {
                 Action callback;
                 if (callbacks.Remove(new CancellationTokenRegistration(id, this), out callback) && callback != null)
                 {
                     if (throwOnFirstException)
                     {
                         callback();
                     }
                     else
                     {
                         try
                         {
                             callback();
                         }
                         catch (Exception exception)
                         {
                             if (ReferenceEquals(exceptions, null))
                             {
                                 exceptions = new List<Exception>();
                             }
                             exceptions.Add(exception);
                         }
                     }
                 }
             } while (id-- != int.MinValue);
         }
         finally
         {
             callbacks.Clear();
         }
         if (exceptions != null)
         {
             throw new AggregateException(exceptions);
         }
     }
 }
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:47,代码来源:CancellationTokenSource.net35.cs

示例2: TryLoadReferencedAssemblies

        /// <summary>
        /// Tries to load the referenced assemblies.
        /// </summary>
        /// <param name="inputAssemblies">Assemblies</param>
        private void TryLoadReferencedAssemblies(Assembly[] inputAssemblies)
        {
            var ws = new SafeDictionary<string, Assembly>();

            foreach (Assembly a in inputAssemblies)
            {
                if (a == null)
                {
                    continue;
                }

                // recursively load all the assemblies reachables from the root!
                if (!Assemblies.ContainsKey(
                    a.GetName().FullName) && !ws.ContainsKey(a.GetName().FullName))
                {
                    ws.Add(a.GetName().FullName, a);
                }

                while (ws.Count > 0)
                {
                    var en = ws.Keys.GetEnumerator();
                    en.MoveNext();
                    var a_name = en.Current;
                    var a_assembly = ws[a_name];
                    Assemblies.Add(a_name, a_assembly);
                    ws.Remove(a_name);

                    foreach (AssemblyName name in a_assembly.GetReferencedAssemblies())
                    {
                        Assembly b;
                        ExtendedReflection.Utilities.ReflectionHelper.TryLoadAssembly(name.FullName, out b);

                        if (b != null)
                        {
                            if (!Assemblies.ContainsKey(b.GetName().FullName) &&
                                !ws.ContainsKey(b.GetName().FullName))
                            {
                                ws.Add(b.GetName().FullName, b);
                            }
                        }
                    }
                }
            }
        }
开发者ID:yonglehou,项目名称:PSharp,代码行数:48,代码来源:RemoteRaceInstrumentationEngine.cs

示例3: Extract

 /// <summary>
 /// 'Borrowed' from Sitecore.Xml.Xsl.ImageRenderer
 /// </summary>
 /// <param name="values"></param>
 /// <param name="keys"></param>
 /// <returns></returns>
 private static string Extract(SafeDictionary<string> values, params string[] keys)
 {
     Assert.ArgumentNotNull((object)values, "values");
     Assert.ArgumentNotNull((object)keys, "keys");
     foreach (string key in keys)
     {
         string str = values[key];
         if (str != null)
         {
             values.Remove(key);
             return str;
         }
     }
     return (string)null;
 }
开发者ID:dresser,项目名称:SitecoreResponsiveImages,代码行数:21,代码来源:MediaUrlOptionsHelper.cs


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