public static IEntitySetMetadata GetEntitySetFor(this IContainerMetadata containerMetadata, IEntityTypeMetadata entityTypeMetadata) { Contract.Requires <ArgumentNullException>(containerMetadata != null); Contract.Requires <ArgumentNullException>(entityTypeMetadata != null); return(containerMetadata.EntitySets.SingleOrDefault(es => es.ElementTypeMetadata.ClrType == entityTypeMetadata.ClrType)); }
public EditDbSetController(Lazy <TDbContext> lazyDbContext, IContainerMetadata <TDbContext> containerMetadata, ODataValidationSettings queryValidationSettings, ODataQuerySettings querySettings) : base(lazyDbContext, containerMetadata, queryValidationSettings, querySettings) { }
public ReadOnlyDbSetController(Lazy <TDbContext> lazyDbContext, IContainerMetadata <TDbContext> containerMetadata, ODataValidationSettings queryValidationSettings, ODataQuerySettings querySettings) : base(containerMetadata, queryValidationSettings, querySettings) { Contract.Requires <ArgumentNullException>(lazyDbContext != null); _lazyDb = lazyDbContext; }
/// <summary> /// Default constructor /// </summary> /// <param name="msd"></param> public H264Parser(SampleBuffer outputBuffer, IContainerMetadata metadata, HLSStream hlsStream) : base(outputBuffer, hlsStream) { string[] resolution = null; string s; if (metadata.Attributes != null && metadata.Attributes.TryGetValue(HLSPlaylistMetaKeys.Resolution, out s)) { string[] components = s.Split(new char[] { 'x' }); if (components != null && components.Length == 2) resolution = components; } if (resolution == null) { HLSTrace.WriteLine("Missing 'Resolution' tag in HLS MetaKeys, defaulting to the maximum supported resolution of 1280x720."); resolution = new string[] { "1280", "720" }; } Dictionary<MediaStreamAttributeKeys, string> streamAttributes = new Dictionary<MediaStreamAttributeKeys, string>(); streamAttributes[MediaStreamAttributeKeys.VideoFourCC] = "H264"; streamAttributes[MediaStreamAttributeKeys.Width] = resolution[0]; streamAttributes[MediaStreamAttributeKeys.Height] = resolution[1]; Description = new MediaStreamDescription(MediaStreamType.Video, streamAttributes); }
public static IEntitySetMetadata GetEntitySet(this IContainerMetadata containerMetadata, string entitySetName) { Contract.Requires <ArgumentNullException>(containerMetadata != null); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(entitySetName)); return(containerMetadata.EntitySets.SingleOrDefault(es => string.Equals(es.Name, entitySetName, StringComparison.Ordinal))); }
/// <summary> /// Callback invoked to set per-controller overrides for this controllerDescriptor. /// </summary> /// <param name="controllerSettings">The controller settings to initialize.</param> /// <param name="controllerDescriptor">The controller descriptor. Note that the <see /// cref="T:System.Web.Http.Controllers.HttpControllerDescriptor" /> can be associated with the derived /// controller type given that <see cref="T:System.Web.Http.Controllers.IControllerConfiguration" /> is /// inherited.</param> public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) { if (controllerSettings == null) { throw new ArgumentNullException("controllerSettings"); } if (controllerDescriptor == null) { throw new ArgumentNullException("controllerDescriptor"); } ServicesContainer services = controllerSettings.Services; Contract.Assert(services != null); IContainerMetadata containerMetadata = controllerDescriptor.GetContainerMetadata(); // Replace the action selector with one that is based on the OData routing conventions IHttpActionSelector originalActionSelector = services.GetActionSelector(); IHttpActionSelector actionSelector; if (containerMetadata != null) { // ContainerMetadata was stored with the HttpControllerDescriptor - so use our "special" ActionSelector actionSelector = new EntityRepositoryActionSelector(containerMetadata, originalActionSelector); } else { // No ContainerMetadata stored with the HttpControllerDescriptor - so use the standard odata ActionSelector actionSelector = new ODataActionSelector(originalActionSelector); } controllerSettings.Services.Replace(typeof(IHttpActionSelector), actionSelector); }
public static IEntityTypeMetadata GetEntityType(this IContainerMetadata containerMetadata, Type clrType) { Contract.Requires <ArgumentNullException>(containerMetadata != null); Contract.Requires <ArgumentNullException>(clrType != null); Contract.Ensures(Contract.Result <IEntityTypeMetadata>() != null); return(containerMetadata.EntityTypes.SingleOrDefault(et => et.ClrType == clrType)); }
public static object GetKeyFor <TEntity>(this IContainerMetadata containerMetadata, TEntity entity) { Contract.Requires <ArgumentNullException>(containerMetadata != null); Contract.Requires <ArgumentNullException>(entity != null); IEntityTypeMetadata entityTypeMetadata = containerMetadata.GetEntityType(typeof(TEntity)); return(entityTypeMetadata.EntityKeyFunction(entity)); }
// TODO: Remove this - but keeping it in for now until we prove in all cases that the ctor below is better. public ODataServerConfigurer(HttpConfiguration webApiConfig, IContainerMetadata containerMetadata) { Contract.Requires <ArgumentNullException>(webApiConfig != null); _webApiConfig = webApiConfig; _containerMetadata = containerMetadata; _controllerSelector = EntityRepositoryControllerSelector.Install(webApiConfig, this); }
// TODO: Remove this - but keeping it in for now until we prove in all cases that the ctor below is better. public ODataServerConfigurer(HttpConfiguration webApiConfig, IContainerMetadata containerMetadata) { Contract.Requires<ArgumentNullException>(webApiConfig != null); _webApiConfig = webApiConfig; _containerMetadata = containerMetadata; _controllerSelector = EntityRepositoryControllerSelector.Install(webApiConfig, this); }
public static IEntitySetMetadata GetEntitySetFor(this IContainerMetadata containerMetadata, IEdmSchemaType edmSchemaType) { Contract.Requires <ArgumentNullException>(containerMetadata != null); Contract.Requires <ArgumentNullException>(edmSchemaType != null); IEntityTypeMetadata entityType = GetEntityType(containerMetadata, edmSchemaType); if (entityType == null) { return(null); } return(containerMetadata.EntitySets.SingleOrDefault(es => es.ElementTypeHierarchyMetadata.Contains(entityType))); }
public static IEntityTypeMetadata GetEntityType(this IContainerMetadata containerMetadata, IEdmSchemaType edmSchemaType) { Contract.Requires <ArgumentNullException>(containerMetadata != null); Contract.Requires <ArgumentNullException>(edmSchemaType != null); return(containerMetadata.EntityTypes.SingleOrDefault(et => { IEdmEntityType edmType = et.EdmType; return edmType.TypeKind == edmSchemaType.TypeKind && edmType.Name == edmSchemaType.Name && ((edmType.Namespace == edmSchemaType.Namespace) || (containerMetadata.Namespace == edmSchemaType.Namespace) || (et.ClrType.Namespace == edmSchemaType.Namespace)); })); }
/// <summary> /// Initializes a new instance of the <see cref="EntityRepositoryActionSelector" /> class. /// </summary> /// <param name="containerMetadata">The container metadata describing all the entity sets in the container.</param> /// <param name="innerSelector">The inner controller selector to call.</param> public EntityRepositoryActionSelector(IContainerMetadata containerMetadata, IHttpActionSelector innerSelector) { if (containerMetadata == null) { throw new ArgumentNullException("containerMetadata"); } if (innerSelector == null) { throw new ArgumentNullException("innerSelector"); } _containerMetadata = containerMetadata; _innerSelector = innerSelector; }
internal EntitySetMetadata(Type contextType, IContainerMetadata container, IEdmEntitySet edmEntitySet, IEntityTypeMetadata entityTypeMetadata, IEntityTypeMetadata[] entityTypeHierarchyMetadata) { Contract.Assert(container != null); Contract.Assert(edmEntitySet != null); Contract.Assert(entityTypeMetadata != null); Contract.Assert(entityTypeHierarchyMetadata != null); Contract.Assert(entityTypeHierarchyMetadata.Length >= 1); ContextType = contextType; ContainerMetadata = container; _edmEntitySet = edmEntitySet; ElementTypeMetadata = entityTypeMetadata; ElementTypeHierarchyMetadata = entityTypeHierarchyMetadata; }
/// <summary> /// Initializes a new instance of the <see cref="EntityRepositoryActionSelector" /> class. /// </summary> /// <param name="containerMetadata">The container metadata describing all the entity sets in the container.</param> /// <param name="innerSelector">The inner controller selector to call.</param> public EntityRepositoryActionSelector(IContainerMetadata containerMetadata, IHttpActionSelector innerSelector) { if (containerMetadata == null) { throw new ArgumentNullException("containerMetadata"); } if (innerSelector == null) { throw new ArgumentNullException("innerSelector"); } _containerMetadata = containerMetadata; _innerSelector = innerSelector; }
internal EntitySetMetadata(Type contextType, IContainerMetadata container, IEdmEntitySet edmEntitySet, IEntityTypeMetadata entityTypeMetadata, IEntityTypeMetadata[] entityTypeHierarchyMetadata) { Contract.Assert(container != null); Contract.Assert(edmEntitySet != null); Contract.Assert(entityTypeMetadata != null); Contract.Assert(entityTypeHierarchyMetadata != null); Contract.Assert(entityTypeHierarchyMetadata.Length >= 1); ContextType = contextType; ContainerMetadata = container; _edmEntitySet = edmEntitySet; ElementTypeMetadata = entityTypeMetadata; ElementTypeHierarchyMetadata = entityTypeHierarchyMetadata; }
public ODataServerConfigurer(HttpConfiguration webApiConfig) { Contract.Requires <ArgumentNullException>(webApiConfig != null); _webApiConfig = webApiConfig; // Obtain the container metadata from the DI service _containerMetadata = webApiConfig.DependencyResolver.Resolve <IContainerMetadata>(); if (_containerMetadata == null) { throw new ArgumentException("IContainerMetadata could not be resolved from HttpConfiguration.DependencyResolver."); } _controllerSelector = EntityRepositoryControllerSelector.Install(webApiConfig, this); }
public ODataServerConfigurer(HttpConfiguration webApiConfig) { Contract.Requires<ArgumentNullException>(webApiConfig != null); _webApiConfig = webApiConfig; // Obtain the container metadata from the DI service _containerMetadata = webApiConfig.DependencyResolver.Resolve<IContainerMetadata>(); if (_containerMetadata == null) { throw new ArgumentException("IContainerMetadata could not be resolved from HttpConfiguration.DependencyResolver."); } _controllerSelector = EntityRepositoryControllerSelector.Install(webApiConfig, this); }
protected EntitySetController(IContainerMetadata containerMetadata, ODataValidationSettings queryValidationSettings, ODataQuerySettings querySettings) { Contract.Requires<ArgumentNullException>(containerMetadata != null); Contract.Requires<ArgumentNullException>(queryValidationSettings != null); Contract.Requires<ArgumentNullException>(querySettings != null); _entitySetMetadata = containerMetadata.GetEntitySetFor(typeof(TEntity)); if (_entitySetMetadata == null) { throw new InvalidOperationException("EntitySet not found in containerMetadata for type " + typeof(TEntity)); } _queryValidationSettings = queryValidationSettings; _querySettings = querySettings; }
public static void ConfigureFromContainer(this ODataModelBuilder modelBuilder, IContainerMetadata containerMetadata) { modelBuilder.ContainerName = containerMetadata.Name; modelBuilder.Namespace = containerMetadata.Namespace; // Add all entity types foreach (IEntityTypeMetadata entityTypeMetadata in containerMetadata.EntityTypes) { EntityTypeConfiguration entityTypeConfig = modelBuilder.AddEntity(entityTypeMetadata.ClrType); } // Add all entity sets foreach (IEntitySetMetadata entitySetMetadata in containerMetadata.EntitySets) { string entitySetName = entitySetMetadata.Name; EntityTypeConfiguration entityTypeConfig = (EntityTypeConfiguration) modelBuilder.GetTypeConfigurationOrNull(entitySetMetadata.ElementTypeMetadata.ClrType); EntitySetConfiguration entitySetConfig = modelBuilder.AddEntitySet(entitySetName, entityTypeConfig); } }
private static void ExpandGenericNavigationActionsForAllNavigationProperties(IEnumerable <HttpActionDescriptor> navigationActions, List <HttpActionDescriptor> expandedDescriptors, List <HttpActionDescriptor> removeDescriptors, Func <string, string> actionNameBuilder) { foreach (HttpActionDescriptor navigationAction in navigationActions) { ReflectedHttpActionDescriptor reflectedHttpActionDescriptor = navigationAction as ReflectedHttpActionDescriptor; if ((reflectedHttpActionDescriptor != null) && reflectedHttpActionDescriptor.MethodInfo.IsGenericMethodDefinition && reflectedHttpActionDescriptor.MethodInfo.GetGenericArguments().Length == 1) { // Lookup the EntitySet metadata for the controller IContainerMetadata containerMetadata = reflectedHttpActionDescriptor.ControllerDescriptor.GetContainerMetadata(); if (containerMetadata != null) { IEntitySetMetadata entitySetMetadata = containerMetadata.GetEntitySet(reflectedHttpActionDescriptor.ControllerDescriptor.ControllerName); if (entitySetMetadata != null) { foreach (IEntityTypeMetadata entityTypeMetadata in entitySetMetadata.ElementTypeHierarchyMetadata) { // Foreach NavigationProperty in all of the entity types, add a new HttpActionDescriptor foreach (var edmNavigationProperty in entityTypeMetadata.EdmType.DeclaredProperties.OfType <IEdmNavigationProperty>()) { IEdmEntityType toEntityType = edmNavigationProperty.ToEntityType(); IEntityTypeMetadata propertyTypeMetadata = containerMetadata.GetEntityType(toEntityType); Type tProperty = propertyTypeMetadata.ClrType; MethodInfo genericMethod = reflectedHttpActionDescriptor.MethodInfo.MakeGenericMethod(tProperty); string expandedActionName = actionNameBuilder(edmNavigationProperty.Name); expandedDescriptors.Add(new RenamedReflectedHttpActionDescriptor(reflectedHttpActionDescriptor.ControllerDescriptor, genericMethod, expandedActionName)); } } } } removeDescriptors.Add(reflectedHttpActionDescriptor); } } }
/// <summary> /// Common construction code for all constructors /// </summary> /// <param name="stream"></param> /// <param name="audioBuffer"></param> /// <param name="videoBuffer"></param> private void CommonConstruct(EncryptedStream stream, SampleBuffer audioBuffer, SampleBuffer videoBuffer, IContainerMetadata metadata, uint bitrate, BandwidthHistory BWHistory) { if (stream == null) throw new ArgumentNullException("stream"); _stream = stream; _metadata = metadata; _audioBuffer = audioBuffer; _audioBuffer.ResetOnSegmentStart(); _videoBuffer = videoBuffer; _videoBuffer.ResetOnSegmentStart(); _previousReadEndTime = stream.RequestStartTime; _bitrate = bitrate; _downloadChunkBuffer = new byte[_downloadChunkSize]; _TSPacketBuffer = new byte[TSPacketSize]; _BWHistory = BWHistory; }
/// <summary> /// Special constructor for creating new demux for next stream in sequence /// </summary> /// <param name="stream"></param> /// <param name="previousDemux"></param> public TSDemux(EncryptedStream stream, TSDemux previousDemux, IContainerMetadata metadata, uint bitrate, BandwidthHistory BWHistory) { if (previousDemux == null) throw new ArgumentNullException("previousDemux"); CommonConstruct(stream, previousDemux._audioBuffer, previousDemux._videoBuffer, metadata, bitrate, BWHistory); if (!stream.Discontinuity) _streams = previousDemux._streams; _audioFormatParser = previousDemux._audioFormatParser; _videoFormatParser = previousDemux._videoFormatParser; _audioFormatParser.HLSStream = stream.HLSStream; _videoFormatParser.HLSStream = stream.HLSStream; }
/// <summary> /// Default constructor. /// </summary> /// <param name="stream"></param> /// <param name="audioBuffer"></param> /// <param name="videoBuffer"></param> public TSDemux(EncryptedStream stream, SampleBuffer audioBuffer, SampleBuffer videoBuffer, IContainerMetadata metadata, uint bitrate, BandwidthHistory BWHistory) { CommonConstruct(stream, audioBuffer, videoBuffer, metadata, bitrate, BWHistory); }
public static void ConfigureFromContainer(this ODataModelBuilder modelBuilder, IContainerMetadata containerMetadata) { modelBuilder.ContainerName = containerMetadata.Name; modelBuilder.Namespace = containerMetadata.Namespace; // Add all entity types foreach (IEntityTypeMetadata entityTypeMetadata in containerMetadata.EntityTypes) { EntityTypeConfiguration entityTypeConfig = modelBuilder.AddEntity(entityTypeMetadata.ClrType); } // Add all entity sets foreach (IEntitySetMetadata entitySetMetadata in containerMetadata.EntitySets) { string entitySetName = entitySetMetadata.Name; EntityTypeConfiguration entityTypeConfig = (EntityTypeConfiguration)modelBuilder.GetTypeConfigurationOrNull(entitySetMetadata.ElementTypeMetadata.ClrType); EntitySetConfiguration entitySetConfig = modelBuilder.AddEntitySet(entitySetName, entityTypeConfig); } }
public EntityRepositoryMetadataController(IContainerMetadata containerMetadata) { Contract.Requires<ArgumentNullException>(containerMetadata != null); _containerMetadata = containerMetadata; }
public EntityRepositoryMetadataController(IContainerMetadata containerMetadata) { Contract.Requires <ArgumentNullException>(containerMetadata != null); _containerMetadata = containerMetadata; }