本文整理汇总了C#中ParameterDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# ParameterDeclaration类的具体用法?C# ParameterDeclaration怎么用?C# ParameterDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterDeclaration类属于命名空间,在下文中一共展示了ParameterDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CompileTimeValidate
public override void CompileTimeValidate(ParameterDeclaration parameter, Type memberType, IMessageSink messages)
{
base.CompileTimeValidate(parameter, memberType, messages);
bool isString = memberType == typeof(string);
if (!isString)
{
messages.Write(new Message(
SeverityType.Error,
"PatternAttribute_TypeNotSupported",
string.Format(CultureInfo.InvariantCulture, "The type '{0}' is not a string to perform the expression validation on.", memberType.Name),
GetType().FullName
));
}
if (string.IsNullOrEmpty(expression))
{
messages.Write(new Message(
SeverityType.Error,
"PatternAttribute_PatternNotNullOrEmpty",
"The expression pattern must not be null or empty.",
GetType().FullName
));
}
}
开发者ID:zevinganez,项目名称:code-o-matic,代码行数:26,代码来源:PatternAttribute.cs
示例2: HandleVisitorParameterDeclarationVisited
void HandleVisitorParameterDeclarationVisited (ParameterDeclaration node, InspectionData data)
{
foreach (var rule in policy.Rules) {
if (rule.CheckParameter (node, data))
return;
}
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:NamingInspector.cs
示例3: ParameterValueToken
/// <summary>
/// Initializes a new instance of the <see cref="ParameterValueToken"/> class
/// with the specified parameter.
/// </summary>
/// <param name="parameter">Parameter whose value the token expands to.</param>
/// <exception cref="ArgumentNullException"><paramref name="parameter"/> is <see langword="null"/>.</exception>
public ParameterValueToken(ParameterDeclaration parameter)
{
if (parameter == null) {
throw new ArgumentNullException("parameter");
}
this.parameter = parameter;
}
开发者ID:kamillangowski,项目名称:postsharp-user-plugins,代码行数:14,代码来源:ParameterValueToken.cs
示例4: ReturnValueToken
/// <summary>
/// Initializes a new instance of the <see cref="ReturnValueToken"/> class
/// with the specified return parameter metadata.
/// </summary>
/// <param name="returnParameter">Return parameter metadata.</param>
/// <exception cref="ArgumentNullException"><paramref name="returnParameter"/> is <see langword="null"/>.</exception>
public ReturnValueToken(ParameterDeclaration returnParameter)
{
if (returnParameter == null) {
throw new ArgumentNullException("returnParameter");
}
this.returnParameter = returnParameter;
}
开发者ID:kamillangowski,项目名称:postsharp-user-plugins,代码行数:14,代码来源:ReturnValueToken.cs
示例5: VisitParameterDeclaration
public override object VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, object data)
{
if (parameterDeclaration.ParameterModifier == ParameterModifier.Params)
{
UnlockWith(parameterDeclaration);
}
return base.VisitParameterDeclaration(parameterDeclaration, data);
}
开发者ID:vlad2135,项目名称:strokes,代码行数:9,代码来源:ParamsParameterAchievement.cs
示例6: AssertInvocationExpression
protected override void AssertInvocationExpression(InvocationExpression invocation, ParameterDeclaration parameter)
{
foreach (var member in invocation.Descendants.OfType<MemberReferenceExpression>())
{
if (member.MemberName == "LoadDocument")
throw new InvalidOperationException("Reduce cannot contain LoadDocument() methods.");
}
base.AssertInvocationExpression(invocation, parameter);
}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:10,代码来源:ThrowOnInvalidMethodCallsInReduce.cs
示例7: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
if (parameterDeclaration.Parent is ConstructorDeclaration)
return;
if (HidesMember (ctx, parameterDeclaration, parameterDeclaration.Name))
AddIssue (parameterDeclaration.NameToken,
ctx.TranslateString ("Parameter has the same name as a member and hides it"));
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:10,代码来源:ParameterHidesMemberIssue.cs
示例8: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
var resolveResult = ctx.Resolve (parameterDeclaration) as LocalResolveResult;
if (resolveResult == null)
return;
if (!TestOnlyAssigned (ctx, unit, resolveResult.Variable))
return;
AddIssue (parameterDeclaration.NameToken,
ctx.TranslateString ("Parameter is assigned by its value is never used"));
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:12,代码来源:ParameterOnlyAssignedIssue.cs
示例9: MakeParameters
public static IEnumerable<ParameterDeclaration> MakeParameters(IEnumerable<ParameterDefinition> paramCol)
{
foreach(ParameterDefinition paramDef in paramCol) {
ParameterDeclaration astParam = new ParameterDeclaration();
astParam.Type = ConvertType(paramDef.ParameterType, paramDef);
astParam.Name = paramDef.Name;
if (!paramDef.IsIn && paramDef.IsOut) astParam.ParameterModifier = ParameterModifier.Out;
if (paramDef.IsIn && paramDef.IsOut) astParam.ParameterModifier = ParameterModifier.Ref;
// TODO: params, this
yield return astParam;
}
}
开发者ID:KleinR,项目名称:ILSpy,代码行数:14,代码来源:AstBuilder.cs
示例10: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
if (!(parameterDeclaration.Parent is MethodDeclaration))
return;
var resolveResult = ctx.Resolve (parameterDeclaration) as LocalResolveResult;
if (resolveResult == null)
return;
if (FindUsage (ctx, unit, resolveResult.Variable, parameterDeclaration))
return;
AddIssue (parameterDeclaration.NameToken, ctx.TranslateString ("Parameter is never used"));
}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:15,代码来源:ParameterNotUsedIssue.cs
示例11: VisitParameterDeclaration
public override void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration(parameterDeclaration);
var resolveResult = ctx.Resolve(parameterDeclaration) as LocalResolveResult;
if (resolveResult == null)
return;
var parameterModifier = parameterDeclaration.ParameterModifier;
if (parameterModifier == ParameterModifier.Out || parameterModifier == ParameterModifier.Ref ||
!TestOnlyAssigned(ctx, parameterDeclaration.Parent, resolveResult.Variable)) {
return;
}
AddIssue(parameterDeclaration.NameToken,
ctx.TranslateString("Parameter is assigned but its value is never used"));
}
开发者ID:riviti,项目名称:NRefactory,代码行数:16,代码来源:ParameterOnlyAssignedIssue.cs
示例12: CompileTimeValidate
public override void CompileTimeValidate(ParameterDeclaration parameter, Type memberType, IMessageSink messages)
{
base.CompileTimeValidate(parameter, memberType, messages);
if(exception != null)
{
if(!ValidateExceptionTypeIsException(messages))
{
return;
}
if(!ValidateExceptionTypeCanBeInstantiated(messages))
{
return;
}
}
}
开发者ID:zevinganez,项目名称:code-o-matic,代码行数:16,代码来源:SpecificExceptionParameterValidatorAttribute.cs
示例13: VisitParameterDeclaration
public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
base.VisitParameterDeclaration (parameterDeclaration);
if (parameterDeclaration.ParameterModifier == ParameterModifier.Out ||
parameterDeclaration.ParameterModifier == ParameterModifier.Ref)
return;
var resolveResult = ctx.Resolve (parameterDeclaration) as LocalResolveResult;
BlockStatement rootStatement = null;
if (parameterDeclaration.Parent is MethodDeclaration) {
rootStatement = ((MethodDeclaration)parameterDeclaration.Parent).Body;
} else if (parameterDeclaration.Parent is AnonymousMethodExpression) {
rootStatement = ((AnonymousMethodExpression)parameterDeclaration.Parent).Body;
} else if (parameterDeclaration.Parent is LambdaExpression) {
rootStatement = ((LambdaExpression)parameterDeclaration.Parent).Body as BlockStatement;
}
CollectIssues (parameterDeclaration, rootStatement, resolveResult);
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:18,代码来源:RedundantAssignmentIssue.cs
示例14: CompileTimeValidate
public override void CompileTimeValidate(ParameterDeclaration parameter, Type memberType, IMessageSink messages)
{
base.CompileTimeValidate(parameter, memberType, messages);
bool isNullable =
!memberType.IsValueType ||
(memberType.IsGenericType && memberType.GetGenericTypeDefinition() == typeof(Nullable<>));
if (!isNullable)
{
messages.Write(new Message(
SeverityType.Error,
"NotNullAttribute_TypeNotNullable",
string.Format(CultureInfo.InvariantCulture, "The type '{0}' is not nullable.", memberType.Name),
GetType().FullName
));
}
}
开发者ID:zevinganez,项目名称:code-o-matic,代码行数:18,代码来源:NotNullAttribute.cs
示例15: CompileTimeValidateParameters
protected override void CompileTimeValidateParameters(MethodDefDeclaration method, IMessageSink messages, ParameterDeclaration firstParameter, ParameterDeclaration secondParameter)
{
base.CompileTimeValidateParameters(method, messages, firstParameter, secondParameter);
if(typeof(IComparable).IsAssignableFrom(firstParameter.ParameterType.GetSystemType(null, null)))
{
firstParameterIsComparable = true;
}
else if(typeof(IComparable).IsAssignableFrom(secondParameter.ParameterType.GetSystemType(null, null)))
{
firstParameterIsComparable = false;
}
else
{
messages.Write(new Message(
SeverityType.Error,
"ComparisonValidatorAttribute_ParametersCantBeCompared",
string.Format(CultureInfo.InvariantCulture, "None of the parameters '{0}' and '{1}' implements IComparable.", firstParameter.Name, secondParameter.Name),
GetType().FullName
));
}
}
开发者ID:zevinganez,项目名称:code-o-matic,代码行数:22,代码来源:ComparisonValidatorAttribute.cs
示例16: InsertFirstParameterDeclarationIntoMethod
public void InsertFirstParameterDeclarationIntoMethod()
{
var input [email protected]"
public class Test
{
void Test()
{
}
}";
var expected = @"
public class Test
{
void Test(int a)
{
}
}";
DoInsertAfterTest(input, expected, (syntaxTree, script) =>
{
var nodeToInsert = new ParameterDeclaration(new PrimitiveType("int"),"a");
var nodeToInsertAfter = syntaxTree.DescendantsAndSelf.OfType<MethodDeclaration>().Single().LParToken;
script.InsertAfter(nodeToInsertAfter,nodeToInsert);
});
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:23,代码来源:ScriptTests.cs
示例17: InsertParameterDeclarationDoesNotIndent
public void InsertParameterDeclarationDoesNotIndent()
{
var input [email protected]"
public class Test
{
void Test(int a)
{
}
}";
var expected = @"
public class Test
{
void Test(int a, int b)
{
}
}";
DoInsertAfterTest(input, expected, (syntaxTree, script) =>
{
var nodeToInsert = new ParameterDeclaration(new PrimitiveType("int"),"b");
var nodeToInsertAfter = syntaxTree.DescendantsAndSelf.OfType<ParameterDeclaration>().Single();
script.InsertAfter(nodeToInsertAfter,nodeToInsert);
});
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:23,代码来源:ScriptTests.cs
示例18: VisitParameterDeclaration
public void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration)
{
StartNode(parameterDeclaration);
WriteAttributes(parameterDeclaration.Attributes);
switch (parameterDeclaration.ParameterModifier) {
case ParameterModifier.Ref:
WriteKeyword(ParameterDeclaration.RefModifierRole);
break;
case ParameterModifier.Out:
WriteKeyword(ParameterDeclaration.OutModifierRole);
break;
case ParameterModifier.Params:
WriteKeyword(ParameterDeclaration.ParamsModifierRole);
break;
case ParameterModifier.This:
WriteKeyword(ParameterDeclaration.ThisModifierRole);
break;
}
parameterDeclaration.Type.AcceptVisitor(this);
if (!parameterDeclaration.Type.IsNull && !string.IsNullOrEmpty(parameterDeclaration.Name)) {
Space();
}
if (!string.IsNullOrEmpty(parameterDeclaration.Name)) {
parameterDeclaration.NameToken.AcceptVisitor(this);
}
if (!parameterDeclaration.DefaultExpression.IsNull) {
Space(policy.SpaceAroundAssignment);
WriteToken(Roles.Assign);
Space(policy.SpaceAroundAssignment);
parameterDeclaration.DefaultExpression.AcceptVisitor(this);
}
EndNode(parameterDeclaration);
}
开发者ID:x-strong,项目名称:ILSpy,代码行数:33,代码来源:CSharpOutputVisitor.cs
示例19: InlineMethod
/// <summary>
/// Refactors the names of parameters and their references so the
/// method body can be copied directly into the output.
/// </summary>
public static void InlineMethod(
IAlgorithm algorithm,
MethodDeclaration method,
string outputName,
string[] inputNames,
Expression x,
Expression y,
Expression z,
Expression i,
Expression j,
Expression k,
Expression width,
Expression height,
Expression depth,
Expression ox,
Expression oy,
Expression oz)
{
if (algorithm == null) throw new ArgumentNullException("algorithm");
if (method == null) throw new ArgumentNullException("method");
if (outputName == null) throw new ArgumentNullException("outputName");
if (inputNames == null) throw new ArgumentNullException("inputNames");
if (x == null) throw new ArgumentNullException("x");
if (y == null) throw new ArgumentNullException("y");
if (z == null) throw new ArgumentNullException("z");
if (i == null) throw new ArgumentNullException("i");
if (j == null) throw new ArgumentNullException("j");
if (k == null) throw new ArgumentNullException("k");
if (width == null) throw new ArgumentNullException("width");
if (height == null) throw new ArgumentNullException("height");
if (depth == null) throw new ArgumentNullException("depth");
if (ox == null) throw new ArgumentNullException("ox");
if (oy == null) throw new ArgumentNullException("oy");
if (oz == null) throw new ArgumentNullException("oz");
var parameterContext = method.Parameters.ElementAt(0);
var parameterInputs = new ParameterDeclaration[method.Parameters.Count - 14];
for (var idx = 1; idx < method.Parameters.Count - 13; idx++)
parameterInputs[idx - 1] = method.Parameters.ElementAt(idx);
var parameterOutput = method.Parameters.Reverse().ElementAt(12);
var parameterX = method.Parameters.Reverse().ElementAt(11);
var parameterY = method.Parameters.Reverse().ElementAt(10);
var parameterZ = method.Parameters.Reverse().ElementAt(9);
var parameterI = method.Parameters.Reverse().ElementAt(8);
var parameterJ = method.Parameters.Reverse().ElementAt(7);
var parameterK = method.Parameters.Reverse().ElementAt(6);
var parameterWidth = method.Parameters.Reverse().ElementAt(5);
var parameterHeight = method.Parameters.Reverse().ElementAt(4);
var parameterDepth = method.Parameters.Reverse().ElementAt(3);
var parameterOX = method.Parameters.Reverse().ElementAt(2);
var parameterOY = method.Parameters.Reverse().ElementAt(1);
var parameterOZ = method.Parameters.Reverse().ElementAt(0);
// Replace properties.
method.AcceptVisitor(new FindPropertiesVisitor
{
Algorithm = algorithm,
ParameterContextName = parameterContext.Name
});
// Replace identifiers.
var identifiers =
method
.Body
.Descendants
.Where(v => v is IdentifierExpression)
.Cast<IdentifierExpression>()
.ToArray();
foreach (var e in identifiers)
{
if (e.Identifier == parameterX.Name)
e.ReplaceWith(x.Clone());
else if (e.Identifier == parameterY.Name)
e.ReplaceWith(y.Clone());
else if (e.Identifier == parameterZ.Name)
e.ReplaceWith(z.Clone());
else if (e.Identifier == parameterI.Name)
e.ReplaceWith(i.Clone());
else if (e.Identifier == parameterJ.Name)
e.ReplaceWith(j.Clone());
else if (e.Identifier == parameterK.Name)
e.ReplaceWith(k.Clone());
else if (e.Identifier == parameterWidth.Name)
e.ReplaceWith(width.Clone());
else if (e.Identifier == parameterHeight.Name)
e.ReplaceWith(height.Clone());
else if (e.Identifier == parameterDepth.Name)
e.ReplaceWith(depth.Clone());
else if (e.Identifier == parameterOX.Name)
e.ReplaceWith(ox.Clone());
else if (e.Identifier == parameterOY.Name)
e.ReplaceWith(oy.Clone());
else if (e.Identifier == parameterOZ.Name)
e.ReplaceWith(oz.Clone());
else if (e.Identifier == parameterOutput.Name)
e.Identifier = outputName;
//.........这里部分代码省略.........
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:101,代码来源:AlgorithmRefactorer.cs
示例20: VisitParameterDeclaration
public virtual void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration)
{
VisitChildren (parameterDeclaration);
}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs
注:本文中的ParameterDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论