/// <summary> /// Creates prop {get; set;} /// </summary> /// <param name="propertyFields">The fields that are being decoded</param> /// <returns>A string with properties</returns> private string GetGetterSetters(List <RuntimePropertyInfo> propertyFields) { var sb = new StringBuilder(); for (int i = 0; i < propertyFields.Count; i++) { sb.Append(string.Format("public {0} {1} {{get;set;}}", RuntimePropertyInfo.GetPrimitiveTypeAlias(propertyFields[i].PropertyType), propertyFields[i].PropertyName)); } return(sb.ToString()); }
/// <summary> /// Pass all the parameters to the constructor, so when the class is instantiated using Activator, /// you can store properties using the constructor /// </summary> /// <param name="propertyFields">The types and names</param> /// <returns>A string with the constructor declaration</returns> private string GetConstructorDeclaration(List <RuntimePropertyInfo> propertyFields) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < propertyFields.Count; i++) { sb.Append(string.Format("{0} {1},", RuntimePropertyInfo.GetPrimitiveTypeAlias(propertyFields[i].PropertyType), propertyFields[i].PropertyName)); } sb.Length--; return(sb.ToString()); }
/// <summary> /// This constrtuctor takes a NetIncomingMessage and decodes its data using Read() /// </summary> /// <param name="propertyFields">The fields that are being decoded</param> /// <returns>A string with the constructor body</returns> private string GetDecodeConstructorBody(List <RuntimePropertyInfo> propertyFields) { var sb = new StringBuilder(); for (int i = 0; i < propertyFields.Count; i++) { sb.Append(string.Format("this.{0} = msg.{1}();", propertyFields[i].PropertyName, RuntimePropertyInfo.GetDecodePrefix(propertyFields[i].PropertyType))); } return(sb.ToString()); }