public PluginRegistrationAttribute(string keyName, MessageType messageType, string primaryEntityLogicalName = null, string secondaryEntityLogicalName = null, string[] filteringAttributes = null, string name = null, string userContext = null, int executionOrder = 1, PipelineStage pipelineStage = PipelineStage.Preoperation, ExecutionMode executionMode = ExecutionMode.Synchronous, SupportedDeployment supportedDeployment = SupportedDeployment.ServerOnly, bool deleteAsyncOpOnSuccess = false, string preImageName = null, string[] preImageAttributes = null, string postImageName = null, string[] postImageAttributes = null) { _messageType = messageType; _primaryEntityLogicalName = primaryEntityLogicalName; _secondaryEntityLogicalName = secondaryEntityLogicalName; _filteringAttributes = filteringAttributes; _name = name; _userContext = userContext; _executionOrder = executionOrder; _pipelineStage = pipelineStage; _executionMode = executionMode; _supportedDeployment = supportedDeployment; _deleteAsyncOpOnSuccess = deleteAsyncOpOnSuccess; _preImageName = preImageName; _preImageAttributes = preImageAttributes; _postImageName = postImageName; _postImageAttributes = postImageAttributes; _keyName = keyName; }
public bool MatchesExecutingPlugin(MessageType messageType, string primaryEntityName, string secondaryEntityName, PipelineStage pipelineStage, ExecutionMode executionMode , bool isExecutingOffline, string preImageName, Entity preImage, string postImageName, Entity postImage) { if (_messageType != messageType) return false; if (!string.IsNullOrEmpty(_primaryEntityLogicalName) && string.Equals(_primaryEntityLogicalName, primaryEntityName, StringComparison.InvariantCultureIgnoreCase)) return false; if (secondaryEntityName != _secondaryEntityLogicalName) return false; if (_pipelineStage != pipelineStage) return false; if (_executionMode != executionMode) return false; if (_supportedDeployment == SupportedDeployment.MicrosoftDynamicsCrmClientForOutlookOnly && !isExecutingOffline) return false; if (_supportedDeployment == SupportedDeployment.ServerOnly && isExecutingOffline) return false; if (!string.IsNullOrEmpty(_preImageName) && _preImageName != preImageName) return false; if (!string.IsNullOrEmpty(_postImageName) && _postImageName != preImageName) return false; if (_preImageAttributes != null && !ImageIncludes(_preImageAttributes, preImage)) return false; if (_postImageAttributes != null && !ImageIncludes(_postImageAttributes, postImage)) return false; return true; }
public static IAppBuilder Localize(this IAppBuilder app, PipelineStage stage = PipelineStage.PreHandlerExecute) { if (app == null) { throw new ArgumentNullException("app"); } app.Use( (ctx, next) => { #if DEBUG #else if (!ctx.Request.IsSecure) { string url = "https://" + ctx.Request.Uri.Host + ctx.Request.Uri.PathAndQuery; ctx.Response.Redirect(url); } #endif DetectLanguage(ctx.Request); return next.Invoke(); }); app.UseStageMarker(stage); return app; }
/// <summary> /// Adds a cookie-based authentication middleware to your web application pipeline. /// </summary> /// <param name="app">The IAppBuilder passed to your configuration method</param> /// <param name="options">An options class that controls the middleware behavior</param> /// <param name="stage"></param> /// <returns>The original app parameter</returns> public static IAppBuilder UseCookieAuthentication(this IAppBuilder app, CookieAuthenticationOptions options, PipelineStage stage) { if (app == null) { throw new ArgumentNullException("app"); } app.Use(typeof(CookieAuthenticationMiddleware), app, options); app.UseStageMarker(stage); return app; }
public static IAppBuilder UseCookieAuthentication( this IAppBuilder app, CookieAuthenticationOptions options, DataProtectionProvider dataProtectionProvider, PipelineStage stage = PipelineStage.Authenticate) { var dataProtector = dataProtectionProvider.CreateProtector( "Microsoft.AspNet.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET 5 type options.AuthenticationType, "v2"); options.TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)); return app.UseCookieAuthentication(options, stage); }
/// <summary> /// Initializes a new instance of the <see cref="HlslWriter"/> class. /// </summary> /// <param name="useNodeStack"> /// if set to <c>true</c> [use node stack]. /// </param> public HlslToGlslWriter(GlslShaderPlatform shaderPlatform, int shaderVersion, PipelineStage pipelineStage, bool useNodeStack = false) : base(useNodeStack) { this.shaderPlatform = shaderPlatform; this.shaderVersion = shaderVersion; this.pipelineStage = pipelineStage; if (shaderPlatform == GlslShaderPlatform.OpenGLES) { TrimFloatSuffix = true; GenerateUniformBlocks = shaderVersion >= 300; SupportsTextureBuffer = shaderVersion >= 320; } }
public Pipeline() { Id = Guid.NewGuid(); State = new State<Pipeline>(this); _onAbortPipeline.Reset(this); _onPipelineException.Reset(this); var stage = new PipelineStage("__PipelineEntry"); stage.WithEvent(_onPipelineStarting); _stages.Add(stage); _log = Log.For(this); }
/// <summary> /// Execute the specified pipeline stage with pre-processing and post-processing. /// </summary> /// <param name="stage">The pipeline stage.</param> /// <param name="func">The stage function.</param> /// <param name="targets">The target list of the stage.</param> /// <param name="context">The working context.</param> internal void ExecuteStage(PipelineStage stage, Action <DotProtectContext> func, Func <IList <IDnlibDef> > targets, DotProtectContext context) { foreach (ProtectionPhase pre in preStage[stage]) { context.CheckCancellation(); context.Logger.DebugFormat("Executing '{0}' phase...", pre.Name); pre.Execute(context, new ProtectionParameters(pre.Parent, Filter(context, targets(), pre))); } context.CheckCancellation(); func(context); context.CheckCancellation(); foreach (ProtectionPhase post in postStage[stage]) { context.Logger.DebugFormat("Executing '{0}' phase...", post.Name); post.Execute(context, new ProtectionParameters(post.Parent, Filter(context, targets(), post))); context.CheckCancellation(); } }
static void HandleHttpApplicationPostResolveRequestCacheEvent(object sender, EventArgs e) { VerifyIisDetected(HttpContext.Current); if (HostingEnvironment.VirtualPathProvider.FileExists(HttpContext.Current.Request.Path)) { return; //don't process file files on disk } if (!HandleRootPath && HttpContext.Current.Request.Path == "/") { return; //don't handle root '/' requests in IIS whatsoever. } if (!HandleDirectories && HttpContext.Current.Request.Path != "/" && HostingEnvironment.VirtualPathProvider.DirectoryExists(HttpContext.Current.Request.Path)) { return; //don't handle actual directories that exist } if (!OverrideHttpHandlers && HandlerAlreadyMapped(HttpContext.Current.Request.HttpMethod, HttpContext.Current.Request.Url)) { return; //don't process requests that are handled by IIS handlers } //else continue processing with OpenRasta Log.StartPreExecution(); var context = CommunicationContext; var stage = context.PipelineData.PipelineStage; if (stage == null) { context.PipelineData.PipelineStage = stage = new PipelineStage(HostManager.Resolver.Resolve <IPipeline>()); } stage.SuspendAfter <KnownStages.IUriMatching>(); Host.RaiseIncomingRequestReceived(context); if (ResourceFound(context) || OperationResultSetByCode(context)) { HttpContext.Current.Items[ORIGINAL_PATH_KEY] = HttpContext.Current.Request.Path; // TODO: This is to make the pipeline recognize the request by extension for handler processing. I *think* that's not necessary in integrated but have no memory of what is supposed to happen.... HttpContext.Current.RewritePath(VirtualPathUtility.ToAppRelative("~/ignoreme.rastahook"), false); Log.PathRewrote(); return; } Log.IgnoredRequest(); }
/// <summary> /// Gets the input or output structure. /// </summary> /// <param name="type">The pipeline stage.</param> /// <param name="input">If set to <c>true</c> input, if set to <c>false</c> output.</param> /// <returns></returns> public static StructType GetStream(this Shader shader, PipelineStage type, bool input) { if (type == PipelineStage.Hull || type == PipelineStage.Domain) { throw new NotImplementedException(); } foreach (var typeDecl in shader.Declarations.OfType <StructType>()) { var stream = typeDecl.Attributes.OfType <AttributeDeclaration>().FirstOrDefault(x => x.Name == "Stream"); if (stream != null) { if ((string)stream.Parameters[0].Value == (input ? "Input" : "Output") && (string)stream.Parameters[1].Value == type.ToString()) { return(typeDecl); } } } return(null); }
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslSourcecode">The HLSL source code.</param> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> public global::SiliconStudio.Shaders.Ast.Shader Convert(string hlslSourcecode, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath = null) { try { // Convert from Framework.Graphics ShaderMacro to Framework.Shaders ShaderMacro var macros = new global::SiliconStudio.Shaders.Parser.ShaderMacro[Macros.Count]; for (int index = 0; index < Macros.Count; index++) macros[index] = new global::SiliconStudio.Shaders.Parser.ShaderMacro(Macros[index].Name, Macros[index].Definition); var result = HlslParser.TryPreProcessAndParse(hlslSourcecode, inputHlslFilepath, macros, IncludeDirectories); if (result.HasErrors) { throw new NotImplementedException("Logging"); //DisplayError(log, result, "Error while parsing file:"); return null; } // Prepare the shader before type inference analysis HlslToGlslConvertor.Prepare(result.Shader); HlslSemanticAnalysis.Run(result); // If there are any type inference analysis, just display all errors but ytu if (result.HasErrors) { throw new NotImplementedException("Logging"); //DisplayError(log, result, "Error with type inferencing:"); } return Convert(result, hlslEntryPoint, stage, inputHlslFilepath); } catch (Exception ex) { throw new NotImplementedException("Logging"); //log.WriteLine("Unexpected error while converting file [{0}] with entry point [{1}] : {2}", inputHlslFilepath, hlslEntryPoint, ex.Message); return null; } }
/// <summary> /// Parses the specified full profile (vs_4_0) and output the stage as well. /// </summary> /// <param name="profile">The profile.</param> /// <param name="stage">The stage.</param> /// <returns>Return the ShaderModel default to 3.0 if not parsed correctly.</returns> public static ShaderModel Parse(string profile, out PipelineStage stage) { profile = profile.ToLower(CultureInfo.InvariantCulture); if (profile.StartsWith("vs")) stage = PipelineStage.Vertex; else if (profile.StartsWith("ps")) stage = PipelineStage.Pixel; else if (profile.StartsWith("gs")) stage = PipelineStage.Geometry; else if (profile.StartsWith("cs")) stage = PipelineStage.Compute; else if (profile.StartsWith("hs")) stage = PipelineStage.Hull; else if (profile.StartsWith("ds")) stage = PipelineStage.Domain; else { stage = PipelineStage.None; } return profile.Length > 4 ? Parse(profile.Substring(3)) : ShaderModel.Model30; }
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslSourcecode">The HLSL source code.</param> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> public global::SiliconStudio.Shaders.Ast.Shader Convert(string hlslSourcecode, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath, IDictionary<int, string> inputAttributeNames, LoggerResult log) { try { // Convert from Framework.Graphics ShaderMacro to Framework.Shaders ShaderMacro var macros = new global::SiliconStudio.Shaders.Parser.ShaderMacro[Macros.Count]; for (int index = 0; index < Macros.Count; index++) macros[index] = new global::SiliconStudio.Shaders.Parser.ShaderMacro(Macros[index].Name, Macros[index].Definition); var result = HlslParser.TryPreProcessAndParse(hlslSourcecode, inputHlslFilepath, macros, IncludeDirectories); if (result.HasErrors) { log.Error(result.ToString()); return null; } // Prepare the shader before type inference analysis HlslToGlslConvertor.Prepare(result.Shader); HlslSemanticAnalysis.Run(result); // If there are any type inference analysis, just display all errors but ytu if (result.HasErrors) { log.Error(result.ToString()); return null; } return Convert(result, hlslEntryPoint, stage, inputHlslFilepath, inputAttributeNames, log); } catch (Exception ex) { log.Error("Unexpected error while converting file [{0}] with entry point [{1}]", ex, inputHlslFilepath, hlslEntryPoint); } return null; }
/// <summary> /// Inserts the phase into post-processing pipeline of the specified stage. /// </summary> /// <param name="stage">The pipeline stage.</param> /// <param name="phase">The protection phase.</param> // Token: 0x060002FB RID: 763 RVA: 0x00012840 File Offset: 0x00010A40 public void InsertPostStage(PipelineStage stage, ProtectionPhase phase) { this.postStage[stage].Add(phase); }
/// <summary> /// In order for preview to work this needs to be called /// </summary> /// <param name="app"></param> /// <param name="umbracoContextAccessor"></param> /// <param name="runtimeState"></param> /// <param name="globalSettings"></param> /// <param name="securitySettings"></param> /// <param name="stage"></param> /// <returns></returns> /// <remarks> /// This ensures that during a preview request that the back office use is also Authenticated and that the back office Identity /// is added as a secondary identity to the current IPrincipal so it can be used to Authorize the previewed document. /// </remarks> public static IAppBuilder UseUmbracoPreviewAuthentication(this IAppBuilder app, IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtimeState, IGlobalSettings globalSettings, ISecuritySection securitySettings, PipelineStage stage) { if (runtimeState.Level != RuntimeLevel.Run) { return(app); } var authOptions = app.CreateUmbracoCookieAuthOptions(umbracoContextAccessor, globalSettings, runtimeState, securitySettings); app.Use(typeof(PreviewAuthenticationMiddleware), authOptions, Current.Configs.Global()); // This middleware must execute at least on PostAuthentication, by default it is on Authorize // The middleware needs to execute after the RoleManagerModule executes which is during PostAuthenticate, // currently I've had 100% success with ensuring this fires after RoleManagerModule even if this is set // to PostAuthenticate though not sure if that's always a guarantee so by default it's Authorize. if (stage < PipelineStage.PostAuthenticate) { throw new InvalidOperationException("The stage specified for UseUmbracoPreviewAuthentication must be greater than or equal to " + PipelineStage.PostAuthenticate); } app.UseStageMarker(stage); return(app); }
private static void UseUmbracoBackOfficeCookieAuthenticationInternal(this IAppBuilder app, CookieAuthenticationOptions options, IRuntimeState runtimeState, PipelineStage stage) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (runtimeState == null) { throw new ArgumentNullException(nameof(runtimeState)); } //First the normal cookie middleware app.Use(typeof(CookieAuthenticationMiddleware), app, options); //don't apply if app is not ready if (runtimeState.Level == RuntimeLevel.Upgrade || runtimeState.Level == RuntimeLevel.Run) { //Then our custom middlewares app.Use(typeof(ForceRenewalCookieAuthenticationMiddleware), app, options, Current.UmbracoContextAccessor); app.Use(typeof(FixWindowsAuthMiddlware)); } //Marks all of the above middlewares to execute on Authenticate app.UseStageMarker(stage); }
/// <summary> /// Ensures that the UmbracoBackOfficeAuthenticationMiddleware is assigned to the pipeline /// </summary> /// <param name="app"></param> /// <param name="umbracoContextAccessor"></param> /// <param name="runtimeState"></param> /// <param name="userService"></param> /// <param name="globalSettings"></param> /// <param name="securitySection"></param> /// <param name="stage"> /// Configurable pipeline stage /// </param> /// <returns></returns> public static IAppBuilder UseUmbracoBackOfficeCookieAuthentication(this IAppBuilder app, IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtimeState, IUserService userService, IGlobalSettings globalSettings, ISecuritySection securitySection, PipelineStage stage) { //Create the default options and provider var authOptions = app.CreateUmbracoCookieAuthOptions(umbracoContextAccessor, globalSettings, runtimeState, securitySection); authOptions.Provider = new BackOfficeCookieAuthenticationProvider(userService, runtimeState, globalSettings) { // Enables the application to validate the security stamp when the user // logs in. This is a security feature which is used when you // change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator .OnValidateIdentity <BackOfficeUserManager, BackOfficeIdentityUser, int>( TimeSpan.FromMinutes(30), (manager, user) => manager.GenerateUserIdentityAsync(user), identity => identity.GetUserId <int>()), }; return(app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, runtimeState, globalSettings, securitySection, authOptions, stage)); }
static void HandleHttpApplicationPostResolveRequestCacheEvent(object sender, EventArgs e) { VerifyIisDetected(HttpContext.Current); if (ShouldIgnoreRequest()) { Log.IgnoredRequest(); return; } //else continue processing with OpenRasta Log.StartPreExecution(); var context = CommunicationContext; var stage = context.PipelineData.PipelineStage; if (stage == null) context.PipelineData.PipelineStage = stage = new PipelineStage(HostManager.Resolver.Resolve<IPipeline>()); stage.SuspendAfter<KnownStages.IUriMatching>(); Host.RaiseIncomingRequestReceived(context); if (!ResourceFound(context) && !OperationResultSetByCode(context)) { Log.IgnoredRequest(); return; } ; HttpContext.Current.Items[ORIGINAL_PATH_KEY] = HttpContext.Current.Request.Path; // TODO: This is to make the pipeline recognize the request by extension for handler processing. I *think* that's not necessary in integrated but have no memory of what is supposed to happen.... HttpContext.Current.RewritePath(VirtualPathUtility.ToAppRelative("~/ignoreme.rastahook"), false); Log.PathRewrote(); }
private string Compile(string shaderSource, string entryPoint, ShaderStage stage, GlslShaderPlatform shaderPlatform, int shaderVersion, ShaderBytecodeResult shaderBytecodeResult, EffectReflection reflection, string sourceFilename = null) { if (shaderPlatform == GlslShaderPlatform.OpenGLES && shaderVersion < 300 && renderTargetCount > 1) { shaderBytecodeResult.Error("OpenGL ES 2 does not support multiple render targets."); } PipelineStage pipelineStage = PipelineStage.None; switch (stage) { case ShaderStage.Vertex: pipelineStage = PipelineStage.Vertex; break; case ShaderStage.Pixel: pipelineStage = PipelineStage.Pixel; break; case ShaderStage.Geometry: shaderBytecodeResult.Error("Geometry stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Hull: shaderBytecodeResult.Error("Hull stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Domain: shaderBytecodeResult.Error("Domain stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Compute: shaderBytecodeResult.Error("Compute stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; default: shaderBytecodeResult.Error("Unknown shader profile."); break; } if (shaderBytecodeResult.HasErrors) { return(null); } Shader glslShader; // null entry point means no shader. In that case, we return a default function in HlslToGlslWriter // TODO: support that directly in HlslToGlslConvertor? if (entryPoint == null) { glslShader = null; } else { // Convert from HLSL to GLSL // Note that for now we parse from shader as a string, but we could simply clone effectPass.Shader to avoid multiple parsing. var glslConvertor = new ShaderConverter(shaderPlatform, shaderVersion); glslShader = glslConvertor.Convert(shaderSource, entryPoint, pipelineStage, sourceFilename, shaderBytecodeResult); if (glslShader == null || shaderBytecodeResult.HasErrors) { return(null); } foreach (var constantBuffer in glslShader.Declarations.OfType <ConstantBuffer>()) { // Update constant buffer itself (first time only) var reflectionConstantBuffer = reflection.ConstantBuffers.FirstOrDefault(x => x.Name == constantBuffer.Name && x.Size == 0); if (reflectionConstantBuffer != null) { // Used to compute constant buffer size and member offsets (std140 rule) int constantBufferOffset = 0; // Fill members for (int index = 0; index < reflectionConstantBuffer.Members.Length; index++) { var member = reflectionConstantBuffer.Members[index]; // Properly compute size and offset according to std140 rules var memberSize = ComputeMemberSize(ref member.Type, ref constantBufferOffset); // Store size/offset info member.Offset = constantBufferOffset; member.Size = memberSize; // Adjust offset for next item constantBufferOffset += memberSize; reflectionConstantBuffer.Members[index] = member; } reflectionConstantBuffer.Size = constantBufferOffset; } // Find binding var resourceBindingIndex = reflection.ResourceBindings.IndexOf(x => x.RawName == constantBuffer.Name); if (resourceBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, resourceBindingIndex, stage); } } foreach (var variable in glslShader.Declarations.OfType <Variable>().Where(x => (x.Qualifiers.Contains(StorageQualifier.Uniform)))) { // Check if we have a variable that starts or ends with this name (in case of samplers) // TODO: Have real AST support for all the list in Keywords.glsl if (variable.Type.Name.Text.Contains("sampler1D") || variable.Type.Name.Text.Contains("sampler2D") || variable.Type.Name.Text.Contains("sampler3D") || variable.Type.Name.Text.Contains("samplerCube")) { // TODO: Make more robust var textureBindingIndex = reflection.ResourceBindings.IndexOf(x => variable.Name.ToString().StartsWith(x.RawName)); var samplerBindingIndex = reflection.ResourceBindings.IndexOf(x => variable.Name.ToString().EndsWith(x.RawName)); if (textureBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, textureBindingIndex, stage); } if (samplerBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, samplerBindingIndex, stage); } } else { var resourceBindingIndex = reflection.ResourceBindings.IndexOf(x => x.RawName == variable.Name); if (resourceBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, resourceBindingIndex, stage); } } } } // Output the result var glslShaderWriter = new HlslToGlslWriter(shaderPlatform, shaderVersion, pipelineStage); if (shaderPlatform == GlslShaderPlatform.OpenGLES && shaderVersion < 320) { glslShaderWriter.ExtraHeaders = "#define texelFetchBufferPlaceholder"; } // Write shader glslShaderWriter.Visit(glslShader); var shaderString = glslShaderWriter.Text; // Build shader source var glslShaderCode = new StringBuilder(); // Append some header depending on target //if (isOpenGLES) //{ // if (isOpenGLES3) // { // glslShaderCode // .AppendLine("#version 300 es") // TODO: 310 version? // .AppendLine(); // } // // if (pipelineStage == PipelineStage.Pixel) // glslShaderCode // .AppendLine("precision highp float;") // .AppendLine(); //} //else //{ // glslShaderCode // .AppendLine("#version 420") // .AppendLine() // .AppendLine("#define samplerBuffer sampler2D") // .AppendLine("#define isamplerBuffer isampler2D") // .AppendLine("#define usamplerBuffer usampler2D") // .AppendLine("#define texelFetchBuffer(sampler, P) texelFetch(sampler, ivec2((P) & 0xFFF, (P) >> 12), 0)"); // //.AppendLine("#define texelFetchBuffer(sampler, P) texelFetch(sampler, P)"); //} glslShaderCode.Append(shaderString); var realShaderSource = glslShaderCode.ToString(); #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP // optimize shader try { var optShaderSource = RunOptimizer(shaderBytecodeResult, realShaderSource, shaderPlatform, shaderVersion, pipelineStage == PipelineStage.Vertex); if (!String.IsNullOrEmpty(optShaderSource)) { realShaderSource = optShaderSource; } } catch (Exception e) { shaderBytecodeResult.Warning("Could not run GLSL optimizer:\n{0}", e.Message); } #else shaderBytecodeResult.Warning("GLSL optimized has not been executed because it is currently not supported on this platform."); #endif return(realShaderSource); }
/// <summary> /// Enable the back office to detect and handle errors registered with external login providers /// </summary> /// <param name="app"></param> /// <param name="stage"></param> /// <returns></returns> public static IAppBuilder UseUmbracoBackOfficeExternalLoginErrors(this IAppBuilder app, PipelineStage stage = PipelineStage.Authorize) { app.Use(typeof(BackOfficeExternalLoginProviderErrorMiddlware)); app.UseStageMarker(stage); return(app); }
/// <summary> /// Runs against all entities. /// </summary> /// <param name="stage"></param> /// <param name="message"></param> /// <param name="execute"></param> public RegisteredEvent(PipelineStage stage, MessageType message, Action <IExtendedPluginContext> execute) : this(stage, message, execute, null) { }
/// <summary> /// Defaults the execute method to be InternalExecute and runs against the specified entity. /// </summary> /// <param name="stage"></param> /// <param name="message"></param> /// <param name="entityLogicalName"></param> public RegisteredEvent(PipelineStage stage, MessageType message, string entityLogicalName) : this(stage, message, null, entityLogicalName) { }
static void HandleHttpApplicationPostResolveRequestCacheEvent(object sender, EventArgs e) { VerifyIisDetected(HttpContext.Current); if (HostingEnvironment.VirtualPathProvider.FileExists(HttpContext.Current.Request.Path)) return; //don't process file files on disk if (!HandleRootPath && HttpContext.Current.Request.Path == "/") return; //don't handle root '/' requests in IIS whatsoever. if (!HandleDirectories && HttpContext.Current.Request.Path != "/" && HostingEnvironment.VirtualPathProvider.DirectoryExists(HttpContext.Current.Request.Path)) return; //don't handle actual directories that exist if (!OverrideHttpHandlers && HandlerAlreadyMapped(HttpContext.Current.Request.HttpMethod, HttpContext.Current.Request.Url)) return; //don't process requests that are handled by IIS handlers //else continue processing with OpenRasta Log.StartPreExecution(); var context = CommunicationContext; var stage = context.PipelineData.PipelineStage; if (stage == null) context.PipelineData.PipelineStage = stage = new PipelineStage(HostManager.Resolver.Resolve<IPipeline>()); stage.SuspendAfter<KnownStages.IUriMatching>(); Host.RaiseIncomingRequestReceived(context); if (context.PipelineData.ResourceKey != null || context.OperationResult != null) { // TODO: This is to make the pipeline recognize the request by extension for handler processing. I *think* that's not necessary in integrated but have no memory of what is supposed to happen.... HttpContext.Current.Items[ORIGINAL_PATH_KEY] = HttpContext.Current.Request.Path; HttpContext.Current.RewritePath(VirtualPathUtility.ToAppRelative("~/ignoreme.rastahook"), false); Log.PathRewrote(); return; } Log.IgnoredRequest(); }
void RunCallGraph(ICommunicationContext context, PipelineStage stage) { lock (stage) { foreach (var contrib in stage) { if (!CanBeExecuted(contrib)) continue; stage.CurrentState = ExecuteContributor(context, contrib); switch (stage.CurrentState) { case PipelineContinuation.Abort: AbortPipeline(context); goto case PipelineContinuation.RenderNow; case PipelineContinuation.RenderNow: RenderNow(context, stage); return; case PipelineContinuation.Finished: FinishPipeline(context); return; } } } }
/// <summary> /// Call after other middleware to specify when they should run in the integrated pipeline. /// </summary> /// <param name="app">The IAppBuilder.</param> /// <param name="stage">The stage of the integrated pipeline in which to run.</param> /// <returns>The original IAppBuilder for chaining.</returns> public static IAppBuilder UseStageMarker(this IAppBuilder app, PipelineStage stage) { return UseStageMarker(app, stage.ToString()); }
/// <summary> /// Insert Pre ProtectionPhase(<paramref name="ProtectionPhase"/>) PipelineStage(<paramref name="Stage"/>). /// </summary> /// <param name="Stage">PipelineStage That Get Added.</param> /// <param name="ProtectionPhase">Phase Will Added Into Specified Stage.</param> public void InsertPreStage(PipelineStage Stage, ProtectionPhase ProtectionPhase) => _prestages[Stage].Add(ProtectionPhase);
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> private global::SiliconStudio.Shaders.Ast.Shader Convert(ParsingResult result, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath, IDictionary<int, string> inputAttributeNames, LoggerResult log) { try { var convertor = new HlslToGlslConvertor(shaderPlatform, shaderVersion, hlslEntryPoint, stage, ShaderModel.Model40) // TODO HARDCODED VALUE to change { // Those settings are now default values //NoSwapForBinaryMatrixOperation = true, //UnrollForLoops = true, //ViewFrustumRemap = true, //FlipRenderTarget = true, //KeepConstantBuffer = !isOpenGLES || isOpenGLES3, //TextureFunctionsCompatibilityProfile = isOpenGLES && !isOpenGLES3, //KeepNonUniformArrayInitializers = !isOpenGLES, UseBindingLayout = false, UseSemanticForVariable = true, IsPointSpriteShader = false, InputAttributeNames = inputAttributeNames }; convertor.Run(result); // After the converter we display the errors but we don't stop writing output glsl if (result.HasErrors) { //DisplayError(log, result, "Error while converting file:"); } return result.Shader; } catch (Exception ex) { log.Error("Unexpected error while converting file [{0}] with entry point [{1}]", ex, inputHlslFilepath, hlslEntryPoint); return null; } }
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> private global::SiliconStudio.Shaders.Ast.Shader Convert(ParsingResult result, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath, LoggerResult log) { try { var convertor = new HlslToGlslConvertor(hlslEntryPoint, stage, ShaderModel.Model40) // TODO HARDCODED VALUE to change { KeepConstantBuffer = !isOpenGLES || isOpenGLES3, TextureFunctionsCompatibilityProfile = isOpenGLES && !isOpenGLES3, NoSwapForBinaryMatrixOperation = true, UseBindingLayout = false, UseLocationLayout = false, UseSemanticForVariable = true, IsPointSpriteShader = false, ViewFrustumRemap = true, FlipRenderTargetFlag = "ParadoxFlipRendertarget", KeepNonUniformArrayInitializers = !isOpenGLES, IsOpenGLES2 = isOpenGLES && !isOpenGLES3 }; convertor.Run(result); // After the converter we display the errors but we don't stop writing output glsl if (result.HasErrors) { //DisplayError(log, result, "Error while converting file:"); } return result.Shader; } catch (Exception ex) { log.Error("Unexpected error while converting file [{0}] with entry point [{1}]", ex, inputHlslFilepath, hlslEntryPoint); return null; } }
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> private global::SiliconStudio.Shaders.Ast.Shader Convert(ParsingResult result, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath, IDictionary <int, string> inputAttributeNames, LoggerResult log) { try { var convertor = new HlslToGlslConvertor(shaderPlatform, shaderVersion, hlslEntryPoint, stage, ShaderModel.Model40) // TODO HARDCODED VALUE to change { // Those settings are now default values //NoSwapForBinaryMatrixOperation = true, //UnrollForLoops = true, //ViewFrustumRemap = true, //FlipRenderTarget = true, //KeepConstantBuffer = !isOpenGLES || isOpenGLES3, //TextureFunctionsCompatibilityProfile = isOpenGLES && !isOpenGLES3, //KeepNonUniformArrayInitializers = !isOpenGLES, UseBindingLayout = false, UseSemanticForVariable = true, IsPointSpriteShader = false, InputAttributeNames = inputAttributeNames }; convertor.Run(result); // After the converter we display the errors but we don't stop writing output glsl if (result.HasErrors) { //DisplayError(log, result, "Error while converting file:"); } return(result.Shader); } catch (Exception ex) { log.Error("Unexpected error while converting file [{0}] with entry point [{1}]", ex, inputHlslFilepath, hlslEntryPoint); return(null); } }
private string Compile(string shaderSource, string entryPoint, ShaderStage stage, GlslShaderPlatform shaderPlatform, int shaderVersion, ShaderBytecodeResult shaderBytecodeResult, EffectReflection reflection, IDictionary <int, string> inputAttributeNames, Dictionary <string, int> resourceBindings, string sourceFilename = null) { if (shaderPlatform == GlslShaderPlatform.OpenGLES && shaderVersion < 300 && renderTargetCount > 1) { shaderBytecodeResult.Error("OpenGL ES 2 does not support multiple render targets."); } PipelineStage pipelineStage = PipelineStage.None; switch (stage) { case ShaderStage.Vertex: pipelineStage = PipelineStage.Vertex; break; case ShaderStage.Pixel: pipelineStage = PipelineStage.Pixel; break; case ShaderStage.Geometry: shaderBytecodeResult.Error("Geometry stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Hull: shaderBytecodeResult.Error("Hull stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Domain: shaderBytecodeResult.Error("Domain stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Compute: shaderBytecodeResult.Error("Compute stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; default: shaderBytecodeResult.Error("Unknown shader profile."); break; } if (shaderBytecodeResult.HasErrors) { return(null); } Shader glslShader; // null entry point means no shader. In that case, we return a default function in HlslToGlslWriter // TODO: support that directly in HlslToGlslConvertor? if (entryPoint == null) { glslShader = null; } else { // Convert from HLSL to GLSL // Note that for now we parse from shader as a string, but we could simply clone effectPass.Shader to avoid multiple parsing. var glslConvertor = new ShaderConverter(shaderPlatform, shaderVersion); glslShader = glslConvertor.Convert(shaderSource, entryPoint, pipelineStage, sourceFilename, inputAttributeNames, shaderBytecodeResult); if (glslShader == null || shaderBytecodeResult.HasErrors) { return(null); } foreach (var constantBuffer in glslShader.Declarations.OfType <ConstantBuffer>()) { // Update constant buffer itself (first time only) var reflectionConstantBuffer = reflection.ConstantBuffers.FirstOrDefault(x => x.Name == constantBuffer.Name && x.Size == 0); if (reflectionConstantBuffer != null) { // Used to compute constant buffer size and member offsets (std140 rule) int constantBufferOffset = 0; // Fill members for (int index = 0; index < reflectionConstantBuffer.Members.Length; index++) { var member = reflectionConstantBuffer.Members[index]; // Properly compute size and offset according to std140 rules var memberSize = ComputeMemberSize(ref member.Type, ref constantBufferOffset); // Store size/offset info member.Offset = constantBufferOffset; member.Size = memberSize; // Adjust offset for next item constantBufferOffset += memberSize; reflectionConstantBuffer.Members[index] = member; } reflectionConstantBuffer.Size = constantBufferOffset; } // Find binding var resourceBindingIndex = reflection.ResourceBindings.IndexOf(x => x.RawName == constantBuffer.Name); if (resourceBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, resourceBindingIndex, stage); } } foreach (var variable in glslShader.Declarations.OfType <Variable>().Where(x => (x.Qualifiers.Contains(StorageQualifier.Uniform)))) { // Check if we have a variable that starts or ends with this name (in case of samplers) // TODO: Have real AST support for all the list in Keywords.glsl if (variable.Type.Name.Text.Contains("sampler1D") || variable.Type.Name.Text.Contains("sampler2D") || variable.Type.Name.Text.Contains("sampler3D") || variable.Type.Name.Text.Contains("samplerCube") || variable.Type.Name.Text.Contains("samplerBuffer")) { // TODO: Make more robust var textureBindingIndex = reflection.ResourceBindings.IndexOf(x => variable.Name.ToString().StartsWith(x.RawName)); var samplerBindingIndex = reflection.ResourceBindings.IndexOf(x => variable.Name.ToString().EndsWith(x.RawName)); if (textureBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, textureBindingIndex, stage); } if (samplerBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, samplerBindingIndex, stage); } } else { var resourceBindingIndex = reflection.ResourceBindings.IndexOf(x => x.RawName == variable.Name); if (resourceBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, resourceBindingIndex, stage); } } } if (shaderPlatform == GlslShaderPlatform.Vulkan) { // Defines the ordering of resource groups in Vulkan. This is mirrored in the PipelineState var resourceGroups = reflection.ResourceBindings.Select(x => x.ResourceGroup ?? "Globals").Distinct().ToList(); // Register "NoSampler", required by HLSL=>GLSL translation to support HLSL such as texture.Load(). var noSampler = new EffectResourceBindingDescription { KeyInfo = { KeyName = "NoSampler" }, RawName = "NoSampler", Class = EffectParameterClass.Sampler, SlotStart = -1, SlotCount = 1 }; reflection.ResourceBindings.Add(noSampler); var bindings = resourceGroups.SelectMany(resourceGroup => reflection.ResourceBindings .Where(x => x.ResourceGroup == resourceGroup || (x.ResourceGroup == null && resourceGroup == "Globals")) .GroupBy(x => new { KeyName = x.KeyInfo.KeyName, RawName = x.RawName, Class = x.Class, Type = x.Type, SlotCount = x.SlotCount, LogicalGroup = x.LogicalGroup }) .OrderBy(x => x.Key.Class == EffectParameterClass.ConstantBuffer ? 0 : 1)) .ToList(); // Add layout(set, bindings) qualifier to all constant buffers foreach (var constantBuffer in glslShader.Declarations.OfType <ConstantBuffer>()) { var layoutBindingIndex = bindings.IndexOf(x => x.Key.RawName == constantBuffer.Name); if (layoutBindingIndex != -1) { var layoutQualifier = constantBuffer.Qualifiers.OfType <Xenko.Core.Shaders.Ast.Glsl.LayoutQualifier>().FirstOrDefault(); if (layoutQualifier == null) { layoutQualifier = new Xenko.Core.Shaders.Ast.Glsl.LayoutQualifier(); constantBuffer.Qualifiers |= layoutQualifier; } //layoutQualifier.Layouts.Add(new LayoutKeyValue("set", resourceGroups.IndexOf(resourceGroup))); layoutQualifier.Layouts.Add(new LayoutKeyValue("set", 0)); layoutQualifier.Layouts.Add(new LayoutKeyValue("binding", layoutBindingIndex + 1)); resourceBindings.Add(bindings[layoutBindingIndex].Key.KeyName, layoutBindingIndex + 1); } } // Add layout(set, bindings) qualifier to all other uniforms foreach (var variable in glslShader.Declarations.OfType <Variable>().Where(x => (x.Qualifiers.Contains(StorageQualifier.Uniform)))) { var layoutBindingIndex = bindings.IndexOf(x => variable.Name.Text.StartsWith(x.Key.RawName)); if (layoutBindingIndex != -1) { var layoutQualifier = variable.Qualifiers.OfType <Xenko.Core.Shaders.Ast.Glsl.LayoutQualifier>().FirstOrDefault(); if (layoutQualifier == null) { layoutQualifier = new Xenko.Core.Shaders.Ast.Glsl.LayoutQualifier(); variable.Qualifiers |= layoutQualifier; } //layoutQualifier.Layouts.Add(new LayoutKeyValue("set", resourceGroups.IndexOf(resourceGroup))); layoutQualifier.Layouts.Add(new LayoutKeyValue("set", 0)); layoutQualifier.Layouts.Add(new LayoutKeyValue("binding", layoutBindingIndex + 1)); resourceBindings.Add(bindings[layoutBindingIndex].Key.KeyName, layoutBindingIndex + 1); } } } } // Output the result var glslShaderWriter = new HlslToGlslWriter(shaderPlatform, shaderVersion, pipelineStage); if (shaderPlatform == GlslShaderPlatform.OpenGLES && shaderVersion < 320) { glslShaderWriter.ExtraHeaders = "#define texelFetchBufferPlaceholder"; } // Write shader glslShaderWriter.Visit(glslShader); var shaderString = glslShaderWriter.Text; // Build shader source var glslShaderCode = new StringBuilder(); // Append some header depending on target //if (isOpenGLES) //{ // if (isOpenGLES3) // { // glslShaderCode // .AppendLine("#version 300 es") // TODO: 310 version? // .AppendLine(); // } // // if (pipelineStage == PipelineStage.Pixel) // glslShaderCode // .AppendLine("precision highp float;") // .AppendLine(); //} //else //{ // glslShaderCode // .AppendLine("#version 420") // .AppendLine() // .AppendLine("#define samplerBuffer sampler2D") // .AppendLine("#define isamplerBuffer isampler2D") // .AppendLine("#define usamplerBuffer usampler2D") // .AppendLine("#define texelFetchBuffer(sampler, P) texelFetch(sampler, ivec2((P) & 0xFFF, (P) >> 12), 0)"); // //.AppendLine("#define texelFetchBuffer(sampler, P) texelFetch(sampler, P)"); //} glslShaderCode.Append(shaderString); var realShaderSource = glslShaderCode.ToString(); return(realShaderSource); }
/// <summary> /// Initializes a new instance of the <see cref="HlslWriter"/> class. /// </summary> /// <param name="useNodeStack"> /// if set to <c>true</c> [use node stack]. /// </param> public HlslToGlslWriter(GlslShaderPlatform shaderPlatform, int shaderVersion, PipelineStage pipelineStage, bool useNodeStack = false) : base(useNodeStack) { this.shaderPlatform = shaderPlatform; this.shaderVersion = shaderVersion; this.pipelineStage = pipelineStage; if (shaderPlatform == GlslShaderPlatform.OpenGLES) { TrimFloatSuffix = true; GenerateUniformBlocks = shaderVersion >= 300; SupportsTextureBuffer = shaderVersion >= 320; } }
static void HandleHttpApplicationPostResolveRequestCacheEvent(object sender, EventArgs e) { VerifyIisDetected(HttpContext.Current); if (!HostingEnvironment.VirtualPathProvider.FileExists(HttpContext.Current.Request.Path) && (HttpContext.Current.Request.Path == "/" || !HostingEnvironment.VirtualPathProvider.DirectoryExists(HttpContext.Current.Request.Path)) && !HandlerAlreadyMapped(HttpContext.Current.Request.HttpMethod, HttpContext.Current.Request.Url)) { Log.StartPreExecution(); var context = CommunicationContext; var stage = context.PipelineData.PipelineStage; if (stage == null) context.PipelineData.PipelineStage = stage = new PipelineStage(HostManager.Resolver.Resolve<IPipeline>()); stage.SuspendAfter<KnownStages.IUriMatching>(); Host.RaiseIncomingRequestReceived(context); if (context.PipelineData.ResourceKey != null || context.OperationResult != null) { HttpContext.Current.Items[ORIGINAL_PATH_KEY] = HttpContext.Current.Request.Path; HttpContext.Current.RewritePath(VirtualPathUtility.ToAppRelative("~/ignoreme.rastahook"), false); Log.PathRewrote(); return; } Log.IgnoredRequest(); } }
void RenderNow(ICommunicationContext context, PipelineStage stage) { PipelineLog.WriteDebug("Pipeline is in RenderNow mode."); if (!stage.ResumeFrom<KnownStages.IOperationResultInvocation>()) { using (PipelineLog.Operation(this, "Rendering contributor has already been executed. Calling a nested pipeline to render the error.")) { var nestedPipeline = new PipelineStage(this); if (!nestedPipeline.ResumeFrom<KnownStages.IOperationResultInvocation>()) throw new InvalidOperationException("Could not find an IOperationResultInvocation in the new pipeline."); RunCallGraph(context, nestedPipeline); } } }
private BasePlugin RegisterMessage(PipelineStage stage, string messageName) { this.availableMessages.Add(stage + messageName); return(this); }
/// <summary> /// Ensures that the UmbracoBackOfficeAuthenticationMiddleware is assigned to the pipeline /// </summary> /// <param name="app"></param> /// <param name="umbracoContextAccessor"></param> /// <param name="runtimeState"></param> /// <param name="globalSettings"></param> /// <param name="securitySection"></param> /// <param name="cookieOptions">Custom auth cookie options can be specified to have more control over the cookie authentication logic</param> /// <param name="stage"> /// Configurable pipeline stage /// </param> /// <returns></returns> public static IAppBuilder UseUmbracoBackOfficeCookieAuthentication(this IAppBuilder app, IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtimeState, IGlobalSettings globalSettings, ISecuritySection securitySection, CookieAuthenticationOptions cookieOptions, PipelineStage stage) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (runtimeState == null) { throw new ArgumentNullException(nameof(runtimeState)); } if (cookieOptions == null) { throw new ArgumentNullException(nameof(cookieOptions)); } if (cookieOptions.Provider == null) { throw new ArgumentNullException("cookieOptions.Provider cannot be null.", nameof(cookieOptions)); } if (cookieOptions.Provider is BackOfficeCookieAuthenticationProvider == false) { throw new ArgumentException($"cookieOptions.Provider must be of type {typeof(BackOfficeCookieAuthenticationProvider)}.", nameof(cookieOptions)); } app.UseUmbracoBackOfficeCookieAuthenticationInternal(cookieOptions, runtimeState, stage); //don't apply if app is not ready if (runtimeState.Level != RuntimeLevel.Upgrade && runtimeState.Level != RuntimeLevel.Run) { return(app); } var cookieAuthOptions = app.CreateUmbracoCookieAuthOptions( umbracoContextAccessor, globalSettings, runtimeState, securitySection, //This defines the explicit path read cookies from for this middleware new[] { $"{globalSettings.Path}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds" }); cookieAuthOptions.Provider = cookieOptions.Provider; //This is a custom middleware, we need to return the user's remaining logged in seconds app.Use <GetUserSecondsMiddleWare>( cookieAuthOptions, Current.Configs.Global(), Current.Configs.Settings().Security, app.CreateLogger <GetUserSecondsMiddleWare>()); //This is required so that we can read the auth ticket format outside of this pipeline app.CreatePerOwinContext <UmbracoAuthTicketDataProtector>( (options, context) => new UmbracoAuthTicketDataProtector(cookieOptions.TicketDataFormat)); return(app); }
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslSourcecode">The HLSL source code.</param> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> public global::SiliconStudio.Shaders.Ast.Shader Convert(string hlslSourcecode, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath, LoggerResult log) { try { // Convert from Framework.Graphics ShaderMacro to Framework.Shaders ShaderMacro var macros = new global::SiliconStudio.Shaders.Parser.ShaderMacro[Macros.Count]; for (int index = 0; index < Macros.Count; index++) { macros[index] = new global::SiliconStudio.Shaders.Parser.ShaderMacro(Macros[index].Name, Macros[index].Definition); } var result = HlslParser.TryPreProcessAndParse(hlslSourcecode, inputHlslFilepath, macros, IncludeDirectories); if (result.HasErrors) { log.Error(result.ToString()); return(null); } // Prepare the shader before type inference analysis HlslToGlslConvertor.Prepare(result.Shader); HlslSemanticAnalysis.Run(result); // If there are any type inference analysis, just display all errors but ytu if (result.HasErrors) { log.Error(result.ToString()); return(null); } return(Convert(result, hlslEntryPoint, stage, inputHlslFilepath, log)); } catch (Exception ex) { log.Error("Unexpected error while converting file [{0}] with entry point [{1}]", ex, inputHlslFilepath, hlslEntryPoint); } return(null); }
/// <summary> /// Ensures that the cookie middleware for validating external logins is assigned to the pipeline with the correct /// Umbraco back office configuration /// </summary> /// <param name="app"></param> /// <param name="umbracoContextAccessor"></param> /// <param name="runtimeState"></param> /// <param name="globalSettings"></param> /// <param name="stage"></param> /// <returns></returns> public static IAppBuilder UseUmbracoBackOfficeExternalCookieAuthentication(this IAppBuilder app, IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtimeState, IGlobalSettings globalSettings, PipelineStage stage) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (runtimeState == null) { throw new ArgumentNullException(nameof(runtimeState)); } app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = Constants.Security.BackOfficeExternalAuthenticationType, AuthenticationMode = AuthenticationMode.Passive, CookieName = Constants.Security.BackOfficeExternalCookieName, ExpireTimeSpan = TimeSpan.FromMinutes(5), //Custom cookie manager so we can filter requests CookieManager = new BackOfficeCookieManager(umbracoContextAccessor, runtimeState, globalSettings), CookiePath = "/", CookieSecure = globalSettings.UseHttps ? CookieSecureOption.Always : CookieSecureOption.SameAsRequest, CookieHttpOnly = true, CookieDomain = Current.Configs.Settings().Security.AuthCookieDomain }, stage); return(app); }
/// <summary> /// Adds a cookie-based authentication middleware to your web application pipeline. /// </summary> /// <param name="app">The IAppBuilder passed to your configuration method</param> /// <param name="options">An options class that controls the middleware behavior</param> /// <param name="stage"></param> /// <returns>The original app parameter</returns> public static IAppBuilder UseCookieAuthentication(this IAppBuilder app, CookieAuthenticationOptions options, PipelineStage stage) { if (app == null) { throw new ArgumentNullException("app"); } app.Use(typeof(CookieAuthenticationMiddleware), app, options); app.UseStageMarker(stage); return(app); }
/// <summary> /// Run the pipeline until it stalls. If FullFlag is true, all the /// stages of the pipeline will be synchronized. /// </summary> public void Run(String reason, bool fullFlag) { Logging.Log(1, "Running pipeline in stage " + CurrentStage + ": " + reason + ", fullFlag: " + fullFlag + "."); QueuedRun = false; // Set the FullSyncFlag as needed. This is done even if the pipeline // is being re-entered. if (fullFlag) FullSyncFlag = true; // Set the next run date to null. We don't want to be stuck in the // exit stage. This is done even if the pipeline is being re-entered. NextRunDate = DateTime.MinValue; // Don't re-enter the pipeline. if (RunFlag) { Logging.Log("The pipeline is already running, exiting."); return; } // We're now running the pipeline. RunFlag = true; try { while (true) { // We stall the pipeline when the UI gate has been entered. if (Share.Gate.EntryCount > 0) { Logging.Log("The UI gate has been entered, stalling the pipeline."); break; } StageAction = PipelineAction.None; // Process the current stage. if (CurrentStage == PipelineStage.Entry) EntryStage(); else if (CurrentStage == PipelineStage.InitScan) InitScanStage(); else if (CurrentStage == PipelineStage.ServerOp) ServerOpStage(); else if (CurrentStage == PipelineStage.PartialScan) PartialScanStage(); else if (CurrentStage == PipelineStage.Transfer) TransferStage(); else if (CurrentStage == PipelineStage.LocalUpdate) LocalUpdateStage(); else if (CurrentStage == PipelineStage.UI) UiStage(); else if (CurrentStage == PipelineStage.Exit) ExitStage(); else Debug.Assert(false); // Stall the pipeline. if (StageAction == PipelineAction.Stall) { // Disable the timer. if (TimerDate == DateTime.MaxValue) WakeupTimer.WakeMeUp(-1); // Enable the timer. else WakeupTimer.WakeMeUp(Math.Max((Int64)(TimerDate - DateTime.Now).TotalMilliseconds + 1, 1)); break; } // Pass to the next stage. else if (StageAction == PipelineAction.Pass) { CurrentStage = (PipelineStage)(((int)CurrentStage + 1) % 8); } // Oops. else throw new Exception("pipeline action not set"); } } catch (Exception ex) { Share.FatalError(ex); } // We're no longer running the pipeline. RunFlag = false; }
async Task RenderNow(ICommunicationContext context, PipelineStage stage) { PipelineLog.WriteDebug("Pipeline is in RenderNow mode."); if (!stage.ResumeFrom<KnownStages.IOperationResultInvocation>()) { if (stage.OwnerStage != null) { PipelineLog.WriteError("Trying to launch nested pipeline to render error failed."); AttemptCatastrophicErrorNotification(context); return; } using ( PipelineLog.Operation(this, "Rendering contributor has already been executed. Calling a nested pipeline to render the error.")) { var nestedPipeline = new PipelineStage(this, stage); if (!nestedPipeline.ResumeFrom<KnownStages.IOperationResultInvocation>()) throw new InvalidOperationException("Could not find an IOperationResultInvocation in the new pipeline."); await RunCallGraph(context, nestedPipeline); } } }
private string Compile(string shaderSource, string entryPoint, ShaderStage stage, bool isOpenGLES, bool isOpenGLES3, ShaderBytecodeResult shaderBytecodeResult, string sourceFilename = null) { if (isOpenGLES && !isOpenGLES3 && renderTargetCount > 1) { shaderBytecodeResult.Error("OpenGL ES 2 does not support multiple render targets."); } PipelineStage pipelineStage = PipelineStage.None; switch (stage) { case ShaderStage.Vertex: pipelineStage = PipelineStage.Vertex; break; case ShaderStage.Pixel: pipelineStage = PipelineStage.Pixel; break; case ShaderStage.Geometry: shaderBytecodeResult.Error("Geometry stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Hull: shaderBytecodeResult.Error("Hull stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Domain: shaderBytecodeResult.Error("Domain stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Compute: shaderBytecodeResult.Error("Compute stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; default: shaderBytecodeResult.Error("Unknown shader profile."); break; } if (shaderBytecodeResult.HasErrors) { return(null); } string shaderString = null; var generateUniformBlocks = isOpenGLES && isOpenGLES3; // null entry point for pixel shader means no pixel shader. In that case, we return a default function. if (entryPoint == null && stage == ShaderStage.Pixel && isOpenGLES) { shaderString = "out float fragmentdepth; void main(){ fragmentdepth = gl_FragCoord.z; }"; } else { // Convert from HLSL to GLSL // Note that for now we parse from shader as a string, but we could simply clone effectPass.Shader to avoid multiple parsing. var glslConvertor = new ShaderConverter(isOpenGLES, isOpenGLES3); var glslShader = glslConvertor.Convert(shaderSource, entryPoint, pipelineStage, sourceFilename, shaderBytecodeResult); if (glslShader == null || shaderBytecodeResult.HasErrors) { return(null); } // Add std140 layout foreach (var constantBuffer in glslShader.Declarations.OfType <ConstantBuffer>()) { if (isOpenGLES3) // TODO: for OpenGL too? { var layoutQualifier = constantBuffer.Qualifiers.OfType <SiliconStudio.Shaders.Ast.Glsl.LayoutQualifier>().FirstOrDefault(); if (layoutQualifier == null) { layoutQualifier = new SiliconStudio.Shaders.Ast.Glsl.LayoutQualifier(); constantBuffer.Qualifiers |= layoutQualifier; } layoutQualifier.Layouts.Add(new LayoutKeyValue("std140")); } else { constantBuffer.Qualifiers |= new LayoutQualifier(new LayoutKeyValue("std140")); } } // Output the result var glslShaderWriter = new HlslToGlslWriter(); if (isOpenGLES) { glslShaderWriter.TrimFloatSuffix = true; glslShaderWriter.GenerateUniformBlocks = generateUniformBlocks; if (!isOpenGLES3) { foreach (var variable in glslShader.Declarations.OfType <Variable>()) { if (variable.Qualifiers.Contains(ParameterQualifier.In)) { variable.Qualifiers.Values.Remove(ParameterQualifier.In); // "in" becomes "attribute" in VS, "varying" in other stages variable.Qualifiers.Values.Add( pipelineStage == PipelineStage.Vertex ? global::SiliconStudio.Shaders.Ast.Glsl.ParameterQualifier.Attribute : global::SiliconStudio.Shaders.Ast.Glsl.ParameterQualifier.Varying); } if (variable.Qualifiers.Contains(ParameterQualifier.Out)) { variable.Qualifiers.Values.Remove(ParameterQualifier.Out); variable.Qualifiers.Values.Add(global::SiliconStudio.Shaders.Ast.Glsl.ParameterQualifier.Varying); } } } } // Write shader glslShaderWriter.Visit(glslShader); shaderString = glslShaderWriter.Text; } // Build shader source var glslShaderCode = new StringBuilder(); // Append some header depending on target if (isOpenGLES) { if (isOpenGLES3) { glslShaderCode .AppendLine("#version 300 es") // TODO: 310 version? .AppendLine(); } if (pipelineStage == PipelineStage.Pixel) { glslShaderCode .AppendLine("precision highp float;") .AppendLine(); } } else { glslShaderCode .AppendLine("#version 420") .AppendLine(); } if ((!isOpenGLES || isOpenGLES3) && pipelineStage == PipelineStage.Pixel && renderTargetCount > 0) { // TODO: identifiers starting with "gl_" should be reserved. Compilers usually accept them but it may should be prevented. glslShaderCode .AppendLine("#define gl_FragData _glesFragData") .AppendLine("out vec4 gl_FragData[" + renderTargetCount + "];") .AppendLine(); } glslShaderCode.Append(shaderString); var realShaderSource = glslShaderCode.ToString(); #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP // optimize shader try { var optShaderSource = RunOptimizer(shaderBytecodeResult, realShaderSource, isOpenGLES, isOpenGLES3, pipelineStage == PipelineStage.Vertex); if (!String.IsNullOrEmpty(optShaderSource)) { realShaderSource = optShaderSource; } } catch (Exception e) { shaderBytecodeResult.Warning("Could not run GLSL optimizer:\n{0}", e.Message); } #else shaderBytecodeResult.Warning("GLSL optimized has not been executed because it is currently not supported on this platform."); #endif return(realShaderSource); }
public PipelineStage RegisterStage(string name) { var stage = new PipelineStage(name); _stages.Add(stage); return stage; }
/// <summary> /// Insert Post ProtectionPhases(<paramref name="ProtectionsPhases"/>) PipelineStage(<paramref name="Stage"/>). /// </summary> /// <param name="Stage">PipelineStage That Get Added.</param> /// <param name="ProtectionsPhases">Phases Will Added Into Specified Stage.</param> public void InsertPreStage(PipelineStage Stage, IEnumerable <ProtectionPhase> ProtectionsPhases) => _prestages[Stage].AddRange(ProtectionsPhases);
/// <summary> /// Ensures that the UmbracoBackOfficeAuthenticationMiddleware is assigned to the pipeline /// </summary> /// <param name="app"></param> /// <param name="umbracoContextAccessor"></param> /// <param name="runtimeState"></param> /// <param name="userService"></param> /// <param name="globalSettings"></param> /// <param name="securitySection"></param> /// <param name="stage"> /// Configurable pipeline stage /// </param> /// <returns></returns> public static IAppBuilder UseUmbracoBackOfficeCookieAuthentication(this IAppBuilder app, IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtimeState, IUserService userService, IGlobalSettings globalSettings, ISecuritySection securitySection, PipelineStage stage) { //Create the default options and provider var authOptions = app.CreateUmbracoCookieAuthOptions(umbracoContextAccessor, globalSettings, runtimeState, securitySection); authOptions.Provider = new BackOfficeCookieAuthenticationProvider(userService, runtimeState, globalSettings) { // Enables the application to validate the security stamp when the user // logs in. This is a security feature which is used when you // change a password or add an external login to your account. OnValidateIdentity = context => { // capture the current ticket for the request var identity = context.Identity; return(SecurityStampValidator .OnValidateIdentity <BackOfficeUserManager, BackOfficeIdentityUser, int>( // This will re-verify the security stamp at a throttled 30 mins // (the standard/default set in aspnet identity). // This ensures that if the security stamp has changed - i.e. passwords, // external logins, or other security profile data changed behind the // scenes while being logged in, that they are logged out and have // to re-verify their identity. TimeSpan.FromMinutes(30), async(manager, user) => { var regenerated = await manager.GenerateUserIdentityAsync(user); // Keep any custom claims from the original identity regenerated.MergeClaimsFromBackOfficeIdentity(identity); return regenerated; }, identity => identity.GetUserId <int>())(context)); } }; return(app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, runtimeState, globalSettings, securitySection, authOptions, stage)); }
/// <summary> /// Converts the specified hlsl source code to glsl. /// </summary> /// <param name="hlslEntryPoint">The HLSL entry point.</param> /// <param name="stage">The stage to convert.</param> /// <param name="shader">The shader.</param> /// <param name="inputHlslFilepath">The input HLSL filepath.</param> /// <returns> /// The resulting glsl AST tree. /// </returns> private global::SiliconStudio.Shaders.Ast.Shader Convert(ParsingResult result, string hlslEntryPoint, PipelineStage stage, string inputHlslFilepath, LoggerResult log) { try { var convertor = new HlslToGlslConvertor(hlslEntryPoint, stage, ShaderModel.Model40) // TODO HARDCODED VALUE to change { KeepConstantBuffer = !isOpenGLES || isOpenGLES3, TextureFunctionsCompatibilityProfile = isOpenGLES && !isOpenGLES3, NoSwapForBinaryMatrixOperation = true, UseBindingLayout = false, UseLocationLayout = false, UseSemanticForVariable = true, IsPointSpriteShader = false, ViewFrustumRemap = true, KeepNonUniformArrayInitializers = !isOpenGLES, IsOpenGLES2 = isOpenGLES && !isOpenGLES3 }; convertor.Run(result); // After the converter we display the errors but we don't stop writing output glsl if (result.HasErrors) { //DisplayError(log, result, "Error while converting file:"); } return(result.Shader); } catch (Exception ex) { log.Error("Unexpected error while converting file [{0}] with entry point [{1}]", ex, inputHlslFilepath, hlslEntryPoint); return(null); } }
private string Compile(string shaderSource, string entryPoint, ShaderStage stage, bool isOpenGLES, bool isOpenGLES3, ShaderBytecodeResult shaderBytecodeResult, EffectReflection reflection, string sourceFilename = null) { if (isOpenGLES && !isOpenGLES3 && renderTargetCount > 1) { shaderBytecodeResult.Error("OpenGL ES 2 does not support multiple render targets."); } PipelineStage pipelineStage = PipelineStage.None; switch (stage) { case ShaderStage.Vertex: pipelineStage = PipelineStage.Vertex; break; case ShaderStage.Pixel: pipelineStage = PipelineStage.Pixel; break; case ShaderStage.Geometry: shaderBytecodeResult.Error("Geometry stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Hull: shaderBytecodeResult.Error("Hull stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Domain: shaderBytecodeResult.Error("Domain stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; case ShaderStage.Compute: shaderBytecodeResult.Error("Compute stage can't be converted to OpenGL. Only Vertex and Pixel shaders are supported"); break; default: shaderBytecodeResult.Error("Unknown shader profile."); break; } if (shaderBytecodeResult.HasErrors) { return(null); } string shaderString = null; var generateUniformBlocks = isOpenGLES && isOpenGLES3; // null entry point for pixel shader means no pixel shader. In that case, we return a default function. if (entryPoint == null && stage == ShaderStage.Pixel && isOpenGLES) { shaderString = "out float fragmentdepth; void main(){ fragmentdepth = gl_FragCoord.z; }"; } else { // Convert from HLSL to GLSL // Note that for now we parse from shader as a string, but we could simply clone effectPass.Shader to avoid multiple parsing. var glslConvertor = new ShaderConverter(isOpenGLES, isOpenGLES3); var glslShader = glslConvertor.Convert(shaderSource, entryPoint, pipelineStage, sourceFilename, shaderBytecodeResult); if (glslShader == null || shaderBytecodeResult.HasErrors) { return(null); } // Add std140 layout foreach (var constantBuffer in glslShader.Declarations.OfType <ConstantBuffer>()) { if (isOpenGLES3) // TODO: for OpenGL too? { var layoutQualifier = constantBuffer.Qualifiers.OfType <SiliconStudio.Shaders.Ast.Glsl.LayoutQualifier>().FirstOrDefault(); if (layoutQualifier == null) { layoutQualifier = new SiliconStudio.Shaders.Ast.Glsl.LayoutQualifier(); constantBuffer.Qualifiers |= layoutQualifier; } layoutQualifier.Layouts.Add(new LayoutKeyValue("std140")); } else { constantBuffer.Qualifiers |= new LayoutQualifier(new LayoutKeyValue("std140")); } } foreach (var constantBuffer in glslShader.Declarations.OfType <ConstantBuffer>()) { // Update constant buffer itself (first time only) var reflectionConstantBuffer = reflection.ConstantBuffers.FirstOrDefault(x => x.Name == constantBuffer.Name && x.Size == 0); if (reflectionConstantBuffer != null) { // Used to compute constant buffer size and member offsets (std140 rule) int constantBufferOffset = 0; // Fill members for (int index = 0; index < reflectionConstantBuffer.Members.Length; index++) { var member = reflectionConstantBuffer.Members[index]; // Properly compute size and offset according to std140 rules var memberSize = ComputeMemberSize(ref member, ref constantBufferOffset); member.Offset = constantBufferOffset; member.Size = memberSize; // Adjust offset for next item constantBufferOffset += memberSize; reflectionConstantBuffer.Members[index] = member; } reflectionConstantBuffer.Size = constantBufferOffset; reflectionConstantBuffer.Stage = stage; // Should we store a flag/bitfield? } // Find binding var resourceBindingIndex = reflection.ResourceBindings.IndexOf(x => x.Param.RawName == constantBuffer.Name); if (resourceBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, resourceBindingIndex, stage); } } foreach (var variable in glslShader.Declarations.OfType <Variable>().Where(x => (x.Qualifiers.Contains(StorageQualifier.Uniform)))) { // Check if we have a variable that starts or ends with this name (in case of samplers) // TODO: Have real AST support for all the list in Keywords.glsl if (variable.Type.Name.Text.Contains("sampler1D") || variable.Type.Name.Text.Contains("sampler2D") || variable.Type.Name.Text.Contains("sampler3D") || variable.Type.Name.Text.Contains("samplerCube")) { // TODO: Make more robust var textureBindingIndex = reflection.ResourceBindings.IndexOf(x => variable.Name.ToString().StartsWith(x.Param.RawName)); var samplerBindingIndex = reflection.ResourceBindings.IndexOf(x => variable.Name.ToString().EndsWith(x.Param.RawName)); if (textureBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, textureBindingIndex, stage); } if (samplerBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, samplerBindingIndex, stage); } } else { var resourceBindingIndex = reflection.ResourceBindings.IndexOf(x => x.Param.RawName == variable.Name); if (resourceBindingIndex != -1) { MarkResourceBindingAsUsed(reflection, resourceBindingIndex, stage); } } } // Output the result var glslShaderWriter = new HlslToGlslWriter(); if (isOpenGLES) { glslShaderWriter.TrimFloatSuffix = true; glslShaderWriter.GenerateUniformBlocks = generateUniformBlocks; if (!isOpenGLES3) { foreach (var variable in glslShader.Declarations.OfType <Variable>()) { if (variable.Qualifiers.Contains(ParameterQualifier.In)) { variable.Qualifiers.Values.Remove(ParameterQualifier.In); // "in" becomes "attribute" in VS, "varying" in other stages variable.Qualifiers.Values.Add( pipelineStage == PipelineStage.Vertex ? global::SiliconStudio.Shaders.Ast.Glsl.ParameterQualifier.Attribute : global::SiliconStudio.Shaders.Ast.Glsl.ParameterQualifier.Varying); } if (variable.Qualifiers.Contains(ParameterQualifier.Out)) { variable.Qualifiers.Values.Remove(ParameterQualifier.Out); variable.Qualifiers.Values.Add(global::SiliconStudio.Shaders.Ast.Glsl.ParameterQualifier.Varying); } } } } // Write shader glslShaderWriter.Visit(glslShader); shaderString = glslShaderWriter.Text; } // Build shader source var glslShaderCode = new StringBuilder(); // Append some header depending on target if (isOpenGLES) { if (isOpenGLES3) { glslShaderCode .AppendLine("#version 300 es") // TODO: 310 version? .AppendLine(); } if (pipelineStage == PipelineStage.Pixel) { glslShaderCode .AppendLine("precision highp float;") .AppendLine(); } } else { glslShaderCode .AppendLine("#version 420") .AppendLine(); } if ((!isOpenGLES || isOpenGLES3) && pipelineStage == PipelineStage.Pixel && renderTargetCount > 0) { // TODO: identifiers starting with "gl_" should be reserved. Compilers usually accept them but it may should be prevented. glslShaderCode .AppendLine("#define gl_FragData _glesFragData") .AppendLine("out vec4 gl_FragData[" + renderTargetCount + "];") .AppendLine(); } glslShaderCode.Append(shaderString); var realShaderSource = glslShaderCode.ToString(); #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP // optimize shader try { var optShaderSource = RunOptimizer(shaderBytecodeResult, realShaderSource, isOpenGLES, isOpenGLES3, pipelineStage == PipelineStage.Vertex); if (!String.IsNullOrEmpty(optShaderSource)) { realShaderSource = optShaderSource; } } catch (Exception e) { shaderBytecodeResult.Warning("Could not run GLSL optimizer:\n{0}", e.Message); } #else shaderBytecodeResult.Warning("GLSL optimized has not been executed because it is currently not supported on this platform."); #endif return(realShaderSource); }
/// <summary> /// Call after other middleware to specify when they should run in the integrated pipeline. /// </summary> /// <param name="app">The IAppBuilder.</param> /// <param name="stage">The stage of the integrated pipeline in which to run.</param> /// <returns>The original IAppBuilder for chaining.</returns> public static IAppBuilder UseStageMarker(this IAppBuilder app, PipelineStage stage) { return(UseStageMarker(app, stage.ToString())); }
/// <summary> /// Gets an enumerable list of <see cref="PipelineComponent"/> instances which have the given stage. /// </summary> /// <param name="stage"><see cref="PipelineStage"/> to get components for.</param> /// <returns>Enumerable list of <see cref="PipelineComponent"/> instances.</returns> public IEnumerable <PipelineComponent> GetComponentsByStage(PipelineStage stage) { return(Components.Where(pc => pc.Stage == stage)); }
public ExtraStage(PipelineStage <byte[], byte[]> toFile, PipelineStage <byte[], byte[]> fromFile) { ToFile = toFile; FromFile = fromFile; }
/// <summary> /// Initialize a RegisteredEvent without an Action /// </summary> /// <param name="stage">Pipeline stage</param> /// <param name="messageName">Message name</param> /// <param name="entityLogicalName">Entity logical name</param> public RegisteredEvent(PipelineStage stage, string messageName, string entityLogicalName) { Stage = stage; MessageName = messageName; EntityLogicalName = entityLogicalName; }
async Task RunCallGraph(ICommunicationContext context, PipelineStage stage) { foreach (var contrib in stage) { if (!CanBeExecuted(contrib)) continue; stage.CurrentState = await ExecuteContributor(context, contrib); switch (stage.CurrentState) { case PipelineContinuation.Abort: { AbortPipeline(context); goto case PipelineContinuation.RenderNow; } case PipelineContinuation.RenderNow: { await RenderNow(context, stage); break; } case PipelineContinuation.Finished: { FinishPipeline(context); return; } } } }
/// <summary> /// Inserts the phase into pre-processing pipeline of the specified stage. /// </summary> /// <param name="stage">The pipeline stage.</param> /// <param name="phase">The protection phase.</param> public void InsertPreStage(PipelineStage stage, ProtectionPhase phase) { preStage[stage].Add(phase); }