本文整理汇总了C#中AccessorDef类的典型用法代码示例。如果您正苦于以下问题:C# AccessorDef类的具体用法?C# AccessorDef怎么用?C# AccessorDef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessorDef类属于命名空间,在下文中一共展示了AccessorDef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: resolveCreator
private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef)
{
TagBuilder initialCreator = null;
_sources.FirstOrDefault(x =>
{
var tagBuilder = x.CreateInitial(accessorDef);
if (tagBuilder == null) { return false; }
initialCreator = tagBuilder;
return true;
});
if (initialCreator == null)
{
throw new Exception(string.Format("Html Conventions have no tag builder for {0}.{1}",
accessorDef.ModelType.FullName, accessorDef.Accessor.Name));
}
TagModifier[] modifiers = (_modifiers).Select((x => x.CreateModifier(accessorDef))).Where((x => x != null)).ToArray();
return (request =>
{
HtmlTag tag = initialCreator(request);
foreach (TagModifier v in modifiers)
{
v(request, tag);
}
return tag;
});
}
示例2: resolveCreator
private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef)
{
TagBuilder initialCreator = (_sources).FirstValue((x => x.CreateInitial(accessorDef)));
if (initialCreator == null)
{
throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", new string[2]
{
accessorDef.
ModelType.
FullName,
accessorDef.
Accessor.
Name
});
}
else
{
TagModifier[] modifiers =
(_modifiers).Select((x => x.CreateModifier(accessorDef))).Where((x => x != null)).ToArray();
return (request =>
{
HtmlTag tag = initialCreator(request);
(modifiers).Each((x => x(request, tag)));
return tag;
});
}
}
示例3: CreateInitial
public TagBuilder CreateInitial(AccessorDef accessorDef)
{
if (matches(accessorDef))
return Build;
else
return null;
}
示例4: CreateModifier
public TagModifier CreateModifier(AccessorDef accessorDef)
{
if (accessorDef.Accessor.PropertyType == typeof(Int16)
|| accessorDef.Accessor.PropertyType == typeof(Int32)
|| accessorDef.Accessor.PropertyType == typeof(Int64)
|| accessorDef.Accessor.PropertyType == typeof(decimal)
|| accessorDef.Accessor.PropertyType == typeof(float)
|| accessorDef.Accessor.PropertyType == typeof(double)
|| accessorDef.Accessor.PropertyType.IsNullableOf(typeof(Int16))
|| accessorDef.Accessor.PropertyType.IsNullableOf(typeof(Int32))
|| accessorDef.Accessor.PropertyType.IsNullableOf(typeof(Int64))
|| accessorDef.Accessor.PropertyType.IsNullableOf(typeof(decimal))
|| accessorDef.Accessor.PropertyType.IsNullableOf(typeof(float))
|| accessorDef.Accessor.PropertyType.IsNullableOf(typeof(double)))
{
TagModifier modifier = (request, tag) =>
tag.AddValidationHelper(ValidationRule.Number + ":true",
ValidationRule.Number + ": '" +
CoreLocalizationKeys.FIELD_MUST_BE_NUMBER.ToFormat(
request.Accessor.FieldName.
ToSeperateWordsFromPascalCase()) + "'");
return modifier;
}
return null;
}
示例5: matches
protected override bool matches(AccessorDef def)
{
var propertyName = def.Accessor.FieldName;
var listPropertyInfo = def.ModelType.GetProperty("_"+propertyName + "List");
// var readOnlyListPropertyInfo = def.ModelType.GetProperty(propertyName.Replace("ReadOnly", "") + "List");
return (listPropertyInfo != null &&
listPropertyInfo.PropertyType == typeof(GroupedSelectViewModel));
}
示例6: matches
protected override bool matches(AccessorDef def)
{
return def.ModelType == typeof(ProjectListModel) ||
def.ModelType == typeof(BoardConfigurationModel) ||
def.ModelType == typeof(CardListModel) ||
def.ModelType == typeof(TimeRecordListModel) ||
def.ModelType == typeof(ProjectModel);
}
示例7: CreateModifier
public TagModifier CreateModifier(AccessorDef accessorDef)
{
if (matches(accessorDef))
{
return Build;
}
return null;
}
示例8: CreateModifier
public TagModifier CreateModifier(AccessorDef accessorDef)
{
if (!accessorDef.Accessor.HasAttribute<ValidateNonEmptyAttribute>()) return null;
TagModifier modifier = (request, tag) =>
tag.AddValidationHelper(ValidationRule.Required + ":true",
ValidationRule.Required + ": '" +
CoreLocalizationKeys.FIELD_REQUIRED.ToFormat(request.Accessor.FieldName.ToSeperateWordsFromPascalCase()) +"'");
return modifier;
}
示例9: matches
protected override bool matches(AccessorDef accessor)
{
var propertyType = accessor.Accessor.PropertyType;
return propertyType == typeof (DateTime)
|| propertyType == typeof (DateTime?)
|| propertyType == typeof (Date)
|| propertyType == typeof (Date?);
}
示例10: CreateModifier
public TagModifier CreateModifier(AccessorDef accessorDef)
{
if (accessorDef.Accessor.Name.EndsWith("Email"))
{
return (req, tag) => { tag.Attr("type", "email"); };
}
return null;
}
示例11: CreateInitial
public TagBuilder CreateInitial(AccessorDef accessorDef)
{
if(accessorDef.ModelType.Equals(typeof(LoanNumber)))
{
return request =>
{
var str = request.Value<LoanNumber>();
return new HtmlTag("span", tag=>tag.Text(str.ToString()));
};
}
return a => { return HtmlTag.Empty(); };
}
示例12: resolveCreator
private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef)
{
TagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef));
TagModifier[] modifiers =
_modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray();
return request =>
{
HtmlTag tag = initialCreator(request);
modifiers.Each(x => x(request, tag));
return tag;
};
}
示例13: matches
protected override bool matches(AccessorDef accessor)
{
var propertyType = accessor.Accessor.PropertyType;
return propertyType == typeof (decimal)
|| propertyType == typeof (decimal?)
|| propertyType == typeof(int)
|| propertyType == typeof(int?)
|| propertyType == typeof(short)
|| propertyType == typeof(short?)
|| propertyType == typeof (float)
|| propertyType == typeof (float?)
|| propertyType == typeof (double)
|| propertyType == typeof (double?)
|| propertyType == typeof (long)
|| propertyType == typeof (long?);
}
示例14: CreateInitial
public TagBuilder CreateInitial(AccessorDef accessorDef)
{
if (accessorDef.ModelType.Equals(typeof(LoanNumber)))
{
return request =>
{
var str = request.Value<LoanNumber>().ToString();
var tag = new HtmlTag("input")
.Attr("type","text")
.Attr("value", str);
return tag;
};
}
return a => { return HtmlTag.Empty(); };
}
示例15: resolveCreator
private Func<ElementRequest, int, int, HtmlTag> resolveCreator(AccessorDef accessorDef)
{
EachPartialTagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef));
if (initialCreator == null)
{
throw new FubuException(3001, "Html Conventions have no tag builder for partials for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name);
}
EachPartialTagModifier[] modifiers =
_modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray();
return (request, index, count) =>
{
HtmlTag tag = initialCreator(request, index, count);
modifiers.Each(x => x(request, tag, index, count));
return tag;
};
}