CodeGen/Builders/CodeBuilderValidation.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using System.IO;
using ComLib;
using ComLib.Models;
namespace ComLib.CodeGeneration
{
/// <summary>
/// Builds the validation for the model, this includes it's properties and
/// it's composite objects.
/// </summary>
public class CodeBuilderValidation : CodeBuilderBase, ICodeBuilder
{
#region ICodeBuilder Members
/// <summary>
/// Create the ORM mappings in xml file.
/// </summary>
/// <param name="ctx"></param>
/// <returns></returns>
public BoolMessageItem<ModelContainer> Process(ModelContext ctx)
{
// Not implemented for now since the main builder ( DomainBuilder will call this per model
// and therefore hook into the method BuildValidationForModel.
return new BoolMessageItem<ModelContainer>(ctx.AllModels, true, string.Empty);
}
#endregion
/// <summary>
/// Build the properties.
/// </summary>
/// <param name="ctx"></param>
/// <param name="model"></param>
/// <returns></returns>
public string BuildValidationForModel(ModelContext ctx, Model model)
{
StringBuilder buffer = new StringBuilder();
string conversionLine = string.Format("{0} entity = ({1})validationEvent.Target;", model.Name, model.Name);
//buffer.Append("var val = new Validator( (valEvent) =>" + Environment.NewLine);
//buffer.Append("{" + Environment.NewLine);
IncrementIndent(4);
buffer.Append(conversionLine + Environment.NewLine);
foreach (PropInfo prop in model.Properties)
{
if (prop.CreateCode)
{
// Build mapping for model.
BuildValidationForProperty(model, prop, buffer);
}
}
后面还有 156 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
