Beispiel #1
0
        public static EDAtmosphereType AtmosphereStr2Enum(string v, out EDAtmosphereProperty atmprop)
        {
            atmprop = EDAtmosphereProperty.None;

            if (v.IsEmpty())
            {
                return(EDAtmosphereType.Unknown);
            }

            if (v.Equals("None", StringComparison.InvariantCultureIgnoreCase))
            {
                return(EDAtmosphereType.No_atmosphere);
            }

            if (atmoscomparestrings == null)
            {
                atmoscomparestrings = new Dictionary <EDAtmosphereType, string>();
                foreach (EDAtmosphereType atm in Enum.GetValues(typeof(EDAtmosphereType)))
                {
                    atmoscomparestrings[atm] = atm.ToString().ToLower().Replace("_", " ");
                }
            }

            var searchstr = v.ToLowerInvariant();

            if (searchstr.Contains("rich"))
            {
                atmprop |= EDAtmosphereProperty.Rich;
            }
            if (searchstr.Contains("thick"))
            {
                atmprop |= EDAtmosphereProperty.Thick;
            }
            if (searchstr.Contains("thin"))
            {
                atmprop |= EDAtmosphereProperty.Thin;
            }
            if (searchstr.Contains("hot"))
            {
                atmprop |= EDAtmosphereProperty.Hot;
            }

            foreach (var kvp in atmoscomparestrings)
            {
                if (searchstr.Contains(kvp.Value))     // both are lower case, does it contain it?
                {
                    return(kvp.Key);
                }
            }

            return(EDAtmosphereType.Unknown);
        }
Beispiel #2
0
        public static EDAtmosphereType AtmosphereStr2Enum(string v, out EDAtmosphereProperty atmprop)
        {
            atmprop = EDAtmosphereProperty.None;

            if (v == null)
            {
                return(EDAtmosphereType.Unknown);
            }

            if (AtmosphereStr2EnumLookup == null)
            {
                AtmosphereStr2EnumLookup = new Dictionary <string, EDAtmosphereType>(StringComparer.InvariantCultureIgnoreCase);
                foreach (EDAtmosphereType atm in Enum.GetValues(typeof(EDAtmosphereType)))
                {
                    AtmosphereStr2EnumLookup[atm.ToString().Replace("_", "")] = atm;
                }
            }

            var searchstr = v.ToLowerInvariant().Replace("_", "").Replace(" ", "").Replace("-", "").Replace("atmosphere", "");

            if (searchstr.Contains("rich"))
            {
                atmprop  |= EDAtmosphereProperty.Rich;
                searchstr = searchstr.Replace("rich", "");
            }
            if (searchstr.Contains("thick"))
            {
                atmprop  |= EDAtmosphereProperty.Thick;
                searchstr = searchstr.Replace("thick", "");
            }
            if (searchstr.Contains("thin"))
            {
                atmprop  |= EDAtmosphereProperty.Thin;
                searchstr = searchstr.Replace("thin", "");
            }
            if (searchstr.Contains("hot"))
            {
                atmprop  |= EDAtmosphereProperty.Hot;
                searchstr = searchstr.Replace("hot", "");
            }

            if (AtmosphereStr2EnumLookup.ContainsKey(searchstr))
            {
                return(AtmosphereStr2EnumLookup[searchstr]);
            }

            // System.Diagnostics.Trace.WriteLine("atm: " + v);

            return(EDAtmosphereType.Unknown);
        }
Beispiel #3
0
        public static EDAtmosphereType AtmosphereStr2Enum(string v, out EDAtmosphereProperty atmprop)
        {
            atmprop = EDAtmosphereProperty.None;

            if (v == null)
            {
                return(EDAtmosphereType.Unknown);
            }

            var searchstr = v.ToLower().Replace("_", "").Replace(" ", "").Replace("-", "").Replace("atmosphere", "");

            if (searchstr.Contains("rich"))
            {
                atmprop  |= EDAtmosphereProperty.Rich;
                searchstr = searchstr.Replace("rich", "");
            }
            if (searchstr.Contains("thick"))
            {
                atmprop  |= EDAtmosphereProperty.Thick;
                searchstr = searchstr.Replace("thick", "");
            }
            if (searchstr.Contains("thin"))
            {
                atmprop  |= EDAtmosphereProperty.Thin;
                searchstr = searchstr.Replace("thin", "");
            }
            if (searchstr.Contains("hot"))
            {
                atmprop  |= EDAtmosphereProperty.Hot;
                searchstr = searchstr.Replace("hot", "");
            }


            foreach (EDAtmosphereType atm in Enum.GetValues(typeof(EDAtmosphereType)))
            {
                string str = atm.ToString().Replace("_", "").ToLower();

                if (searchstr.Equals(str))
                {
                    return(atm);
                }
            }

            // System.Diagnostics.Trace.WriteLine("atm: " + v);

            return(EDAtmosphereType.Unknown);
        }
Beispiel #4
0
        public static EDAtmosphereType AtmosphereStr2Enum(string v, out EDAtmosphereProperty atmprop)
        {
            atmprop = EDAtmosphereProperty.None;

            if (v == null)
                return EDAtmosphereType.Unknown;

            var searchstr = v.ToLower().Replace("_", "").Replace(" ", "").Replace("-", "").Replace("atmosphere", "");

            if (searchstr.Contains("rich"))
            {
                atmprop |= EDAtmosphereProperty.Rich;
                searchstr = searchstr.Replace("rich", "");
            }
            if (searchstr.Contains("thick"))
            {
                atmprop |= EDAtmosphereProperty.Thick;
                searchstr = searchstr.Replace("thick", "");
            }
            if (searchstr.Contains("thin"))
            {
                atmprop |= EDAtmosphereProperty.Thin;
                searchstr = searchstr.Replace("thin", "");
            }
            if (searchstr.Contains("hot"))
            {
                atmprop |= EDAtmosphereProperty.Thin;
                searchstr = searchstr.Replace("hot", "");
            }

            foreach (EDAtmosphereType atm in Enum.GetValues(typeof(EDAtmosphereType)))
            {
                string str = atm.ToString().Replace("_", "").ToLower();

                if (searchstr.Equals(str))
                    return atm;
            }

            System.Diagnostics.Trace.WriteLine("atm: " + v);

            return EDAtmosphereType.Unknown;
        }