本文整理汇总了C#中IKey类的典型用法代码示例。如果您正苦于以下问题:C# IKey类的具体用法?C# IKey怎么用?C# IKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IKey类属于命名空间,在下文中一共展示了IKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGet
public bool TryGet(IKey key, out IEntry entry)
{
Entry tempEntry;
var result = _entries.TryGetValue(key, out tempEntry) && !tempEntry.IsReserved;
entry = result ? tempEntry : null;
return result;
}
示例2: deletePair
public bool deletePair(IKey key, bool firstCall = false)
{
bool canRemoveKey = true;
if(firstCall)
canRemoveKey = m_rkm.removeKey(key);
if (!canRemoveKey)
return false;
bool retVal = m_pairsManager.removePair(key);
//the key is in the local server
if (retVal)
{
m_pairsManager.saveToDisk();
return retVal;
}
//if key doesn't exists on the server need ask the ring for it
String serviceAddress = m_nextServer.Channel + "://" + m_nextServer.ServerAddress + ":" + m_nextServer.ServerPort + "/" + m_nextServer.ServiceName;
//Creating server proxy
IServer svc = (IServer)Activator.GetObject(
typeof(IServer),
serviceAddress);
try
{
return svc.deletePair(key);
}
catch (Exception)
{
m_rkm.removeServerFromRKM(m_nextServer);
return false;
}
}
示例3: AddKey
public void AddKey(IKey key)
{
lock (this)
{
_keys.AddLast(key.Key);
}
}
示例4: EqualTo
/// <summary>
/// Value equality for two IKey's
/// </summary>
/// <returns>true if all parts of of the keys are the same</returns>
public static bool EqualTo(this IKey key, IKey other)
{
return (key.Base == other.Base)
&& (key.TypeName == other.TypeName)
&& (key.ResourceId == other.ResourceId)
&& (key.VersionId == other.VersionId);
}
示例5: DeletePair
public void DeletePair(IKey key)
{
if (_manager.Trykey(key))
{
if (_hashtable.ContainsKey(key.Key))
{
_manager.RemoveKey(key);
_hashtable.Remove(key.Key);
}
else
{
bool b = true;
while (b)
{
try
{
if (_nextserverUri == null) return;
_mysuccessorServer.DeletePair(key);
b = false;
}
catch (Exception ex)
{
if (ex is WebException || ex is RemotingException)
{
_manager.RemakeRing(_nextserverUri);
}
}
}
}
}
}
示例6: TryOneRequest
async Task<RegisterOperationResult?> TryOneRequest(IKey key, KeyRegisterRequest request,
CancellationToken cancellationToken)
{
try
{
var result = await key.RegisterAsync(request, cancellationToken);
log.Info(result.Status.ToString());
switch (result.Status)
{
case KeyResponseStatus.Success:
return RegisterOperationResult.Success(request, result.Data);
}
}
catch (KeyGoneException)
{
// No sense in continuing with this signer, the key isn't physically present anymore
log.DebugFormat("Key '{0}' is gone", keyId);
throw;
}
catch (TaskCanceledException)
{
// Let cancellation bubble up
throw;
}
catch (KeyBusyException)
{
// Maybe it won't be busy later
}
catch (Exception exception)
{
log.Error("Authenticate request failed", exception);
}
return null;
}
示例7: HasTypeName
public static void HasTypeName(IKey key)
{
if (string.IsNullOrEmpty(key.TypeName))
{
throw Error.BadRequest("Resource type is missing: {0}", key);
}
}
示例8: BTree
public BTree(uint topSid, SegmentManager sm, IKey keyFactory)
{
this.m_top_sid = topSid;
this.m_sgManager = sm;
this.m_keyFactory = keyFactory;
this.m_nodeFactory = new BNode();
}
示例9: GetKeyFactory
public virtual EntityKeyFactory GetKeyFactory(IKey key)
=> _cache.GetOrAdd(
key,
k =>
{
if (k.Properties.Count == 1)
{
var keyProperty = k.Properties[0];
var keyType = keyProperty.ClrType;
// Use composite key for anything with structural (e.g. byte[]) properties even if they are
// not composite because it is setup to do structural comparisons and the generic typing
// advantages of the simple key don't really apply anyway.
if (!typeof(IStructuralEquatable).GetTypeInfo().IsAssignableFrom(keyType.GetTypeInfo()))
{
var sentinel = keyProperty.SentinelValue;
return (EntityKeyFactory)(sentinel == null
? Activator.CreateInstance(
typeof(SimpleNullSentinelEntityKeyFactory<>).MakeGenericType(keyType.UnwrapNullableType()), k)
: Activator.CreateInstance(
typeof(SimpleEntityKeyFactory<>).MakeGenericType(keyType.UnwrapNullableType()), k, sentinel));
}
}
return new CompositeEntityKeyFactory(k);
});
示例10: Get
public IEntry Get(IKey key)
{
IEntry entry;
if (TryGet(key, out entry))
return entry;
throw new EntryNotFoundException(key);
}
示例11: Add
public override void Add(string name, IKey key)
{
string keyPath = Path.Combine (this.path, name);
if (File.Exists (keyPath + privateSuffix) || File.Exists (keyPath + publicSuffix))
throw new ArgumentException ("Key with that name already exists");
WriteKey (key, name);
}
示例12: TryRemove
public bool TryRemove(IKey key)
{
var fragments = _fragments;
foreach (var fragment in fragments)
if (fragment.TableOfContent.Contains(key))
return fragment.TryRemove(key);
return false;
}
示例13: TryGet
public bool TryGet(IKey key, out IEntry entry)
{
foreach (var fragment in _fragments)
if (fragment.TableOfContent.TryGet(key, out entry))
return true;
entry = null;
return false;
}
示例14: For
public override IEnumerable<IAnnotation> For(IKey key)
{
if (key.SqlServer().IsClustered.HasValue)
{
yield return new Annotation(
SqlServerAnnotationNames.Prefix + SqlServerAnnotationNames.Clustered,
key.SqlServer().IsClustered.Value);
}
}
示例15: put
private void put(IKey key, int level, IEnumerable<Resource> resources)
{
if (resources == null) return;
foreach (var resource in resources)
{
if (resource is DomainResource)
put(key, level, resource as DomainResource);
}
}