Пример #1
0
 public FieldCoordinate(
     NameString typeName,
     NameString fieldName,
     NameString?argumentName = null)
 {
     TypeName     = typeName.EnsureNotEmpty(nameof(typeName));
     FieldName    = fieldName.EnsureNotEmpty(nameof(fieldName));
     ArgumentName = argumentName?.EnsureNotEmpty(nameof(argumentName));
     HasValue     = true;
 }
Пример #2
0
        public DirectiveType GetDirectiveType(NameString directiveName)
        {
            if (_directiveTypes.TryGetValue(
                    directiveName.EnsureNotEmpty(nameof(directiveName)),
                    out DirectiveType? type))
            {
                return(type);
            }

            throw new ArgumentException(
                      string.Format(TypeResources.Schema_GetDirectiveType_DoesNotExist, directiveName),
                      nameof(directiveName));
        }
Пример #3
0
        public DirectiveType GetDirectiveType(NameString directiveName)
        {
            if (_directiveTypes.TryGetValue(
                    directiveName.EnsureNotEmpty(nameof(directiveName)),
                    out DirectiveType? type))
            {
                return(type);
            }

            // TODO : resource
            throw new ArgumentException(
                      $"The specified type `{directiveName}` does not exist.",
                      nameof(directiveName));
        }
        public static void TryBindRuntimeType(
            this IDescriptorContext context,
            NameString typeName,
            Type runtimeType)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (runtimeType is null)
            {
                throw new ArgumentNullException(nameof(runtimeType));
            }

            typeName.EnsureNotEmpty(nameof(typeName));

            if (context.ContextData.TryGetValue(WellKnownContextData.RuntimeTypes, out var o) &&
                o is Dictionary <NameString, Type> runtimeTypes)
            {
                runtimeTypes[typeName] = runtimeType;
            }
        }
Пример #5
0
 public T GetType <T>(NameString typeName)
     where T : INamedType =>
 _types.GetType <T>(typeName.EnsureNotEmpty(nameof(typeName)));
Пример #6
0
 public bool TryGetDirectiveType(
     NameString directiveName,
     [NotNullWhen(true)] out DirectiveType?directiveType) =>
 _directiveTypes.TryGetValue(
     directiveName.EnsureNotEmpty(nameof(directiveName)),
     out directiveType);
Пример #7
0
 public bool TryGetRuntimeType(NameString typeName, [NotNullWhen(true)] out Type?clrType) =>
 _types.TryGetClrType(typeName.EnsureNotEmpty(nameof(typeName)), out clrType);
Пример #8
0
 public bool TryGetType <T>(NameString typeName, [NotNullWhen(true)] out T type)
     where T : INamedType =>
 _types.TryGetType(typeName.EnsureNotEmpty(nameof(typeName)), out type);
Пример #9
0
 /// <summary>
 /// Tries to get the .net type representation of a schema.
 /// </summary>
 /// <param name="typeName">The name of the type.</param>
 /// <param name="clrType">The resolved .net type.</param>
 /// <returns>
 /// <c>true</c>, if a .net type was found that was bound
 /// the the specified schema type, <c>false</c> otherwise.
 /// </returns>
 public bool TryGetClrType(NameString typeName, out Type clrType)
 {
     return(_types.TryGetClrType(
                typeName.EnsureNotEmpty(nameof(typeName)),
                out clrType));
 }
Пример #10
0
 public NamePathSegment Append(NameString name)
 {
     name.EnsureNotEmpty(nameof(name));
     return(new NamePathSegment(this, name));
 }
Пример #11
0
 public bool TryGetRuntimeType(NameString typeName, [MaybeNullWhen(false)] out Type?runtimeType) =>
 _types.TryGetClrType(typeName.EnsureNotEmpty(nameof(typeName)), out runtimeType);