本文整理汇总了C#中DataSpace.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DataSpace.ToString方法的具体用法?C# DataSpace.ToString怎么用?C# DataSpace.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSpace
的用法示例。
在下文中一共展示了DataSpace.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStoreGeneratedPatternValue
/// <summary>
/// Obtains the StoreGeneratedPattern value of an EdmProperty, given a target version and DataSpace
/// </summary>
/// <param name="property">The EdmProperty.</param>
/// <param name="targetVersion">Used to correctly look up the StoreGeneratedPattern value in the EdmProperty</param>
/// <param name="dataSpace">DataSpace where the EdmProperty lives (either CSDL or SSDL)</param>
/// <returns>One of the StoreGeneratedPattern values, or String.Empty if the attribute or value does not exist</returns>
public static StoreGeneratedPattern GetStoreGeneratedPatternValue(
this EdmMember property, Version targetVersion, DataSpace dataSpace)
{
if (targetVersion == null)
{
throw new ArgumentNullException("targetVersion");
}
if (dataSpace == DataSpace.CSSpace
|| dataSpace == DataSpace.OCSpace
|| dataSpace == DataSpace.OSpace)
{
throw new ArgumentException(
String.Format(CultureInfo.CurrentCulture, Resources.ErrorNonValidDataSpace, dataSpace.ToString()));
}
if (dataSpace == DataSpace.CSpace)
{
// In the CSDL, StoreGeneratedPattern exists as an annotation in the EntityStoreSchemaGeneratorNamespace
var sgpNamespace = SchemaManager.GetAnnotationNamespaceName();
if (String.IsNullOrEmpty(sgpNamespace))
{
throw new ArgumentException(
String.Format(CultureInfo.CurrentCulture, Resources.ErrorNonValidTargetVersion, targetVersion));
}
MetadataProperty sgpMetadataProperty = null;
if (property.MetadataProperties.TryGetValue(
sgpNamespace + ":" + EdmConstants.facetNameStoreGeneratedPattern, false, out sgpMetadataProperty))
{
var sgpValue = sgpMetadataProperty.Value as string;
Debug.Assert(
false == String.IsNullOrEmpty(sgpValue),
"If we found the StoreGeneratedPattern annotation in the CSDL, why weren't we able to find a value?");
if (false == String.IsNullOrEmpty(sgpValue))
{
return (StoreGeneratedPattern)Enum.Parse(typeof(StoreGeneratedPattern), sgpValue, false);
}
}
}
else if (dataSpace == DataSpace.SSpace)
{
// In the SSDL, StoreGeneratedPattern exists as a facet
Facet item = null;
if (property.TypeUsage.Facets.TryGetValue(EdmConstants.facetNameStoreGeneratedPattern, false, out item))
{
return (StoreGeneratedPattern)item.Value;
}
}
return StoreGeneratedPattern.None;
}