コード例 #1
0
ファイル: GetTiaProgramItem.cs プロジェクト: hothing/tia-ps
        private PlcBlockGroup GetUserGroup(string path, PlcBlockUserGroupComposition root)
        {
            PlcBlockUserGroupComposition ugc = root;
            PlcBlockGroup grp = null;

            char[]   sep     = { pathDelimeter };
            string[] ugnames = path.Split(sep, StringSplitOptions.RemoveEmptyEntries);
            WriteDebug($"[GetUserGroup] path is {path}");
            if (ugnames.Length > 0)
            {
                WriteDebug($"[GetUserGroup] root group is {ugnames[0]}");
                foreach (String gn in ugnames)
                {
                    if (ugc != null)
                    {
                        WriteDebug($"[GetUserGroup] the group {gn} is finding");
                        grp = ugc.Find(gn);
                        if (grp != null)
                        {
                            ugc = grp.Groups;
                            WriteDebug($"[GetUserGroup] the group {gn} is found");
                        }
                        else
                        {
                            WriteDebug($"[GetUserGroup] the group {gn} is not found");
                            break;
                        }
                    }
                    else
                    {
                        grp = null;
                        break;
                    }
                }
                return(grp);
            }
            return(null);
        }