Esempio n. 1
0
        internal Telimena(ITelimenaStartupInfo startupInfo)
        {
            try
            {
                this.SetConnectionSecurityProtocol();

                this.propertiesInternal = new TelimenaProperties(startupInfo);
                this.Locator            = new Locator(this.Properties.StaticProgramInfo);

                this.telemetryModule = new TelemetryModule(this.Properties);
                this.updates         = new UpdatesModule(this);

                this.httpClient = new TelimenaHttpClient(new HttpClient
                {
                    BaseAddress = this.propertiesInternal.StartupInfo.TelemetryApiBaseUrl
                });
                this.Messenger = new Messenger(this.Serializer, this.httpClient);

                ((TelemetryModule)this.telemetryModule).InitializeTelemetryClient();
                if (startupInfo.RegisterUnhandledExceptionsTracking)
                {
                    AppDomain.CurrentDomain.UnhandledException += this.CurrentDomain_UnhandledException;
                }
            }
            catch (Exception e)
            {
                TelemetryDebugWriter.WriteLine($"Error while initializing {nameof(Telimena)}. Error: {e}");
                //above all, we don't want to throw errors in client apps.
                //No telemetry is better than boom.
                throw;
            }
        }
Esempio n. 2
0
 public static ITelimena Construct(ITelimenaStartupInfo startupInfo)
 {
     try
     {
         Telimena instance = new Telimena(startupInfo);
         return(instance);
     }
     catch
     {
         return(GetNullObjectTeli(startupInfo));
     }
 }
Esempio n. 3
0
        /// <summary>
        ///     Creates new instance
        /// </summary>
        /// <param name="info"></param>
        public TelimenaProperties(ITelimenaStartupInfo info)
        {
            this.StartupInfo = info;

            this.StaticProgramInfo = info.ProgramInfo ?? new ProgramInfo {
                PrimaryAssembly = new Model.AssemblyInfo(this.StartupInfo.MainAssembly), Name = this.StartupInfo.MainAssembly.GetName().Name
            };
            this.UserInfo = info.UserInfo ?? new UserInfo {
                UserIdentifier = Environment.UserName, MachineName = Environment.MachineName
            };

            this.SuppressAllErrors = info.SuppressAllErrors;

            this.TelimenaVersion = TelimenaVersionReader.ReadToolkitVersion(Assembly.GetExecutingAssembly());
        }
Esempio n. 4
0
        /// <summary>
        ///     Creates new instance
        /// </summary>
        /// <param name="info"></param>
        public TelimenaProperties(ITelimenaStartupInfo info)
        {
            this.StartupInfo = info;

            this.StaticProgramInfo = info.ProgramInfo ?? new ProgramInfo {
                PrimaryAssembly = new Model.AssemblyInfo(this.StartupInfo.MainAssembly), Name = this.StartupInfo.MainAssembly.GetName().Name
            };
            this.Locator = new Locator(this.StaticProgramInfo);

            this.SuppressAllErrors = info.SuppressAllErrors;

            this.TelimenaVersion = TelimenaVersionReader.ReadToolkitVersion(Assembly.GetExecutingAssembly());

            this.InstrumentationKey = this.StartupInfo.InstrumentationKey;
        }
Esempio n. 5
0
        internal static ITelimena GetNullObjectTeli(ITelimenaStartupInfo startupInfo)
        {
//something went wrong when building telimena
            //return something that will not break client's code
            ITelimenaProperties props;

            try
            {
                //try at least building properties if possible
                props = new TelimenaProperties(startupInfo);
            }
            catch
            {
                //ok, even that failed, return fail safe thing
                props = new NullObjectTelimenaProperties();
            }

            return(new NullObjectTelimena(props));
        }
Esempio n. 6
0
 public static ITelimena Construct(ITelimenaStartupInfo startupInfo)
 {
     try
     {
         if (startupInfo.TelemetryApiBaseUrl != null)
         {
             Telimena instance = new Telimena(startupInfo);
             return(instance);
         }
         else
         {
             throw new TelimenaException("Error - Telimena URL is not specified. Telimena will not work. See logs for details.");
         }
     }
     catch
     {
         return(GetNullObjectTeli(startupInfo));
     }
 }
Esempio n. 7
0
 public static ITelimena Construct(ITelimenaStartupInfo startupInfo)
 {
     return(TelimenaFactory.Construct(startupInfo));
 }