public Router( IPathParser pathParser, Func <TRequest, TResponse> handleFallbackRequest) { _pathParser = pathParser; _handleFallbackRequest = handleFallbackRequest; }
public virtual void Handle(IHttpContext context, IPathParser pathParser, NetworkCredential credentials) { this.credentials = credentials; Initialize(context, pathParser); sourceControlProvider = Container.Resolve <TFSSourceControlProvider>(); Handle(context, sourceControlProvider); }
private void Initialize(string rawPath, IPathParser parser) { if (rawPath == null) { return; } Drive = parser.ParseDrive(rawPath) ?? ""; DriveLabel = PathUtils.GetDriveLabel(rawPath) ?? ""; Root = parser.ParseRoot(rawPath) ?? ""; if (Drive.Length + Root.Length >= rawPath.Length) { return; } rawPath = rawPath.Substring(Drive.Length + Root.Length); // Since the drive can contain invalid characters like '\\?\' or // ':', we want to wait until after we parse the drive and root. char reservedCharacter; if (parser.ReservedCharactersInPath(rawPath, out reservedCharacter)) { throw new InvalidPathException(rawPath, String.Format( "Path contains reserved character '{0}'.", reservedCharacter)); } // Remove trailing slash // This is what Python's pathlib does, but I don't think it's // necessarily required by spec if (rawPath.EndsWith(PathSeparator)) { rawPath = rawPath.TrimEnd(PathSeparator.ToCharArray()); } Dirname = parser.ParseDirname(rawPath) ?? ""; rawPath = rawPath.Substring(Dirname.Length); Basename = parser.ParseBasename(rawPath) ?? ""; rawPath = rawPath.Substring(Basename.Length); Extension = parser.ParseExtension(rawPath) ?? ""; // If filename is just an extension, consider it a "hidden file" // where the leading dot is the filename, not the extension. if (Basename == String.Empty && Extension != String.Empty) { Basename = Extension; Extension = String.Empty; } Normalize(); }
public virtual void Start(IPathParser parser) { if (!port.HasValue) { throw new InvalidOperationException("A port must be specified before starting the listener."); } ErrorOccured += OnErrorOccured; dispatcher = new HttpContextDispatcher(parser, actionTracking); isListening = true; server = parser.GetServerUrl(null, null); listener = new TcpListener(IPAddress.Parse(server), Port); listener.Start(); listener.BeginAcceptTcpClient(Accept, null); }
protected override void OnStart(IServiceContainer container) { base.OnStart(container); /* Support XLua */ INodeProxyFactoryRegister objectSourceProxyFactoryRegistry = container.Resolve <INodeProxyFactoryRegister>(); objectSourceProxyFactoryRegistry.Register(new LuaNodeProxyFactory(), 20); IPathParser pathParser = container.Resolve <IPathParser>(); ISourceProxyFactory sourceFactoryService = container.Resolve <ISourceProxyFactory>(); ISourceProxyFactoryRegistry sourceProxyFactoryRegistry = container.Resolve <ISourceProxyFactoryRegistry>(); sourceProxyFactoryRegistry.Register(new LuaExpressionSourceProxyFactory(sourceFactoryService, pathParser), 20); ITargetProxyFactoryRegister targetProxyFactoryRegister = container.Resolve <ITargetProxyFactoryRegister>(); targetProxyFactoryRegister.Register(new LuaTargetProxyFactory(), 30); }
public MongoDbDokanOperations ( ILogger logger, CommandLineArguments commandLineArguments, IPathParser pathParser, IMongoDb mongoDb, FindFilesWithPatternHandler findFilesWithPatternHander, GetFileInformationHandler getFileInformationHandler, ReadFileHandler readFileHandler ) { _logger = logger.ForContext <MongoDbDokanOperations>(); _commandLineArgs = commandLineArguments; _pathParser = pathParser; _mongoDb = mongoDb; _findFilesWithPatternHander = findFilesWithPatternHander; _getFileInformationHandler = getFileInformationHandler; _readFileHandler = readFileHandler; }
/// <summary> /// Create a path by joining the given path strings. /// </summary> /// <param name="parser">Parses parts out of a path.</param> /// <param name="paths">Paths to combine.</param> protected PurePath(IPathParser parser, params string[] paths) { string rawPath = null; if (paths.Length > 1) { var components = paths.Select(p => PurePathFactory(NormalizeSeparators(p))); var path = JoinInternal(components); rawPath = path.ToString(); Assimilate(path); } else if (paths.Length == 1 && !String.IsNullOrEmpty(paths[0])) { rawPath = NormalizeSeparators(paths[0]); Drive = ""; DriveLabel = ""; Root = ""; Dirname = ""; Basename = ""; Extension = ""; } else // no paths { Drive = ""; DriveLabel = ""; Root = ""; Dirname = ""; Basename = PathUtils.CurrentDirectoryIdentifier; Extension = ""; } if (rawPath != null && rawPath.StartsWith(NormalizeSeparators(UriPrefix))) { rawPath = rawPath.Substring(UriPrefix.Length); } Initialize(rawPath, parser); }
public MemoizedPathParser(IPathParser innnerParser) { _innnerParser = innnerParser; }
public HttpContextDispatcher(IPathParser parser, ActionTrackingViaPerfCounter actionTracking) { this.parser = parser; this.actionTracking = actionTracking; }
/// <summary> /// In this function, we check if username and password are correct. /// </summary> /// <param name="context"> The HTTP Context</param> /// <param name="pathParser">Path Parser</param> /// <param name="credentials">Net Credential</param> public override void Handle(IHttpContext context, IPathParser pathParser, NetworkCredential credentials) { // We establish a list to record usernames and passwords. If the new credential is in this list, // we can returns true because it has been verified. // Otherwise we call server to check it. this.credentials = credentials; Initialize(context, pathParser); /* * string strPath = context.Request.LocalPath; * string[] strs = strPath.Split('/', ':', '/'); * string strServerIP = strs[1]; * int nPort = int.Parse(strs[2]); */ if (credentials == null) { throw new CodePlex.TfsLibrary.NetworkAccessDeniedException(); } bool bFind = false; string rep = credentials.Domain; if (rep.Length == 0) { rep = SAWCommon.RepositoryName; } userInfoLock.EnterReadLock(); try { foreach (SAWSUserInfo info in verifiedLicense) { if (info.strUserName == credentials.UserName && info.strPassword == credentials.Password && string.Compare(info.strRepository, rep, true) == 0) { bFind = true; UserInfo = info; break; } } } finally { userInfoLock.ExitReadLock(); } if (!bFind) {// user must contain repository info, if not include, default as default // Not found, create a new object. UserInfo = new SAWSUserInfo(SAWCommon.SourceControlServer, SAWCommon.SourceControlPort, credentials.UserName, credentials.Password, rep); userInfoLock.EnterWriteLock(); try { verifiedLicense.Add(UserInfo); } finally { userInfoLock.ExitWriteLock(); } } Handle(context, null); }
public MemoizedPathParser(IPathParser innnerParser) { _innnerParser = innnerParser; }
public void Initialize(IHttpContext context, IPathParser parser) { this.httpContext = context; this.pathParser = parser; }
public LuaExpressionSourceProxyFactory(ISourceProxyFactory factory, IPathParser pathParser) { this.factory = factory; this.pathParser = pathParser; }
public static RouteRegistryBuilder <TRequest, TResponse> WithCustomPathParserAndFallbackRequestHandler( IPathParser pathParser, Func <TRequest, TResponse> handleFallbackRequest) => new RouteRegistryBuilder <TRequest, TResponse>(new Router <TRequest, TResponse>( pathParser, handleFallbackRequest));