コード例 #1
0
        /// <summary>
        /// Gets the type for a property
        /// </summary>
        /// <param name="pi">
        /// The property to generate a type for
        /// </param>
        /// <returns>
        /// .NET data type
        /// </returns>
        private string GetPropertyType(PropertyInfoBase pi)
        {
            if (pi == null)
            {
                throw new ArgumentNullException("pi");
            }

            string optional = (pi.Optional && !pi.NetDataType.Equals("string", StringComparison.Ordinal))
                                  ? "?"
                                  : string.Empty;
            return pi.GetCSharpDataTypeDeclaration() + optional;
        }
コード例 #2
0
        /// <summary>
        /// Gets the type to be used for a parameter in the constructor
        /// </summary>
        /// <param name="propertyInfo">
        /// the property
        /// </param>
        /// <returns>
        /// the constructor parameter type
        /// </returns>
        protected override string GetConstructorParameterType(PropertyInfoBase propertyInfo)
        {
            if (propertyInfo == null)
            {
                throw new ArgumentNullException("propertyInfo");
            }

            return propertyInfo.GetCSharpDataTypeDeclaration()
                   +
                   ((propertyInfo.Optional && !propertyInfo.NetDataType.Equals("string", StringComparison.Ordinal))
                        ? "?"
                        : string.Empty);
        }
コード例 #3
0
        /// <summary>
        /// Generates the field code for a property member
        /// </summary>
        /// <param name="sb">
        /// The String Builder to add the code to
        /// </param>
        /// <param name="pi">
        /// The property to generate a field for
        /// </param>
        protected override void OnDoFieldItem(StringBuilder sb, PropertyInfoBase pi)
        {
            if (sb == null)
            {
                throw new ArgumentNullException("sb");
            }

            if (pi == null)
            {
                throw new ArgumentNullException("pi");
            }

            string optional = (pi.Optional && !pi.NetDataType.Equals("string", StringComparison.Ordinal))
                                  ? "?"
                                  : string.Empty;
            sb.AppendLine(
                "            private " + pi.GetCSharpDataTypeDeclaration() + optional + " "
                + Helpers.GetVariableName(pi.Name) + ";");
        }