internal static void Init(ServerConnectionItemManager itemManager)
        {
            _regLicenseReceiver = EnvironmentManager.Instance.RegisterReceiver(NewLicense,
                                                                               new MessageIdFilter(
                                                                                   MessageId.System.LicenseChangedIndication));

            _activatedServerLicense = EnvironmentManager.Instance.LicenseManager.GetLicense(
                ServerConnectionDefinition.ServerConnectionPluginId,
                ServerConnectionDefinition.ServerLicenseId);
            _myServerLicense = EnvironmentManager.Instance.LicenseManager.ReservedLicenseManager.GetLicenseInformation(
                ServerConnectionDefinition.ServerConnectionPluginId,
                ServerConnectionDefinition.ServerLicenseId);

            if (_myServerLicense == null)
            {
                // If real license already activated, use that one as a starting point
                if (_activatedServerLicense != null)
                {
                    _myServerLicense = _activatedServerLicense;
                }
                else
                {
                    // If no license is available, store today + 30 days as the trial period
                    _myServerLicense = new LicenseInformation()
                    {
                        PluginId            = ServerConnectionDefinition.ServerConnectionPluginId,
                        Counter             = 0,
                        CustomData          = "Here we can add some custom data",
                        LicenseType         = ServerConnectionDefinition.ServerLicenseId,
                        Name                = "Server Connection License Sample",
                        Expire              = DateTime.UtcNow + TimeSpan.FromDays(30),
                        TrialMode           = true,
                        ItemIdentifications = new System.Collections.ObjectModel.Collection <LicenseItem>(),
                        CounterMethod       = LicenseInformation.CounterMethodEnum.CountByItemIdentifications
                    };
                }
                EnvironmentManager.Instance.LicenseManager.ReservedLicenseManager.SaveLicenseInformation(_myServerLicense);
            }

            // Now check for consistancy
            List <Item> items = itemManager.GetItems();
            Dictionary <string, Item> dictionaryItems = new Dictionary <string, Item>();

            foreach (Item item in items)
            {
                dictionaryItems.Add(item.FQID.ObjectId.ToString(), item);
            }

            Dictionary <string, LicenseItem> alreadyRegistreredItems = new Dictionary <string, LicenseItem>();
            List <LicenseItem> toRemove = new List <LicenseItem>();

            foreach (LicenseItem li in _myServerLicense.ItemIdentifications)
            {
                if (dictionaryItems.ContainsKey(li.Id) == false)
                {
                    toRemove.Add(li);
                }
                alreadyRegistreredItems.Add(li.Id, li);
            }

            // Lets remove any residuals (In case of crash or hack)
            foreach (LicenseItem li in toRemove)
            {
                _myServerLicense.UnRegisterConfiguredLicenseItem(li);
            }

            // Now add any missing items (crash or hack)
            foreach (Item item in items)
            {
                if (alreadyRegistreredItems.ContainsKey(item.FQID.ObjectId.ToString()) == false)
                {
                    LicenseItem li = new LicenseItem()
                    {
                        Id           = item.FQID.ObjectId.ToString(),
                        Name         = item.Name,
                        ItemTrial    = true,
                        ItemTrialEnd = DateTime.UtcNow + TimeSpan.FromDays(14)
                    };
                    _myServerLicense.RegisterConfiguredLicenseItem(li);
                }
            }

            // In this sample the number of reserved Items is also the counter for 'used' licenses
            _myServerLicense.Counter       = _myServerLicense.ItemIdentifications.Count;
            _myServerLicense.CounterMethod = LicenseInformation.CounterMethodEnum.CountByItemIdentifications;
        }