internal static String FindInPath(String filename)
        {
            if (string.IsNullOrEmpty(filename))
                return string.Empty;

            String[] extensions = { "", ".exe", ".com" };
            StringBuilder s = new StringBuilder(260); // MAX_PATH

            // Step 1: Pre-process the path; if path contains WOW64 folder ref., replace it.
            if (Environment.Is64BitProcess && filename.ToLowerInvariant().Contains("sysnative")) {
                return filename.ToLowerInvariant().Replace("sysnative", "system32");
            }

            // Step 2a: If the ref. filename contains extension, use it with no modifications.
            if (Path.GetExtension(filename) != string.Empty)
            {
                IntPtr p = new IntPtr();
                SearchPath(null, filename, null, s.Capacity, s, out p);
            }

            // Step 2b: ... otherwise, iterate through some defaults.
            else
            {
                foreach (String ext in extensions)
                {
                    IntPtr p = new IntPtr();
                    if (SearchPath(null, String.Concat(filename, ext), null, s.Capacity, s, out p) != 0)
                        break;
                }
            }

            // Step 3: Return the result.
            return (s.Length == 0 ? filename : s.ToString());
        }
示例#2
0
文件: Scope.cs 项目: Blecki/BMud
 public void PopVariable(String name)
 {
     name = name.ToLowerInvariant();
     if (!HasVariable(name)) return;
     var list = variables[name.ToLowerInvariant()];
     list.RemoveAt(list.Count - 1);
     if (list.Count == 0)
         variables.Remove(name);
 }
示例#3
0
        public static bool Filter(this String source, String search)
        {
            if (String.IsNullOrWhiteSpace(source))
            {
                return false;
            }
            if (String.IsNullOrWhiteSpace(search))
            {
                return true;
            }

            // 不区分大小写
            source = source.ToLowerInvariant();
			search = search.ToLowerInvariant();

            if (source.Contains(search)) return true;
            else return false;

			//int index = source.IndexOf(search[0]);
			//if (index < 0) return false;

			//for (short i = 1; i < search.Length; i++)
			//{
			//	char ch = search[i];
			//	index = source.IndexOf(ch, index + 1);
			//	if (index < 0)
			//	{
			//		return false;
			//	}
			//}
			//return true;
        }
示例#4
0
        public override String GetVaryByCustomString(HttpContext context, String custom)
        {
            custom = custom.ToLowerInvariant();

            if (String.Equals(custom, "nm"))
            {
                return "nm:" + context.User.Identity.Name + ";";
            }
            else if (String.Equals(custom, "in"))
            {
                return (context.User.Identity.IsAuthenticated ? "in=t;" : "in=f;");
            }
            else if (String.Equals(custom, "pm"))
            {
                return (context.User.IsInRole("ProblemManage") ? "pm=t;" : "pm=f;");
            }
            else if (String.Equals(custom, "sa"))
            {
                return (context.User.IsInRole("SuperAdministrator") ? "sa=t;" : "sa=f;");
            }
            else
            {
                return base.GetVaryByCustomString(context, custom);
            }
        }
示例#5
0
 //EncryptCaesar given the user inputs
 public String EncryptCaesar(String Text, int Shift)
 {
     String EncryptedText = "";
     foreach (char c in Text.ToLowerInvariant()) // loop through each character in the text
     {
         int AsciiCode = (int)c;// change the character to an asciicode
         if (AsciiCode >= 97 && AsciiCode <= 122)  // check to see if the character is a letter from A-z
         {
             AsciiCode = AsciiCode + Shift; // add the shift to the asciicode
             if (AsciiCode > 122)// if the asciicode is above 122, then the character is greater than Z and needs to restart at A
             {
                 int NewShiftAmount = AsciiCode - 122; // work out what the amount should be added to A
                 AsciiCode = 96 + NewShiftAmount;// add the newly worked out shift to the asciicode
             }
             Char NewCharacter = (char)AsciiCode;// transform asciicode to character
             EncryptedText = EncryptedText + NewCharacter;// add the newly shifted text to the rest of the different shifts
         }
     }
     //show output to TextBox on gui
     Program.writeToConsole("\nInputed Text");
     Program.writeToConsole("\n"+ Text);
     Program.writeToConsole("\nEncrypted using a "+Shift+ " shift");
     Program.writeToConsole("\n"+EncryptedText);
     return EncryptedText; // return the newly encrypted text
 }
