コード例 #1
0
 private void InvokeAfterRegister(MRegistrationListener listener)
 {
     if (listener != null)
     {
         listener.AfterRegister();
     }
 }
コード例 #2
0
 private void InvokeBeforeRegister(MRegistrationListener listener, ManagedObjectName name)
 {
     if (listener != null)
     {
         listener.BeforeRegister(server, name);
     }
 }
コード例 #3
0
        public void UnregisterManagedObject(ManagedObjectName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            String domainName = name.Domain;

            try
            {
                Domain domain = FindDomain(domainName);
                Entry  entry  = domain[name];

                if (entry != null)
                {
                    MRegistrationListener listener = entry.Instance as MRegistrationListener;

                    InvokeBeforeDeregister(listener);

                    domain.Remove(name);

                    InvokeAfterDeregister(listener);
                }
            }
            catch (InvalidDomainException)
            {
            }
        }
コード例 #4
0
 private void InvokeAfterDeregister(MRegistrationListener listener)
 {
     if (listener != null)
     {
         try
         {
             listener.AfterDeregister();
         }
         catch (Exception)
         {
             // An exception here shall not stop us from continue
         }
     }
 }
コード例 #5
0
 private void InvokeBeforeRegister(MRegistrationListener listener, ManagedObjectName name)
 {
     if (listener != null)
     {
         listener.BeforeRegister(server, name);
     }
 }
コード例 #6
0
 private void InvokeBeforeDeregister(MRegistrationListener listener)
 {
     if (listener != null)
     {
         try
         {
             listener.BeforeDeregister();
         }
         catch(Exception)
         {
             // An exception here shall not stop us from continue
         }
     }
 }
コード例 #7
0
 private void InvokeAfterRegister(MRegistrationListener listener)
 {
     if (listener != null)
     {
         listener.AfterRegister();
     }
 }
コード例 #8
0
        public ManagedInstance RegisterManagedObject(Object instance, ManagedObjectName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            ComponentType   cType   = MInspector.Inspect(instance);
            MDynamicSupport dynamic = null;

            if (cType == ComponentType.None)
            {
                throw new InvalidComponentException("Component is not a managed component.");
            }

            if (cType == ComponentType.Standard)
            {
                dynamic = MDynamicSupportFactory.Create(instance);
            }
            else if (cType == ComponentType.Dynamic)
            {
                dynamic = (MDynamicSupport)instance;
            }

            String domainName = name.Domain;
            Domain domain     = null;

            lock (domains)
            {
                domain = domains[domainName];

                if (domain == null)
                {
                    domain = new Domain(domainName);
                    domains.Add(domain);
                }
            }

            Entry entry = new Entry(instance, dynamic);

            try
            {
                MRegistrationListener registration = instance as MRegistrationListener;

                InvokeBeforeRegister(registration, name);

                lock (domain)
                {
                    if (domain.Contains(name))
                    {
                        throw new InstanceAlreadyRegistredException(name.ToString());
                    }

                    domain.Add(name, entry);
                }

                InvokeAfterRegister(registration);
            }
            catch (Exception e)
            {
                domain.Remove(name);

                throw e;
            }

            return(new ManagedInstance(instance.GetType().FullName, name));
        }