当前位置: 首页>>代码示例>>C#>>正文


C# EntityModelSchema.GetDefaultEntityContainer方法代码示例

本文整理汇总了C#中Microsoft.Test.Taupo.Contracts.EntityModel.EntityModelSchema.GetDefaultEntityContainer方法的典型用法代码示例。如果您正苦于以下问题:C# EntityModelSchema.GetDefaultEntityContainer方法的具体用法?C# EntityModelSchema.GetDefaultEntityContainer怎么用?C# EntityModelSchema.GetDefaultEntityContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Test.Taupo.Contracts.EntityModel.EntityModelSchema的用法示例。


在下文中一共展示了EntityModelSchema.GetDefaultEntityContainer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Fixup

        /// <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);
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:42,代码来源:SetDefaultDataServiceConfigurationBehaviors.cs

示例2: GenerateModel

        public EntityModelSchema GenerateModel()
        {
            var model = new EntityModelSchema()
                {
                    new EntityType("Customer")
                    {
                        Properties = 
                        {
                            new MemberProperty("CustomerId", DataTypes.Integer) { IsPrimaryKey = true },
                            new MemberProperty("Name", DataTypes.String.WithMaxLength(100)).WithDataGenerationHints(DataGenerationHints.InterestingValue<string>(string.Empty), DataGenerationHints.AnsiString, DataGenerationHints.MinLength(3)),                  
                            new MemberProperty("PrimaryContactInfo1", DataTypes.ComplexType.WithName("ContactDetails"))
                            {
                                Annotations =
                                {
                                    new MetadataDeclaredPropertyAnnotation(),
                                }
                            },
                            new MemberProperty("PrimaryContactInfo2", DataTypes.ComplexType.WithName("ContactDetails")),
                            new MemberProperty("Thumbnail", DataTypes.Stream),
                        },
                        IsOpen = true,
                    },
                    new ComplexType("ContactDetails")
                    {
                        new MemberProperty("FirstContacted", DataTypes.Binary),                        
                        new MemberProperty("LastContacted", DataTypes.DateTime.WithTimeZoneOffset(true)),
                        new MemberProperty("Contacted", DataTypes.DateTime),
                        new MemberProperty("GUID", DataTypes.Guid),
                        new MemberProperty("PreferedContactTime", DataTypes.TimeOfDay),                                                                                              
                        new MemberProperty("Byte", EdmDataTypes.Byte),
                        new MemberProperty("SignedByte", EdmDataTypes.SByte),
                        new MemberProperty("Double", EdmDataTypes.Double),
                        new MemberProperty("Single", EdmDataTypes.Single),
                        new MemberProperty("Short", EdmDataTypes.Int16),
                        new MemberProperty("Int", EdmDataTypes.Int32),
                        new MemberProperty("Long", EdmDataTypes.Int64),                                                                                      
                    },  
                };      

            // Apply default fixups
            new ResolveReferencesFixup().Fixup(model);
            new ApplyDefaultNamespaceFixup("OpenTypesComplexPropertiesModelGenerator").Fixup(model);
            new AddDefaultContainerFixup().Fixup(model);

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

            return model;
       }
开发者ID:larsenjo,项目名称:odata.net,代码行数:52,代码来源:OpenTypesComplexPropertiesModelGenerator.cs

示例3: Fixup

        /// <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;
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:20,代码来源:RemoveHigherVersionFeaturesFixup.cs

示例4: GenerateModel


