Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
 /// <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);
     }
 }
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj)
     where TGrainObserverInterface : IGrainObserver
 {
     return(((IGrainFactory)this.runtimeClient.InternalGrainFactory).CreateObjectReference <TGrainObserverInterface>(obj));
 }
Ejemplo n.º 6
0
 public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj)
     where TGrainObserverInterface : IGrainObserver
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 /// <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));
 }
Ejemplo n.º 8
0
 /// <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));
 }
Ejemplo n.º 10
0
 /// <inheritdoc />
 public Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj)
     where TGrainObserverInterface : IGrainObserver
 {
     return(Task.FromResult(this.CreateObjectReferenceImpl <TGrainObserverInterface>(obj)));
 }
Ejemplo n.º 11
0
 public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver
 {
     return(_clusterClientFactory.Create <TGrainObserverInterface>().DeleteObjectReference <TGrainObserverInterface>(obj));
 }
Ejemplo n.º 12
0
 public async Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver
 {
     await(await _instance.Value).DeleteObjectReference <TGrainObserverInterface>(obj);
 }
Ejemplo n.º 13
0
 public async Task <TGrainObserverInterface> CreateObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver
 {
     return(await(await _instance.Value).CreateObjectReference <TGrainObserverInterface>(obj));
 }
Ejemplo n.º 14
0
 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)));
 }
Ejemplo n.º 16
0
 /// <inheritdoc />
 public Task DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver
 {
     return(this.grainFactory.DeleteObjectReference <TGrainObserverInterface>(obj));
 }
Ejemplo n.º 17
0
        /// <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);
        }
Ejemplo n.º 18
0
 /// <inheritdoc />
 public Task DeleteObjectReference <TGrainObserverInterface>(
     IGrainObserver obj) where TGrainObserverInterface : IGrainObserver
 {
     this.runtimeClient.DeleteObjectReference(obj);
     return(Task.CompletedTask);
 }
Ejemplo n.º 19
0
 /// <inheritdoc />
 public void DeleteObjectReference <TGrainObserverInterface>(IGrainObserver obj) where TGrainObserverInterface : IGrainObserver
 {
     this.grainFactory.DeleteObjectReference <TGrainObserverInterface>(obj);
 }