System.Xml.Serialization.TypeData.IsKeyword C# (CSharp) Method

IsKeyword() static private method

static private IsKeyword ( string name ) : bool
name string
return bool
		static bool IsKeyword (string name)
		{
			if (keywordsTable == null) {
				Hashtable t = new Hashtable ();
				foreach (string s in keywords)
					t [s] = s;
				keywordsTable = t;
			}
			return keywordsTable.Contains (name);
		}

Usage Example

Example #1
0
        public static string ToCSharpName(Type type, bool full)
        {
            if (type.IsArray)
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(TypeData.ToCSharpName(type.GetElementType(), full));
                stringBuilder.Append('[');
                int arrayRank = type.GetArrayRank();
                for (int i = 1; i < arrayRank; i++)
                {
                    stringBuilder.Append(',');
                }
                stringBuilder.Append(']');
                return(stringBuilder.ToString());
            }
            if (type.IsGenericType && !type.IsGenericTypeDefinition)
            {
                StringBuilder stringBuilder2 = new StringBuilder();
                stringBuilder2.Append(TypeData.ToCSharpName(type.GetGenericTypeDefinition(), full));
                stringBuilder2.Append('<');
                foreach (Type type2 in type.GetGenericArguments())
                {
                    stringBuilder2.Append(TypeData.ToCSharpName(type2, full)).Append(',');
                }
                stringBuilder2.Length--;
                stringBuilder2.Append('>');
                return(stringBuilder2.ToString());
            }
            string text = (!full) ? type.Name : type.FullName;

            text = text.Replace('+', '.');
            int num = text.IndexOf('`');

            text = ((num <= 0) ? text : text.Substring(0, num));
            if (TypeData.IsKeyword(text))
            {
                return("@" + text);
            }
            return(text);
        }