Example #1
0
 public NonNullTypeNode(
     Location location,
     INullableType type)
 {
     Location = location;
     Type     = type ?? throw new ArgumentNullException(nameof(type));
 }
Example #2
0
        public bool IsValid(IStructuralItem modelItem)
        {
            INullableType nullableType = modelItem as INullableType;

            // Get underlying type if it is an INullableType.
            modelItem =
                null != nullableType ? nullableType.UnderlyingType : modelItem;

            // Ensure the type matches the business type,
            // or the underlying type
            while (modelItem is ISemanticType)
            {
                if (String.Equals(((ISemanticType)modelItem).Id,
                                  "ApressExtensionCS:DurationType",
                                  StringComparison.Ordinal))
                {
                    return(true);
                }
                modelItem = ((ISemanticType)modelItem).UnderlyingType;
            }

            //Don't apply the validation if the conditions aren't met
            return(false);
        }
Example #3
0
 public NonNullTypeNode WithType(INullableType type)
 {
     return(new NonNullTypeNode(Location, Type));
 }