示例#1
0
        /// <inheritdoc />
        public void RegisterSubject <T>(ulong objectId, T subject) where T : class
        {
            var registration = new SubjectRegistration <T>(objectId, subject);

            // TODO: This method is missing some sort of verification of the given subject type.
            //       Currently, verification only happens when we are connected to an endpoint.
            //       This is bad because a user of this class only noticies that stuff goes wrong
            //       because no other endpoint can establish connections with this endpoint.

            var stopwatch = Stopwatch.StartNew();

            lock (_syncRoot)
            {
                _subjects.Add(objectId, registration);
                foreach (var endPoint in _internalEndPoints)
                {
                    registration.RegisterSubjectWith(endPoint);
                }
            }

            stopwatch.Stop();
            Log.DebugFormat("{0}: Created new servant (#{1}) '{2}' implementing '{3}', took {4}ms",
                            _name,
                            objectId,
                            subject,
                            typeof(T),
                            stopwatch.ElapsedMilliseconds);
        }