本文整理汇总了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);
}
}
示例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;
}
示例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;
}
}
示例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;
}