protected override void BeginProcessing()
        {
            // | registered by Mdbc
            if (ClassMap.Contains(Type))
            {
                WriteVerbose($"Type {Type} was registered by Mdbc, doing nothing.");
                return;
            }

            // | registered by driver
            if (BsonClassMap.IsClassMapRegistered(Type))
            {
                if (ParameterSetName != psForce)
                {
                    WriteException(new PSInvalidOperationException("Class map is registered by driver. If this is expected invoke with just -Type and -Force."), Type);
                    return;
                }

                WriteVerbose($"Type {Type} was registered by driver, registering by Mdbc.");
                ClassMap.Add(Type);
                return;
            }

            try
            {
                var cm = new BsonClassMap(Type);
                if (Init == null)
                {
                    cm.AutoMap();
                }
                else
                {
                    var res = Actor.InvokeScript(Init, cm);
                    if (res.Count > 0)
                    {
                        throw new PSArgumentException("The Init script must not return anything.");
                    }
                }

                if (IdProperty != null)
                {
                    cm.MapIdProperty(IdProperty);
                }

                if (Discriminator != null)
                {
                    cm.SetDiscriminator(Discriminator);
                }
                if (DiscriminatorIsRequired)
                {
                    cm.SetDiscriminatorIsRequired(true);
                }

                if (IgnoreExtraElements)
                {
                    cm.SetIgnoreExtraElements(IgnoreExtraElements);
                }
                if (ExtraElementsProperty != null)
                {
                    cm.MapExtraElementsProperty(ExtraElementsProperty);
                }

                // in theory, may throw if the map is registered in another thread
                BsonClassMap.RegisterClassMap(cm);

                // done
                ClassMap.Add(Type);
            }
            catch (ArgumentException exn)
            {
                WriteException(exn, Type);
            }
        }
 public static void ConfigureExtraProperties <T>(this BsonClassMap <T> map)
     where T : class, IHasExtraProperties
 {
     map.MapExtraElementsProperty(x => x.ExtraProperties);
 }