示例#1
0
        public SectionTemplate(XNode sectionNode, int languageCode, EntityMetadata entityMetadata, ICellTemplateFactory cellTemplateFactory, RowTemplateFactory rowTemplateFactory)
            : base(sectionNode, languageCode, entityMetadata, cellTemplateFactory)
        {
            rowTemplateFactory.ThrowOnNull("rowTemplateFactory");

            RowTemplateFactory = rowTemplateFactory;

            string description;

            if (XNodeUtility.TryGetAttributeValue(sectionNode, "labels/label[@languagecode='{0}']".FormatWith(LanguageCode), "description", out description))
            {
                Label = description;
            }

            bool showLabel;

            if (XNodeUtility.TryGetBooleanAttributeValue(sectionNode, ".", "showlabel", out showLabel))
            {
                ShowLabel = showLabel;
            }

            bool showBar;

            if (XNodeUtility.TryGetBooleanAttributeValue(sectionNode, ".", "showbar", out showBar))
            {
                ShowBar = showBar;
            }
        }
示例#2
0
        public FormXmlCellMetadata(XNode cellNode, EntityMetadata entityMetadata, int languageCode)
            : base(cellNode, entityMetadata, languageCode, GetDataFieldName)
        {
            bool disabled;

            if (XNodeUtility.TryGetBooleanAttributeValue(cellNode, "control", "disabled", out disabled))
            {
                // Preserve any existing true value of Disabled.
                Disabled = Disabled || disabled;
            }

            XNodeUtility.TryGetAttributeValue(cellNode, "labels/label[@languagecode='{0}']".FormatWith(LanguageCode), "description", out _label);

            if (!XNodeUtility.TryGetBooleanAttributeValue(cellNode, ".", "showlabel", out _showLabel))
            {
                // The CRM defaults to true if the showlabel attribute does not exist, so we will do the same.
                _showLabel = true;
            }
        }
        protected CellMetadata(XNode cellNode, EntityMetadata entityMetadata, int languageCode, Func <XNode, EntityMetadata, string> getDataFieldName)
        {
            cellNode.ThrowOnNull("cellNode");
            entityMetadata.ThrowOnNull("entityMetadata");

            string colSpan;

            if (XNodeUtility.TryGetAttributeValue(cellNode, ".", "colspan", out colSpan))
            {
                ColumnSpan = int.Parse(colSpan);
            }

            string rowSpan;

            if (XNodeUtility.TryGetAttributeValue(cellNode, ".", "rowspan", out rowSpan))
            {
                RowSpan = int.Parse(rowSpan);
            }

            EntityMetadata = entityMetadata;
            LanguageCode   = languageCode;

            var dataFieldName = getDataFieldName(cellNode, entityMetadata);

            var attributeMetadata = entityMetadata.Attributes.FirstOrDefault(attribute => attribute.LogicalName == dataFieldName);

            if (string.IsNullOrEmpty(dataFieldName) || attributeMetadata == null)
            {
                Disabled = true;

                return;
            }

            DataFieldName     = dataFieldName;
            AttributeMetadata = attributeMetadata;

            ExtractMetadata();
        }
        private static string GetDataFieldName(XNode cellNode, EntityMetadata entityMetadata)
        {
            string dataFieldName;

            return(XNodeUtility.TryGetAttributeValue(cellNode, ".", "name", out dataFieldName) ? dataFieldName : null);
        }