Ejemplo n.º 1
0
        public bool TryAddExtension(IGrainExtension handler)
        {
            var currentActivation = GetCurrentActivationData();
            var invoker = TryGetExtensionInvoker(handler.GetType());
            if (invoker == null)
                throw new InvalidOperationException("Extension method invoker was not generated for an extension interface");

            return currentActivation.TryAddExtension(invoker, handler);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the specified extension handler to the currently running activation.
        /// This method must be called during an activation turn.
        /// </summary>
        /// <param name="handler"></param>
        /// <returns></returns>
        internal bool TryAddExtension(IGrainExtension handler)
        {
            var currentActivation = GetCurrentActivationData();
            var invoker           = TryGetExtensionInvoker(handler.GetType());

            if (invoker == null)
            {
                throw new SystemException("Extension method invoker was not generated for an extension interface");
            }

            return(currentActivation.TryAddExtension(invoker, handler));
        }
Ejemplo n.º 3
0
        public bool TryAddExtension(IGrainExtension handler)
        {
            ExtensionInvoker extensionInvoker = GetCurrentExtensionInvoker();
            var methodInvoker = TryGetExtensionMethodInvoker(this.typeManager, handler.GetType());

            if (methodInvoker == null)
            {
                throw new InvalidOperationException("Extension method invoker was not generated for an extension interface");
            }

            return(extensionInvoker.TryAddExtension(methodInvoker, handler));
        }
Ejemplo n.º 4
0
            /// <summary>
            /// Removes all extensions for the specified interface id.
            /// Returns true if the chained invoker no longer has any extensions and may be safely retired.
            /// </summary>
            /// <param name="extension"></param>
            /// <returns>true if the chained invoker is now empty, false otherwise</returns>
            public bool Remove(IGrainExtension extension)
            {
                int interfaceId = 0;

                foreach(int iface in extensionMap.Keys)
                    if (extensionMap[iface].Item1 == extension)
                    {
                        interfaceId = iface;
                        break;
                    }

                if (interfaceId == 0) // not found
                    throw new InvalidOperationException(String.Format("Extension {0} is not installed",
                        extension.GetType().FullName));

                extensionMap.Remove(interfaceId);
                return extensionMap.Count == 0;
            }
Ejemplo n.º 5
0
            /// <summary>
            /// Removes all extensions for the specified interface id.
            /// Returns true if the chained invoker no longer has any extensions and may be safely retired.
            /// </summary>
            /// <param name="extension"></param>
            /// <returns>true if the chained invoker is now empty, false otherwise</returns>
            public bool Remove(IGrainExtension extension)
            {
                int interfaceId = 0;

                foreach (int iface in extensionMap.Keys)
                {
                    if (extensionMap[iface].Item1 == extension)
                    {
                        interfaceId = iface;
                        break;
                    }
                }

                if (interfaceId == 0) // not found
                {
                    throw new InvalidOperationException(String.Format("Extension {0} is not installed",
                                                                      extension.GetType().FullName));
                }

                extensionMap.Remove(interfaceId);
                return(extensionMap.Count == 0);
            }