示例#1
0
        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);
        }
示例#2
0
            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;
            }
示例#3
0
 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;
 }
示例#4
0
        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);
        }
示例#5
0
        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;
        }
示例#6
0
文件: TextureAtlas.cs 项目: zhuowp/ge
 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));
 }
示例#7
0
        public ICreationPolicyConfigurator UseDynamicProvider(Action <IDynamicDataProviderConfigurator> config)
        {
            var dataProvider  = new DynamicDataProvider();
            var dynamicConfig = new DynamicDataProviderConfigurator(dataProvider);

            config.Invoke(dynamicConfig);
            Configuration.DataProvider = dataProvider;
            return(new CreationPolicyConfigurator());
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
 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;
 }
示例#11
0
        public ImGuiRenderer(RenderContext rc)
        {
            CreateFontsTexture(rc);
            _projectionMatrixProvider = new DynamicDataProvider <Matrix4x4>();

            InitializeContextObjects(rc);
            SetOpenTKKeyMappings();

            SetPerFrameImGuiData(rc, 1f / 60f);
            ImGui.NewFrame();
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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);
        }
示例#15
0
 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;
 }
示例#16
0
        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);
        }
示例#17
0
            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);
            }
示例#18
0
        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);
                }
            }
        }
示例#19
0
#pragma warning restore CS3008 // Identifier is not CLS-compliant

        public DynamicDataProviderConfigurator(DynamicDataProvider dynamicDataProvider)
        {
            _dynamicDataProvider = dynamicDataProvider;
        }
示例#20
0
 public MaterialPropsAndBuffer(MaterialProperties mp)
 {
     _properties = new DynamicDataProvider <MaterialProperties>(mp);
     _properties.DataChangedByRef += OnDataChanged;
 }