internal ActorEventManager(ActorTypeInformation actorTypeInformation)
        {
            this.eventIdToEventTypeMap = actorTypeInformation.EventInterfaceTypes.ToDictionary(
                t => new InterfaceId(IdUtil.ComputeId(t), IdUtil.ComputeIdWithCRC(t)),
                t => t);

            this.actorIdToEventProxyMap =
                new ConcurrentDictionary <ActorId, ConcurrentDictionary <Type, ActorEventProxy> >();
        }
 static ActorEventSubscription()
 {
     InterfaceName         = "IActorEventSubscription";
     SubscribeMethodName   = "SubscribeAsync";
     UnSubscribeMethodName = "UnSubscribeAsyc";
     InterfaceId           = IdUtil.ComputeIdWithCRC(InterfaceName);
     SubscribeMethodId     = IdUtil.ComputeIdWithCRC(SubscribeMethodName);
     UnSubscribeMethodId   = IdUtil.ComputeIdWithCRC(UnSubscribeMethodName);
 }
コード例 #3
0
        private int GetAndEnsureEventId(Type eventInterfaceType)
        {
            if (this.eventIdToDispatchersMap != null)
            {
                var eventId = IdUtil.ComputeIdWithCRC(eventInterfaceType);
                if (this.eventIdToDispatchersMap.ContainsKey(eventId))
                {
                    return(eventId);
                }
            }

            throw new ArgumentException();
        }
コード例 #4
0
        private MethodDescription(
            MethodInfo methodInfo,
            MethodArgumentDescription[] arguments,
            bool hasCancellationToken,
            bool useCRCIdGeneration)
        {
            this.MethodInfo         = methodInfo;
            this.useCRCIdGeneration = useCRCIdGeneration;
            if (this.useCRCIdGeneration)
            {
                this.Id = IdUtil.ComputeIdWithCRC(methodInfo);
            }
            else
            {
                this.Id = IdUtil.ComputeId(methodInfo);
            }

            this.Arguments            = arguments;
            this.HasCancellationToken = hasCancellationToken;
        }
コード例 #5
0
        private MethodDescription(
            MethodInfo methodInfo,
            MethodArgumentDescription[] arguments,
            bool hasCancellationToken, bool useCRCIdGeneration)
        {
            this.methodInfo         = methodInfo;
            this.useCRCIdGeneration = useCRCIdGeneration;
            if (this.useCRCIdGeneration)
            {
                this.methodId = IdUtil.ComputeIdWithCRC(methodInfo);
                //This is needed for backward compatibility support to V1 Stack like ActorEventproxy where Code-gen happens only once.
                this.methodIdV1 = IdUtil.ComputeId(methodInfo);
            }
            else
            {
                this.methodId = IdUtil.ComputeId(methodInfo);
            }

            this.arguments            = arguments;
            this.hasCancellationToken = hasCancellationToken;
        }
コード例 #6
0
        protected InterfaceDescription(
            string remotedInterfaceKindName,
            Type remotedInterfaceType,
            bool useCRCIdGeneration,
            MethodReturnCheck methodReturnCheck = MethodReturnCheck.EnsureReturnsTask)
        {
            EnsureNotGeneric(remotedInterfaceKindName, remotedInterfaceType);

            this.remotedInterfaceType = remotedInterfaceType;
            this.useCRCIdGeneration   = useCRCIdGeneration;
            if (this.useCRCIdGeneration)
            {
                this.interfaceId = IdUtil.ComputeIdWithCRC(remotedInterfaceType);
                //This is needed for backward compatibility support to V1 Stack like ActorEventproxy
                this.interfaceIdV1 = IdUtil.ComputeId(remotedInterfaceType);
            }
            else
            {
                this.interfaceId = IdUtil.ComputeId(remotedInterfaceType);
            }

            this.methods = GetMethodDescriptions(remotedInterfaceKindName, remotedInterfaceType, methodReturnCheck, useCRCIdGeneration);
        }
コード例 #7
0
        public static void AddMethodsForProxyOrService(IEnumerable <Type> interfaces, Type baseInterfaceType)
        {
            foreach (Type interfaceType in interfaces)
            {
                if (!baseInterfaceType.IsAssignableFrom(interfaceType) || interfaceType == baseInterfaceType)
                {
                    continue;
                }

                int interfaceIdv1 = IdUtil.ComputeId(interfaceType);
                int interfaceIdv2 = IdUtil.ComputeIdWithCRC(interfaceType);

                // Add if it's not there, don't add if it's there already
                if (!idToMethodNameMap.TryGetValue(interfaceIdv1, out InterfaceEntry ifc))
                {
                    // Since idToMethodNameMap can be accessed by multiple threads, it is important to make sure
                    // the inner dictionary has everything added, before this is added to idToMethodNameMap. The
                    // inner dictionary will never be thread safe and it doesn't need to be, as long as it always
                    // is effectively "read-only". If the order is reverse, you risk having another thread trying
                    // to fetch a method from it prematurely.
                    ifc = new InterfaceEntry(interfaceType);
                    foreach (MethodInfo method in interfaceType.GetMethods())
                    {
                        int methodIdv1 = IdUtil.ComputeId(method);
                        int methodIdv2 = IdUtil.ComputeIdWithCRC(method);

                        ifc.Methods[methodIdv1] = new MethodEntry(method);
                        ifc.Methods[methodIdv2] = new MethodEntry(method);
                    }

                    // If multiple threads are trying to set this entry, the last one wins, and this is ok to have
                    // since this method map should always look the same once it's constructed.
                    idToMethodNameMap[interfaceIdv1] = ifc;
                    idToMethodNameMap[interfaceIdv2] = ifc;
                }
            }
        }
 static ActorMessageDispatch()
 {
     InterfaceId   = IdUtil.ComputeId("IActorCommunication", "Microsoft.ServiceFabric.Actors.Communication");
     InterfaceIdV2 = IdUtil.ComputeIdWithCRC("Microsoft.ServiceFabric.Actors.Communication.IActorCommunication");
 }