Пример #1
0
 ///<summary>
 /// Проверка функции с выбросом эксепшенов
 ///</summary>
 ///<param name="checkSubFunctions"></param>
 ///<exception cref="NullFunctionDefException"></exception>
 ///<exception cref="ParameterCountException"></exception>
 ///<exception cref="UncompatibleParameterTypeException"></exception>
 public void Check(bool checkSubFunctions)
 {
     if (_fieldFunctionDef == null)
     {
         throw new NullFunctionDefException();
     }
     if ((fieldParameters.Count != _fieldFunctionDef.Parameters.Count) &&
         (fieldParameters.Count > _fieldFunctionDef.Parameters.Count) &&
         (!_fieldFunctionDef.Parameters[_fieldFunctionDef.Parameters.Count - 1].MultiValueSupport))
     {
         throw new ParameterCountException();
     }
     for (int i = 0; i < fieldParameters.Count; i++)
     {
         ObjectType parameterDefType = (i >= _fieldFunctionDef.Parameters.Count)
                                           ? _fieldFunctionDef.Parameters[
             _fieldFunctionDef.Parameters.Count - 1].Type
                                           : _fieldFunctionDef.Parameters[i].Type;
         if (fieldParameters[i] is Function)
         {
             ObjectType parameterType = (fieldParameters[i] as Function).FunctionDef.ReturnType;
             if (parameterType != parameterDefType)
             {
                 if (
                     CompatibilityTypeTest.Check(parameterType.NetCompatibilityType,
                                                 parameterDefType.NetCompatibilityType) ==
                     TypesCompatibilities.No)
                 {
                     throw new UncompatibleParameterTypeException(i);
                 }
                 if (checkSubFunctions)
                 {
                     (fieldParameters[i] as Function).Check(true);
                 }
             }
         }
         else if (fieldParameters[i] is VariableDef)
         {
             if (
                 CompatibilityTypeTest.Check((fieldParameters[i] as VariableDef).Type.NetCompatibilityType,
                                             parameterDefType.NetCompatibilityType) ==
                 TypesCompatibilities.No)
             {
                 throw new UncompatibleParameterTypeException(i);
             }
         }
         else
         {
             if (
                 CompatibilityTypeTest.Check(fieldParameters[i].GetType(),
                                             parameterDefType.NetCompatibilityType) ==
                 TypesCompatibilities.No)
             {
                 throw new UncompatibleParameterTypeException(i);
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Совместим с...
        /// </summary>
        /// <param name="type">тип</param>
        /// <returns>совместим ли</returns>
        public virtual bool CompatWith(ObjectType type)
        {
            if (this == type)
            {
                return(true);
            }
            //CompatibilityTypeTest tst = new CompatibilityTypeTest();

            bool retBool = CompatibilityTypeTest.Check(NetCompatibilityType, type.NetCompatibilityType) != TypesCompatibilities.No;

            return(retBool);
        }
Пример #3
0
 /// <summary>
 /// Получатель ObjectType по .NET-типу (для DataObject возвращается тип первичного ключа)
 /// </summary>
 /// <param name="type">.NET-тип</param>
 /// <returns>ObjectType-тип</returns>
 public virtual ObjectType GetObjectTypeForNetType(Type type)
 {
     foreach (ObjectType t in Types)
     {
         if (t.NetCompatibilityType == type)
         {
             return(t);
         }
     }
     foreach (ObjectType t in Types)
     {
         if (CompatibilityTypeTest.Check(type, t.NetCompatibilityType) != TypesCompatibilities.No)
         {
             return(t);
         }
     }
     return(null);
 }