public Context(Socket socket, Request request, ResponseWriter response, CancellationToken cancellationToken) { this.Socket = socket; this.Reqeust = request; this.Response = response; this.CancellationToken = cancellationToken; }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("comment|Invalid number of arguments. " + "Usage: create {template name} {item name} {template arguments}"); return; } var project = getFile(arguments[1]); var template = pickTemplate(arguments[0]); if (template == null) { return; } template.Run(project, getArguments(arguments)); writer.Write("comment|Created {0}", project); if (template.File == null) { return; } gotoFile(writer, template.File.Fullpath, template.Line, template.Column, Path.GetDirectoryName(project)); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: reference {assembly/project} {project to add reference to"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to add this reference to does not exist. " + "Usage: reference {assembly/project} {project to add reference to"); return; } if (!_project.Read(projectFile, _provider)) return; _project.Reference(file); _project.Write(); writer.Write("Added reference {0} to {1}", file, projectFile); }
/// <summary> /// Writes a integral property to the specified writer if the value is not null. /// </summary> /// <param name="writer">The writer to write.</param> /// <param name="name">The name of the property.</param> /// <param name="value">The value of the property.</param> public static void WritePropertyIfNeeded(this IResponseWriter writer, string name, int?value) { if (value != null) { writer.WriteProperty(name, value.Value); } }
private void gotoFile(IResponseWriter writer, string file, int line, int column, string location) { writer.Write( string.Format("editor goto \"{0}|{1}|{2}\"", file, line, column)); writer.Write("editor setfocus"); }
public void Execute(IResponseWriter writer, string[] arguments) { var args = parseArguments(writer, arguments); if (args == null) { return; } var provider = _getTypesProviderByLocation(args.File); if (provider == null) { return; } var files = filesFromArgument(args); var with = provider.TypesProvider; var project = with.Reader().Read(provider.ProjectFile); foreach (var fileToAdd in files) { var file = with.FileTypeResolver().Resolve(fileToAdd); if (file == null) { return; } with.FileAppenderFor(file).Append(project, file); with.Writer().Write(project); } }
public void Execute(IResponseWriter writer, string[] args) { if (args.Length != 1) return; var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (chunks.Length != 3) return; try { var file = chunks[0]; var line = int.Parse(chunks[1]); var column = int.Parse(chunks[2]); var signatureFetcher = new EnclosingSignatureFromPosition( _globalCache, (fileName) => File.ReadAllText(fileName), (fileName) => File.Delete(fileName), (fileName) => { var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory); if (instance != null) return instance.GetDirtyFiles(fileName); return ""; }); var signature = signatureFetcher.GetSignature(file, line, column); writer.Write(signature); } catch (Exception ex) { writer.Write(ex.ToString()); } }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to remove this reference for does not exist. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } if (!_project.Read(projectFile, _getTypesProviderByLocation)) return; _project.Dereference(file); _project.Write(); writer.Write("Rereferenced {0} from {1}", file, projectFile); }
public void SetUp() { _publishedCommands = new List <Tuple <string, object> >(); _writer = new FakeWriter(this); _sut = new ProjectionCoreResponseWriter(_writer); Given(); When(); }
public void Execute(IResponseWriter writer, string[] args) { var output = ""; _dispatcher.GetHandlers() .Where(x => x.Usage != null).ToList() .ForEach(x => output += x.Usage + " "); writer.Write(output); }
public RestfulResult(IResponseWriter responseWriter, object content, string viewName, IResponseUpdater responseUpdater, IStatusCodeTranslator statusCodeTranslator, ILocationProvider locationProvider, IContextHelper contextHelper) { _responseWriter = responseWriter; _responseUpdater = responseUpdater; _statusCodeTranslator = statusCodeTranslator; _locationProvider = locationProvider; _contextHelper = contextHelper; _viewName = viewName; _content = content; }
public void Execute(IResponseWriter writer, string[] args) { if (args.Length != 1) { return; } var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (chunks.Length != 3) { return; } try { var file = chunks[0]; var line = int.Parse(chunks[1]); var column = int.Parse(chunks[2]); var cache = new DirtyFileParser( _globalCache, (fileName) => File.ReadAllText(fileName), (fileName) => File.Delete(fileName), (fileName) => { var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory); if (instance != null) { return(instance.GetDirtyFiles(fileName)); } return(""); }).Parse(file); var name = new TypeUnderPositionResolver() .GetTypeName(file, File.ReadAllText(file), line, column); writer.Write("comment|Found name {0}", name); var signature = new FileContextAnalyzer(_globalCache, cache) .GetSignatureFromNameAndPosition(file, name, line, column); writer.Write("comment|Found signature {0}", signature); var pos = cache.PositionFromSignature(signature); if (pos != null) { writer.Write("editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column); return; } writer.Write("comment|Looking in global cache"); pos = _globalCache.PositionFromSignature(signature); if (pos != null) { writer.Write("editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column); } } catch (Exception ex) { writer.Write(ex.ToString()); } }
public void Execute(IResponseWriter writer, string[] arguments) { var provider = _getTypesProviderByLocation(arguments[0]); if (provider == null) return; var with = provider.TypesProvider; var file = with.FileTypeResolver().Resolve(arguments[0]); if (file == null) return; var project = with.Reader().Read(provider.ProjectFile); with.FileRemoverFor(file).Remove(project, file); with.Writer().Write(project); }
/// <summary> /// Writes a EmbedData to the specified writer. /// </summary> /// <param name="writer">The writer to write.</param> /// <param name="obj">The <see cref="EmbedData" />.</param> /// <param name="hash">The URL hash to append.</param> public static async Task WriteEmbedDataAsync(this IResponseWriter writer, EmbedData obj, string hash = null) { writer.WriteStartResponse(); writer.WritePropertyIfNeeded("type", obj.Type); writer.WritePropertyIfNeeded("url", obj.Url + hash); writer.WritePropertyIfNeeded("title", obj.Title); writer.WritePropertyIfNeeded("description", obj.Description); writer.WritePropertyIfNeeded("author_name", obj.AuthorName); writer.WritePropertyIfNeeded("author_url", obj.AuthorUrl); writer.WritePropertyIfNeeded("provider_name", obj.ProviderName); writer.WritePropertyIfNeeded("provider_url", obj.ProviderUrl); writer.WritePropertyIfNeeded("cache_age", obj.CacheAge); writer.WriteStartObjectProperty("metadata_image"); writer.WritePropertyIfNeeded("type", obj.MetadataImage?.Type); writer.WritePropertyIfNeeded("restriction_policy", obj.MetadataImage?.RestrictionPolicy); writer.WritePropertyIfNeeded("raw_url", obj.MetadataImage?.RawUrl); writer.WritePropertyIfNeeded("location", obj.MetadataImage?.Location); writer.WriteStartObjectProperty("thumbnail"); writer.WritePropertyIfNeeded("url", obj.MetadataImage?.Thumbnail?.Url); writer.WritePropertyIfNeeded("width", obj.MetadataImage?.Thumbnail?.Width); writer.WritePropertyIfNeeded("height", obj.MetadataImage?.Thumbnail?.Height); writer.WriteEndObjectProperty(); writer.WriteEndObjectProperty(); writer.WritePropertyIfNeeded("restriction_policy", obj.RestrictionPolicy); if (obj.Medias.Count > 0) { writer.WriteStartArrayProperty("medias"); foreach (var media in obj.Medias) { writer.WriteStartObject("media"); writer.WriteProperty("type", media.Type.ToString()); if (media.Thumbnail != null) { writer.WriteStartObjectProperty("thumbnail"); writer.WritePropertyIfNeeded("url", media.Thumbnail.Url); writer.WritePropertyIfNeeded("width", media.Thumbnail.Width); writer.WritePropertyIfNeeded("height", media.Thumbnail.Height); writer.WriteEndObjectProperty(); } writer.WritePropertyIfNeeded("raw_url", media.RawUrl); writer.WritePropertyIfNeeded("location", media.Location); writer.WritePropertyIfNeeded("restriction_policy", media.RestrictionPolicy); writer.WriteEndObject(); } writer.WriteEndArrayProperty(); } await writer.WriteEndResponseAsync(); }
public static Task UseWriter(object model, HttpResponse response, IResponseWriter writer) { if (model == null) { response.StatusCode = 404; response.ContentType = "text/plain"; response.ContentLength = ResourceNotFound.Length; return(response.WriteAsync(ResourceNotFound)); } response.ContentType = writer.ContentType; return(writer.WriteToStream(model, response)); }
private CommandArguments parseArguments(IResponseWriter writer, string[] arguments) { var file = arguments.FirstOrDefault(x => !x.StartsWith("-")); if (file == null) { writer.Write("error|No file argument provided"); return(null); } return(new CommandArguments() { File = file, Recursive = arguments.Contains("--recursive") || arguments.Contains("-r") }); }
public OutputWriter(IResponseWriter writer) { _writer = writer; Projects = new List <Project>(); Usings = new List <Using>(); UsingAliases = new List <UsingAlias>(); Files = new List <FileRef>(); Namespaces = new List <Namespce>(); Classes = new List <Class>(); Interfaces = new List <Interface>(); Structs = new List <Struct>(); Enums = new List <EnumType>(); Fields = new List <Field>(); Methods = new List <Method>(); Parameters = new List <Parameter>(); Variables = new List <Variable>(); }
public void Setup() { request = new Mock<HttpRequestBase>(); response = new Mock<HttpResponseBase>(); cache = new Mock<HttpCachePolicyBase>(); encoder = new Mock<IEncoder>(); bundle = new BundleImpl(); bundle.Hash = new byte[1]; response.Setup(r => r.Cache).Returns(cache.Object); response.Setup(r => r.Headers).Returns(new NameValueCollection()); httpContext = new Mock<HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(request.Object); httpContext.Setup(c => c.Response).Returns(response.Object); writer = new ResponseWriter(httpContext.Object); }
public void Execute(IResponseWriter writer, string[] args) { if (args.Length != 1) return; var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (chunks.Length != 3) return; try { var file = chunks[0]; var line = int.Parse(chunks[1]); var column = int.Parse(chunks[2]); var cache = new DirtyFileParser( _globalCache, (fileName) => File.ReadAllText(fileName), (fileName) => File.Delete(fileName), (fileName) => { var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory); if (instance != null) return instance.GetDirtyFiles(fileName); return ""; }).Parse(file); var name = new TypeUnderPositionResolver() .GetTypeName(file, File.ReadAllText(file), line, column); writer.Write("Found name {0}", name); var signature = new FileContextAnalyzer(_globalCache, cache) .GetSignatureFromNameAndPosition(file, name, line, column); writer.Write("Found signature {0}", signature); var pos = cache.PositionFromSignature(signature); if (pos != null) { writer.Write("command|editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column); return; } writer.Write("Looking in global cache"); pos = _globalCache.PositionFromSignature(signature); if (pos != null) writer.Write("command|editor goto {0}|{1}|{2}", pos.Fullpath, pos.Line, pos.Column); } catch (Exception ex) { writer.Write(ex.ToString()); } }
public void Execute(IResponseWriter writer, string[] arguments) { var provider = _getTypesProviderByLocation(arguments[0]); if (provider == null) { return; } var with = provider.TypesProvider; var file = with.FileTypeResolver().Resolve(arguments[0]); if (file == null) { return; } var project = with.Reader().Read(provider.ProjectFile); with.FileRemoverFor(file).Remove(project, file); with.Writer().Write(project); }
/// <summary> /// Writes a property to the specified writer if the value is not null. /// </summary> /// <param name="writer">The writer to write.</param> /// <param name="name">The name of the property.</param> /// <param name="value">The value of the property.</param> public static void WritePropertyIfNeeded(this IResponseWriter writer, string name, object value) { if (value != null) { var t = value.GetType(); if (t == typeof(bool)) { writer.WriteProperty(name, (bool)value); } else if (Regex.IsMatch(t.FullName, "^System.(U?Int(16|32|64)|S?Byte|Single|Double|Decimal)$")) { writer.WriteProperty(name, ((IConvertible)value).ToDouble(null)); } else { writer.WriteProperty(name, value.ToString()); } } }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 1) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: dereference REFERENCE [PROJECT"); return; } if (arguments.Length > 1) { var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to remove this reference for does not exist. " + "Usage: dereference REFERENCE [PROJECT"); return; } if (!_project.Read(projectFile, _getTypesProviderByLocation)) return; } else { if (!_project.Read(Environment.CurrentDirectory, _getTypesProviderByLocation)) { writer.Write("error|Could not locate project within " + Environment.CurrentDirectory + ". " + "Usage: dereference REFERENCE [PROJECT]"); return; } } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); _project.Dereference(file); _project.Write(); writer.Write("Rereferenced {0} from {1}", fullpath, _project.Fullpath); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("error|Invalid number of arguments. " + "Usage: new {template name} {item name} {template arguments}"); return; } var className = getFileName(arguments[1]); var location = getLocation(arguments[1]); if (!_project.Read(location, _getTypesProviderByLocation)) { return; } var template = _pickTemplate(arguments[0], _project.Type); if (template == null) { writer.Write("error|No template with the name {0} exists.", arguments[0]); return; } var ns = getNamespace(location, _project.Fullpath, _project.DefaultNamespace); template.Run(location, className, ns, _project.Fullpath, _project.Type, getArguments(arguments)); if (template.File == null) { return; } _project.AppendFile(template.File); _project.Write(); writer.Write("comment|Created class {0}.{1}", ns, className); writer.Write("comment|Full path {0}", template.File.Fullpath); gotoFile(writer, template.File.Fullpath, template.Line, template.Column, location); }
public void Execute(IResponseWriter writer, string[] arguments) { var args = parseArguments(writer, arguments); if (args == null) return; var provider = _getTypesProviderByLocation(args.File); if (provider == null) return; var files = filesFromArgument(args); var with = provider.TypesProvider; var project = with.Reader().Read(provider.ProjectFile); foreach (var fileToAdd in files) { var file = with.FileTypeResolver().Resolve(fileToAdd); if (file == null) return; with.FileAppenderFor(file).Append(project, file); with.Writer().Write(project); } }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 1) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: reference REFERENCE [PROJECT]"); return; } if (arguments.Length > 1) { var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to add this reference to does not exist. " + "Usage: reference REFERENCE [PROJECT]"); return; } if (!_project.Read(projectFile, _provider)) return; } else { if (!_project.Read(Environment.CurrentDirectory, _provider)) { writer.Write("error|Could not locate project within " + Environment.CurrentDirectory + ". " + "Usage: reference REFERENCE [PROJECT]"); return; } } var fullpath = new PathParser(arguments[0]).ToAbsolute(Environment.CurrentDirectory); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) file = new VSProjectFile().New(fullpath); else file = new AssemblyFile().New(fullpath); _project.Reference(file); _project.Write(); writer.Write("Added reference {0} to {1}", fullpath, _project.Fullpath); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) { file = new VSProjectFile().New(fullpath); } else { file = new AssemblyFile().New(fullpath); } var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to remove this reference for does not exist. " + "Usage: dereference {assembly/project} {project to remove reference from}"); return; } if (!_project.Read(projectFile, _getTypesProviderByLocation)) { return; } _project.Dereference(file); _project.Write(); writer.Write("comment|Rereferenced {0} from {1}", file, projectFile); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length != 2) { writer.Write("error|The handler needs the full path to the reference. " + "Usage: reference {assembly/project} {project to add reference to"); return; } var fullpath = getFile(arguments[0]); IFile file; if (new VSProjectFile().SupportsExtension(fullpath)) { file = new VSProjectFile().New(fullpath); } else { file = new AssemblyFile().New(fullpath); } var projectFile = getFile(arguments[1]); if (!File.Exists(projectFile)) { writer.Write("error|The project to add this reference to does not exist. " + "Usage: reference {assembly/project} {project to add reference to"); return; } if (!_project.Read(projectFile, _provider)) { return; } _project.Reference(file); _project.Write(); writer.Write("comment|Added reference {0} to {1}", file, projectFile); }
public void Execute(IResponseWriter writer, string[] args) { var output = new OutputWriter(writer); if (args.Length != 1) { output.WriteError("crawl-source requires one parameters which is path to the " + "file containing files/directories to crawl"); return; } var crawler = new CSharpCrawler(output, _mainCache); if (Directory.Exists(args[0])) { crawler.Crawl(new CrawlOptions(args[0])); } else { var lines = File .ReadAllText(args[0]) .Split(new string[]Â { Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries).ToList(); if (lines.Count > 0 && File.Exists(lines[0]) || Directory.Exists(lines[0])) { lines.ForEach(x => crawler.Crawl(new CrawlOptions(x))); } else { crawler.Crawl(new CrawlOptions(args[0])); } } System.Threading.ThreadPool.QueueUserWorkItem((m) => { lock (_mainCache) { Logger.Write("Merging crawl result into cache"); var cacheToMerge = (IOutputWriter)m; if (_mainCache == null) return; _mainCache.MergeWith(cacheToMerge); Logger.Write("Disposing and cleaning up"); cacheToMerge.Dispose(); GC.Collect(5); } }, output); }
public void Execute(IResponseWriter writer, string[] args) { if (args.Length != 1) { return; } var chunks = args[0].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (chunks.Length != 3) { return; } try { var file = chunks[0]; var line = int.Parse(chunks[1]); var column = int.Parse(chunks[2]); var signatureFetcher = new EnclosingSignatureFromPosition( _globalCache, (fileName) => File.ReadAllText(fileName), (fileName) => File.Delete(fileName), (fileName) => { var instance = new EngineLocator(new FS()).GetInstance(Environment.CurrentDirectory); if (instance != null) { return(instance.GetDirtyFiles(fileName)); } return(""); }); var signature = signatureFetcher.GetSignature(file, line, column); writer.Write(signature); } catch (Exception ex) { writer.Write(ex.ToString()); } }
private static void handleMessage(CommandMessage msg, IResponseWriter writer, bool serverMode) { if (msg == null) { return; } var handler = _dispatcher.GetHandler(msg.Command); if (handler == null) { writer.Write("comment|" + msg.Command + " is not a valid C# plugin command. For a list of commands type oi."); return; } try { if (handler == null) { return; } handler.Execute(writer, msg.Arguments.ToArray()); } catch (Exception ex) { var builder = new OutputWriter(writer); writeException(builder, ex); } }
public void Execute(IResponseWriter writer, string[] args) { var output = new OutputWriter(writer); if (args.Length != 1) { output.WriteError("crawl-source requires one parameters which is path to the " + "file containing files/directories to crawl"); return; } var crawler = new CSharpCrawler(output, _mainCache); if (Directory.Exists(args[0])) { crawler.Crawl(new CrawlOptions(args[0])); } else { File.ReadAllText(args[0]) .Split(new string[] Â { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList() .ForEach(x => { crawler.Crawl(new CrawlOptions(x)); }); } System.Threading.ThreadPool.QueueUserWorkItem((m) => { var cacheToMerge = (IOutputWriter)m; if (_mainCache != null) { _mainCache.MergeWith(cacheToMerge); } cacheToMerge.Dispose(); GC.Collect(5); }, output); }
internal ControllerContext(IResponseContext context, Controller controller, IResponseWriter writer) { ResponseWriter = writer; ResponseContext = context; Controller = controller; }
public void Execute(IResponseWriter writer, string[] args) { writer.Write(".csproj|.cs"); }
public void Execute(IResponseWriter writer, string[] arguments) { _wasExecuted = true; }
/// <summary> /// Initializes a new instance of the <see cref="StaticFileResponseFactory"/> class. /// </summary> /// <param name="responseWriter">The response writer.</param> public StaticFileResponseFactory(IResponseWriter responseWriter) { _responseWriter = responseWriter; }
public static Task <HttpResponseMessage> Write(this IResponseWriter writer, object response) { return(writer.Write(new ResponseWriterContext(response))); }
/// <summary> /// Initializes a new instance of the <see cref="PageProcessor"/> class. /// </summary> /// <param name="pageBuilder">The page builder.</param> /// <param name="responseWriter">The response writer.</param> /// <param name="redirector">The redirector.</param> public PageProcessor(IPageBuilder pageBuilder, IResponseWriter responseWriter, IRedirector redirector) { _pageBuilder = pageBuilder; _responseWriter = responseWriter; _redirector = redirector; }
public static Task <HttpResponseMessage> Write(this IResponseWriter writer, Configuration configuration, RequestContext context, object response) { return(writer.Write(new ResponseWriterContext(configuration, context, response))); }
public void Execute(IResponseWriter writer, string[] args) { // TODO when the code parsing is done implement this }
public void Send(IResponseWriter response) { VerifyArgument.IsNotNull("response", response); response.Write(this); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("error|Invalid number of arguments. " + "Usage: create {template name} {item name} {template arguments}"); return; } var project = getFile(arguments[1]); var template = pickTemplate(arguments[0]); if (template == null) return; template.Run(project, getArguments(arguments)); writer.Write("Created {0}", project); if (template.File == null) return; gotoFile(writer, template.File.Fullpath, template.Line, template.Column, Path.GetDirectoryName(project)); }
private void gotoFile(IResponseWriter writer, string file, int line, int column, string location) { writer.Write( string.Format("command|editor goto \"{0}|{1}|{2}\"", file, line, column)); writer.Write("command|editor setfocus"); }
public RestfulResult Build(IResponseWriter responseWriter, object content, string viewName, IStatusCodeTranslator statusCodeTranslator, ILocationProvider locationProvider) { return new RestfulResult(responseWriter, content, viewName, _responseUpdater, statusCodeTranslator, locationProvider, _contextHelper); }
private CommandArguments parseArguments(IResponseWriter writer, string[] arguments) { var file = arguments.FirstOrDefault(x => !x.StartsWith("-")); if (file == null) { writer.Write("error|No file argument provided"); return null; } return new CommandArguments() { File = file, Recursive = arguments.Contains("--recursive") || arguments.Contains("-r") }; }
/// <summary> /// Initializes a new instance of the <see cref="StaticFileResponse"/> class. /// </summary> /// <param name="response">The response.</param> /// <param name="responseWriter">The response writer.</param> public StaticFileResponse(IOwinResponse response, IResponseWriter responseWriter) { _response = response; _responseWriter = responseWriter; }
private void RenderEventEvents(IResponseWriter objWriter, ScheduleBoxEvent objEvent) { EventTypes eventCriticalEvents = this.GetEventCriticalEvents(objEvent); if (eventCriticalEvents != EventTypes.None) { objWriter.WriteAttributeString("E", ((int)eventCriticalEvents).ToString()); } }
protected override void RenderControls(IContext objContext, IResponseWriter objWriter, long lngRequestID) { MarkNode(Nodes); base.RenderControls(objContext, objWriter, lngRequestID); }
public ProjectionCoreResponseWriter(IResponseWriter responseWriter) { _writer = responseWriter; }
/// <summary> /// Initializes a new instance of the <see cref="StaticFileResponseFactory"/> class. /// </summary> /// <param name="responseWriter">The response writer.</param> public StaticFileResponseFactory(IResponseWriter responseWriter) => _responseWriter = responseWriter;
/// <summary> /// Initializes a new instance of the <see cref="StaticFilesRequestHandler" /> class. /// </summary> /// <param name="staticFilesPaths">The static files paths.</param> /// <param name="sitePhysicalPath">The environment.</param> /// <param name="responseWriter">The response writer.</param> public StaticFilesRequestHandler(IList <string> staticFilesPaths, string sitePhysicalPath, IResponseWriter responseWriter) { _staticFilesPaths = staticFilesPaths; _sitePhysicalPath = sitePhysicalPath; _responseWriter = responseWriter; }
/// <summary> /// Initializes a new instance of the <see cref="StaticFilesRequestHandler" /> class. /// </summary> /// <param name="staticFilesPaths">The static files paths.</param> /// <param name="sitePhysicalPath">The environment.</param> /// <param name="responseWriter">The response writer.</param> public StaticFilesRequestHandler(IList<string> staticFilesPaths, string sitePhysicalPath, IResponseWriter responseWriter) { _staticFilesPaths = staticFilesPaths; _sitePhysicalPath = sitePhysicalPath; _responseWriter = responseWriter; }
/// <summary> /// Takes the <see cref="HttpContext" /> object, and writes a embed data response. /// </summary> public async Task HandleAsync(HttpContext context) { var queries = context.Request.Query; var url = queries["url"].FirstOrDefault(); var fmt = queries["format"].FirstOrDefault(); EmbedDataResult result = null; string hash = null; string contentType = null; IResponseWriter writer = null; try { if (string.IsNullOrEmpty(fmt) || fmt == "json") { contentType = JSON_CONTENT_TYPE; writer = new JsonResponseWriter(context.Response.Body); } else if (fmt == "xml") { contentType = "text/xml"; writer = new XmlResponseWriter(context.Response.Body); } else { result = new EmbedDataResult() { Succeeded = false, ErrorMessage = "Invalid format." }; } if (result == null) { var hashIndex = url.IndexOf('#'); if (hashIndex >= 0) { hash = url.Substring(hashIndex); url = url.Substring(0, hashIndex); } if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) { _Logger.LogInformation("Handling URL: {0}{1}", url, hash); var mw = int.TryParse(queries["max_width"].FirstOrDefault(), out int w) ? (int?)w : null; var mh = int.TryParse(queries["max_height"].FirstOrDefault(), out int h) ? (int?)h : null; var req = new ConsumerRequest(new Uri(url), mw, mh, fmt); result = await _Service.GetDataAsync(req).ConfigureAwait(false); } else { result = new EmbedDataResult() { Succeeded = false, ErrorMessage = "Invalid URL." }; } } } catch (Exception ex) { _Logger.LogInformation("An exception thrown: {0}", ex); result = new EmbedDataResult() { Succeeded = false, ErrorMessage = "Internal server error." }; if (writer == null) { contentType = JSON_CONTENT_TYPE; writer = new JsonResponseWriter(context.Response.Body); } } if (!result.Succeeded) { context.Response.StatusCode = 404; } context.Response.ContentType = contentType; if (result.Data != null) { await writer.WriteEmbedDataAsync(result.Data, hash); } else { writer.WriteStartResponse(); writer.WriteProperty("error", result.ErrorMessage); await writer.WriteEndResponseAsync(); } }
private static void handleMessage(CommandMessage msg, IResponseWriter writer, bool serverMode) { if (msg == null) return; Logger.Write("Handling message: " + msg); var handler = _dispatcher.GetHandler(msg.Command); if (handler == null) { writer.Write("error|" + msg.Command + " is not a valid C# plugin command. For a list of commands type oi."); return; } try { if (handler == null) return; handler.Execute(writer, msg.Arguments.ToArray()); } catch (Exception ex) { var builder = new OutputWriter(writer); writeException(builder, ex); } Logger.Write("Done handling message"); }
public void Execute(IResponseWriter writer, string[] arguments) { if (arguments.Length < 2) { writer.Write("error|Invalid number of arguments. " + "Usage: new {template name} {item name} {template arguments}"); return; } var className = getFileName(arguments[1]); var location = getLocation(arguments[1]); if (!_project.Read(location, _getTypesProviderByLocation)) return; var template = _pickTemplate(arguments[0], _project.Type); if (template == null) { writer.Write("error|No template with the name {0} exists.", arguments[0]); return; } var ns = getNamespace(location, _project.Fullpath, _project.DefaultNamespace); template.Run(location, className, ns, _project.Fullpath, _project.Type, getArguments(arguments)); if (template.File == null) return; _project.AppendFile(template.File); _project.Write(); writer.Write("Created class {0}.{1}", ns, className); writer.Write("Full path {0}", template.File.Fullpath); gotoFile(writer, template.File.Fullpath, template.Line, template.Column, location); }
public void SetUp() { _responseUpdater = MockRepository.GenerateStub<IResponseUpdater>(); _responseWriter = MockRepository.GenerateStub<IResponseWriter>(); _statusCodeTranslator = MockRepository.GenerateStub<IStatusCodeTranslator>(); _locationProvider = MockRepository.GenerateStub<ILocationProvider>(); _contextHelper = MockRepository.GenerateStub<IContextHelper>(); _content = new {}; }