コード例 #1
0
        private string GetRelativeName(IComponent2 comp)
        {
            var parentComp = comp.GetParent();

            if (parentComp == null)
            {
                return(comp.Name2);
            }
            else
            {
                if (comp.Name2.StartsWith(parentComp.Name2, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(comp.Name2.Substring(parentComp.Name2.Length + 1));
                }
                else
                {
                    throw new Exception("Invalid component name");
                }
            }
        }