//.........这里部分代码省略.........
                new AssociationType("Barcode_IncorrectScanExpected")
                {
                    new AssociationEnd("Barcode", "Barcode", EndMultiplicity.One),
                    new AssociationEnd("Expected", "IncorrectScan", EndMultiplicity.Many),
                    new ReferentialConstraint()
                        .WithDependentProperties("Expected", "ExpectedCode")
                        .ReferencesPrincipalProperties("Barcode", "Code"),
                },
                new AssociationType("Husband_Wife")
                {
                    new AssociationEnd("Husband", "Customer", EndMultiplicity.ZeroOne) { Annotations = { new PrincipalAnnotation() } },
                    new AssociationEnd("Wife", "Customer", EndMultiplicity.ZeroOne),
                },
                new AssociationType("Barcode_IncorrectScanActual")
                {
                    new AssociationEnd("Barcode", "Barcode", EndMultiplicity.ZeroOne),
                    new AssociationEnd("Actual", "IncorrectScan", EndMultiplicity.Many),
                    new ReferentialConstraint()
                        .WithDependentProperties("Actual", "ActualCode")
                        .ReferencesPrincipalProperties("Barcode", "Code"),
                },
                new AssociationType("Product_Barcodes")
                {
                    new AssociationEnd("Product", "Product", EndMultiplicity.One),
                    new AssociationEnd("Barcodes", "Barcode", EndMultiplicity.Many),
                    new ReferentialConstraint()
                        .WithDependentProperties("Barcodes", "ProductId")
                        .ReferencesPrincipalProperties("Product", "ProductId"),
                },
                new AssociationType("Barcode_BarcodeDetail")
                {
                    new AssociationEnd("Barcode", "Barcode", EndMultiplicity.One),
                    new AssociationEnd("BarcodeDetail", "BarcodeDetail", EndMultiplicity.ZeroOne),
                    new ReferentialConstraint()
                        .WithDependentProperties("BarcodeDetail", "Code")
                        .ReferencesPrincipalProperties("Barcode", "Code"),
                },
                new AssociationType("Login_SuspiciousActivity")
                {
                    new AssociationEnd("Login", "Login", EndMultiplicity.ZeroOne),
                    new AssociationEnd("Activity", "SuspiciousActivity", EndMultiplicity.Many),
                },
                new AssociationType("Login_RSAToken")
                {
                    new AssociationEnd("Login", "Login", EndMultiplicity.One),
                    new AssociationEnd("RSAToken", "RSAToken", EndMultiplicity.ZeroOne),
                },
                new AssociationType("Login_SmartCard")
                {
                    new AssociationEnd("Login", "Login", EndMultiplicity.One),
                    new AssociationEnd("SmartCard", "SmartCard", EndMultiplicity.ZeroOne),
                    new ReferentialConstraint()
                        .WithDependentProperties("SmartCard", "Username")
                        .ReferencesPrincipalProperties("Login", "Username"),
                },
                new AssociationType("Login_PasswordResets")
                {
                    new AssociationEnd("Login", "Login", EndMultiplicity.One),
                    new AssociationEnd("PasswordResets", "PasswordReset", EndMultiplicity.Many),
                    new ReferentialConstraint()
                        .WithDependentProperties("PasswordResets", "Username")
                        .ReferencesPrincipalProperties("Login", "Username"),
                },

                new AssociationType("Login_PageViews")
                {
                    new AssociationEnd("Login", "Login", EndMultiplicity.One),
                    new AssociationEnd("PageViews", "PageView", EndMultiplicity.Many),
                    new ReferentialConstraint()
                        .WithDependentProperties("PageViews", "Username")
                        .ReferencesPrincipalProperties("Login", "Username"),
                },
                new AssociationType("Computer_ComputerDetail")
                {
                    new AssociationEnd("Computer", "Computer", EndMultiplicity.One) { Annotations = { new PrincipalAnnotation() } },
                    new AssociationEnd("ComputerDetail", "ComputerDetail", EndMultiplicity.One),
                },
                new AssociationType("Driver_License")
                {
                    new AssociationEnd("Driver", "Driver", EndMultiplicity.One),
                    new AssociationEnd("License", "License", EndMultiplicity.One),
                    new ReferentialConstraint()
                        .WithDependentProperties("License", "Name")
                        .ReferencesPrincipalProperties("Driver", "Name"),
                },
            };

            // Apply default fixups
            new ResolveReferencesFixup().Fixup(model);
            new ApplyDefaultNamespaceFixup("AstoriaPhoneModelGenerator").Fixup(model);
            new AddDefaultContainerFixup().Fixup(model);

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

            return model;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:101,代码来源:AstoriaPhoneModelGenerator.cs


注:本文中的Microsoft.Test.Taupo.Contracts.EntityModel.EntityModelSchema.GetDefaultEntityContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。