Brunet.Connections.Connection.StringToMainType C# (CSharp) Метод

StringToMainType() статический публичный Метод

static public StringToMainType ( string s ) : ConnectionType
s string
Результат ConnectionType
    static public ConnectionType StringToMainType(string s)
    {
      ConnectionType result;
      lock( _string_to_main_type ) {
        if( false ==_string_to_main_type.TryGetValue(s, out result)) {
          int dot_idx = s.IndexOf('.');
          string maintype = s;
          if( dot_idx > 0 ) {
            maintype = s.Substring(0, dot_idx);
          }
          try {
            result = (ConnectionType)Enum.Parse(typeof(ConnectionType),
                                               maintype,
                                               true);
          }
          catch { result = ConnectionType.Unknown; }
          _string_to_main_type[String.Intern(s)] = result;
        }
      }
      return result;
    }

Usage Example

Пример #1
0
 public LinkerTask(Address local, Address target, string ct, string task_diff)
 {
     _local     = local;
     _target    = target;
     _ct        = Connection.StringToMainType(ct);
     _task_diff = task_diff;
 }
All Usage Examples Of Brunet.Connections.Connection::StringToMainType