本文整理汇总了C#中TypeUsage类的典型用法代码示例。如果您正苦于以下问题:C# TypeUsage类的具体用法?C# TypeUsage怎么用?C# TypeUsage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeUsage类属于命名空间,在下文中一共展示了TypeUsage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetType
/// <summary>
/// Given a clrType attempt to return the corresponding target type from
/// the worksapce
/// </summary>
/// <param name="clrType"> The clr type to resolve </param>
/// <param name="outTypeUsage"> an out param for the typeUsage to be resolved to </param>
/// <returns> true if a TypeUsage can be found for the target type </returns>
internal bool TryGetType(Type clrType, out TypeUsage outTypeUsage)
{
return TryGetTypeByName(
clrType.FullNameWithNesting(),
false /*ignoreCase*/,
out outTypeUsage);
}
示例2: TryGetTypeByName
/// <summary>
/// Look up a type in the target data space based upon the fullName
/// </summary>
/// <param name="fullName"> fullName </param>
/// <param name="ignoreCase"> true for case-insensitive lookup </param>
/// <param name="typeUsage"> The type usage object to return </param>
/// <returns> True if the retrieval succeeded </returns>
internal override bool TryGetTypeByName(string fullName, bool ignoreCase, out TypeUsage typeUsage)
{
typeUsage = null;
Map map = null;
// From ClrPerspective, we should not allow anything from SSpace. So make sure that the CSpace type does not
// have the Target attribute
if (MetadataWorkspace.TryGetMap(fullName, DataSpace.OSpace, ignoreCase, DataSpace.OCSpace, out map))
{
// Check if it's primitive type, if so, then use the MetadataWorkspace to get the mapped primitive type
if (map.EdmItem.BuiltInTypeKind
== BuiltInTypeKind.PrimitiveType)
{
// Reassign the variable with the provider primitive type, then create the type usage
var primitiveType = MetadataWorkspace.GetMappedPrimitiveType(
((PrimitiveType)map.EdmItem).PrimitiveTypeKind, DataSpace.CSpace);
if (primitiveType != null)
{
typeUsage = EdmProviderManifest.Instance.GetCanonicalModelTypeUsage(primitiveType.PrimitiveTypeKind);
}
}
else
{
Debug.Assert(((GlobalItem)map.EdmItem).DataSpace == DataSpace.CSpace);
typeUsage = GetMappedTypeUsage(map);
}
}
return (null != typeUsage);
}
示例3: DbUnaryExpression
internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument)
: base(kind, resultType)
{
Debug.Assert(argument != null, "DbUnaryExpression.Argument cannot be null");
_argument = argument;
}
示例4: GetEdmType
public override TypeUsage GetEdmType(TypeUsage storeType)
{
if (storeType == null)
{
throw new ArgumentNullException("storeType");
}
string storeTypeName = storeType.EdmType.Name.ToLowerInvariant();
if (!base.StoreTypeNameToEdmPrimitiveType.ContainsKey(storeTypeName))
{
throw new ArgumentException(String.Format("The underlying provider does not support the type '{0}'.", storeTypeName));
}
PrimitiveType edmPrimitiveType = base.StoreTypeNameToEdmPrimitiveType[storeTypeName];
if (edmPrimitiveType.PrimitiveTypeKind == PrimitiveTypeKind.Binary)
{
return TypeUsage.CreateBinaryTypeUsage(edmPrimitiveType, false);
}
if (edmPrimitiveType.PrimitiveTypeKind == PrimitiveTypeKind.String)
{
Facet facet;
if (storeType.Facets.TryGetValue("MaxLength", false, out facet) && !facet.IsUnbounded && facet.Value != null)
return TypeUsage.CreateStringTypeUsage(edmPrimitiveType, false, false, (int)facet.Value);
else
return TypeUsage.CreateStringTypeUsage(edmPrimitiveType, false, false);
}
return TypeUsage.CreateDefaultTypeUsage(edmPrimitiveType);
}
示例5: DbUnaryExpression
internal DbUnaryExpression(DbExpressionKind kind, TypeUsage resultType, DbExpression argument)
: base(kind, resultType)
{
DebugCheck.NotNull(argument);
_argument = argument;
}
示例6: ResolveCanonicalFunction
private static EdmFunction ResolveCanonicalFunction(string functionName, TypeUsage[] argumentTypes)
{
DebugCheck.NotEmpty(functionName);
var functions = new List<EdmFunction>(
EdmProviderManifest.Instance.GetStoreFunctions().Where(
func => string.Equals(func.Name, functionName, StringComparison.Ordinal))
);
EdmFunction foundFunction = null;
var ambiguous = false;
if (functions.Count > 0)
{
foundFunction = FunctionOverloadResolver.ResolveFunctionOverloads(functions, argumentTypes, false, out ambiguous);
if (ambiguous)
{
throw new ArgumentException(Strings.Cqt_Function_CanonicalFunction_AmbiguousMatch(functionName));
}
}
if (foundFunction == null)
{
throw new ArgumentException(Strings.Cqt_Function_CanonicalFunction_NotFound(functionName));
}
return foundFunction;
}
示例7: ColumnModel
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
/// <param name = "type">The data type for this column.</param>
/// <param name = "typeUsage">
/// Additional details about the data type.
/// This includes details such as maximum length, nullability etc.
/// </param>
public ColumnModel(PrimitiveTypeKind type, TypeUsage typeUsage)
{
_type = type;
_typeUsage = typeUsage;
_clrType = PrimitiveType.GetEdmPrimitiveType(_type).ClrEquivalentType;
_clrDefaultValue = CreateDefaultValue();
}
示例8: EdmMember
/// <summary>
/// Initializes a new instance of EdmMember class
/// </summary>
/// <param name="name">name of the member</param>
/// <param name="memberTypeUsage">type information containing info about member's type and its facet</param>
internal EdmMember(string name, TypeUsage memberTypeUsage)
{
EntityUtil.CheckStringArgument(name, "name");
EntityUtil.GenericCheckArgumentNull(memberTypeUsage, "memberTypeUsage");
_name = name;
_typeUsage = memberTypeUsage;
}
示例9: GetEdmType
public override TypeUsage GetEdmType(TypeUsage storeType)
{
string storeTypeName = storeType.EdmType.Name.ToLower();
PrimitiveType edmPrimitiveType = base.StoreTypeNameToEdmPrimitiveType[storeTypeName];
if (storeTypeName == "string" || storeTypeName == "varchar")
{
Facet f;
int maxLength = -1;
if (storeType.Facets.TryGetValue("MaxLength", false, out f) && !f.IsUnbounded && f.Value != null)
maxLength = (int)f.Value;
if (maxLength != -1)
return TypeUsage.CreateStringTypeUsage(edmPrimitiveType, false, false, maxLength);
else
return TypeUsage.CreateStringTypeUsage(edmPrimitiveType, false, false);
}
else if (storeTypeName == "decimal" || storeTypeName == "numeric")
{
Facet f;
byte precision = 0;
if (storeType.Facets.TryGetValue("Precision", false, out f) && !f.IsUnbounded && f.Value != null)
precision = (byte)f.Value;
byte scale = 0;
if (storeType.Facets.TryGetValue("Scale", false, out f) && !f.IsUnbounded && f.Value != null)
scale = (byte)f.Value;
if (precision != 0 && scale != 0)
return TypeUsage.CreateDecimalTypeUsage(edmPrimitiveType, precision, scale);
else
return TypeUsage.CreateDecimalTypeUsage(edmPrimitiveType);
}
else
return TypeUsage.CreateDefaultTypeUsage(edmPrimitiveType);
throw new NotImplementedException();
}
示例10: NavigationProperty
/// <summary>
/// Initializes a new instance of the navigation property class
/// </summary>
/// <param name="name">name of the navigation property</param>
/// <param name="typeUsage">TypeUsage object containing the navigation property type and its facets</param>
/// <exception cref="System.ArgumentNullException">Thrown if name or typeUsage arguments are null</exception>
/// <exception cref="System.ArgumentException">Thrown if name argument is empty string</exception>
internal NavigationProperty(string name, TypeUsage typeUsage)
: base(name, typeUsage)
{
EntityUtil.CheckStringArgument(name, "name");
EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage");
_accessor = new NavigationPropertyAccessor(name);
}
示例11: ResolveCanonicalFunction
private static EdmFunction ResolveCanonicalFunction(string functionName, TypeUsage[] argumentTypes)
{
Debug.Assert(!string.IsNullOrEmpty(functionName), "Function name must not be null");
List<EdmFunction> functions = new List<EdmFunction>(
System.Linq.Enumerable.Where(
EdmProviderManifest.Instance.GetStoreFunctions(),
func => string.Equals(func.Name, functionName, StringComparison.Ordinal))
);
EdmFunction foundFunction = null;
bool ambiguous = false;
if (functions.Count > 0)
{
foundFunction = EntitySql.FunctionOverloadResolver.ResolveFunctionOverloads(functions, argumentTypes, false, out ambiguous);
if (ambiguous)
{
throw EntityUtil.Argument(Strings.Cqt_Function_CanonicalFunction_AmbiguousMatch(functionName));
}
}
if (foundFunction == null)
{
throw EntityUtil.Argument(Strings.Cqt_Function_CanonicalFunction_NotFound(functionName));
}
return foundFunction;
}
示例12: CollectionType
/// <summary>
/// The constructor for constructing a CollectionType object with the element type (as a TypeUsage) it contains
/// </summary>
/// <param name="elementType">The element type that this collection type contains</param>
/// <exception cref="System.ArgumentNullException">Thrown if the argument elementType is null</exception>
internal CollectionType(TypeUsage elementType)
: base(GetIdentity(EntityUtil.GenericCheckArgumentNull(elementType, "elementType")),
EdmConstants.TransientNamespace, elementType.EdmType.DataSpace)
{
_typeUsage = elementType;
SetReadOnly();
}
示例13: MapPrimitivePropertyFacets
internal static void MapPrimitivePropertyFacets(
EdmProperty property, EdmProperty column, TypeUsage typeUsage)
{
DebugCheck.NotNull(property);
DebugCheck.NotNull(column);
DebugCheck.NotNull(typeUsage);
if (IsValidFacet(typeUsage, XmlConstants.FixedLengthElement))
{
column.IsFixedLength = property.IsFixedLength;
}
if (IsValidFacet(typeUsage, XmlConstants.MaxLengthElement))
{
column.IsMaxLength = property.IsMaxLength;
column.MaxLength = property.MaxLength;
}
if (IsValidFacet(typeUsage, XmlConstants.UnicodeElement))
{
column.IsUnicode = property.IsUnicode;
}
if (IsValidFacet(typeUsage, XmlConstants.PrecisionElement))
{
column.Precision = property.Precision;
}
if (IsValidFacet(typeUsage, XmlConstants.ScaleElement))
{
column.Scale = property.Scale;
}
}
示例14: Symbol
// <summary>
// Use this constructor if the symbol represents a SqlStatement for which the output columns need to be tracked.
// </summary>
public Symbol(string name, TypeUsage type, Dictionary<string, Symbol> outputColumns, bool outputColumnsRenamed)
{
this.name = name;
NewName = name;
Type = type;
this.outputColumns = outputColumns;
OutputColumnsRenamed = outputColumnsRenamed;
}
示例15: DbFunctionAggregate
internal DbFunctionAggregate(TypeUsage resultType, DbExpressionList arguments, EdmFunction function, bool isDistinct)
: base(resultType, arguments)
{
DebugCheck.NotNull(function);
_aggregateFunction = function;
_distinct = isDistinct;
}