public static void Create(string rootFolder, bool skipCrawl = true, bool skipPrecompile = true) { _Instance = new WebApplicationProxy(rootFolder, skipCrawl, skipPrecompile); InjectTestValuesIntoHttpRuntime(); _hostingEnvironment = new HostingEnvironmentWrapper(); SubstituteDummyHttpContext("/"); _Instance.InitializeInternal(); }
internal CodeCompileUnit GetCodeModel() { if ((this.sourceString == null) || (this.sourceString.Length == 0)) { return(null); } CodeSnippetCompileUnit unit = new CodeSnippetCompileUnit(this.sourceString); string fileName = HostingEnvironmentWrapper.MapPath(this.virtualPath); unit.LinePragma = new CodeLinePragma(fileName, this.lineNumber); return(unit); }
bool CheckServiceExists(string serviceFile) { try { return((ServiceHostingEnvironment.IsConfigurationBasedService(serviceFile) || HostingEnvironmentWrapper.ServiceFileExists(serviceFile)) && AspNetEnvironment.Current.IsWithinApp(VirtualPathUtility.ToAbsolute(serviceFile))); } catch (ArgumentException ex) { MsmqDiagnostics.ExpectedException(ex); return(false); } }
bool GetServiceFileStreamOrCompiledCustomString(string virtualPath, Uri[] baseAddresses, out Stream serviceFileStream, out string compiledCustomString) { AspNetPartialTrustHelpers.FailIfInPartialTrustOutsideAspNet(); IDisposable unsafeImpersonate = null; compiledCustomString = null; serviceFileStream = null; try { try { try { } finally { unsafeImpersonate = HostingEnvironmentWrapper.UnsafeImpersonate(); } if (HostingEnvironment.VirtualPathProvider.FileExists(virtualPath)) { serviceFileStream = HostingEnvironment.VirtualPathProvider.GetFile(virtualPath).Open(); return(true); } else { if (!AspNetEnvironment.Current.IsConfigurationBased) { compiledCustomString = BuildManager.GetCompiledCustomString(baseAddresses[0].AbsolutePath); } return(false); } } finally { if (null != unsafeImpersonate) { unsafeImpersonate.Dispose(); } } } catch { throw; } }
/// <summary> /// This method returns a code compile unit that will be added /// to the other depdnecies in order to compile /// </summary> internal CodeCompileUnit GetCodeModel() { // Do we have something to compile? // if (sourceString == null || sourceString.Length == 0) { return(null); } CodeSnippetCompileUnit snippetCompileUnit = new CodeSnippetCompileUnit(sourceString); // Put in some context so that the file can be debugged. // string pragmaFile = HostingEnvironmentWrapper.MapPath(virtualPath); snippetCompileUnit.LinePragma = new CodeLinePragma(pragmaFile, lineNumber); return(snippetCompileUnit); }
private bool GetServiceFileStreamOrCompiledCustomString(string virtualPath, Uri[] baseAddresses, out Stream serviceFileStream, out string compiledCustomString) { IDisposable disposable = null; bool flag; compiledCustomString = null; serviceFileStream = null; try { try { try { } finally { disposable = HostingEnvironmentWrapper.UnsafeImpersonate(); } if (HostingEnvironment.VirtualPathProvider.FileExists(virtualPath)) { serviceFileStream = HostingEnvironment.VirtualPathProvider.GetFile(virtualPath).Open(); return(true); } if (!AspNetEnvironment.Current.IsConfigurationBased) { compiledCustomString = BuildManager.GetCompiledCustomString(baseAddresses[0].AbsolutePath); } flag = false; } finally { if (disposable != null) { disposable.Dispose(); } } } catch { throw; } return(flag); }
internal static void GetSupportedVersionStreams(string xamlFileName, out IList <Tuple <string, Stream> > streams) { AspNetPartialTrustHelpers.FailIfInPartialTrustOutsideAspNet(); string virtualFileFolder = string.Format(CultureInfo.InvariantCulture, "~\\{0}", Path.Combine(SupportedVersionsFolder, xamlFileName)); IDisposable unsafeImpersonate = null; List <Tuple <string, Stream> > streamList = new List <Tuple <string, Stream> >(); bool cleanExit = false; streams = null; try { try { try { } finally { unsafeImpersonate = HostingEnvironmentWrapper.UnsafeImpersonate(); } if (HostingEnvironment.VirtualPathProvider.DirectoryExists(virtualFileFolder)) { string xamlFileFolder = HostingEnvironmentWrapper.MapPath(virtualFileFolder); string[] files = Directory.GetFiles(xamlFileFolder, "*.xamlx"); foreach (string file in files) { Stream activityStream; string path = Path.Combine(SupportedVersionsFolder, xamlFileName, Path.GetFileName(file)); string virtualFile = string.Format(CultureInfo.InvariantCulture, "~\\{0}", path); if (HostingEnvironment.VirtualPathProvider.FileExists(virtualFile)) { activityStream = HostingEnvironment.VirtualPathProvider.GetFile(virtualFile).Open(); streamList.Add(Tuple.Create(path, activityStream)); } } } cleanExit = true; } finally { if (unsafeImpersonate != null) { unsafeImpersonate.Dispose(); unsafeImpersonate = null; } } } catch { cleanExit = false; throw; } finally { if (cleanExit) { streams = streamList; } else { foreach (Tuple <string, Stream> stream in streamList) { stream.Item2.Dispose(); } } } }
public override void DecrementBusyCount() { HostingEnvironmentWrapper.DecrementBusyCount(); }
private bool CheckServiceExists(string serviceFile) { try { return(ServiceHostingEnvironment.IsConfigurationBasedService(serviceFile) || HostingEnvironmentWrapper.ServiceFileExists(serviceFile)); } catch (ArgumentException exception) { MsmqDiagnostics.ExpectedException(exception); return(false); } }
public static HostedInnerImpersonationContext UnsafeCreate(IntPtr token) { return(new HostedInnerImpersonationContext(HostingEnvironmentWrapper.UnsafeImpersonate(token))); }