Exemple #1
0
 /// <summary>
 /// Adds a function if it does not currently
 /// exist in the registry, or replaces the existing one
 /// with the same signature.
 /// </summary>
 /// <param name="func">A function</param>
 public void Add(IGeometryFunction func)
 {
     _functions.Add(func);
     _sortedFunctions.Add(func.Name, func);
     _categorizedFunctions.Put(func.Category, func.Name, func);
     if (HasGeometryResult(func))
     {
         _categorizedGeometryFunctions.Put(func.Category, func.Name, func);
     }
 }
        //public Type GetReturnType(String opName)
        //{
        //    IGeometryFunction func = registry.Find(opName);
        //    if (func == null)
        //        return defaultOp.GetReturnType(opName);
        //    return func.ReturnType;
        //}

        public IResult Invoke(XmlTestType opName, Geometry geometry, Object[] args)
        {
            IGeometryFunction func = registry.Find(opName.ToString(), args.Length);

            if (func == null)
            {
                return(defaultOp.Invoke(opName, geometry, args));
            }

            return(Invoke(func, geometry, args));
        }
        /// <summary>
        /// Gets the return type for the operation
        /// </summary>
        /// <param name="op">The name of the operation</param>
        /// <returns>The return type of the operation</returns>
        public Type GetReturnType(XmlTestType op)
        {
            string            opName = op.ToString();
            IGeometryFunction func   = registry.Find(opName);

            if (func == null)
            {
                return(defaultOp.GetReturnType(op));
            }
            return(func.ReturnType);
        }
 private IResult Invoke(IGeometryFunction func, IGeometry geometry, Object[] args)
 {
     Object[] actualArgs = argConverter.Convert(func.ParameterTypes, args);
     if (func.ReturnType == typeof(bool))
         return new BooleanResult((Boolean)func.Invoke(geometry, actualArgs));
     if (typeof(IGeometry).IsAssignableFrom(func.ReturnType))
         return new GeometryResult((IGeometry)func.Invoke(geometry, actualArgs));
     if (func.ReturnType == typeof(double))
         return new DoubleResult((double)func.Invoke(geometry, actualArgs));
     if (func.ReturnType == typeof(int))
         return new IntegerResult((int)func.Invoke(geometry, actualArgs));
     string opName = String.Format("Unsupported result type: {0}", func.ReturnType);
     throw new NTSTestReflectionException(opName);
 }
        //public IResult Invoke(String opName, Geometry geometry, Object[] args)
        //{
        //    IGeometryFunction func = registry.Find(opName, args.Length);
        //    if (func == null)
        //        return defaultOp.Invoke(opName, geometry, args);

        //    return Invoke(func, geometry, args);
        //}

        private IResult Invoke(IGeometryFunction func, Geometry geometry, Object[] args)
        {
            Object[] actualArgs = argConverter.Convert(func.ParameterTypes, args);

            if (func.ReturnType == typeof(bool))
            {
                return(new BooleanResult((Boolean)func.Invoke(geometry, actualArgs)));
            }
            if (typeof(Geometry).IsAssignableFrom(func.ReturnType))
            {
                return(new GeometryResult((Geometry)func.Invoke(geometry, actualArgs)));
            }
            if (func.ReturnType == typeof(double))
            {
                return(new DoubleResult((double)func.Invoke(geometry, actualArgs)));
            }
            if (func.ReturnType == typeof(int))
            {
                return(new IntegerResult((int)func.Invoke(geometry, actualArgs)));
            }
            throw new NTSTestReflectionException("Unsupported result type: "
                                                 + func.ReturnType);
        }
        private IResult Invoke(IGeometryFunction func, IGeometry geometry, object[] args)
        {
            object[] actualArgs = argConverter.Convert(func.ParameterTypes, args);
            if (func.ReturnType == typeof(bool))
            {
                return(new BooleanResult((bool)func.Invoke(geometry, actualArgs)));
            }
            if (typeof(IGeometry).IsAssignableFrom(func.ReturnType))
            {
                return(new GeometryResult((IGeometry)func.Invoke(geometry, actualArgs)));
            }
            if (func.ReturnType == typeof(double))
            {
                return(new DoubleResult((double)func.Invoke(geometry, actualArgs)));
            }
            if (func.ReturnType == typeof(int))
            {
                return(new IntegerResult((int)func.Invoke(geometry, actualArgs)));
            }
            string opName = string.Format("Unsupported result type: {0}", func.ReturnType);

            throw new NTSTestReflectionException(opName);
        }
	public static bool HasGeometryResult(IGeometryFunction func)
	{
		return typeof(IGeometry).IsAssignableFrom(func.ReturnType);
	}
	/**
	 * Adds a function if it does not currently
   * exist in the registry, or replaces the existing one
	 * with the same signature.
	 * 
	 * @param func a function
	 */
	public void Add(IGeometryFunction func)
	{
		functions.Add(func);
		sortedFunctions.Add(func.Name, func);
		categorizedFunctions.Put(func.Category, func.Name, func);
		if (HasGeometryResult(func))
			categorizedGeometryFunctions.Put(func.Category, func.Name, func);
	}
Exemple #9
0
 public static bool HasGeometryResult(IGeometryFunction func)
 {
     return(typeof(IGeometry).IsAssignableFrom(func.ReturnType));
 }
Exemple #10
0
 public SpreaderGeometryFunction(IGeometryFunction fun, bool isEachA, bool isEachB)
 {
     _fun     = fun;
     _isEachA = isEachA;
     _isEachB = isEachB;
 }
 public SpreaderGeometryFunction(IGeometryFunction fun)
 {
     _fun = fun;
 }