Пример #1
0
        public static ProcessChain FromText(string[] lines)
        {
            EpistemicModel epistemicModel = EpistemicModel.FromText(ref lines);
            if (epistemicModel == null)
                return null;
            ProcessChain processChain = new ProcessChain(epistemicModel);
            int ln = 0;

            try
            {
                if (!lines.Any())
                    return processChain;

                if (lines[ln++] != "START_MODEL_VARS")
                    return null;
                int modelCount = int.Parse(lines[ln++]);
                for (int i = 0; i < modelCount; i++)
                {
                    processChain.CreateNewModel(lines[ln++]);
                }
                if (lines[ln++] != "END_MODEL_VARS")
                    return null;

                if (lines[ln++] != "START_PROCESS")
                    return null;
                int procCount = int.Parse(lines[ln++]);
                for (int i = 0; i < procCount; i++)
                {
                    string procName = lines[ln++];
                    EpistemicProcess ep = processChain.CreateNewProcess(procName);
                    ep.Start = new ModelConfiguration(lines[ln++]);
                    ep.Resault = new ModelConfiguration(lines[ln++]);
                    int actionCount = int.Parse(lines[ln++]);
                    for (int j = 0; j < actionCount; j++)
                    {
                        ep.AddActionModel(processChain._actionModels[lines[ln++]]);
                    }
                }
                if (lines[ln++] != "END_PROCESS")
                    return null;
            }
            catch (IndexOutOfRangeException)
            {

                return null;
            }

            return processChain;
        }
Пример #2
0
        public static ProcessChain FromText(string[] lines)
        {
            EpistemicModel epistemicModel = EpistemicModel.FromText(ref lines);

            if (epistemicModel == null)
            {
                return(null);
            }
            ProcessChain processChain = new ProcessChain(epistemicModel);
            int          ln           = 0;

            try
            {
                if (!lines.Any())
                {
                    return(processChain);
                }

                if (lines[ln++] != "START_MODEL_VARS")
                {
                    return(null);
                }
                int modelCount = int.Parse(lines[ln++]);
                for (int i = 0; i < modelCount; i++)
                {
                    processChain.CreateNewModel(lines[ln++]);
                }
                if (lines[ln++] != "END_MODEL_VARS")
                {
                    return(null);
                }

                if (lines[ln++] != "START_PROCESS")
                {
                    return(null);
                }
                int procCount = int.Parse(lines[ln++]);
                for (int i = 0; i < procCount; i++)
                {
                    string           procName = lines[ln++];
                    EpistemicProcess ep       = processChain.CreateNewProcess(procName);
                    ep.Start   = new ModelConfiguration(lines[ln++]);
                    ep.Resault = new ModelConfiguration(lines[ln++]);
                    int actionCount = int.Parse(lines[ln++]);
                    for (int j = 0; j < actionCount; j++)
                    {
                        ep.AddActionModel(processChain._actionModels[lines[ln++]]);
                    }
                }
                if (lines[ln++] != "END_PROCESS")
                {
                    return(null);
                }
            }
            catch (IndexOutOfRangeException)
            {
                return(null);
            }

            return(processChain);
        }