Ejemplo n.º 1
0
 public static bool IsValidLocalPartOfWindowsLiveID(string liveID)
 {
     if (string.IsNullOrEmpty(liveID) || !char.IsLetter(liveID[0]) || liveID[liveID.Length - 1] == '.' || liveID.IndexOf("..") >= 0 || liveID.Length > 63)
     {
         return(false);
     }
     foreach (char c in liveID)
     {
         if (!WindowsLiveIDLocalPartConstraint.IsValidCharForWindowsLiveID(c))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
 public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag)
 {
     if (value != null)
     {
         string text = value.ToString();
         if (this.allowEmptyLocalPart && string.IsNullOrEmpty(text))
         {
             return(null);
         }
         if (!WindowsLiveIDLocalPartConstraint.IsValidLocalPartOfWindowsLiveID(text))
         {
             return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationInvalidWindowsLiveIDLocalPart, propertyDefinition, value, this));
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        public static string RemoveInvalidPartOfWindowsLiveID(string liveID)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(liveID))
            {
                foreach (char c in liveID)
                {
                    if (stringBuilder.Length >= 63)
                    {
                        break;
                    }
                    if (WindowsLiveIDLocalPartConstraint.IsValidCharForWindowsLiveID(c) && (stringBuilder.Length != 0 || char.IsLetter(c)) && (stringBuilder.Length <= 0 || c != '.' || c != stringBuilder[stringBuilder.Length - 1]))
                    {
                        stringBuilder.Append(c);
                    }
                }
                if (stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] == '.')
                {
                    stringBuilder.Remove(stringBuilder.Length - 1, 1);
                }
            }
            return(stringBuilder.ToString());
        }