crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianUtils/Strings/StringUtils.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 using System;
       
    18 using System.Collections.Generic;
       
    19 using System.Text;
       
    20 
       
    21 namespace SymbianUtils.Strings
       
    22 {
       
    23     public static class StringUtils
       
    24     {
       
    25         public static string MakeRandomString()
       
    26         {
       
    27             return MakeRandomString( 20 );
       
    28         }
       
    29 
       
    30         public static string MakeRandomString( int aLength )
       
    31         {
       
    32             StringBuilder ret = new StringBuilder();
       
    33 
       
    34             Random random = new Random( DateTime.UtcNow.Millisecond );
       
    35             for ( int i = 0; i < aLength; i++ )
       
    36             {
       
    37                 char c = Convert.ToChar( Convert.ToInt32( Math.Floor( 26 * random.NextDouble() + 65 ) ) );
       
    38                 ret.Append( c );
       
    39             }
       
    40 
       
    41             return ret.ToString();
       
    42         }
       
    43 
       
    44         public static bool StartsWithAny( string[] aPrefixes, string aText )
       
    45         {
       
    46             bool ret = false;
       
    47             //
       
    48             foreach ( string p in aPrefixes )
       
    49             {
       
    50                 if ( aText.StartsWith( p ) )
       
    51                 {
       
    52                     ret = true;
       
    53                     break;
       
    54                 }
       
    55             }
       
    56             //
       
    57             return ret;
       
    58         }
       
    59     }
       
    60 }