Example #1
0
        static GribEnvironment()
        {
            if (Initialized)
            {
                return;
            }

            lock (_initLock)
            {
                Initialized = true;

                if (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GRIB_API_NO_ABORT")))
                {
                    NoAbort = true;
                }

                string definitions = Environment.GetEnvironmentVariable("GRIB_DEFINITION_PATH");
                if (String.IsNullOrWhiteSpace(definitions))
                {
                    GribEnvironmentLoadHelper.TryFindDefinitions(out definitions);
                }

                AssertValidEnvironment(definitions);

                _libHandle = GribEnvironmentLoadHelper.BootStrapLibrary();
                GribApiNative.HookGribExceptions();

                SamplesPath     = definitions.Remove(definitions.LastIndexOf("definitions")) + "samples";
                DefinitionsPath = definitions;

                // grib_api discourages enabling multi-fields because they do not use them regularly and do not feel they
                // are well-tested, however leaving them disabled has caused considerable confusion among users.
                GribContext.Default.EnableMultipleFieldMessages = true;
            }
        }
Example #2
0
        //static GribEnvironment ()
        //{
        //    GribEnvironment.Init();
        //    // grib_api discourages enabling multi-fields, however leaving it disabled has caused
        //    // considerable confusion among users.
        //    GribContext.Default.EnableMultipleFieldMessages = true;
        //}

        /// <summary>
        /// Initializes GribApi.NET. In very rare cases, you may need to call this method directly
        /// to ensure the native libraries are bootstrapped and the environment setup correctly.
        /// </summary>
        /// <exception cref="System.ComponentModel.Win32Exception"></exception>
        public static void Init()
        {
            lock (_initLock)
            {
                if (Initialized)
                {
                    return;
                }

                Initialized = true;

                if (String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("GRIB_API_NO_ABORT")))
                {
                    NoAbort = true;
                }

                string definitions = Environment.GetEnvironmentVariable("GRIB_DEFINITION_PATH");
                if (String.IsNullOrWhiteSpace(definitions))
                {
                    GribEnvironmentLoadHelper.TryFindDefinitions(out definitions);
                }

                AssertValidEnvironment(definitions);

                _libHandle = GribEnvironmentLoadHelper.BootStrapLibrary();
                GribApiNative.HookGribExceptions();

                SamplesPath     = definitions.Remove(definitions.LastIndexOf("definitions")) + "samples";
                DefinitionsPath = definitions;
            }
        }
Example #3
0
        /// <summary>
        /// Initializes GribApi.NET. In very rare cases, you may need to call this method directly
        /// to ensure the native libraries are bootstrapped and the environment setup correctly.
        /// </summary>
        /// <exception cref="System.ComponentModel.Win32Exception"></exception>
        public static void Init()
        {
            lock (_initLock)
            {
                if (Initialized)
                {
                    return;
                }

                Initialized = true;
                string definitions = "";

                if (String.IsNullOrWhiteSpace(DefinitionsPath) &&
                    GribEnvironmentLoadHelper.TryFindDefinitions(out definitions))
                {
                    DefinitionsPath = definitions;
                }

                _libHandle = GribEnvironmentLoadHelper.BootStrapLibrary();
                AssertValidEnvironment();
            }
        }