示例#1
0
        /// <summary>
        /// Gets a value indicating whether there are errors in field names assigned to the field list.
        /// </summary>
        /// <param name="fields">Field list.</param>
        /// <param name="errorTable">Dictionary of fields that contains the list of objects with error.</param>
        /// <returns>
        /// <strong>true</strong> if field not found; otherwise, <strong>false</strong>.
        /// </returns>
        /// <remarks>
        /// The parameter <paramref name="errorTable" /> contains a dictionary containing the field and the list of elements whose is not properly defined.
        /// </remarks>
        private static bool HasFieldErrors(FieldsModel fields, out Dictionary <BaseDataFieldModel, List <string> > errorTable)
        {
            SentinelHelper.ArgumentNull(fields);

            errorTable = new Dictionary <BaseDataFieldModel, List <string> >();
            foreach (var field in fields)
            {
                var typeFieldList = new List <string>();
                switch (field.FieldType)
                {
                case KnownFieldType.Fixed:
                    var fixedField = (FixedFieldModel)field;

                    var fix   = fixedField.Owner.Parent.Parent.Resources.Fixed;
                    var exist = fix.Contains(fixedField.Pieces);
                    if (!exist)
                    {
                        typeFieldList.Add("Pieces");
                    }
                    else
                    {
                        var pieces = fix[fixedField.Pieces];
                        exist = pieces.Pieces.Contains(fixedField.Piece);
                        if (!exist)
                        {
                            typeFieldList.Add("Piece");
                        }
                    }
                    break;

                case KnownFieldType.Group:
                    var groupField = (GroupFieldModel)field;

                    var groups          = field.Owner.Parent.Parent.Resources.Groups;
                    var existGroupField = groups.Contains(groupField.Name);
                    if (!existGroupField)
                    {
                        typeFieldList.Add("Group");
                    }
                    break;
                }

                var totalFixed = typeFieldList.Count;
                if (totalFixed > 0)
                {
                    errorTable.Add(field, typeFieldList);
                }
            }

            return(errorTable.Count > 0);
        }
示例#2
0
        /// <summary>
        /// Gets a value indicating whether there are errors in style names assigned to the field list.
        /// </summary>
        /// <param name="fields">Field list.</param>
        /// <param name="errorTable">Dictionary of fields that contains the list of objects with error <c>Style</c> property.</param>
        /// <returns>
        /// <strong>true</strong> if a specified style to a field is empty or not found in the list of defined styles; otherwise, <strong>false</strong>.
        /// </returns>
        /// <remarks>
        /// The parameter <paramref name="errorTable" /> contains a dictionary containing the field and the list of elements whose style is not properly defined.
        /// </remarks>
        private static bool HasStyleErrors(FieldsModel fields, out Dictionary <BaseDataFieldModel, List <string> > errorTable)
        {
            SentinelHelper.ArgumentNull(fields);

            errorTable = new Dictionary <BaseDataFieldModel, List <string> >();
            foreach (var field in fields)
            {
                var styles = new List <string>();

                var exist = field.Header.CheckStyleName();
                if (!exist)
                {
                    styles.Add("Header");
                }

                exist = field.Value.CheckStyleName();
                if (!exist)
                {
                    styles.Add("Value");
                }

                exist = field.Aggregate.CheckStyleName();
                if (!exist)
                {
                    styles.Add("Aggregate");
                }

                var totalStyles = styles.Count;
                if (totalStyles > 0)
                {
                    errorTable.Add(field, styles);
                }
            }

            var totalFields = errorTable.Count;

            return(totalFields > 0);
        }