Пример #1
0
        /// <summary>
        /// Generates the code that gets the row data for reading a data reader into a strongly typed class
        /// </summary>
        /// <param name="generatedCode">
        /// The String Builder to add the code to
        /// </param>
        /// <param name="properties">
        /// The collection of properties for the class
        /// </param>
        protected static void DoDifferenceGetRowData(StringBuilder generatedCode, PropertyInfoBase[] properties)
        {
            if (generatedCode == null)
            {
                throw new ArgumentNullException(nameof(generatedCode));
            }

            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            foreach (var pi in properties.Where(pi => pi.SqlDataReaderType != null))
            {
                generatedCode.AppendLine("            bool " + Helpers.GetVariableName("row" + pi.Name) + " = false;");
                generatedCode.AppendLine("            if (" + Helpers.GetVariableName(pi.Name) + "Ordinal > -1)");
                generatedCode.AppendLine("            {");
                generatedCode.AppendLine(
                    "                " + Helpers.GetVariableName("row" + pi.Name) + " = dataReader.GetBoolean("
                    + Helpers.GetVariableName(pi.Name) + "Ordinal);");
                generatedCode.AppendLine("            }");
                generatedCode.AppendLine(string.Empty);
            }
        }
Пример #2
0
        /// <summary>
        /// Builds the Fields Region
        /// </summary>
        /// <param name="sb">
        /// The String Builder to add the code to
        /// </param>
        /// <param name="properties">
        /// The collection of properties for the class
        /// </param>
        protected virtual void DoFieldsRegion(StringBuilder sb, PropertyInfoBase[] properties)
        {
            sb.AppendLine("        #region fields");

            foreach (PropertyInfoBase pi in properties.Where(pi => !pi.GenerateAutoProperty))
            {
                sb.AppendLine("            /// <summary>");
                sb.AppendLine("            /// " + pi.Description);
                sb.AppendLine("            /// </summary>");
                sb.AppendLine(
                    "            [System.Diagnostics.CodeAnalysis.SuppressMessage(\"StyleCop.CSharp.ReadabilityRules\", \"SA1121:UseBuiltInTypeAlias\", Justification = \"Reviewed. Suppression is OK here.\")]");
                this.OnDoFieldItem(sb, pi);
                sb.AppendLine(string.Empty);
            }

            sb.AppendLine("        #endregion");
            sb.AppendLine(string.Empty);
        }
Пример #3
0
        /// <summary>
        /// Generates the code that gets the row data for reading a data reader into a strongly typed class
        /// </summary>
        /// <param name="generatedCode">
        /// The String Builder to add the code to
        /// </param>
        /// <param name="properties">
        /// The collection of properties for the class
        /// </param>
        protected static void DoViewFilterGetRowData(StringBuilder generatedCode, PropertyInfoBase[] properties)
        {
            if (generatedCode == null)
            {
                throw new ArgumentNullException(nameof(generatedCode));
            }

            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            foreach (PropertyInfoBase pi in properties.Where(pi => pi.SqlDataReaderType != null))
            {
                generatedCode.AppendLine("            bool " + Helpers.GetVariableName(pi.Name) + " =");
                generatedCode.AppendLine(
                    "                (" + Helpers.GetVariableName(pi.Name) + "Ordinal > -1) && (dataReader.GetBoolean("
                    + Helpers.GetVariableName(pi.Name) + "Ordinal));");
                generatedCode.AppendLine(string.Empty);
            }
        }