Example #1
0
 protected virtual void FillClassInfo(ref PClassInfo info, ClassRegistration reg)
 {
     info.Cardinality = PClassInfo.ClassCardinalityManyInstances;
     info.Category    = ObjectClassToCategory(reg.ObjectClass);
     info.ClassId     = reg.ClassTypeId;
     info.Name        = reg.DisplayName;
 }
Example #2
0
        public ClassRegistration Register(Type classType, ClassRegistration.ObjectClasses objClass)
        {
            var reg = new ClassRegistration
            {
                ClassType   = classType,
                ObjectClass = objClass,
            };

            Register(reg);

            return(reg);
        }
Example #3
0
 protected virtual void FillClassInfoW(ref PClassInfoW info, ClassRegistration reg)
 {
     info.Cardinality         = PClassInfoW.ClassCardinalityManyInstances;
     info.Category.Value      = ObjectClassToCategory(reg.ObjectClass);
     info.ClassFlags          = reg.ClassFlags;
     info.ClassId             = reg.ClassType.GUID;
     info.Name                = reg.DisplayName;
     info.SdkVersion          = FormatSdkVersionString(SdkVersion);
     info.SubCategories.Value = reg.Categories.ToString();
     info.Vendor              = reg.Vendor;
     info.Version             = reg.Version.ToString();
 }
Example #4
0
        public void Register(ClassRegistration registration)
        {
            if (registration.ClassTypeId == Guid.Empty && registration.ClassType.GUID == Guid.Empty)
            {
                throw new ArgumentException("The ClassTypeId property is not set and the ClassType (class) does not have a GuidAttribute set.", "ClassType");
            }
            if (String.IsNullOrEmpty(registration.DisplayName) && registration.ClassType.GetDisplayName() == null)
            {
                throw new ArgumentException("The DisplayName property is not set and the ClassType (class) does not have a DisplayNameAttribute set.", "ClassType");
            }

            EnrichRegistration(registration);

            _registrations.Add(registration);
        }
Example #5
0
        protected virtual object CreateObjectInstance(ClassRegistration registration)
        {
            object instance = null;

            if (registration.CreatorCallback != null)
            {
                instance = registration.CreatorCallback(ServiceContainer, registration.ClassType);
            }
            else
            {
                instance = Activator.CreateInstance(registration.ClassType);
            }

            // link-up service container hierarchy
            var site = instance as IServiceContainerSite;

            if (site != null && site.ServiceContainer != null)
            {
                site.ServiceContainer.ParentContainer = ServiceContainer;
            }

            return(instance);
        }
Example #6
0
        protected virtual void EnrichRegistration(ClassRegistration registration)
        {
            // internals

            if (registration.ClassTypeId == Guid.Empty)
            {
                registration.ClassTypeId = registration.ClassType.GUID;
            }

            if (String.IsNullOrEmpty(registration.DisplayName))
            {
                registration.DisplayName = registration.ClassType.GetDisplayName();
            }

            if (String.IsNullOrEmpty(registration.Vendor))
            {
                registration.Vendor = Vendor;
            }

            if (registration.Version == null)
            {
                registration.Version = DefaultVersion;
            }
        }