コード例 #1
0
ファイル: Eagle.cs プロジェクト: jdruin/F5Eagle
            ///////////////////////////////////////////////////////////////////

            private static SubstitutionFlags GetSubstitutionFlags(
                NameValueCollection appSettings,
                SubstitutionFlags @default
                )
            {
                try
                {
                    string value = Utility.GetEnvironmentVariable(
                        SubstitutionFlags, true, true);

                    if (String.IsNullOrEmpty(value) && (appSettings != null))
                    {
                        value = appSettings[SubstitutionFlags];
                    }

                    //
                    // NOTE: Were we able to get the value from somewhere?
                    //
                    if (!String.IsNullOrEmpty(value))
                    {
                        Result error = null;

                        object enumValue = Utility.TryParseFlagsEnum(
                            null, typeof(SubstitutionFlags),
                            @default.ToString(), value, null, true,
                            true, true, ref error);

                        if (enumValue is SubstitutionFlags)
                        {
                            return((SubstitutionFlags)enumValue);
                        }
                    }
                }
                catch
                {
                    // do nothing.
                }

                return(@default);
            }