コード例 #1
0
        private bool CheckPrePost(ILSpecification ilSpecification, ParBase parPrefix, ParBase parPostfix, bool checkContent = true)
        {
            ilSpecification.prefix  = parPrefix?.xmlValue ?? string.Empty;
            ilSpecification.postfix = parPostfix?.xmlValue ?? string.Empty;
            if (string.IsNullOrEmpty(ilSpecification.prefix) && string.IsNullOrEmpty(ilSpecification.postfix))
            {
                return(true);    // if no prefix or postfix is defined, then all vars match naming by definition.
            }
            if (!checkContent)
            {
                return(true);
            }

            foreach (string v in ParIL.GetILComponents(ilSpecification.ilName, infoStore.operandAdmin))
            {
                if (v.StartsWith(ilSpecification.prefix, StringComparison.OrdinalIgnoreCase) &&
                    v.EndsWith(ilSpecification.postfix, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                {
                    isWarning = false,
                    message   = $"{description.Get()}: {ilSpecification.ilName}: contained variables must be named {GetFullVarName("*", ilSpecification)}; " +
                                $"variable {v} does not follow this rule"
                });
                return(false);
            }
            return(true);
        }
コード例 #2
0
        private List <string> GetCoreVars(ILSpecification ilSpecification)
        {
            List <string> cv = new List <string>();

            foreach (string v in ParIL.GetILComponents(ilSpecification.ilName, infoStore.operandAdmin))
            {
                cv.Add(GetCoreVarName(v, ilSpecification));
            }
            return(cv);
        }
コード例 #3
0
 private void PrepareDefILPar()
 {
     foreach (ParIL parIL in GetNonUniquePar <ParIL>(DefPar.DefOutput.DefIL))
     {   // see comment in PrepareOutVar upon creating a ParIL
         // note, that existence of IL and IL-content is checked in the "standard" parameter checking
         foreach (string v in ParIL.GetILComponents(parIL.name, infoStore.operandAdmin))
         {
             AddToOutList(v, parIL.description);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// called by OperandAdmin.CheckRegistration, i.e. on checking if a variable/IL, e.g. used in a formula, is valid
        /// checks if this Store-function could be possibly "responsible" for this variable/IL
        /// (e.g. ask for yem_loop3 - Store is responsible if POSTLOOP-parameter=loop and there is a VAR-parameter=yem)
        /// if responsible, registration takes place as described above
        /// </summary>
        internal bool IsStoreOperand(string testOperandName)
        {
            if (storeType == STORETYPE.FIX)
            {
                return(false);                            // variables of POSTFIX-Stores are not produced "on demand" (see explanation above)
            }
            int iteration = NOTAP;

            foreach (ParVar par in GetNonUniquePar <ParVar>(DefPar.Store.Var))
            {
                if (CheckIfResponsibleAndGetIteration(par.name))
                {
                    RegisterVar(par.name, par.description, iteration); return(true);
                }
            }
            foreach (ParIL par in GetNonUniquePar <ParIL>(DefPar.Store.IL))
            {
                // first check for IL itself, e.g. ils_earns_loop7
                if (CheckIfResponsibleAndGetIteration(par.name))
                {
                    RegisterILAndContent(par, iteration); return(true);
                }
                // then check for the content, e.g. yem_loop7, yse_loop7
                foreach (string ilVar in ParIL.GetILComponents(par.name, infoStore.operandAdmin))
                {
                    if (CheckIfResponsibleAndGetIteration(ilVar))
                    {
                        RegisterVar(ilVar, par.description, iteration); return(true);
                    }
                }
            }
            return(false);

            bool CheckIfResponsibleAndGetIteration(string origName)
            {
                string storeName = ComposeStoreName(origName, NOTAP);

                return(testOperandName.StartsWith(storeName) &&
                       int.TryParse(testOperandName.Substring(storeName.Length), out iteration));
            }
        }
コード例 #5
0
        internal bool IsProspectiveLoopOperand(string operand) // see InfoStore.IsProspectiveStoreOperand for description
        {                                                      // note that this can be called before (or after) PrepareNonCommonPar, therefore one cannot rely on variables (e.g. post, storeType, ...)
          // also note that we are only looking for the "running" operands, e.g. yem_loop, ils_earns_loop (i.e. without an iteration)
            ParBase parPostLoop = GetUniquePar <ParBase>(DefPar.Store.PostLoop);

            if (parPostLoop == null)
            {
                return(false);                     // most likely a PostFix-Store, thus not relevant
            }
            foreach (ParVar par in GetNonUniquePar <ParVar>(DefPar.Store.Var))
            {
                if (ComposeStoreName(par.xmlValue, NOTAP, parPostLoop.xmlValue).ToLower() == operand.ToLower())
                {
                    return(true);
                }
            }

            foreach (ParIL par in GetNonUniquePar <ParIL>(DefPar.Store.IL))
            {
                // first check for IL itself, e.g. ils_earns_loop
                string ili = ComposeStoreName(par.xmlValue, NOTAP, parPostLoop.xmlValue);
                if (ComposeStoreName(par.xmlValue, NOTAP, parPostLoop.xmlValue).ToLower() == operand.ToLower())
                {
                    return(true);
                }
                // then check for the content, e.g. yem_loop, yse_loop
                if (!infoStore.operandAdmin.Exists(par.xmlValue))
                {
                    continue;                                               // only check if il is already registered
                }
                foreach (string ilVar in ParIL.GetILComponents(par.xmlValue, infoStore.operandAdmin))
                {
                    if (ComposeStoreName(ilVar, NOTAP, parPostLoop.xmlValue).ToLower() == operand.ToLower())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }