DroidExplorer.Core.Adb.Device.GetStateFromString C# (CSharp) Méthode

GetStateFromString() public static méthode

public static GetStateFromString ( String state ) : DeviceState
state String
Résultat DeviceState
        public static DeviceState GetStateFromString( String state )
        {
            if ( Enum.IsDefined ( typeof ( DeviceState ), state ) ) {
                return (DeviceState)Enum.Parse ( typeof ( DeviceState ), state, true );
            } else {
                foreach ( var fi in typeof ( DeviceState ).GetFields ( ) ) {
                    /*
                    FieldDisplayNameAttribute dna = ReflectionHelper.GetCustomAttribute<FieldDisplayNameAttribute> ( fi );
                    if ( dna != null ) {
                        if ( string.Compare ( dna.DisplayName, state, false ) == 0 ) {
                            return (DeviceState)fi.GetValue ( null );
                        }
                    } else { */
                        if ( string.Compare ( fi.Name, state, true ) == 0 ) {
                            return (DeviceState)fi.GetValue ( null );
                        }
                    // }
                }
            }
            return DeviceState.Unknown;
        }