private void EnsureComponentLoaded() { if (_isComponentLoaded) return; try { _component = BXIncludeComponentHelper.ReadFromFile(TargetFileAppRelPath, TargetElementID, null);//new string[] { "Template" }); } catch (FileIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_SOURCE_FILE_IS_NOT_FOUND"), TargetFileAppRelPath), exc); } catch (FileIsEmptyException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_SOURCE_FILE_IS_EMPTY"), TargetFileAppRelPath), exc); } catch (ElementIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_ELEMENT_IS_NOT_FOUND"), TargetElementID, TargetFileAppRelPath), exc); } catch (ElementAttributesParsingException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_ELEMENT_COULD_NOT_PARSE_ATTRIBUTES"), TargetElementID, TargetFileAppRelPath), exc); } catch (ElementComponentNameIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_ELEMENT_NAME_ATTR_IS_NOT_FOUND"), TargetElementID, TargetFileAppRelPath), exc); } catch (ComponentPathIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_PATH_IS_NOT_FOUND"), exc.Name), exc); } catch (ComponentCreationFailedException exc) { throw new InvalidOperationException(GetMessageRaw("ERROR_COMPONENT_IS_NOT_FOUND"), exc); } /* * теперь параметры получаются из запроса //Нужно для прохождения компонентом "жизненного цикла" в странице. Иначе TemplatePath получить несудьба :( _component.Visible = false; Controls.Add(_component); //Controls.Remove(_component); */ _isComponentLoaded = true; }
private void EnsureComponentLoaded() { if (_isComponentLoaded) return; try { _component = BXIncludeComponentHelper.ReadFromFile(TargetFileAppRelPath, TargetElementID, null, false, Request.QueryString["site"]); } catch (FileIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_SOURCE_FILE_IS_NOT_FOUND"), TargetFileAppRelPath), exc); } catch (FileIsEmptyException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_SOURCE_FILE_IS_EMPTY"), TargetFileAppRelPath), exc); } catch (ElementIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_ELEMENT_IS_NOT_FOUND"), TargetElementID, TargetFileAppRelPath), exc); } catch (ElementAttributesParsingException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_ELEMENT_COULD_NOT_PARSE_ATTRIBUTES"), TargetElementID, TargetFileAppRelPath), exc); } catch (ElementComponentNameIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_ELEMENT_NAME_ATTR_IS_NOT_FOUND"), TargetElementID, TargetFileAppRelPath), exc); } catch (ComponentPathIsNotFoundException exc) { throw new InvalidOperationException(string.Format(GetMessageRaw("ERROR_FORMATTED_COMPONENT_PATH_IS_NOT_FOUND"), exc.Name), exc); } catch (ComponentCreationFailedException exc) { throw new InvalidOperationException(GetMessageRaw("ERROR_COMPONENT_IS_NOT_FOUND"), exc); } _isComponentLoaded = true; }