本文整理汇总了C#中Accessor类的典型用法代码示例。如果您正苦于以下问题:C# Accessor类的具体用法?C# Accessor怎么用?C# Accessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Accessor类属于命名空间,在下文中一共展示了Accessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetMessageSubstitutions
public IEnumerable<KeyValuePair<string, string>> GetMessageSubstitutions(Accessor accessor)
{
return new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(LENGTH, Length.ToString())
};
}
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:7,代码来源:MaximumStringLengthFieldStrategy.cs
示例2: EmitIndexerMethod
protected virtual void EmitIndexerMethod(IndexerDeclaration indexerDeclaration, Accessor accessor, bool setter)
{
if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
{
XmlToJsDoc.EmitComment(this, this.IndexerDeclaration);
var overloads = OverloadsCollection.Create(this.Emitter, indexerDeclaration, setter);
string name = overloads.GetOverloadName();
this.Write((setter ? "set" : "get") + name);
this.EmitMethodParameters(indexerDeclaration.Parameters, indexerDeclaration, setter);
if (setter)
{
this.Write(", value");
this.WriteColon();
name = BridgeTypes.ToTypeScriptName(indexerDeclaration.ReturnType, this.Emitter);
this.Write(name);
this.WriteCloseParentheses();
this.WriteColon();
this.Write("void");
}
else
{
this.WriteColon();
name = BridgeTypes.ToTypeScriptName(indexerDeclaration.ReturnType, this.Emitter);
this.Write(name);
}
this.WriteSemiColon();
this.WriteNewLine();
}
}
开发者ID:GavinHwa,项目名称:Bridge,代码行数:33,代码来源:IndexerBlock.cs
示例3: GetActions
public IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
var pdecl = GetPropertyDeclaration(context);
if (pdecl == null) {
yield break;
}
var type = pdecl.Parent as TypeDeclaration;
if (type != null && type.ClassType == ClassType.Interface) {
yield break;
}
yield return new CodeAction (pdecl.Setter.IsNull ? context.TranslateString("Add getter") : context.TranslateString("Add setter"), script => {
var accessorStatement = BuildAccessorStatement(context, pdecl);
Accessor accessor = new Accessor () {
Body = new BlockStatement { accessorStatement }
};
accessor.Role = pdecl.Setter.IsNull ? PropertyDeclaration.SetterRole : PropertyDeclaration.GetterRole;
if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull) {
script.InsertBefore(pdecl.RBraceToken, accessor);
} else if (pdecl.Getter.IsNull && !pdecl.Setter.IsNull) {
script.InsertBefore(pdecl.Setter, accessor);
} else {
script.InsertBefore(pdecl.Getter, accessor);
}
script.Select(accessorStatement);
script.FormatText(pdecl);
});
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:30,代码来源:AddAnotherAccessorAction.cs
示例4: establish_context
public override void establish_context()
{
property = ReflectionHelper.GetAccessor(GetPropertyExpression());
target = new PropertyEntity();
sut = new Property<PropertyEntity, string>(property, "expected");
}
开发者ID:roelofb,项目名称:fluent-nhibernate,代码行数:7,代码来源:PropertySpecs.cs
示例5: establish_context
public override void establish_context()
{
property = ReflectionHelper.GetAccessor((Expression<Func<ListEntity, IEnumerable<string>>>)(x => x.GetterAndSetter));
target = new ListEntity();
sut = new ReferenceBag<ListEntity, string>(property, new[] { "foo", "bar", "baz" });
}
开发者ID:rohitv,项目名称:fluent-nhibernate,代码行数:7,代码来源:ReferenceBagSpec.cs
示例6: FormatValue
/// <summary>
/// Formats the provided value using the property accessor metadata
/// </summary>
/// <param name="modelType">The type of the model to which the property belongs (i.e. Case where the property might be on its base class WorkflowItem)</param>
/// <param name="formatter">The formatter</param>
/// <param name="property">The property that holds the given value</param>
/// <param name="value">The data to format</param>
public static string FormatValue(this IDisplayFormatter formatter, Type modelType, Accessor property, object value)
{
return formatter.GetDisplay(new GetStringRequest(property, value, null)
{
OwnerType = modelType
});
}
开发者ID:NTCoding,项目名称:FubuRaven.NTCoding.com,代码行数:14,代码来源:DisplayFormatter.cs
示例7: RegisterRule
public RemoteFieldRule RegisterRule(Accessor accessor, IFieldValidationRule rule)
{
var remote = RemoteFieldRule.For(accessor, rule);
_rules[accessor].Fill(remote);
return remote;
}
开发者ID:thunklife,项目名称:fubuvalidation,代码行数:7,代码来源:RemoteRuleGraph.cs
示例8: fillFields
private static void fillFields(ValidationOptions options, IValidationNode node, IServiceLocator services, Accessor accessor)
{
var mode = node.DetermineMode(services, accessor);
var field = new FieldOptions
{
field = accessor.Name,
mode = mode.Mode
};
var graph = services.GetInstance<ValidationGraph>();
var rules = graph.FieldRulesFor(accessor);
var ruleOptions = new List<FieldRuleOptions>();
rules.Each(rule =>
{
var ruleMode = rule.Mode ?? mode;
ruleOptions.Add(new FieldRuleOptions
{
rule = RuleAliases.AliasFor(rule),
mode = ruleMode.Mode
});
});
field.rules = ruleOptions.ToArray();
options._fields.Add(field);
}
开发者ID:joemcbride,项目名称:fubuvalidation,代码行数:27,代码来源:ValidationOptions.cs
示例9: FormatValue
/// <summary>
/// Formats the provided value using the accessor accessor metadata and a custom format
/// </summary>
/// <param name="formatter">The formatter</param>
/// <param name="modelType">The type of the model to which the accessor belongs (i.e. Case where the accessor might be on its base class WorkflowItem)</param>
/// <param name="accessor">The property that holds the given value</param>
/// <param name="value">The data to format</param>
/// <param name="format">The custom format specifier</param>
public static string FormatValue(this IDisplayFormatter formatter, Type modelType, Accessor accessor,
object value, string format)
{
var request = new GetStringRequest(accessor, value, null, format, null);
return formatter.GetDisplay(request);
}
开发者ID:calebjenkins,项目名称:htmltags,代码行数:15,代码来源:DisplayFormatterExtensions.cs
示例10: GetActions
public override IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
var pdecl = context.GetNode<PropertyDeclaration> ();
if (pdecl == null || !pdecl.Getter.IsNull && !pdecl.Setter.IsNull || !pdecl.NameToken.Contains(context.Location)) {
yield break;
}
var type = pdecl.Parent as TypeDeclaration;
if (type != null && type.ClassType == ClassType.Interface) {
yield break;
}
yield return new CodeAction (pdecl.Setter.IsNull ? context.TranslateString("Add setter") : context.TranslateString("Add getter"), script => {
Statement accessorStatement = null;
var accessor = new Accessor ();
if (!pdecl.Getter.IsNull && !pdecl.Getter.Body.IsNull || !pdecl.Setter.IsNull && !pdecl.Setter.Body.IsNull) {
accessorStatement = BuildAccessorStatement(context, pdecl);
accessor.Body = new BlockStatement { accessorStatement };
}
accessor.Role = pdecl.Setter.IsNull ? PropertyDeclaration.SetterRole : PropertyDeclaration.GetterRole;
if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull) {
script.InsertAfter(pdecl.Getter, accessor);
} else if (pdecl.Getter.IsNull && !pdecl.Setter.IsNull) {
script.InsertBefore(pdecl.Setter, accessor);
} else {
script.InsertBefore(pdecl.Getter, accessor);
}
script.FormatText(pdecl);
if (accessorStatement != null)
script.Select(accessorStatement);
}, pdecl.NameToken);
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:34,代码来源:AddAnotherAccessorAction.cs
示例11: RouteParameter
public RouteParameter(Accessor accessor)
{
_accessor = accessor;
accessor.ForAttribute<RouteInputAttribute>(x => DefaultValue = x.DefaultValue);
_regex = new Regex(@"{\*?" + Name + @"(?:\:.*?)?}", RegexOptions.Compiled);
}
开发者ID:jemacom,项目名称:fubumvc,代码行数:7,代码来源:RouteParameter.cs
示例12: VisitAccessor
public virtual void VisitAccessor(Accessor accessor)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(accessor);
}
}
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs
示例13: GetMessageSubstitutions
public IEnumerable<KeyValuePair<string, string>> GetMessageSubstitutions(Accessor accessor)
{
return new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(FIELD, accessor.Name)
};
}
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:7,代码来源:RequiredFieldStrategy.cs
示例14: EmitPropertyMethod
protected virtual void EmitPropertyMethod(PropertyDeclaration propertyDeclaration, Accessor accessor, bool setter)
{
var memberResult = this.Emitter.Resolver.ResolveNode(propertyDeclaration, this.Emitter) as MemberResolveResult;
if (memberResult != null &&
(memberResult.Member.Attributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute") ||
(propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull)))
{
return;
}
if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
{
this.EnsureComma();
this.ResetLocals();
var prevMap = this.BuildLocalsMap();
var prevNamesMap = this.BuildLocalsNamesMap();
if (setter)
{
this.AddLocals(new ParameterDeclaration[] { new ParameterDeclaration { Name = "value" } }, accessor.Body);
}
XmlToJsDoc.EmitComment(this, this.PropertyDeclaration);
var overloads = OverloadsCollection.Create(this.Emitter, propertyDeclaration, setter);
string name = overloads.GetOverloadName();
this.Write((setter ? "set" : "get") + name);
this.WriteColon();
this.WriteFunction();
this.WriteOpenParentheses();
this.Write(setter ? "value" : "");
this.WriteCloseParentheses();
this.WriteSpace();
var script = this.Emitter.GetScript(accessor);
if (script == null)
{
accessor.Body.AcceptVisitor(this.Emitter);
}
else
{
this.BeginBlock();
foreach (var line in script)
{
this.Write(line);
this.WriteNewLine();
}
this.EndBlock();
}
this.ClearLocalsMap(prevMap);
this.ClearLocalsNamesMap(prevNamesMap);
this.Emitter.Comma = true;
}
}
开发者ID:GavinHwa,项目名称:Bridge,代码行数:60,代码来源:VisitorPropertyBlock.cs
示例15: Validate
public void Validate(Accessor accessor, ValidationContext context)
{
var rawValue = accessor.GetValue(context.Target);
if (rawValue != null && rawValue.ToString().Length > Length)
{
context.Notification.RegisterMessage(accessor, Token, TemplateValue.For(LENGTH, _length));
}
}
开发者ID:jrios,项目名称:fubuvalidation,代码行数:8,代码来源:MaximumLengthRule.cs
示例16: Validate
public void Validate(Accessor accessor, ValidationContext context)
{
var value = accessor.GetValue(context.Target);
if(_bounds.CompareTo(value) < 0)
{
context.Notification.RegisterMessage(accessor, Token, TemplateValue.For("bounds", _bounds));
}
}
开发者ID:jrios,项目名称:fubuvalidation,代码行数:8,代码来源:MaxValueFieldRule.cs
示例17: Validate
public void Validate(Accessor accessor, ValidationContext context)
{
var email = context.GetFieldValue<string>(accessor);
if(!EmailExpression.IsMatch(email))
{
context.Notification.RegisterMessage(accessor, ValidationKeys.Email);
}
}
开发者ID:thunklife,项目名称:fubuvalidation,代码行数:8,代码来源:EmailFieldRule.cs
示例18: GetName
public string GetName(Type modelType, Accessor accessor)
{
if (accessor.PropertyNames != null)
{
return string.Join(".", accessor.PropertyNames);
}
return accessor.Name;
}
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:8,代码来源:DottedElementNamingConvention.cs
示例19: Failure
public static EditPropertyResult Failure(Accessor accessor, Type entityType, string failureMessage)
{
return new EditPropertyResult(accessor, entityType)
{
WasNotApplied = true,
FailureMessage = failureMessage
};
}
开发者ID:pjdennis,项目名称:fubumvc,代码行数:8,代码来源:EditPropertyResult.cs
示例20: BeforeEach
public void BeforeEach()
{
_notification = new Notification();
_model = new AddressModel();
_strategy = new MaximumStringLengthFieldStrategy() { Length = 10 };
_accessor = AccessorFactory.Create<AddressModel>(m => m.Address1);
_rule = new FieldRule(_accessor, new TypeResolver(), _strategy);
}
开发者ID:RobertTheGrey,项目名称:fubumvc,代码行数:8,代码来源:when_validating_maximum_length.cs
注:本文中的Accessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论