/// <summary> /// Initializes a new instance of the <see cref="ViewLocationResult"/> class. /// </summary> /// <param name="location">The location of where the view was found.</param> /// <param name="name">The name of the view.</param> /// <param name="extension">The file extension of the located view.</param> /// <param name="contents">A <see cref="TextReader"/> that can be used to read the contents of the located view.</param> /// <param name="fullFilename">Full filename of the file</param> /// <param name="fileSystem">An <see cref="IFileSystemReader"/> instance that should be used when retrieving view information from the file system.</param> public FileSystemViewLocationResult(string location, string name, string extension, Func<TextReader> contents, string fullFilename, IFileSystemReader fileSystem) { this.fileSystem = fileSystem; this.Location = location; this.Name = name; this.Extension = extension; this.fileContents = contents; this.Contents = this.GetContents; this.fileName = fullFilename; }
/// <summary> /// Initializes a new instance of the <see cref="ViewLocationResult"/> class. /// </summary> /// <param name="location">The location of where the view was found.</param> /// <param name="name">The name of the view.</param> /// <param name="extension">The file extension of the located view.</param> /// <param name="contents">A <see cref="TextReader"/> that can be used to read the contents of the located view.</param> /// <param name="fullFilename">Full filename of the file</param> /// <param name="fileSystem">An <see cref="IFileSystemReader"/> instance that should be used when retrieving view information from the file system.</param> public FileSystemViewLocationResult(string location, string name, string extension, Func <TextReader> contents, string fullFilename, IFileSystemReader fileSystem) { this.fileSystem = fileSystem; this.Location = location; this.Name = name; this.Extension = extension; this.fileContents = contents; this.Contents = this.GetContents; this.fileName = fullFilename; }
private static ArgumentCompletionContext CreateContext(IFileSystemReader reader = null) { return(new ArgumentCompletionContext { ParseContext = new ArgumentParseContext { FileSystemReader = reader }, Tokens = new List <string> { string.Empty }, TokenIndex = 0 }); }
public FileSystemViewLocationProviderFixture() { this.reader = A.Fake <IFileSystemReader>(); this.rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns("rootPath"); this.provider = new FileSystemViewLocationProvider(this.rootPathProvider, this.reader); this.locationResult = new Tuple <string, Func <StreamReader> >( Path.Combine("this", "is", "a", "fake", "view.html"), () => null); A.CallTo(() => this.reader.GetViewsWithSupportedExtensions(A <string> ._, A <IEnumerable <string> > ._)).Returns(new[] { this.locationResult }); }
public FileSystemViewLocationProviderFixture() { this.reader = A.Fake<IFileSystemReader>(); this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns("rootPath"); this.provider = new FileSystemViewLocationProvider(this.rootPathProvider, this.reader); this.locationResult = new Tuple<string, Func<StreamReader>>( Path.Combine("this", "is", "a", "fake", "view.html"), () => null); A.CallTo(() => this.reader.GetViewsWithSupportedExtensions(A<string>._, A<IEnumerable<string>>._)).Returns(new[] { this.locationResult }); }
/// <summary> /// Finalizes parsing of the argument, reporting any errors from policy /// violations (e.g. missing required arguments). /// </summary> /// <param name="destination">The destination object being filled in.</param> /// <param name="fileSystemReader">File system reader to use.</param> /// <returns>True indicates that finalization completed successfully; /// false indicates that a failure occurred.</returns> public bool TryFinalize(object destination, IFileSystemReader fileSystemReader) { if (FixedDestination != null) { destination = FixedDestination; } if (!SeenValue && HasDefaultValue) { if (!TryValidateValue(DefaultValue, new ArgumentValidationContext(fileSystemReader))) { return(false); } if (destination != null && !TrySetValue(destination, DefaultValue)) { return(false); } } // For RestOfLine arguments, null means not seen, 0-length array means argument was given // but the rest of the line was empty, longer array contains rest of the line. if (IsCollection && (SeenValue || !TakesRestOfLine) && (destination != null)) { if (!TryCreateCollection(_collectionArgType, _collectionValues, out object collection)) { return(false); } if (!TrySetValue(destination, collection)) { return(false); } } if (IsRequired && !SeenValue) { ReportMissingRequiredArgument(); return(false); } return(true); }
/// <summary> /// Finalizes parsing of the argument, reporting any errors from policy /// violations (e.g. missing required arguments). /// </summary> /// <param name="fileSystemReader">File system reader to use.</param> /// <returns>True indicates that finalization completed successfully; /// false indicates that a failure occurred.</returns> public bool TryFinalize(IFileSystemReader fileSystemReader) { // If we haven't seen a value for this argument, then fill in the default. if (!SeenValue && Argument.HasDefaultValue) { if (!TryValidateValue(Argument.DefaultValue, new ArgumentValidationContext(fileSystemReader))) { return(false); } if (DestinationObject != null && !TrySetValue(DestinationObject, Argument.DefaultValue)) { return(false); } } // If this is a collection, then create the collection. if (Argument.IsCollection && (SeenValue || !Argument.TakesRestOfLine) && (DestinationObject != null)) { if (!TryCreateCollection(Argument.CollectionArgumentType, CollectionValues, out object collection)) { return(false); } if (!TrySetValue(DestinationObject, collection)) { return(false); } } if (Argument.IsRequired && !SeenValue) { ReportMissingRequiredArgument(); return(false); } return(true); }
public FileSystemViewLocationResultFixture() { this.reader = A.Fake <IFileSystemReader>(); }
public NSembleViewLocationProvider(IRootPathProvider rootPathProvider, IFileSystemReader fileSystemReader, global::Nancy.TinyIoc.TinyIoCContainer container) { _documentStore = container.Resolve<IDocumentStore>("DocStore"); fsViewLocationProvider = new FileSystemViewLocationProvider(rootPathProvider, fileSystemReader); resourcesViewLocationProvider = new ResourceViewLocationProvider(new NSembleResourceReader(), new NSembleResourceAssemblyProvider()); }
public FileSystemViewLocationResultFixture() { this.reader = A.Fake<IFileSystemReader>(); }
/// <summary> /// Initializes a new instance of the <see cref="FileSystemViewLocationProvider"/> class. /// </summary> /// <param name="rootPathProvider">A <see cref="IRootPathProvider"/> instance.</param> /// <param name="fileSystemReader">An <see cref="IFileSystemReader"/> instance that should be used when retrieving view information from the file system.</param> public FileSystemViewLocationProvider(IRootPathProvider rootPathProvider, IFileSystemReader fileSystemReader) { this.fileSystemReader = fileSystemReader; this.rootPath = rootPathProvider.GetRootPath(); }
/// <summary> /// Primary constructor. /// </summary> /// <param name="fileSystemReader">File system reader for context. /// </param> public ArgumentValidationContext(IFileSystemReader fileSystemReader) { FileSystemReader = fileSystemReader; }
private static bool Exists( IFileSystemReader fileSystem, string dataStorePath, Func<IFileSystemReader, string, string[]> getEntries ) { Ensure.Debug(fileSystem, f => f.NotNull()); if( dataStorePath.NullOrEmpty() || !DataStore.IsValidPath(dataStorePath) ) throw new ArgumentException().Store("dataStorePath", dataStorePath); var parentPath = DataStore.GetParentPath(dataStorePath); var entries = getEntries(fileSystem, parentPath); foreach( var f in entries ) { if( DataStore.Comparer.Equals(dataStorePath, DataStore.Combine(parentPath, f)) ) return true; } return false; }
/// <summary> /// Primary constructor. /// </summary> /// <param name="fileSystemReader">File system reader for context. /// </param> public ArgumentValidationContext(IFileSystemReader fileSystemReader) { FileSystemReader = fileSystemReader; }
public Searcher(IFileSystemReader fileSystemReader) { _fileSystemReader = fileSystemReader; }
private static void AddEntriesRecursively( IFileSystemReader fileSystem, List<string> entries, string directory, bool addFiles, bool addDirectories, string prefix = "" ) { if( addDirectories && !directory.NullOrEmpty() ) entries.Add(directory); foreach( var d in fileSystem.GetDirectoryNames(directory) ) AddEntriesRecursively(fileSystem, entries, DataStore.Combine(directory, d), addFiles, addDirectories, DataStore.Combine(prefix, d)); if( addFiles ) { foreach( var f in fileSystem.GetFileNames(directory) ) entries.Add(DataStore.Combine(prefix, f)); } }
/// <summary> /// Initializes a new instance of the <see cref="FileSystemViewLocationProvider"/> class. /// </summary> /// <param name="rootPathProvider">A <see cref="IRootPathProvider"/> instance.</param> /// <param name="fileSystemReader">An <see cref="IFileSystemReader"/> instance that should be used when retrieving view information from the file system.</param> public FileSystemViewLocationProvider(IRootPathProvider rootPathProvider, IFileSystemReader fileSystemReader) { this.fileSystemReader = fileSystemReader; this.rootPath = rootPathProvider.GetRootPath(); }
public NSembleViewLocationProvider(IRootPathProvider rootPathProvider, IFileSystemReader fileSystemReader, global::Nancy.TinyIoc.TinyIoCContainer container) { _documentStore = container.Resolve <IDocumentStore>("DocStore"); fsViewLocationProvider = new FileSystemViewLocationProvider(rootPathProvider, fileSystemReader); resourcesViewLocationProvider = new ResourceViewLocationProvider(new NSembleResourceReader(), new NSembleResourceAssemblyProvider()); }
private static ArgumentCompletionContext CreateContext(IFileSystemReader reader = null) { return new ArgumentCompletionContext { ParseContext = new ArgumentParseContext { FileSystemReader = reader }, Tokens = new List<string> { string.Empty }, TokenIndex = 0 }; }
/// <summary> /// Initializes a new instance of the <see cref="FileSystemViewLocationProvider"/> class. /// </summary> /// <param name="rootPathProvider">A <see cref="IRootPathProvider"/> instance.</param> /// <param name="fileSystemReader">An <see cref="IFileSystemReader"/> instance that should be used when retrieving view information from the file system.</param> public FileSystemViewLocationProvider(IRootPathProvider rootPathProvider, IFileSystemReader fileSystemReader) { this.fileSystemReader = fileSystemReader; this.rootPath = _ReConfig.path_root;// rootPathProvider.GetRootPath(); }