/// <summary>
        /// Override in descendant classes to supply all dialect supported operators.
        /// </summary>
        /// <param name="typeConverter">The concrete <see cref="IPrimitiveTypeConverter" /> implementation used for type conversions.</param>
        /// <returns>
        /// An array of all supported operators.
        /// </returns>
        /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
        protected override IEnumerable <Operator> CreateOperators(IPrimitiveTypeConverter typeConverter)
        {
            Debug.Assert(typeConverter != null);

            return(new Operator[]
            {
                new RelationalEqualsOperator(StringLiteralComparer, typeConverter),
                new RelationalNotEqualsOperator(StringLiteralComparer, typeConverter),
                new RelationalGreaterThanOperator(StringLiteralComparer, typeConverter),
                new RelationalGreaterThanOrEqualsOperator(StringLiteralComparer, typeConverter),
                new RelationalLowerThanOperator(StringLiteralComparer, typeConverter),
                new RelationalLowerThanOrEqualsOperator(StringLiteralComparer, typeConverter),
                new LogicalAndOperator(typeConverter),
                new LogicalOrOperator(typeConverter),
                new LogicalNotOperator(typeConverter),
                new BitwiseAndOperator(typeConverter),
                new BitwiseOrOperator(typeConverter),
                new BitwiseXorOperator(typeConverter),
                new BitwiseNotOperator(typeConverter),
                new BitwiseShiftLeftOperator(typeConverter),
                new BitwiseShiftRightOperator(typeConverter),
                new ArithmeticDivideOperator(typeConverter),
                new ArithmeticModuloOperator(typeConverter),
                new ArithmeticMultiplyOperator(typeConverter),
                new ArithmeticNegateOperator(typeConverter),
                new ArithmeticNeutralOperator(typeConverter),
                new ArithmeticSubtractOperator(typeConverter),
                new ArithmeticSumOperator(typeConverter),
                new SequenceOperator(typeConverter),
                new FormatOperator(Culture, typeConverter)
            });
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RelationalNotEqualsOperator" /> class.
 /// </summary>
 /// <param name="symbol">The operator's symbol.</param>
 /// <param name="stringComparer">The string literal comparer.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> or <paramref name="typeConverter" /> or <paramref name="stringComparer" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
 public RelationalNotEqualsOperator(
     [NotNull] string symbol,
     [NotNull] IComparer <string> stringComparer,
     [NotNull] IPrimitiveTypeConverter typeConverter)
     : base(symbol, 7, stringComparer, typeConverter)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardBinaryOperator" /> class.
        /// </summary>
        /// <param name="symbol">The operator's symbol.</param>
        /// <param name="precedence">The operator's precedence.</param>
        /// <param name="typeConverter">The type converter.</param>
        /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
        /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
        protected StandardBinaryOperator([NotNull] string symbol, int precedence, [NotNull] IPrimitiveTypeConverter typeConverter)
            : base(symbol, precedence, Associativity.LeftToRight)
        {
            Expect.NotNull(nameof(typeConverter), typeConverter);

            TypeConverter = typeConverter;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardUnaryOperator" /> class.
        /// </summary>
        /// <param name="symbol">The operator's symbol.</param>
        /// <param name="typeConverter">The type converter.</param>
        /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
        /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
        protected StandardUnaryOperator([NotNull] string symbol, [NotNull] IPrimitiveTypeConverter typeConverter)
            : base(symbol)
        {
            Expect.NotNull(nameof(typeConverter), typeConverter);

            TypeConverter = typeConverter;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RelationalLowerThanOperator" /> class.
 /// </summary>
 /// <param name="symbol">The operator's symbol.</param>
 /// <param name="stringComparer">The string literal comparer.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> or <paramref name="typeConverter" /> or <paramref name="stringComparer" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
 public RelationalLowerThanOperator(
     [NotNull] string symbol,
     [NotNull] IComparer <string> stringComparer,
     [NotNull] IPrimitiveTypeConverter typeConverter)
     : base(symbol, 6, stringComparer, typeConverter)
 {
 }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardDirective"/> class.
        /// </summary>
        /// <param name="typeConverter">The type converter.</param>
        /// <param name="tags">The tags that make up this directive.</param>
        /// <exception cref="ArgumentNullException">Argument <paramref name="tags"/> or <paramref name="typeConverter"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Argument <paramref name="tags"/> is empty.</exception>
        /// <exception cref="InvalidOperationException">One or more tags have no defined components.</exception>
        protected StandardDirective([NotNull] IPrimitiveTypeConverter typeConverter, [NotNull][ItemNotNull] params Tag[] tags)
            : base(tags)
        {
            Expect.NotNull(nameof(typeConverter), typeConverter);

            TypeConverter = typeConverter;
        }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardRelationalOperator" /> class.
        /// </summary>
        /// <param name="symbol">The operator's symbol.</param>
        /// <param name="precedence">The operator's precedence.</param>
        /// <param name="stringComparer">The string literal comparer.</param>
        /// <param name="typeConverter">The type converter.</param>
        /// <exception cref="ArgumentNullException">Arguments <paramref name="symbol" />, <paramref name="typeConverter" /> or <paramref name="stringComparer" /> are <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Argument <paramref name="precedence"/> is less than zero.</exception>
        protected StandardRelationalOperator(
            [NotNull] string symbol,
            int precedence,
            [NotNull] IComparer <string> stringComparer,
            [NotNull] IPrimitiveTypeConverter typeConverter)
            : base(symbol, precedence, typeConverter)
        {
            Expect.NotNull(nameof(stringComparer), stringComparer);

            StringComparer = stringComparer;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PreFormattedUnParsedTextDirective" /> class.
        /// </summary>
        /// <param name="startTagMarkup">The start tag markup.</param>
        /// <param name="endTagMarkup">The end tag markup.</param>
        /// <param name="stateObject">The state object to register.</param>
        /// <param name="typeConverter">The type converter.</param>
        /// <exception cref="FormatException">Argument <paramref name="startTagMarkup" /> or <paramref name="endTagMarkup" /> cannot be parsed.</exception>
        /// <exception cref="ArgumentNullException">Argument <paramref name="stateObject" /> is <c>null</c>.</exception>
        public PreFormattedUnParsedTextDirective(
            [NotNull] string startTagMarkup,
            [NotNull] string endTagMarkup,
            [NotNull] object stateObject,
            [NotNull] IPrimitiveTypeConverter typeConverter)
            : base(typeConverter, Tag.Parse(startTagMarkup), Tag.Parse(endTagMarkup))
        {
            Debug.Assert(Tags.Count == 2, "Expected a tag count of 2.");

            Expect.NotNull(nameof(stateObject), stateObject);

            _stateObject = stateObject;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InterpolationDirective"/> class.
        /// <remarks>
        /// The <paramref name="tagMarkup"/> is expected to contain exactly one expression component - the interpolated expression.
        /// </remarks>
        /// </summary>
        /// <param name="tagMarkup">The tag markup.</param>
        /// <param name="typeConverter">The type converter.</param>
        /// <exception cref="InvalidOperationException">Argument <paramref name="tagMarkup"/> does not correspond to the expressed rules.</exception>
        /// <exception cref="System.FormatException">Argument <paramref name="tagMarkup"/> cannot be parsed.</exception>
        public InterpolationDirective([NotNull] string tagMarkup, [NotNull] IPrimitiveTypeConverter typeConverter)
            : base(typeConverter, Tag.Parse(tagMarkup))
        {
            Debug.Assert(Tags.Count == 1, "Expected a tag count of 1.");

            /* Find all expressions. */
            var tag = Tags[0];
            var expressionComponents = Enumerable.Range(0, tag.ComponentCount)
                                       .Where(index => tag.MatchesExpression(index)).Select(index => index).ToArray();

            Expect.IsTrue(nameof(expressionComponents), expressionComponents.Length == 1);

            _interpolatedExpressionComponentIndex = expressionComponents[0];
        }
        /// <summary>
        /// Override in descendant classes to supply all dialect supported directives.
        /// </summary>
        /// <param name="typeConverter">The concrete <see cref="IPrimitiveTypeConverter" /> implementation used for type conversions.</param>
        /// <returns>
        /// An array of all supported directives.
        /// </returns>
        /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
        protected override IEnumerable <Directive> CreateDirectives(IPrimitiveTypeConverter typeConverter)
        {
            Debug.Assert(typeConverter != null);

            return(new Directive[]
            {
                new ConditionalInterpolationDirective(AdjustCasing("$ IF $"), false, typeConverter),
                new ForEachDirective(AdjustCasing("FOR EACH ? IN $"), AdjustCasing("END"), typeConverter),
                new IfDirective(AdjustCasing("IF $ THEN"), AdjustCasing("END"), typeConverter),
                new IfElseDirective(AdjustCasing("IF $ THEN"), AdjustCasing("ELSE"), AdjustCasing("END"), typeConverter),
                new InterpolationDirective(typeConverter),
                new RepeatDirective(AdjustCasing("REPEAT $ TIMES"), AdjustCasing("END"), typeConverter),
                new PreFormattedUnParsedTextDirective(AdjustCasing("PREFORMATTED"), AdjustCasing("END"), PreformattedStateObject, typeConverter)
            });
        }
        /// <summary>
        /// Override in descendant classes to supply all dialect supported directives.
        /// </summary>
        /// <param name="typeConverter">The concrete <see cref="IPrimitiveTypeConverter" /> implementation used for type conversions.</param>
        /// <returns>
        /// An array of all supported directives.
        /// </returns>
        /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
        protected override IEnumerable <Directive> CreateDirectives(IPrimitiveTypeConverter typeConverter)
        {
            Expect.NotNull(nameof(typeConverter), typeConverter);

            return(new Directive[]
            {
                new ConditionalInterpolationDirective(AdjustCasing("$ IF $"), false, typeConverter),
                new UsingDirective(AdjustCasing("? AS $"), AdjustCasing("END"), typeConverter),
                new ForEachDirective(AdjustCasing("FOR ? IN $"), AdjustCasing("END"), typeConverter),
                new SeparatedForEachDirective(AdjustCasing("FOR ? IN $"), AdjustCasing("WITH"), AdjustCasing("END"), typeConverter),
                new ForDirective(AdjustCasing("FOR $"), AdjustCasing("END"), typeConverter),
                new IfDirective(AdjustCasing("IF $"), AdjustCasing("END"), typeConverter),
                new IfElseDirective(AdjustCasing("IF $"), AdjustCasing("ELSE"), AdjustCasing("END"), typeConverter),
                new InterpolationDirective(typeConverter),
                new PreFormattedUnParsedTextDirective(AdjustCasing("PRE"), AdjustCasing("END"), PreformattedStateObject, typeConverter)
            });
        }
 private bool TryGetConverter(Type type, out IPrimitiveTypeConverter primitiveTypeConverter)
 {
     if (typeof(ISpatial).IsAssignableFrom(type))
     {
         KeyValuePair <Type, IPrimitiveTypeConverter> pair = new KeyValuePair <Type, IPrimitiveTypeConverter>(typeof(object), null);
         foreach (KeyValuePair <Type, IPrimitiveTypeConverter> pair2 in this.spatialPrimitiveTypeConverters)
         {
             if (pair2.Key.IsAssignableFrom(type) && pair.Key.IsAssignableFrom(pair2.Key))
             {
                 pair = pair2;
             }
         }
         primitiveTypeConverter = pair.Value;
         return(pair.Value != null);
     }
     primitiveTypeConverter = null;
     return(false);
 }
Exemple #13
0
 private bool TryGetConverter(Type type, out IPrimitiveTypeConverter primitiveTypeConverter)
 {
     if (typeof(ISpatial).IsAssignableFrom(type))
     {
         KeyValuePair<Type, IPrimitiveTypeConverter> pair = new KeyValuePair<Type, IPrimitiveTypeConverter>(typeof(object), null);
         foreach (KeyValuePair<Type, IPrimitiveTypeConverter> pair2 in this.spatialPrimitiveTypeConverters)
         {
             if (pair2.Key.IsAssignableFrom(type) && pair.Key.IsAssignableFrom(pair2.Key))
             {
                 pair = pair2;
             }
         }
         primitiveTypeConverter = pair.Value;
         return (pair.Value != null);
     }
     primitiveTypeConverter = null;
     return false;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UsingDirective"/> class.
        /// </summary>
        /// <remarks>
        /// The <paramref name="startTagMarkup"/> is expected to contain exactly one expression components and one "any identifier" component.
        /// The identifier is used to represent each element in the evaluated sequence.
        /// </remarks>
        /// <param name="startTagMarkup">The start tag markup.</param>
        /// <param name="endTagMarkup">The end tag markup.</param>
        /// <param name="typeConverter">The type converter.</param>
        /// <exception cref="InvalidOperationException">Argument <paramref name="startTagMarkup"/> or <paramref name="endTagMarkup"/>  does not correspond to the expressed rules.</exception>
        /// <exception cref="System.FormatException">Argument <paramref name="startTagMarkup"/> or <paramref name="endTagMarkup"/> cannot be parsed.</exception>
        public UsingDirective(
            [NotNull] string startTagMarkup,
            [NotNull] string endTagMarkup,
            [NotNull] IPrimitiveTypeConverter typeConverter) :
            base(typeConverter, Tag.Parse(startTagMarkup), Tag.Parse(endTagMarkup))
        {
            Debug.Assert(Tags.Count == 2, "Expected a tag count of 2.");

            /* Find all expressions. */
            var tag = Tags[0];
            var expressionComponents = Enumerable.Range(0, tag.ComponentCount)
                                       .Where(index => tag.MatchesExpression(index)).Select(index => index).ToArray();
            var identifierComponents = Enumerable.Range(0, tag.ComponentCount)
                                       .Where(index => tag.MatchesAnyIdentifier(index)).Select(index => index).ToArray();

            Expect.IsTrue(nameof(expressionComponents), expressionComponents.Length == 1);
            Expect.IsTrue(nameof(identifierComponents), identifierComponents.Length == 1);

            _expressionComponentIndex = expressionComponents[0];
            _identifierComponentIndex = identifierComponents[0];
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardDialectBase" /> class.
        /// <remarks>
        /// This constructor is not actually called directly.
        /// </remarks>
        /// </summary>
        /// <param name="name">A human-readable name for the dialect.</param>
        /// <param name="culture">A <see cref="CultureInfo" /> object that drives the formatting and collation behavior of the dialect.</param>
        /// <param name="casing">A <see cref="DialectCasing" /> value that controls the dialect string casing behavior.</param>
        /// <exception cref="ArgumentNullException">Either argument <paramref name="name" /> or <paramref name="culture" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Argument <paramref name="name" /> is an empty string.</exception>
        protected StandardDialectBase([NotNull] string name, [NotNull] CultureInfo culture, DialectCasing casing)
        {
            Expect.NotEmpty(nameof(name), name);
            Expect.NotNull(nameof(culture), culture);

            /* Build culture-aware values.*/
            Name           = name;
            Culture        = culture;
            _typeConverter = new FlexiblePrimitiveTypeConverter(Culture, this);
            _dialectCasing = casing;

            var casedUndefined = AdjustCasing("Undefined");

            Debug.Assert(casedUndefined != null);
            _dialectUndefinedSpecialIdentifier = casedUndefined;

            var comparer = StringComparer.Create(culture, casing == DialectCasing.IgnoreCase);

            IdentifierComparer    = comparer;
            StringLiteralComparer = comparer;
        }
Exemple #16
0
        /// <summary>
        /// Get the primitive type converter for the given type.
        /// </summary>
        /// <param name="type">Clr type whose primitive type converter needs to be returned.</param>
        /// <param name="primitiveTypeConverter">Converter for the given clr type.</param>
        /// <returns>True if a converter was found for the given type, otherwise returns false.</returns>
        private bool TryGetConverter(Type type, out IPrimitiveTypeConverter primitiveTypeConverter)
        {
            if (typeof(ISpatial).IsAssignableFrom(type))
            {
                KeyValuePair <Type, IPrimitiveTypeConverter> bestMatch = new KeyValuePair <Type, IPrimitiveTypeConverter>(typeof(object), null);
                foreach (KeyValuePair <Type, IPrimitiveTypeConverter> possibleMatch in this.spatialPrimitiveTypeConverters)
                {
                    // If the current primitive type is assignable from the given parameter type and
                    // is a more derived type from the previous match, then the current type is a better match.
                    if (possibleMatch.Key.IsAssignableFrom(type) && bestMatch.Key.IsAssignableFrom(possibleMatch.Key))
                    {
                        bestMatch = possibleMatch;
                    }
                }

                primitiveTypeConverter = bestMatch.Value;
                return(bestMatch.Value != null);
            }
            else
            {
                primitiveTypeConverter = null;
                return(false);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BitwiseShiftLeftOperator" /> class using the standard '&lt;&lt;' symbol.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
 public BitwiseShiftLeftOperator([NotNull] IPrimitiveTypeConverter typeConverter)
     : this("<<", typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BitwiseShiftLeftOperator" /> class.
 /// </summary>
 /// <param name="symbol">The operator's symbol.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> or <paramref name="typeConverter" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
 public BitwiseShiftLeftOperator([NotNull] string symbol, [NotNull] IPrimitiveTypeConverter typeConverter)
     : base(symbol, 5, typeConverter)
 {
 }
 protected override StandardSelfObject CreateSelfObject(IPrimitiveTypeConverter typeConverter)
 {
     return(new CodeMonkeySelfObject(typeConverter));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BitwiseOrOperator" /> class using the standard '|' symbol.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
 public BitwiseOrOperator([NotNull] IPrimitiveTypeConverter typeConverter)
     : this("|", typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RelationalLowerThanOperator" /> class using the standard '&lt;' symbol.
 /// </summary>
 /// <param name="stringComparer">The string literal comparer.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> or <paramref name="stringComparer" /> is <c>null</c>.</exception>
 public RelationalLowerThanOperator([NotNull] IComparer <string> stringComparer, [NotNull] IPrimitiveTypeConverter typeConverter)
     : this("<", stringComparer, typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UsingDirective"/> class using the standard markup {USING ? AS $}...{END}.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 public UsingDirective([NotNull] IPrimitiveTypeConverter typeConverter) :
     this("USING ? AS $", "END", typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ArithmeticModuloOperator" /> class.
 /// </summary>
 /// <param name="symbol">The operator's symbol.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> or <paramref name="typeConverter" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
 public ArithmeticModuloOperator([NotNull] string symbol, [NotNull] IPrimitiveTypeConverter typeConverter)
     : base(symbol, 3, typeConverter)
 {
 }
Exemple #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogicalNotOperator" /> class using the standard '!' symbol.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
 public LogicalNotOperator([NotNull] IPrimitiveTypeConverter typeConverter)
     : base("!", typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ArithmeticModuloOperator" /> class using the standard '%' symbol.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
 public ArithmeticModuloOperator([NotNull] IPrimitiveTypeConverter typeConverter)
     : this("%", typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RelationalLowerThanOperator" /> class using the standard '&lt;' symbol and current culture string comparer.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="typeConverter" /> is <c>null</c>.</exception>
 public RelationalLowerThanOperator([NotNull] IPrimitiveTypeConverter typeConverter)
     : this(System.StringComparer.CurrentCulture, typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PreFormattedUnParsedTextDirective" /> class using the standard markup {PREFORMATTED}...{END}.
 /// </summary>
 /// <param name="stateObject">The state object to register.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="stateObject" /> is <c>null</c>.</exception>
 public PreFormattedUnParsedTextDirective(
     [NotNull] object stateObject,
     [NotNull] IPrimitiveTypeConverter typeConverter)
     : this("PREFORMATTED", "END", stateObject, typeConverter)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RepeatDirective"/> class using the standard markup {REPEAT $ TIMES}...{END}.
 /// </summary>
 /// <param name="typeConverter">The type converter.</param>
 public RepeatDirective([NotNull] IPrimitiveTypeConverter typeConverter) :
     this("REPEAT $ TIMES", "END", typeConverter)
 {
 }
        /// <summary>
        /// Get the primitive type converter for the given type.
        /// </summary>
        /// <param name="type">Clr type whose primitive type converter needs to be returned.</param>
        /// <param name="primitiveTypeConverter">Converter for the given clr type.</param>
        /// <returns>True if a converter was found for the given type, otherwise returns false.</returns>
        private bool TryGetConverter(Type type, out IPrimitiveTypeConverter primitiveTypeConverter)
        {
            if (typeof(ISpatial).IsAssignableFrom(type))
            {
                KeyValuePair<Type, IPrimitiveTypeConverter> bestMatch = new KeyValuePair<Type, IPrimitiveTypeConverter>(typeof(object), null);
                foreach (KeyValuePair<Type, IPrimitiveTypeConverter> possibleMatch in this.spatialPrimitiveTypeConverters)
                {
                    // If the current primitive type is assignable from the given parameter type and
                    // is a more derived type from the previous match, then the current type is a better match.
                    if (possibleMatch.Key.IsAssignableFrom(type) && bestMatch.Key.IsAssignableFrom(possibleMatch.Key))
                    {
                        bestMatch = possibleMatch;
                    }
                }

                primitiveTypeConverter = bestMatch.Value;
                return bestMatch.Value != null;
            }
            else
            {
                primitiveTypeConverter = null;
                return false;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BitwiseOrOperator" /> class.
 /// </summary>
 /// <param name="symbol">The operator's symbol.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> or <paramref name="typeConverter" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
 public BitwiseOrOperator([NotNull] string symbol, [NotNull] IPrimitiveTypeConverter typeConverter)
     : base(symbol, 10, typeConverter)
 {
 }
Exemple #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogicalNotOperator" /> class.
 /// </summary>
 /// <param name="symbol">The operator's symbol.</param>
 /// <param name="typeConverter">The type converter.</param>
 /// <exception cref="ArgumentNullException">Argument <paramref name="symbol" /> or <paramref name="typeConverter" /> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Argument <paramref name="symbol" /> is empty.</exception>
 public LogicalNotOperator([NotNull] string symbol, [NotNull] IPrimitiveTypeConverter typeConverter)
     : base(symbol, typeConverter)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="StandardSelfObject"/> class.
        /// </summary>
        /// <param name="typeConverter">The type converter.</param>
        public StandardSelfObject([CanBeNull] IPrimitiveTypeConverter typeConverter)
        {
            Expect.NotNull(nameof(typeConverter), typeConverter);

            TypeConverter = typeConverter;
        }