Exemple #1
0
        public bool IsParentElementValid(IRenderable r, object startObject, bool raiseException)
        {
            string parentRenderableName = r.GetParentRenderableName();

            if (parentRenderableName != string.Empty && parentRenderableName != "(none)")
            {
                NamedElement element = this.GetElement(parentRenderableName);
                if (element != null)
                {
                    if (element == startObject)
                    {
                        if (raiseException)
                        {
                            throw new ApplicationException(Utils.SRGetStr("ExceptionCircularReference"));
                        }
                        return(false);
                    }
                    if (!(element is IRenderable))
                    {
                        if (raiseException)
                        {
                            throw new ApplicationException(Utils.SRGetStr("ExceptionParentNotRenderable", parentRenderableName));
                        }
                        return(false);
                    }
                    return(this.IsParentElementValid((IRenderable)element, startObject, raiseException));
                }
                if (raiseException)
                {
                    throw new ApplicationException(Utils.SRGetStr("ExceptionInvalidParent", parentRenderableName));
                }
                return(false);
            }
            return(true);
        }