Exemple #1
0
 public ParameterDef(string ParamName, ICSSoft.STORMNET.FunctionalLanguage.ObjectType type, bool Multiply, string Advansed)
     : base(type, "@" + ParamName, "@" + ParamName)
 {
     fParamName = ParamName;
     fAdv       = Advansed;
     fMultiply  = Multiply;
 }
 public DetailVariableDef(ICSSoft.STORMNET.FunctionalLanguage.ObjectType type, string name, View v, string cmp, params string[] ocp)
     : base(type, name, name)
 {
     fView             = v;
     ConnectMasterPorp = cmp ?? Information.GetAgregatePropertyName(v.DefineClassType);
     OwnerConnectProp  = (ocp == null || (ocp.Length == 1 && ocp[0] == null)) ? new string[] { FunctionalLanguage.SQLWhere.SQLWhereLanguageDef.StormMainObjectKey } : ocp;
     fView.AddProperty(ConnectMasterPorp);
 }
        /// <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);
                    }
                }
            }
        }