/// <summary>
 /// Encapsulates a find operation. Will strip trailing separator as FindFile will not take it.
 /// </summary>
 /// <param name="directory">The directory to search in.</param>
 /// <param name="nameFilter">
 /// The filter. Can contain wildcards, full details can be found at
 /// <a href="https://msdn.microsoft.com/en-us/library/ff469270.aspx">[MS-FSA] 2.1.4.4 Algorithm for Determining if a FileName Is in an Expression</a>.
 /// </param>
 /// <param name="getAlternateName">Returns the alternate (short) file name in the FindResult.AlternateName field if it exists.</param>
 public FindOperation(
     string directory,
     string nameFilter = "*",
     bool recursive    = false,
     IFindTransform <T> findTransform = null,
     IFindFilter findFilter           = null)
 {
     _directory = directory;
     _recursive = recursive;
     if (findTransform == null)
     {
         if (typeof(T) == typeof(string))
         {
             findTransform = (IFindTransform <T>)FindTransforms.ToFullPath.Instance;
         }
         else if (typeof(T) == typeof(FindResult))
         {
             findTransform = (IFindTransform <T>)FindTransforms.ToFindResult.Instance;
         }
         else
         {
             throw new ArgumentException(nameof(findTransform), $"No default filter for {typeof(T)}");
         }
     }
     _transform = findTransform;
     _filter    = findFilter ?? new FindFilters.Multiple(FindFilters.NormalDirectory.Instance, new FindFilters.DosMatch(nameFilter, ignoreCase: true));
 }
Exemple #2
0
 /// <summary>
 /// Creates a wrapper for finding files.
 /// </summary>
 /// <param name="directory">The directory to search in.</param>
 /// <param name="recursive">True to find files recursively.</param>
 /// <param name="nameFilter">
 /// The filename filter. Can contain wildcards, full details can be found at
 /// <a href="https://msdn.microsoft.com/en-us/library/ff469270.aspx">[MS-FSA] 2.1.4.4 Algorithm for Determining if a FileName Is in an Expression</a>.
 /// If custom <paramref name="findFilter"/> is specified this parameter is ignored.
 /// </param>
 /// <param name="findFilter">Custom filter, if default behavior isn't desired. (Which is no "." or "..", and use the filter string.)</param>
 /// <param name="findTransform">Custom transform, if the default transform isn't desired.</param>
 public static FindOperation <T> CreateFindOperation <T>(
     string directory,
     string nameFilter = "*",
     bool recursive    = false,
     IFindTransform <T> findTransform = null,
     IFindFilter findFilter           = null)
 {
     return(new FindOperation <T>(directory, nameFilter, recursive, findTransform, findFilter));
 }
 public IEnumerable<DomainObjects.Person> findPerson(IFindFilter filter)
 {
     throw new NotImplementedException();
 }
 public IEnumerable<DomainObjects.Employee> findEmployee(IFindFilter filter)
 {
     throw new NotImplementedException();
 }
 //// Mock implementations. Unfortunately C# wouldn't accept it. Cannot infer the types?
 //public static IEnumerable<T> getEmployees(this T obj, IFindFilter filter)
 //{
 //    yield return obj;
 //}
 //TODO: Make abstraction over HrApplicationFacadeService to get emploeeys
 /// <summary>
 /// Return employees from HR Application by given filter
 /// </summary>
 public static IEnumerable<DomainObjects.Employee> getEmployees(this DomainObjects.Employee obj, IFindFilter filter)
 {
     yield return obj;
 }
 public IEnumerable<DomainObjects.Person> findPerson(IFindFilter filter)
 {
     return _peopleFinder.findPerson(filter);
 }
 public IEnumerable<DomainObjects.Employee> findEmployee(IFindFilter filter)
 {
     return _employeeFinder.findEmployee(filter);
 }