Esempio n. 1
0
        protected override void ValidateElement(object element)
        {
            Monitor.Enter(_syncRoot);
            try
            {
                if (element == null)
                {
                    if (AllowNull)
                    {
                        return;
                    }
                    throw new ValidationMetadataException("Value cannot be null");
                }

                TypeNameInfo typeName = TypeNameInfo.AsTypeNameInfo(element);

                if (string.IsNullOrWhiteSpace(typeName.FullName))
                {
                    if (AllowEmpty)
                    {
                        return;
                    }
                    throw new ValidationMetadataException("Value cannot be empty");
                }

                if (!TypeNameInfo.IsValidLanguageIndependentFullName(typeName.TypeReference))
                {
                    throw new ValidationMetadataException("Invalid language-independent identifier");
                }
            }
            finally { Monitor.Exit(_syncRoot); }
        }