本文整理汇总了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);
}
}
}
示例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);
}
}
}
}
}
}
示例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;
}