示例#6
0
        private List<ConnectionEntity> SendMessageTo(String who, String message)
        {
            //var name = Context.User.Identity.Name;
            var name = this.GetConnectionUser();

            if (!String.IsNullOrEmpty(name))
            {
                var table = GetConnectionTable();

                // Notice that the partition keys are stored in azure storage as lower case
                var query = new TableQuery<ConnectionEntity>()
                    .Where(TableQuery.GenerateFilterCondition(
                    "PartitionKey",
                    QueryComparisons.Equal,
                    who.ToLowerInvariant()));

                var queryResult = table.ExecuteQuery(query).ToList();
                if (queryResult.Count == 0)
                {
                    Clients.Caller.showErrorMessage("The user is no longer connected.");
                }
                else
                {
                    // Load only once the host application connections to display the data there
                    if(queryResult.Count(o=>o.PartitionKey.Equals(Constants.SignalR_HostApplicationUserName.ToLowerInvariant())) <= 0)
                        queryResult.AddRange(this.SendMessageTo(Constants.SignalR_HostApplicationUserName, message));

                    return queryResult;
                }
            }

            return new List<ConnectionEntity>();
        }
示例#7
0
文件: Drawer.cs 项目: htb012/ssoawfc
 /// <summary>
 /// 绘制方法
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="filePath"></param>
 public void draw(Graphics graphics, String filePath)
 {
     this.graphics = graphics;
     filePath = filePath.ToLowerInvariant();
     if (filePath.Contains("pot"))
     {
         reader = new potLoader();
     }
     else if (filePath.EndsWith("gnt"))
     {
         reader = new GntLoader();
     }
     else if (filePath.EndsWith("ptts"))
     {
         reader = new PttsLoader();
     }
     else if (filePath.EndsWith("dgr"))
     {
         reader = new dgrLoader();
     }
     else if (filePath.EndsWith("newp")|| filePath.EndsWith("txt"))
     {
         reader = new TEHONLoader();
     }
     else if (filePath.EndsWith("p"))
     {
         reader = new pFileLoader();
     }
     if (reader.load(filePath))
     {
         this.drawNext();
     }
 }
        public void Add(String name, String value)
        {
            Guard.ParameterCannotBeNull(name, "name");
            name = name.ToLowerInvariant();

            _headers.Add(name, value);

            Uri uri;
            switch (name)
            {
                case WebSocketHeaders.Origin:
                    if (String.Equals(value, "null", StringComparison.OrdinalIgnoreCase))
                        uri = null;
                    else if (!Uri.TryCreate(value, UriKind.Absolute, out uri))
                        throw new WebSocketException("Cannot parse '" + value + "' as Origin header Uri");
                    Origin = uri;
                    break;

                case WebSocketHeaders.Host:
                    Host = value;
                    break;

                case WebSocketHeaders.Version:
                    WebSocketVersion = Int16.Parse(value);
                    break;
            }
        }
 public static int FromString(String logLevel)
 {
     int mLogLevel = -1;
     if (!String.IsNullOrWhiteSpace(logLevel))
     {
         switch(logLevel.ToLowerInvariant())
         {
             case "verbose":
                 mLogLevel = KeyValues.LOG_LEVEL_VERBOSE;
                 break;
             case "debug":
                 mLogLevel = KeyValues.LOG_LEVEL_DEBUG;
                 break;
             case "info":
                 mLogLevel = KeyValues.LOG_LEVEL_INFO;
                 break;
             case "warn":
                 mLogLevel = KeyValues.LOG_LEVEL_WARN;
                 break;
             case "error":
                 mLogLevel = KeyValues.LOG_LEVEL_ERROR;
                 break;
         }
     }
     return mLogLevel;
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="ImplementationKey"/> struct.
 /// </summary>
 /// <param name="fileName">The configuration file name.</param>
 /// <param name="applicationName">The application name.</param>
 /// <param name="enableGroupPolicies">true to enable Group Policy; otherwise, false.</param>
 public ImplementationKey(String fileName,
                          String applicationName,
                          Boolean enableGroupPolicies)
 {
     FileName = fileName != null ? fileName.ToLowerInvariant() : null;
     ApplicationName = applicationName != null ? applicationName.ToLowerInvariant() : null;
     EnableGroupPolicies = enableGroupPolicies;
 }
示例#11
0
文件: Scope.cs 项目: Blecki/BMud
 public Object GetVariable(String name)
 {
     name = name.ToLowerInvariant();
     if (name == "@parent") return parentScope;
     if (!HasVariable(name)) return null;
     var list = variables[name];
     return list[list.Count - 1];
 }
示例#12
0
文件: Scope.cs 项目: Blecki/BMud
 public void ChangeVariable(String name, Object newValue)
 {
     name = name.ToLowerInvariant();
     if (!variables.ContainsKey(name))
         throw new ScriptError("Variable does not exist.", null);
     var list = variables[name];
     list.RemoveAt(list.Count - 1);
     list.Add(newValue);
 }
示例#13
0
        /// <summary>
        /// Wrapper function for recursive call to search for Acronym validation.  The acronym must contain at 
        /// least 1 letter from each word in the Product Name List and the letters must be in order of the Product Name.
        /// </summary>
        /// <param name="acronym">Acronym needing validation</param>
        /// <param name="productName">Product Name List</param>
        /// <returns>True if the acronym is valid for the Product List.</returns>
        public static Boolean IsValid(String acronym, List<String> productName )
        {
            Int32 partCount = 0;
            String lcAcronym = acronym.ToLowerInvariant();
            List<String> productPartsRequired = new List<String>();

            //Test for the null cases
            if (productName.Count == 0)
                throw new ArgumentException("Empty product name.  Product must exist.");

            if (productName.Count >=0 && productName.Contains(String.Empty) )
                throw new ArgumentException("Empty product name.  Product must exist.");

            if (acronym == String.Empty)
                throw new ArgumentException("Empty acronym specified.  Acronym must include letters");

            if (acronym.Length < productName.Count)
                return false;
            //Push the product name list ot the lowercase equivalient
            foreach (var product in productName)
            {
                productPartsRequired.Add(product.ToLowerInvariant());
            }

            if(!productPartsRequired[0].Contains(lcAcronym[0]) )
                return false;

            //Determine if the acronym parts are contained within every word of the Product name or
            //if the parts contain the complete acronym. If so return valid otherwise start seeking paths.
            foreach (String part in productName)
            {
                if (part.ToLowerInvariant().Contains(acronym.ToLowerInvariant()) || acronym.ToLowerInvariant().Contains(part.ToLowerInvariant()))
                    partCount++;

            }

            if (partCount == productName.Count)
                return true;

             return Validation( lcAcronym, productPartsRequired, 0, 0, 0);
        }
示例#14
0
 public static void LoadChampion(String Name)
 {
     switch (Name.ToLowerInvariant())
     {
         case "cassiopeia":
             new Instance.Cassiopeia();
             break;
         default:
             new Instance.Orbwalker();
             break;
     }
 }
示例#15
0
 public void Override(Case nounCase, Number number, String value)
 {
     value = value.ToLowerInvariant();
       if (value == GetRegular(nounCase, number))
       {
     DeleteOverride(nounCase, number);
     return;
       }
       if (!Overrides.ContainsKey(nounCase))
       {
     Overrides.Add(nounCase, new Dictionary<Number, string>());
       }
       Overrides[nounCase][number] = value;
 }
示例#16
0
        public static ReplyConfiguration Create(String exchangeType, String exchangeName, String routingKey)
        {
            switch (exchangeType.ToLowerInvariant())
            {
                case "direct":
                    return new DirectReplyConfiguration(exchangeName, routingKey);
                case "topic":
                    return new TopicReplyConfiguration(exchangeName, routingKey);
                case "fanout":
                    return new FanoutReplyConfiguration(exchangeName);
            }

            throw new ArgumentException($"Exchange type not recognized: {exchangeType}");
        }
示例#17
0
 public static SmaliLine.LineReturnType GetReturnType(String s)
 {
     String rt = s.ToLowerInvariant().Trim();
     if (rt.StartsWith("[")) // This is an array
     {
         rt = rt.Substring(1);
         switch (rt)
         {
             case "v":
                 return SmaliLine.LineReturnType.VoidArray;
             case "i":
                 return SmaliLine.LineReturnType.IntArray;
             case "z":
                 return SmaliLine.LineReturnType.BooleanArray;
             case "b":
                 return SmaliLine.LineReturnType.ByteArray;
             case "s":
                 return SmaliLine.LineReturnType.ShortArray;
             case "c":
                 return SmaliLine.LineReturnType.CharArray;
             case "j":
                 return SmaliLine.LineReturnType.LongArray;
             case "d":
                 return SmaliLine.LineReturnType.DoubleArray;
             default:
                 return SmaliLine.LineReturnType.CustomArray;
         }    
     }
     switch(rt)
     {
         case "v":
             return SmaliLine.LineReturnType.Void;
         case "i":
             return SmaliLine.LineReturnType.Int;
         case "z":
             return SmaliLine.LineReturnType.Boolean;
         case "b":
             return SmaliLine.LineReturnType.Byte;
         case "s":
             return SmaliLine.LineReturnType.Short;
         case "c":
             return SmaliLine.LineReturnType.Char;
         case "j":
             return SmaliLine.LineReturnType.Long;
         case "d":
             return SmaliLine.LineReturnType.Double;
         default: 
             return SmaliLine.LineReturnType.Custom;
     }                
 }
示例#18
0
 // method for shifting the affine cipher
 private string shiftaffine(String EncryptedText, int a, int b)
 {
     String DecryptedText = "";
     foreach (char c in EncryptedText.ToLowerInvariant()) // loop through each character in the encrypted text
     {
         int AsciiCode = (int)c; // get the asciicode for the specfic character
         if (AsciiCode >= 97 && AsciiCode <= 122) // check to see if the character is a letter from A-z
         {
             int x = c - 97; // transform the ascii code to a postion in the alphabet
             AsciiCode = ((a * x + b) % 26) + 97; // perfrom the shift and add 97 to transfrom in back into a ascii code
             Char NewCharacter = (char)AsciiCode; // transfrom in back into a ascii code
             DecryptedText = DecryptedText + NewCharacter; // add the character to the existing decrypted text
         }
     }
     return DecryptedText; // return the decrypted text
 }
示例#19
0
        public String Stem(String word)
        {
            word = word.ToLowerInvariant();
            word = word.Replace('ё', 'е');
            var m = RVRE.Match(word);
            if (m.Success) {
            String pre = m.Groups[1].Value;
            String rv = m.Groups[2].Value;
            String temp = PERFECTIVEGROUND.Replace(rv, "", 1);
            if (temp.Equals(rv)) {
                rv = REFLEXIVE.Replace(rv, "", 1);
                temp = ADJECTIVE.Replace(rv, "", 1);
                if (!temp.Equals(rv)) {
                    rv = temp;
                    rv = PARTICIPLE.Replace(rv, "", 1);
                } else {
                    temp = VERB.Replace(rv, "", 1);
                    if (temp.Equals(rv)) {
                        rv = NOUN.Replace(rv,"",1);
                    } else {
                        rv = temp;
                    }
                }

            } else {
                rv = temp;
            }

            rv = I.Replace(rv,"",1);

            if (DERIVATIONAL.Match(rv).Success) {
                rv = DER.Replace(rv, "", 1);
            }

            temp = P.Replace(rv, "", 1);
            if (temp.Equals(rv)) {
                rv = SUPERLATIVE.Replace(rv, "", 1);
                rv = NN.Replace(rv, "н", 1);
            }else{
                rv = temp;
            }
            word = pre + rv;

            }

            return word;
        }
        internal void Run(JavaEventServerPerfTestHelperOptions evetServerPerfTestOptions)
        {
            produceOption = evetServerPerfTestOptions;
            perfTestOption = evetServerPerfTestOptions;
            url = evetServerPerfTestOptions.EventServerFullAddress + "/eventserver?type=" + evetServerPerfTestOptions.Topic + "&sendtype=" + evetServerPerfTestOptions.SendType;
            if (url.ToLowerInvariant().StartsWith("https:"))
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(AcceptAllCertifications);
            }

            byte[] bKey = null;
            byte[] bVal = null;
            for (int i = 0; i < evetServerPerfTestOptions.MessageCountPerBatch; i++)
            {
                String key = RandomString(56);
                bKey = System.Text.Encoding.UTF8.GetBytes(key);
                String val = RandomString(evetServerPerfTestOptions.MessageSize);
                bVal = System.Text.Encoding.UTF8.GetBytes(val);
                messages.Add(new Message(bKey, bVal));
            }

            bufferLenth = evetServerPerfTestOptions.MessageCountPerBatch * (8 + bKey.Length + bVal.Length);

            Thread[] threads = new Thread[evetServerPerfTestOptions.ThreadCount];
            AutoResetEvent[] autos = new AutoResetEvent[evetServerPerfTestOptions.ThreadCount];
            threadPareamaters = new PerfTestThreadParameter[evetServerPerfTestOptions.ThreadCount];

            Logger.InfoFormat("start send {0} ", DateTime.Now);

            stopWatch.Restart();
            for (int i = 0; i < evetServerPerfTestOptions.ThreadCount; i++)
            {
                AutoResetEvent Auto = new AutoResetEvent(false);
                PerfTestThreadParameter p = new PerfTestThreadParameter();
                p.ThreadId = i;
                p.SpeedConstrolMBPerSecond = (evetServerPerfTestOptions.SpeedConstrolMBPerSecond * 1.0) / evetServerPerfTestOptions.ThreadCount;
                p.EventOfFinish = Auto;
                Thread t = new Thread(new ParameterizedThreadStart(RunOneThread));
                t.Start(p);
                autos[i] = Auto;
                threadPareamaters[i] = p;
            }

            WaitHandle.WaitAll(autos);
            stopWatch.Stop();
            Statistics();
        }
        protected override System.Data.DataTable GetData(HttpContext context, String query, int rows, Structures.Languages lang)
        {
            Pokedex.Pokedex pokedex = AppStateHelper.Pokedex(context.Application);
            String iso = Format.ToIso639_1(lang);
            query = query.ToLowerInvariant();
            int natDex = 0;
            Int32.TryParse(query, out natDex);
            int limit = 0;
            if (context.Request.QueryString["limit"] != null)
            {
                limit = Convert.ToInt32(context.Request.QueryString["limit"]);
                if (natDex > limit) return null;
            }

            Func<KeyValuePair<int, Species>, bool> filter;
            if (natDex > 0)
                filter = pair => pair.Key == natDex;
            else
                filter = pair => pair.Key <= limit && pair.Value.Name[iso].ToLowerInvariant().Contains(query);

            IEnumerable<Species> data;
            data = pokedex.Species.Where(filter).OrderBy(pair => pair.Key).Take(rows).Select(pair => pair.Value);

            DataTable dt = new DataTable();
            dt.Columns.Add("Text", typeof(String));
            dt.Columns.Add("Value", typeof(int));
            dt.Columns.Add("html", typeof(String));

            foreach (Species s in data)
            {
                String name = s.Name[iso];
                String html = "<img src=\"" + Common.ResolveUrl(WebFormat.SpeciesImageSmall(s)) +
                    "\" alt=\"" + Common.HtmlEncode(name) +
                    "\" class=\"sprite speciesSmall\" width=\"40px\" height=\"32px\" />" +
                    String.Format("{0} (#{1})",
                    Common.HtmlEncode(name),
                    s.NationalDex);

                dt.Rows.Add(name, s.NationalDex, html);
            }

            return dt;
        }
