/// <summary> /// Deletes the provided object reference. /// </summary> /// <typeparam name="TGrainObserverInterface"> /// The specific <see cref="IGrainObserver"/> type of <paramref name="obj"/>. /// </typeparam> /// <param name="obj">The reference being deleted.</param> /// <returns>A <see cref="Task"/> representing the work performed.</returns> public static Task DeleteObjectReference <TGrainObserverInterface>( IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { var interfaceType = typeof(TGrainObserverInterface); if (!interfaceType.IsInterface) { throw new ArgumentException( string.Format( "The provided type parameter must be an interface. '{0}' is not an interface.", interfaceType.FullName)); } if (!interfaceType.IsInstanceOfType(obj)) { throw new ArgumentException( string.Format("The provided object must implement '{0}'.", interfaceType.FullName), "obj"); } Delegate destroyer; if (!referenceDestoyers.TryGetValue(interfaceType, out destroyer)) { destroyer = referenceDestoyers.GetOrAdd(interfaceType, MakeDeleteObjectReferenceDelegate); } return(((Func <TGrainObserverInterface, Task>)destroyer)((TGrainObserverInterface)obj)); }
/// <summary> /// Check that a grain observer parameter is of the correct underlying concrent type -- either extending from <c>GrainRefereence</c> or <c>Grain</c> /// </summary> /// <param name="grainObserver">Grain observer parameter to be checked.</param> /// <exception cref="ArgumentNullException">If grainObserver is <c>null</c></exception> /// <exception cref="NotSupportedException">If grainObserver class is not an appropriate underlying concrete type.</exception> public static void CheckGrainObserverParamInternal(IGrainObserver grainObserver) { if (grainObserver == null) { throw new ArgumentNullException("grainObserver", "IGrainObserver parameters cannot be null"); } if (grainObserver is GrainReference || grainObserver is Grain) { // OK } else { string errMsg = string.Format("IGrainObserver parameters must be GrainReference or Grain and cannot be type {0}. Did you forget to CreateObjectReference?", grainObserver.GetType()); throw new NotSupportedException(errMsg); } }
/// <summary> /// Check that a grain observer parameter is of the correct underlying concrent type -- either extending from <c>GrainRefereence</c> or <c>Grain</c> /// </summary> /// <param name="grainObserver">Grain observer parameter to be checked.</param> /// <exception cref="ArgumentNullException">If grainObserver is <c>null</c></exception> /// <exception cref="NotSupportedException">If grainObserver class is not an appropriate underlying concrete type.</exception> public static void CheckGrainObserverParamInternal(IGrainObserver grainObserver) { if (grainObserver == null) { throw new ArgumentNullException("grainObserver", "IGrainObserver parameters cannot be null"); } if (grainObserver is GrainReference || grainObserver is Grain) { // OK } else { string errMsg = string.Format("IGrainObserver parameters must be GrainReference or Grain and cannot be type {0}. Did you forget to CreateObjectReference?", grainObserver.GetType()); throw new NotSupportedException(errMsg); } }
/// <summary> /// Deletes the provided object reference. /// </summary> /// <typeparam name="TGrainObserverInterface"> /// The specific <see cref="IGrainObserver"/> type of <paramref name="obj"/>. /// </typeparam> /// <param name="obj">The reference being deleted.</param> /// <returns>A <see cref="Task"/> representing the work performed.</returns> public Task DeleteObjectReference <TGrainObserverInterface>( IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { RuntimeClient.Current.DeleteObjectReference(obj); return(TaskDone.Done); }
/// <inheritdoc /> public Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(((IGrainFactory)this.runtimeClient.InternalGrainFactory).CreateObjectReference <TGrainObserverInterface>(obj)); }
public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { throw new NotImplementedException(); }
/// <summary> /// Deletes the provided object reference. /// </summary> /// <typeparam name="TGrainObserverInterface"> /// The specific <see cref="IGrainObserver"/> type of <paramref name="obj"/>. /// </typeparam> /// <param name="obj">The reference being deleted.</param> /// <returns>A <see cref="Task"/> representing the work performed.</returns> public Task DeleteObjectReference <TGrainObserverInterface>( IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(GrainReference.DeleteObjectReference(obj)); }
/// <summary> /// Creates a reference to the provided <paramref name="obj"/>. /// </summary> /// <typeparam name="TGrainObserverInterface"> /// The specific <see cref="IGrainObserver"/> type of <paramref name="obj"/>. /// </typeparam> /// <param name="obj">The object to create a reference to.</param> /// <returns>The reference to <paramref name="obj"/>.</returns> public Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(CreateObjectReferenceImpl <TGrainObserverInterface>(obj)); }
public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { this.objectReferences.TryRemove(Tuple.Create(typeof(TGrainObserverInterface), obj.GetHashCode()), out obj); return(Task.FromResult(0)); }
/// <inheritdoc /> public Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(Task.FromResult(this.CreateObjectReferenceImpl <TGrainObserverInterface>(obj))); }
public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(_clusterClientFactory.Create <TGrainObserverInterface>().DeleteObjectReference <TGrainObserverInterface>(obj)); }
public async Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { await(await _instance.Value).DeleteObjectReference <TGrainObserverInterface>(obj); }
public async Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(await(await _instance.Value).CreateObjectReference <TGrainObserverInterface>(obj)); }
public async Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { throw new NotSupportedException(); }
public Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return (Task.FromResult( (TGrainObserverInterface) this.objectReferences.GetOrAdd( Tuple.Create(typeof(TGrainObserverInterface), obj.GetHashCode()), _ => obj))); }
/// <inheritdoc /> public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { return(this.grainFactory.DeleteObjectReference <TGrainObserverInterface>(obj)); }
/// <summary> /// Creates a reference to the provided <paramref name="obj"/>. /// </summary> /// <typeparam name="TGrainObserverInterface"> /// The specific <see cref="IGrainObserver"/> type of <paramref name="obj"/>. /// </typeparam> /// <param name="obj">The object to create a reference to.</param> /// <returns>The reference to <paramref name="obj"/>.</returns> public static Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { var interfaceType = typeof(TGrainObserverInterface); if (!interfaceType.IsInterface) { throw new ArgumentException( string.Format( "The provided type parameter must be an interface. '{0}' is not an interface.", interfaceType.FullName)); } if (!interfaceType.IsInstanceOfType(obj)) { throw new ArgumentException( string.Format("The provided object must implement '{0}'.", interfaceType.FullName), "obj"); } Delegate creator; if (!referenceCreators.TryGetValue(interfaceType, out creator)) { creator = referenceCreators.GetOrAdd(interfaceType, MakeCreateObjectReferenceDelegate); } var resultTask = ((Func <TGrainObserverInterface, Task <TGrainObserverInterface> >)creator)((TGrainObserverInterface)obj); return(resultTask); }
/// <inheritdoc /> public Task DeleteObjectReference <TGrainObserverInterface>( IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { this.runtimeClient.DeleteObjectReference(obj); return(Task.CompletedTask); }
/// <inheritdoc /> public void DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver { this.grainFactory.DeleteObjectReference <TGrainObserverInterface>(obj); }