/// <summary>
 /// Registers a component as a singleton.
 /// </summary>
 public void RegisterSingleton(Type iface, Type implementationType)
 {
     if (CanCreateInstance(implementationType))
     {
         if (AOPUitl.IsTypeComponent(implementationType))
         {
             RegisterFactory(iface, FromComponentType(implementationType));
         }
         else
         {
             RegisterFactory(iface, new TypeComponentFactory(implementationType, null, false, null));
         }
     }
     else
     {
         throw new NotSupportedException(String.Format("Can not create an instance of type {0}", implementationType));
     }
 }
        private TypeComponentFactory FromComponentType(Type implementationType)
        {
            var component          = AOPUitl.GetComponentAttribute(implementationType);
            var implementationName = component.Name;

            bool isPrimary = false;

            Type[] primaryForTypes = null;


            var primary = AOPUitl.GetPrimaryAttribute(implementationType);

            if (primary != null)
            {
                isPrimary       = true;
                primaryForTypes = primary.PrimaryForTypes;
            }

            return(new TypeComponentFactory(implementationType, implementationName, isPrimary, primaryForTypes));
        }