Example #1
0
        private static IBaseConstruct GetBaseConstructfromUID(string uniqueIdentifier, ICodeRoot codeRoot)
        {
            if (string.IsNullOrEmpty(uniqueIdentifier))
            {
                return(null);
            }

            string[]       identifiers   = BaseConstructConstants.SplitFullyQualifiedIdentifier(uniqueIdentifier);
            IBaseConstruct baseConstruct = codeRoot.FindChild(identifiers[0]);

            if (baseConstruct == null)
            {
                return(null);
            }
            for (int i = 1; i < identifiers.Length; i++)
            {
                baseConstruct = baseConstruct.FindChild(identifiers[i]);
                if (baseConstruct == null)
                {
                    return(null);
                }
            }
            if (baseConstruct == null)
            {
                throw new ArgumentException("Could not find the object by unique id.");
            }
            return(baseConstruct);
        }