public void Test_Signalr_CustomAuditScopeFactory() { var evs = new List <AuditEvent>(); Configuration.DataProvider = null; var dp = new DynamicDataProvider(); dp.AttachOnInsertAndReplace(ev => { evs.Add(ev); }); var factory = new Mock <IAuditScopeFactory>(); factory.Setup(_ => _.Create(It.IsAny <AuditScopeOptions>())) .Returns(new AuditScope(new AuditScopeOptions() { DataProvider = dp, AuditEvent = new AuditEventSignalr() })); var module = new TestAuditPipelineModule() { AuditScopeFactory = factory.Object }; SimulateIncomingError(module, new ArgumentNullException("SomeParameter", "message"), "cnn-Error", "err", new object[] { 0 }); Task.Delay(50).Wait(); Assert.AreEqual(1, evs.Count); }
public PreviewModel( VertexBuffer vb, IndexBuffer ib, int elementCount, Material regularMaterial, Material shadowmapMaterial, ConstantBuffer worldBuffer, DynamicDataProvider <Matrix4x4> worldProvider, ConstantBuffer inverseTransposeWorldBuffer, Dictionary <string, ConstantBuffer> buffersDict, ShaderTextureBinding surfaceTextureBinding ) { _vb = vb; _ib = ib; _elementCount = elementCount; _regularMaterial = regularMaterial; _shadowmapMaterial = shadowmapMaterial; _worldProvider = worldProvider; _inverseWorldProvider = new DependantDataProvider <Matrix4x4>(worldProvider, Utilities.CalculateInverseTranspose); _textureBinding = surfaceTextureBinding; _worldBuffer = worldBuffer; _inverseTransposeWorldBuffer = inverseTransposeWorldBuffer; _buffersDict = buffersDict; }
public GeometryShaderBox(AssetDatabase ad, RenderContext rc, Camera camera, string geometryShaderName = "cube-geometry") { _geometryShaderName = geometryShaderName; _worldProvider = new DynamicDataProvider <Matrix4x4>(Matrix4x4.CreateTranslation(Position)); InitializeContextObjects(ad, rc); _camera = camera; }
public async Task Test_HttpAction_CustomAuditScopeFactory() { var actions = new List <HttpAction>(); Audit.Core.Configuration.DataProvider = null; var dp = new DynamicDataProvider(); dp.AttachOnInsertAndReplace(ev => { actions.Add(JsonAdapter.Deserialize <HttpAction>(JsonAdapter.Serialize(ev.GetHttpAction()))); }); var factory = new Mock <IAuditScopeFactory>(); factory.Setup(_ => _.Create(It.IsAny <AuditScopeOptions>())) .Returns(new AuditScope(new AuditScopeOptions() { DataProvider = dp, AuditEvent = new AuditEventHttpClient() })); var url = "http://google.com/?q=test"; using (var cli = new HttpClient(new AuditHttpClientHandler() { RequestFilter = _ => true, AuditScopeFactory = factory.Object })) { await cli.GetAsync(url); } Assert.AreEqual(1, actions.Count); Assert.AreEqual(url, actions[0].Url); Assert.AreEqual("GET", actions[0].Method); }
public EFCoreAudit(DbContextOptions <System.Entities.SystemContext> options) : base(options) { var dataProvider = new DynamicDataProvider(); dataProvider.AttachOnInsert(ev => Console.Write(ev.ToJson())); Audit.Core.Configuration.DataProvider = dataProvider; }
public TextureAtlas(RenderContext rc, int size) { _size = size; _rc = rc; _texture = rc.ResourceFactory.CreateTexture(IntPtr.Zero, size, size, 1, PixelFormat.R8_UInt); _textureBinding = rc.ResourceFactory.CreateShaderTextureBinding(_texture); _atlasInfo = new DynamicDataProvider <FontAtlasInfo>(new FontAtlasInfo(size)); }
public ICreationPolicyConfigurator UseDynamicProvider(Action <IDynamicDataProviderConfigurator> config) { var dataProvider = new DynamicDataProvider(); var dynamicConfig = new DynamicDataProviderConfigurator(dataProvider); config.Invoke(dynamicConfig); Configuration.DataProvider = dataProvider; return(new CreationPolicyConfigurator()); }
public WireframeShapeRenderer(RenderContext rc, RgbaFloat color) { _textureData = new RawTextureDataArray <RgbaFloat>(new RgbaFloat[] { color }, 1, 1, RgbaFloat.SizeInBytes, PixelFormat.R32_G32_B32_A32_Float); _worldProvider = new DynamicDataProvider <Matrix4x4>(Matrix4x4.Identity); _inverseTransposeWorldProvider = new DependantDataProvider <Matrix4x4>(_worldProvider, Utilities.CalculateInverseTranspose); _perObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider }; InitializeContextObjects(rc); }
public TeapotRenderer(RenderContext rc) { _worldProvider = new DynamicDataProvider <Matrix4x4>(); _inverseTransposeWorldProvider = new DependantDataProvider <Matrix4x4>(_worldProvider, CalculateInverseTranspose); _perObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider }; _centeredBounds = BoundingSphere.CreateFromPoints(LoadTeapotMesh().Vertices); InitializeContextObjects(rc); }
public MeshRenderer(RefOrImmediate <MeshData> meshData, RefOrImmediate <TextureData> texture) { _worldProvider = new DynamicDataProvider <Matrix4x4>(); _inverseTransposeWorldProvider = new DependantDataProvider <Matrix4x4>(_worldProvider, CalculateInverseTranspose); _tintInfoProvider = new DynamicDataProvider <TintInfo>(); _materialInfo = new DynamicDataProvider <MaterialInfo>(new MaterialInfo(1.0f)); _perObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider, _tintInfoProvider }; _transparentPerObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider, _tintInfoProvider, _materialInfo }; Mesh = meshData; Texture = texture; }
public ImGuiRenderer(RenderContext rc) { CreateFontsTexture(rc); _projectionMatrixProvider = new DynamicDataProvider <Matrix4x4>(); InitializeContextObjects(rc); SetOpenTKKeyMappings(); SetPerFrameImGuiData(rc, 1f / 60f); ImGui.NewFrame(); }
public WireframeShapeRenderer(AssetDatabase ad, RenderContext rc, RgbaFloat color) { _materialAsset = ad.LoadAsset <MaterialAsset>("MaterialAsset/ShadowCaster_MtlTemplate.json"); _textureData = new RawTextureDataArray <RgbaFloat>(new RgbaFloat[] { color }, 1, 1, RgbaFloat.SizeInBytes, PixelFormat.R32_G32_B32_A32_Float); _worldProvider = new DynamicDataProvider <Matrix4x4>(Matrix4x4.Identity); _inverseTransposeWorldProvider = new DependantDataProvider <Matrix4x4>(_worldProvider, Utilities.CalculateInverseTranspose); var materialProvider = new DynamicDataProvider <ForwardRendering.MtlMaterialProperties>(new ForwardRendering.MtlMaterialProperties(new Vector3(4, 5, 6), 7)); _perObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider, materialProvider }; InitializeContextObjects(ad, rc); }
public ImGuiRenderer(RenderContext rc, NativeWindow window, InputSystem input) { _rc = rc; _input = input; ImGui.GetIO().FontAtlas.AddDefaultFont(); _projectionMatrixProvider = new DynamicDataProvider <Matrix4x4>(); InitializeContextObjects(rc); SetOpenTKKeyMappings(); SetPerFrameImGuiData(rc, 1f / 60f); ImGui.NewFrame(); input.RegisterCallback(OnInputUpdated); }
public void Test_DynamicDataProvider_FluentApi() { int ins = 0; int upd = 0; var dyn = new DynamicDataProvider(_ => _ .OnInsert(ev => ins++) .OnReplace((id, ev) => upd++)); using (var scope = AuditScope.Create(_ => _ .CreationPolicy(EventCreationPolicy.InsertOnStartReplaceOnEnd) .DataProvider(dyn))) { } Assert.AreEqual(1, ins); Assert.AreEqual(1, upd); }
public PreviewModel( VertexBuffer vb, IndexBuffer ib, int elementCount, Material regularMaterial, Material shadowmapMaterial, DynamicDataProvider <Matrix4x4> worldProvider, ShaderTextureBinding surfaceTextureBinding = null) { _vb = vb; _ib = ib; _elementCount = elementCount; _regularMaterial = regularMaterial; _shadowmapMaterial = shadowmapMaterial; _worldProvider = worldProvider; _inverseWorldProvider = new DependantDataProvider <Matrix4x4>(worldProvider, Utilities.CalculateInverseTranspose); _perObjectInputs = new ConstantBufferDataProvider[] { _worldProvider, _inverseWorldProvider }; _textureBinding = surfaceTextureBinding; }
public ShadowCaster( RenderContext rc, AssetDatabase ad, VertexPositionNormalTexture[] vertices, int[] indices, MaterialAsset regularPassMaterial, TextureData overrideTexture = null) { _meshData = new SimpleMeshDataProvider(vertices, indices); _shadowPassMaterialAsset = ad.LoadAsset <MaterialAsset>("MaterialAsset/ShadowCaster_ShadowMap.json"); _regularPassMaterialAsset = regularPassMaterial; _overrideTextureData = overrideTexture; _worldProvider = new DynamicDataProvider <Matrix4x4>(); _inverseTransposeWorldProvider = new DependantDataProvider <Matrix4x4>(_worldProvider, Utilities.CalculateInverseTranspose); _perObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider }; _centeredBounds = BoundingSphere.CreateFromPoints(vertices); InitializeContextObjects(ad, rc); }
public PreviewScene(RenderContext rc, ConstructedMeshInfo previewItem) { _rc = rc; ResourceFactory factory = rc.ResourceFactory; _fb = factory.CreateFramebuffer(Width, Height); _projection = new DynamicDataProvider <Matrix4x4>(); UpdateProjectionData(); _view = new DynamicDataProvider <Matrix4x4>(Matrix4x4.CreateLookAt(Vector3.UnitZ * 7f + Vector3.UnitY * 1.5f, Vector3.Zero, Vector3.UnitY)); _lightProjection = new DynamicDataProvider <Matrix4x4>(Matrix4x4.CreateOrthographicOffCenter(-18, 18, -18, 18, -10, 60f)); _lightView = new DynamicDataProvider <Matrix4x4>(Matrix4x4.CreateLookAt(-_lightDirection * 20f, Vector3.Zero, Vector3.UnitY)); _lightInfo = new DynamicDataProvider <Vector4>(new Vector4(_lightDirection, 1)); _standardPipelineStage = new StandardPipelineStage(rc, "Standard", _fb); _stages = new PipelineStage[] { new ShadowMapStage(rc, "ShadowMap_Preview"), _standardPipelineStage, }; _sceneProviders.Add("ProjectionMatrix", _projection); _sceneProviders.Add("ViewMatrix", _view); _sceneProviders.Add("LightProjMatrix", _lightProjection); _sceneProviders.Add("LightViewMatrix", _lightView); _sceneProviders.Add("LightInfo", _lightInfo); _floor = CreatePreviewModel(PlaneModel.Vertices, PlaneModel.Indices); _floor.WorldMatrix.Data = Matrix4x4.CreateScale(10f, 1f, 10f); _previewItem = CreatePreviewModel(previewItem.Vertices, previewItem.Indices); _previewItem.WorldMatrix.Data = Matrix4x4.CreateTranslation(0, 1.5f, 0); _visiblityManager = new FlatListVisibilityManager(); _visiblityManager.AddRenderItem(_floor); _visiblityManager.AddRenderItem(_previewItem); }
public TexturedMeshRenderer(AssetDatabase ad, RenderContext context, VertexPositionNormalTexture[] vertices, int[] indices, TextureData texture) { _worldProvider = new DynamicDataProvider <Matrix4x4>(); _inverseTransposeWorldProvider = new DependantDataProvider <Matrix4x4>(_worldProvider, CalculateInverseTranspose); _perObjectProviders = new ConstantBufferDataProvider[] { _worldProvider, _inverseTransposeWorldProvider }; _vertices = vertices; _indices = indices; _texture = texture; _centeredBounds = BoundingSphere.CreateFromPoints(vertices); if (context != _currentContext) { if (_currentContext == null) { InitializeContextObjects(context); } else { ChangeRenderContext(ad, context); } } }
#pragma warning restore CS3008 // Identifier is not CLS-compliant public DynamicDataProviderConfigurator(DynamicDataProvider dynamicDataProvider) { _dynamicDataProvider = dynamicDataProvider; }
public MaterialPropsAndBuffer(MaterialProperties mp) { _properties = new DynamicDataProvider <MaterialProperties>(mp); _properties.DataChangedByRef += OnDataChanged; }