本文整理汇总了C#中IParameterDefinition类的典型用法代码示例。如果您正苦于以下问题:C# IParameterDefinition类的具体用法?C# IParameterDefinition怎么用?C# IParameterDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParameterDefinition类属于命名空间,在下文中一共展示了IParameterDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintParameterDefinitionModifiers
public virtual void PrintParameterDefinitionModifiers(IParameterDefinition parameterDefinition) {
Contract.Requires(parameterDefinition != null);
if (parameterDefinition.Index == 0) {
var meth = parameterDefinition.ContainingSignature as IMethodDefinition;
if (meth != null ) {
if (Utils.FindAttribute(meth.Attributes, SpecialAttribute.Extension) != null) {
PrintToken(CSharpToken.This);
PrintToken(CSharpToken.Space);
}
}
}
foreach (var attribute in SortAttributes(parameterDefinition.Attributes)) {
if (Utils.GetAttributeType(attribute) == SpecialAttribute.ParamArray)
sourceEmitterOutput.Write("params");
else
this.PrintAttribute(parameterDefinition, attribute, false, null);
PrintToken(CSharpToken.Space);
}
if (parameterDefinition.IsOut && !parameterDefinition.IsIn && parameterDefinition.IsByReference) {
// C# out keyword means [Out] ref (with no [In] allowed)
PrintKeywordOut();
} else {
if (parameterDefinition.IsIn)
PrintPseudoCustomAttribute(parameterDefinition, "System.Runtime.InteropServices.In", null, false, null);
if (parameterDefinition.IsOut)
PrintPseudoCustomAttribute(parameterDefinition, "System.Runtime.InteropServices.Out", null, false, null);
if (parameterDefinition.IsByReference)
PrintKeywordRef();
}
}
示例2: TraverseChildren
public override void TraverseChildren(IParameterDefinition parameterDefinition) {
PrintParameterDefinitionModifiers(parameterDefinition);
PrintParameterDefinitionName(parameterDefinition);
PrintToken(VBToken.Space);
PrintToken(VBToken.As);
PrintToken(VBToken.Space);
PrintParameterDefinitionType(parameterDefinition);
}
示例3: GetModifier
private string GetModifier(IParameterDefinition parameter)
{
if (parameter.IsOut && !parameter.IsIn && parameter.IsByReference)
return "out";
else if (parameter.IsByReference)
return "ref";
return "in";
}
示例4: ParameterDefinition
public ParameterDefinition(IParameterDefinition copyFrom) : base(copyFrom)
{
Context = copyFrom.Context;
DataType = copyFrom.DataType;
IsRequired = copyFrom.IsRequired;
IsVariadic = copyFrom.IsVariadic;
Name = copyFrom.Name;
Type = copyFrom.Type;
}
示例5: CciParameterDetails
public CciParameterDetails(IParameterDefinition parameter)
{
if (parameter == null)
{
throw new ArgumentNullException("parameter");
}
_parameter = parameter;
}
示例6: MethodParameter
public MethodParameter(IParameterDefinition parameterDefinition, Bpl.Type ptype) {
this.underlyingParameter = parameterDefinition;
var parameterToken = parameterDefinition.Token();
var typeToken = parameterDefinition.Type.Token();
var parameterName = TranslationHelper.TurnStringIntoValidIdentifier(parameterDefinition.Name.Value);
if (String.IsNullOrWhiteSpace(parameterName)) parameterName = "P" + parameterDefinition.Index.ToString();
this.inParameterCopy = new Bpl.Formal(parameterToken, new Bpl.TypedIdent(typeToken, parameterName + "$in", ptype), true);
if (parameterDefinition.IsByReference) {
this.outParameterCopy = new Bpl.Formal(parameterToken, new Bpl.TypedIdent(typeToken, parameterName + "$out", ptype), false);
} else {
this.outParameterCopy = new Bpl.LocalVariable(parameterToken, new Bpl.TypedIdent(typeToken, parameterName, ptype));
}
}
示例7: MethodParameter
public MethodParameter(IParameterDefinition parameterDefinition) {
this.underlyingParameter = parameterDefinition;
Bpl.Type ptype = Bpl.Type.Int;
var parameterToken = parameterDefinition.Token();
var typeToken = parameterDefinition.Type.Token();
var parameterName = parameterDefinition.Name.Value;
if (!parameterDefinition.IsOut) {
this.inParameterCopy = new Bpl.Formal(parameterToken, new Bpl.TypedIdent(typeToken, parameterName + "$in", ptype), true);
}
if (parameterDefinition.IsByReference || parameterDefinition.IsOut) {
this.outParameterCopy = new Bpl.Formal(parameterToken, new Bpl.TypedIdent(typeToken, parameterName + "$out", ptype), false);
} else {
this.outParameterCopy = new Bpl.LocalVariable(parameterToken, new Bpl.TypedIdent(typeToken, parameterName, ptype));
}
}
示例8: Visit
//^ ensures this.path.Count == old(this.path.Count);
/// <summary>
/// Performs some computation with the given parameter definition.
/// </summary>
/// <param name="parameterDefinition"></param>
public virtual void Visit(IParameterDefinition parameterDefinition)
{
if (this.stopTraversal) return;
//^ int oldCount = this.path.Count;
this.path.Push(parameterDefinition);
this.Visit(parameterDefinition.Attributes);
if (parameterDefinition.IsModified)
this.Visit(parameterDefinition.CustomModifiers);
if (parameterDefinition.HasDefaultValue)
this.Visit((IMetadataExpression)parameterDefinition.DefaultValue);
if (parameterDefinition.IsMarshalledExplicitly)
this.Visit(parameterDefinition.MarshallingInformation);
this.Visit(parameterDefinition.Type);
//^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count.
this.path.Pop();
}
示例9: AddOriginalParameter
public void AddOriginalParameter(IParameterDefinition parameter)
{
var parameterInfo = new ReplacementParameterInfo();
parameterInfo.Name = parameter.Name.Value;
parameterInfo.IsOut = parameter.IsOut;
parameterInfo.IsRef = parameter.IsByReference;
parameterInfo.Type = parameter.Type;
parameterInfo.Definition = parameter;
}
示例10: GetModuleParameters
protected IParameterDefinition[] GetModuleParameters(bool useParamInfo, ISignature signatureDefinition, int paramCount) {
MethodDefinition/*?*/ moduleMethod = signatureDefinition as MethodDefinition;
int paramIndex = 0;
var parameters = new IParameterDefinition[paramCount];
while (paramIndex < paramCount) {
bool dummyPinned;
var customModifiers = this.GetCustomModifiers(out dummyPinned);
byte currByte = this.SignatureMemoryReader.PeekByte(0);
if (currByte == ElementType.Sentinel) {
this.SignatureMemoryReader.SkipBytes(1);
var requiredParameters = new IParameterDefinition[paramIndex];
for (int i = 0; i < paramIndex; i++) requiredParameters[i] = parameters[i];
return requiredParameters;
}
bool isByReference = false;
ITypeReference/*?*/ typeReference;
if (currByte == ElementType.TypedReference) {
this.SignatureMemoryReader.SkipBytes(1);
typeReference = this.PEFileToObjectModel.PlatformType.SystemTypedReference;
} else {
if (currByte == ElementType.ByReference) {
this.SignatureMemoryReader.SkipBytes(1);
isByReference = true;
}
typeReference = this.GetTypeReference();
}
ParamInfo? paramInfo = useParamInfo ? this.GetParamInfo(paramIndex + 1) : null;
IParameterDefinition moduleParameter;
if (paramInfo.HasValue) {
var paramArrayType = typeReference as IArrayTypeReference;
moduleParameter = new ParameterWithMetadata(this.PEFileToObjectModel, paramIndex, customModifiers, typeReference, moduleMethod, isByReference,
(paramIndex == paramCount - 1) && paramArrayType != null && paramArrayType.IsVector, paramInfo.Value.ParamRowId, paramInfo.Value.ParamName, paramInfo.Value.ParamFlags);
} else
moduleParameter = new ParameterWithoutMetadata(this.PEFileToObjectModel, paramIndex, customModifiers, typeReference, signatureDefinition, isByReference);
parameters[paramIndex++] = moduleParameter;
}
return parameters;
}
示例11: Visit
public virtual void Visit(IParameterDefinition parameterDefinition)
{
var marshalling = parameterDefinition.MarshallingInformation;
Debug.Assert((marshalling != null || !parameterDefinition.MarshallingDescriptor.IsDefaultOrEmpty) == parameterDefinition.IsMarshalledExplicitly);
this.Visit(parameterDefinition.GetAttributes(Context));
this.Visit(parameterDefinition.CustomModifiers);
IMetadataConstant defaultValue = parameterDefinition.GetDefaultValue(Context);
if (defaultValue != null)
{
this.Visit((IMetadataExpression)defaultValue);
}
if (marshalling != null)
{
// Note, we are not visiting MarshallingDescriptor. It is used only for
// NoPia embedded/local types and VB Dev11 simply copies the bits without
// cracking them.
this.Visit(marshalling);
}
this.Visit(parameterDefinition.GetType(Context));
}
示例12: WriteParameter
private void WriteParameter(IParameterDefinition parameter, bool extensionMethod)
{
WriteAttributes(parameter.Attributes, true);
if (extensionMethod)
WriteKeyword("this");
if (parameter.IsParameterArray)
WriteKeyword("params");
if (parameter.IsOut && !parameter.IsIn && parameter.IsByReference)
{
WriteKeyword("out");
}
else
{
// For In/Out we should not emit them until we find a scenario that is needs thems.
//if (parameter.IsIn)
// WriteFakeAttribute("System.Runtime.InteropServices.In", writeInline: true);
//if (parameter.IsOut)
// WriteFakeAttribute("System.Runtime.InteropServices.Out", writeInline: true);
if (parameter.IsByReference)
WriteKeyword("ref");
}
WriteTypeName(parameter.Type, isDynamic: IsDynamic(parameter.Attributes));
WriteIdentifier(parameter.Name);
if (parameter.IsOptional && parameter.HasDefaultValue)
{
WriteSymbol("=");
WriteMetadataConstant(parameter.DefaultValue, parameter.Type);
}
}
示例13: VisitReference
public void VisitReference(IParameterDefinition parameterDefinition)
{
throw new NotImplementedException();
}
示例14: VisitReference
/// <summary>
/// Performs some computation with the given parameter definition.
/// </summary>
public void VisitReference(IParameterDefinition parameterDefinition)
{
}
示例15: Traverse
/// <summary>
/// Traverses the parameter definition.
/// </summary>
public void Traverse(IParameterDefinition parameterDefinition)
{
Contract.Requires(parameterDefinition != null);
if (!this.objectsThatHaveAlreadyBeenTraversed.Add(parameterDefinition)) return;
if (this.preorderVisitor != null) this.preorderVisitor.Visit(parameterDefinition);
if (this.stopTraversal) return;
this.TraverseChildren(parameterDefinition);
if (this.stopTraversal) return;
if (this.postorderVisitor != null) this.postorderVisitor.Visit(parameterDefinition);
}