示例#22
0
文件: XTRMUtil.cs 项目: cs180011/XTRM
        public static int GetWordCount(String strText, String strTerm = null)
        {
            //Convert the string into an array of words
            string[] source = strText.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' }, StringSplitOptions.RemoveEmptyEntries);
            var matchQuery = from word in source
                             select word;

            // Create and execute the query. It executes immediately
            // because a singleton value is produced.
            // Use ToLowerInvariant to match "data" and "Data"
            if (strTerm != null)
            {
                matchQuery = from word in source
                             where word.ToLowerInvariant() == strTerm.ToLowerInvariant()
                             select word;
            }

            // Count the matches.
            return matchQuery.Count();
        }
示例#23
0
        public static string ToInvariant(this string text)
        {
            List<char> newText = new List<char>();

            foreach (char character in text)
            {
                string temp = new String(new char[] { character });

                if (Char.IsUpper(character)) temp.ToUpperInvariant();
                if (Char.IsLower(character)) temp.ToLowerInvariant();

                foreach (char newchar in temp)
                {
                    newText.Add(newchar);
                    temp.NotNullOrDefault("");
                }
            }

            return new String(newText.ToArray());
        }
示例#24
0
        public static bool Filter(this String source, String search)
        {
            if (String.IsNullOrWhiteSpace(source))
            {
                return(false);
            }
            if (String.IsNullOrWhiteSpace(search))
            {
                return(true);
            }

            // 不区分大小写
            source = source.ToLowerInvariant();
            search = search.ToLowerInvariant();

            if (source.Contains(search))
            {
                return(true);
            }
            else
            {
                return(false);
            }

            //int index = source.IndexOf(search[0]);
            //if (index < 0) return false;

            //for (short i = 1; i < search.Length; i++)
            //{
            //	char ch = search[i];
            //	index = source.IndexOf(ch, index + 1);
            //	if (index < 0)
            //	{
            //		return false;
            //	}
            //}
            //return true;
        }
