/// <summary>
        /// Fires after the entry was materialized
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <param name="entity">The entity.</param>
        internal void ExecuteEntityMaterializedActions(ODataResource entry, object entity)
        {
            Debug.Assert(entry != null, "entry != null");
            Debug.Assert(entity != null, "entity != entity");

            if (this.materializedEntityActions.Count > 0)
            {
                MaterializedEntityArgs args = new MaterializedEntityArgs(entry, entity);
                foreach (Action <MaterializedEntityArgs> materializedEntryArgsAction in this.materializedEntityActions)
                {
                    materializedEntryArgsAction(args);
                }
            }
        }
Exemplo n.º 2
0
        public void AfterEntryMaterializedShouldOccur()
        {
            foreach (ODataFormat format in new ODataFormat[] { ODataFormat.Atom, ODataFormat.Json })
            {
                var entity = new SimpleEntity()
                {
                    ID = 1
                };
                var odataEntry = CreateEntryWithMaterializerEntry(format, entity);
                MaterializedEntityArgs found = null;
                this.context.Configurations.ResponsePipeline.OnEntityMaterialized((MaterializedEntityArgs materializedEntryEventArgs) => found = materializedEntryEventArgs);

                this.context.Configurations.ResponsePipeline.FireEndEntryEvents(MaterializerEntry.GetEntry(odataEntry));
                Assert.IsNotNull(found);
                found.Entity.Should().Be(entity);
                found.Entry.Should().Be(odataEntry);
            }
        }