Esempio n. 1
0
        public CatalogueElementName(CatalogueName catalogueName, System.Enum element, string name)
        {
            const string method = ".ctor";

            // Check catalogue name.

            if (catalogueName == null)
            {
                throw new NullParameterException(typeof(CatalogueElementName), method, "catalogueName");
            }

            // Check element.

            if (!NameRegex.IsMatch(element.ToString()))
            {
                throw new InvalidParameterFormatException(typeof(CatalogueElementName), method, "element", element.ToString(), Constants.Validation.CompleteNamePattern);
            }

            // Check name.

            if (name == null)
            {
                throw new NullParameterException(typeof(CatalogueElementName), method, "name");
            }
            if (!NameRegex.IsMatch(name))
            {
                throw new InvalidParameterFormatException(typeof(CatalogueElementName), method, "name", name, Constants.Validation.CompleteNamePattern);
            }

            // Assign.

            m_catalogueName = catalogueName.Clone();
            m_element       = element.ToString();
            m_name          = name;
        }
Esempio n. 2
0
 /// <summary>
 /// Validates that the specified name meets minimum requirements.
 /// </summary>
 /// <param name="name">The desired name/alias.</param>
 /// <param name="result">Any error messages about the desired name.</param>
 /// <returns></returns>
 public virtual bool ValidateName(string name, ExecutionResults result)
 {
     if (!NameRegex.IsMatch(name) && !EmailRegex.IsMatch(name))
     {
         //if this message is changed, do the same anywhere else it is used
         result.AppendError(
             "The name contains invalid characters.  The name must be an email address OR contain only letters, numbers, dashes, underscores, and spaces, are allowed.");
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
 /// <summary>
 /// Verifies that a string is a valid hive name.
 /// </summary>
 /// <param name="name">The name being tested.</param>
 /// <returns><c>true</c> if the name is valid.</returns>
 public static bool IsValidName(string name)
 {
     return(name != null && NameRegex.IsMatch(name));
 }
Esempio n. 4
0
 public override bool Matches(UserMarkerLocation uml)
 {
     return(PathRegex.IsMatch(uml.m_path) && NameRegex.IsMatch(uml.m_name));
 }
        public void PerformTask(TaskDetail taskDetail, UIOption Verbose = UIOption.OnlyErrorDialogs)
        {
            try {
                int    TotalCount = 0, CurrentCount = 0;
                string FileName, FileExtension, FileNewName;
                taskDetail(-1, 0, "", "", ""); // Loading...
                List <FileInfo> FileInfoList = new List <FileInfo>(Source.GetFiles());
                FileInfoList = FileInfoList.FindAll(delegate(FileInfo fileInfoObject) {
                    return(ExtensionRegex.IsMatch(fileInfoObject.Extension.ToLower()) &&
                           NameRegex.IsMatch(Path.GetFileNameWithoutExtension(fileInfoObject.Name)));
                });
                TotalCount = FileInfoList.Count;
                List <Tuple <FileInfo, IEnumerable <FileTag> > > FileList = new List <Tuple <FileInfo, IEnumerable <FileTag> > >();
                if (AttributeMatchList != null)
                {
                    IEnumerable <FileTag> FileTagInfoList, FileTagInfoListIntersected;
                    foreach (FileInfo FileInfoObject in FileInfoList)
                    {
                        FileTagInfoList            = GenerateFileInfo.GetFileTag(FileInfoObject.FullName);
                        FileTagInfoListIntersected = FileTagInfoList;
                        FileTagInfoListIntersected = FileTagInfoListIntersected.Intersect(AttributeMatchList);
                        if (FileTagInfoListIntersected.Count() > 0)
                        {
                            FileList.Add(new Tuple <FileInfo, IEnumerable <FileTag> >(FileInfoObject, FileTagInfoList));
                        }
                    }
                }
                else
                {
                    foreach (FileInfo FileInfoObject in FileInfoList)
                    {
                        FileList.Add(new Tuple <FileInfo, IEnumerable <FileTag> >(FileInfoObject, GenerateFileInfo.GetFileTag(FileInfoObject.FullName)));
                    }
                }
                TotalCount   = FileList.Count;
                CurrentCount = 0;
                taskDetail(TotalCount, 0, "", "", ""); // Loading Done...
                foreach (Tuple <FileInfo, IEnumerable <FileTag> > FileListObject in FileList)
                {
                    FileName      = Path.GetFileNameWithoutExtension(FileListObject.Item1.Name);
                    FileExtension = Path.GetExtension(FileListObject.Item1.Name);
                    FileNewName   = GetFormattedName(FileName, FileListObject.Item2);
                    taskDetail(TotalCount, CurrentCount, FileName, FileExtension, FileNewName);
                    switch (PerformType)
                    {
                    case PerformTaskType.Copy:
                        FileSystem.CopyFile(FileListObject.Item1.FullName, Destination + "/" + FileNewName + FileExtension, Verbose);
                        break;

                    case PerformTaskType.Move:
                        FileSystem.MoveFile(FileListObject.Item1.FullName, Destination + "/" + FileNewName + FileExtension, Verbose);
                        break;

                    case PerformTaskType.Rename:
                        FileSystem.RenameFile(FileListObject.Item1.FullName, FileNewName + FileExtension);
                        break;

                    case PerformTaskType.Delete:
                        FileSystem.DeleteFile(FileListObject.Item1.FullName, Verbose, RecycleOption.SendToRecycleBin);
                        break;

                    default:
                        Log.Write("PerformTask() Warning -> Invalid PerformType Given In " + Name);
                        break;
                    }
                    taskDetail(TotalCount, ++CurrentCount, FileName, FileExtension, FileNewName);
                }
            } catch (Exception ex) {
                Log.Write("Task::PerformTask() Error -> Task - " + Name + " [" + ex.Message + "]");
            }
        }