示例#25
0
 // method used for encrypted affine cipher
 public String encryptAffine(String Text, int a, int b)
 {
     // A has to be a coprime of 26
     // b is the magnitude of the shift so must between 0-25
     // is this validated on the AffineCipherInput GUI
     string EncryptedText = "";
     Program.writeToConsole("\nInputed Text");
     Program.writeToConsole("\n" + Text);
     foreach (char c in Text.ToLowerInvariant())// loop through each character in the text
     {
         if (c >= 97 && c <= 122) // check to see if the character is a letter from A-z
         {
             int x = c - 97;// transform the ascii code to a postion in the alphabet
             int AsciiCode = ((a * x + b) % 26) + 97; // perfrom the shift and add 97 to transfrom in back into a ascii code
             Char NewCharacter = (char)AsciiCode;// transfrom in back into a ascii code
             EncryptedText = EncryptedText + NewCharacter;// add the character to the existing encrypted text
         }
     }
     //show output to TextBox on gui
     Program.writeToConsole("\nEncrypted Text:");
     Program.writeToConsole("\n" + EncryptedText);
     return EncryptedText; // return the newly encrypted text
 }
示例#26
0
        /// <summary>
        /// Parses a number in the specified radix.
        /// </summary>
        /// <param name="s">An input System.String.</param>
        /// <param name="radix">A radix.</param>
        /// <returns>The parsed number in the specified radix.</returns>
        public static long Parse(System.String s, int radix)
        {
            if (s is null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            if (radix < MIN_RADIX)
            {
                throw new NotSupportedException("radix " + radix +
                                                " less than Number.MIN_RADIX");
            }
            if (radix > MAX_RADIX)
            {
                throw new NotSupportedException("radix " + radix +
                                                " greater than Number.MAX_RADIX");
            }

            long result = 0;
            long mult   = 1;

            s = s.ToLowerInvariant();

            for (int i = s.Length - 1; i >= 0; i--)
            {
                int weight = digits.IndexOf(s[i]);
                if (weight == -1)
                {
                    throw new FormatException("Invalid number for the specified radix");
                }

                result += (weight * mult);
                mult   *= radix;
            }

            return(result);
        }
示例#27
0
        /// <summary>
        /// Parses a number in the specified radix.
        /// </summary>
        /// <param name="s">An input System.String.</param>
        /// <param name="radix">A radix.</param>
        /// <returns>The parsed number in the specified radix.</returns>
        public static long Parse(System.String s, int radix)
        {
            if (s == null)
            {
                throw new ArgumentException("null");
            }

            if (radix < MIN_RADIX)
            {
                throw new NotSupportedException("radix " + radix +
                                                " less than Number.MIN_RADIX");
            }
            if (radix > MAX_RADIX)
            {
                throw new NotSupportedException("radix " + radix +
                                                " greater than Number.MAX_RADIX");
            }

            long result = 0;
            long mult   = 1;

            s = s.ToLowerInvariant(); // LUCENENET TODO: Do we need to deal with Turkish? If so, this won't work right...

            for (int i = s.Length - 1; i >= 0; i--)
            {
                int weight = digits.IndexOf(s[i]);
                if (weight == -1)
                {
                    throw new FormatException("Invalid number for the specified radix");
                }

                result += (weight * mult);
                mult   *= radix;
            }

            return(result);
        }
示例#28
0
        /// <summary>
        /// Sets the format hint.
        /// </summary>
        /// <param name="formatHint">Format hint - must be 3 characters or less</param>
        public void SetFormatHint(String formatHint) {
            char[] hintChars = (String.IsNullOrEmpty(formatHint)) ? s_nullFormat : formatHint.ToLowerInvariant().ToCharArray();

            int count = hintChars.Length;

            fixed(sbyte* charPtr = FormatHint) {
                charPtr[0] = (sbyte) ((count > 0) ? hintChars[0] : '\0');
                charPtr[1] = (sbyte) ((count > 1) ? hintChars[1] : '\0');
                charPtr[2] = (sbyte) ((count > 2) ? hintChars[2] : '\0');
                charPtr[3] = (sbyte) '\0';
            }
        }
 /// <summary>
 /// Determines whether the specified cache key contains cache.
 /// </summary>
 /// <param name="cacheKey">The cache key.</param>
 /// <returns>
 /// <c>true</c> if the specified cache key contains cache; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsCache(String cacheKey)
 {
     return caches.ContainsKey(cacheKey.ToLowerInvariant());
 }
 public void setRequestHeader(String key, String value)
 {
     key = key.ToLowerInvariant();
     if (key == "content-type")
         mRequest.ContentType = value;
     else
         mRequest.Headers[key] = value;
 }
示例#31
0
        /// <summary>
        /// Adds a new attribute or changes the value of an existing attribute
        /// on the specified element.
        /// </summary>
        /// <param name="name">The name of the attribute as a string.</param>
        /// <param name="value">The desired new value of the attribute.</param>
        public void SetAttribute(String name, String value)
        {
            if (value != null)
            {
                if (!name.IsXmlName())
                    throw new DomException(DomError.InvalidCharacter);

                if (_namespace == Namespaces.HtmlUri)
                    name = name.ToLowerInvariant();

                for (int i = 0; i < _attributes.Count; i++)
                {
                    if (_attributes[i].Prefix == null && _attributes[i].LocalName == name)
                    {
                        _attributes[i].Value = value;
                        return;
                    }
                }

                _attributes.Add(new Attr(this, name, value));
                AttributeChanged(name, null, null);
            }
            else
                RemoveAttribute(name);
        }
示例#32
0
        /// <summary>
        /// Returns a boolean value indicating whether the specified element
        /// has the specified attribute or not.
        /// </summary>
        /// <param name="name">The attributes name.</param>
        /// <returns>The return value of true or false.</returns>
        public Boolean HasAttribute(String name)
        {
            if (_namespace == Namespaces.HtmlUri)
                name = name.ToLowerInvariant();

            return _attributes.Has(name);
        }
 public string MatchCaseInsensitive(String sKey)
 {
     foreach (string fieldName in typeof(ConfigStore).GetFields().Select(field => field.Name)) {
         if (fieldName.ToLowerInvariant () == sKey.ToLowerInvariant ()) {
             return fieldName;
         }
     }
     return "";
 }