/// <summary>
        /// Sets the EntityContainer to default DataServiceConfiguration settings if not specified
        /// Default settings are all permissions for all entitysets
        /// All permissions for ServiceOperations
        /// Visible permissions for all actions
        /// and UseVerboseErrors = true
        /// </summary>
        /// <param name="model">The model to fix up</param>
        public void Fixup(EntityModelSchema model)
        {
            EntityContainer container = model.GetDefaultEntityContainer();
            if (!container.Annotations.OfType<EntitySetRightsAnnotation>().Any())
            {
                container.Annotations.Add(new EntitySetRightsAnnotation() { Value = EntitySetRights.All });
            }

            if (!container.Annotations.OfType<ServiceOperationRightsAnnotation>().Any())
            {
                container.Annotations.Add(new ServiceOperationRightsAnnotation() { Value = ServiceOperationRights.All });
            }

            if (!container.Annotations.OfType<ActionOperationRightsAnnotation>().Any())
            {
                container.Annotations.Add(new ActionOperationRightsAnnotation() { Value = ActionOperationRights.Invoke });
            }

            DataServiceConfigurationAnnotation dataServiceConfigurationAnnotation = container.GetDataServiceConfiguration();
            if (dataServiceConfigurationAnnotation == null)
            {
                dataServiceConfigurationAnnotation = new DataServiceConfigurationAnnotation();
                dataServiceConfigurationAnnotation.UseVerboseErrors = true;
                container.Annotations.Add(dataServiceConfigurationAnnotation);
            }
            
            DataServiceBehaviorAnnotation dataServiceBehaviorAnnotation = container.GetDataServiceBehavior();
            if (dataServiceBehaviorAnnotation == null)
            {
                dataServiceBehaviorAnnotation = new DataServiceBehaviorAnnotation();
                dataServiceBehaviorAnnotation.MaxProtocolVersion = this.MaxProtocolVersion;
                container.Annotations.Add(dataServiceBehaviorAnnotation);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Remove V3 features
        /// </summary>
        /// <param name="model">The model to fix up</param>
        public void Fixup(EntityModelSchema model)
        {
            if (this.version < DataServiceProtocolVersion.V4)
            {
                EntityContainer defaultContainer = model.GetDefaultEntityContainer();
                ExceptionUtilities.CheckObjectNotNull(defaultContainer, "Expected a EntityContainer in the model, likely need to execute AddDefaultContainerFixup");
                DataServiceBehaviorAnnotation serviceBehaviorAnnotation = defaultContainer.GetDataServiceBehavior();
                ExceptionUtilities.CheckObjectNotNull(serviceBehaviorAnnotation, "Expected a EntityContainer in the model, likely need to execute SetDefaultDataServiceConfigurationBehaviors fixup");

                new RemoveActionsFixup().Fixup(model);
                new RemoveMultiValueFixup().Fixup(model);
                new RemoveNamedStreamsFixup().Fixup(model);
                new RemoveNavigationPropertiesFromDerivedTypesFixup().Fixup(model);
                serviceBehaviorAnnotation.IncludeAssociationLinksInResponse = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the EntityContainer to default DataServiceConfiguration settings if not specified
        /// Default settings are all permissions for all entitysets
        /// All permissions for ServiceOperations
        /// Visible permissions for all actions
        /// and UseVerboseErrors = true
        /// </summary>
        /// <param name="model">The model to fix up</param>
        public void Fixup(EntityModelSchema model)
        {
            EntityContainer container = model.GetDefaultEntityContainer();

            if (!container.Annotations.OfType <EntitySetRightsAnnotation>().Any())
            {
                container.Annotations.Add(new EntitySetRightsAnnotation()
                {
                    Value = EntitySetRights.All
                });
            }

            if (!container.Annotations.OfType <ServiceOperationRightsAnnotation>().Any())
            {
                container.Annotations.Add(new ServiceOperationRightsAnnotation()
                {
                    Value = ServiceOperationRights.All
                });
            }

            if (!container.Annotations.OfType <ActionOperationRightsAnnotation>().Any())
            {
                container.Annotations.Add(new ActionOperationRightsAnnotation()
                {
                    Value = ActionOperationRights.Invoke
                });
            }

            DataServiceConfigurationAnnotation dataServiceConfigurationAnnotation = container.GetDataServiceConfiguration();

            if (dataServiceConfigurationAnnotation == null)
            {
                dataServiceConfigurationAnnotation = new DataServiceConfigurationAnnotation();
                dataServiceConfigurationAnnotation.UseVerboseErrors = true;
                container.Annotations.Add(dataServiceConfigurationAnnotation);
            }

            DataServiceBehaviorAnnotation dataServiceBehaviorAnnotation = container.GetDataServiceBehavior();

            if (dataServiceBehaviorAnnotation == null)
            {
                dataServiceBehaviorAnnotation = new DataServiceBehaviorAnnotation();
                dataServiceBehaviorAnnotation.MaxProtocolVersion = this.MaxProtocolVersion;
                container.Annotations.Add(dataServiceBehaviorAnnotation);
            }
        }