internal void StartInstance()

in SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/AppCenter.cs [417:468]


        internal void StartInstance(params Type[] services)
        {
            if (services == null)
            {
                throw new AppCenterException("Services array is null.");
            }
            if (!_instanceConfigured)
            {
                throw new AppCenterException("App Center has not been configured.");
            }

            var serviceNames = new List<string>();
            foreach (var serviceType in services)
            {
                if (serviceType == null)
                {
                    AppCenterLog.Warn(AppCenterLog.LogTag, "Skipping null service. Please check that you did not pass a null argument.");
                    continue;
                }
                try
                {
                    var serviceInstance = serviceType.GetRuntimeProperty("Instance")?.GetValue(null) as IAppCenterService;
                    if (serviceInstance == null)
                    {
                        throw new AppCenterException("Service type does not contain static 'Instance' property of type IAppCenterService. The service is either not an App Center service or it's unsupported on this platform or the SDK is used from a .NET standard library and the nuget was not also added to the UWP/WPF/WinForms project.");
                    }
                    StartService(serviceInstance);
                    serviceNames.Add(serviceInstance.ServiceName);
                }
                catch (AppCenterException e)
                {
                    AppCenterLog.Error(AppCenterLog.LogTag, $"Failed to start service '{serviceType.Name}'; skipping it.", e);
                }
            }

            // Enqueue a log indicating which services have been initialized
            if (serviceNames.Count > 0)
            {
                if (InstanceEnabled)
                {
                    _channel.EnqueueAsync(new StartServiceLog { Services = serviceNames }).ConfigureAwait(false);
                }
                else
                {
                    if (_startedServiceNames == null)
                    {
                        _startedServiceNames = new List<string>();
                    }
                    _startedServiceNames.AddRange(serviceNames);
                }
            }
        }