YAXLib.StringUtils.LooksLikeExpandedXName C# (CSharp) Method

LooksLikeExpandedXName() public static method

Heuristically determines if the supplied name conforms to the "expanded XML name" form supported by the System.Xml.Linq.XName class.
public static LooksLikeExpandedXName ( string name ) : bool
name string The name to be examined.
return bool
        public static bool LooksLikeExpandedXName(string name)
        {
            // XName permits strings of the form '{namespace}localname'. Detecting such cases allows
            // YAXLib to support explicit namespace use.
            // http://msdn.microsoft.com/en-us/library/system.xml.linq.xname.aspx

            name = name.Trim();

            // Needs at least 3 chars ('{}a' is, in theory, valid), must start with '{', must have a following closing '}' which must not be last char.
            if (name.Length >= 3)
            {
                if (name[ 0 ] == '{')
                {
                    int closingBrace = name.IndexOf('}', 1);
                    return closingBrace != -1 && closingBrace < (name.Length - 1);
                }
            }
            return false;
        }