本文整理汇总了C#中System.Reflection.ConstructorInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructorInfo.ToString方法的具体用法?C# ConstructorInfo.ToString怎么用?C# ConstructorInfo.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ConstructorInfo
的用法示例。
在下文中一共展示了ConstructorInfo.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitNewObject
public void EmitNewObject(ConstructorInfo ci)
{
ProcessCommand(
OpCodes.Newobj,
ci.GetParameters().Length * -1 + 1,
ci.ToString()
);
ilGenerator.Emit(OpCodes.Newobj, ci);
}
示例2: GetCommentLines
public IEnumerable<string> GetCommentLines(ConstructorInfo constructor)
{
string memberName = "M:" + constructor.DeclaringType.FullName + ".#" + constructor.ToString().Substring(6);
memberName = memberName.Replace("()", "");
memberName = memberName.Replace(", ", ",");
memberName = memberName.Replace("Boolean", "System.Boolean");
memberName = memberName.Replace("Double", "System.Double");
memberName = memberName.Replace("Int32", "System.Int32");
if (memberName.Contains("IEnumerable"))
{
memberName = memberName.Replace("`1[", "{");
memberName = memberName.Replace("])", "})");
}
var comment = _Comments.XPathSelectElement("/doc/members/member[@name='" + memberName + "']");
if (comment == null)
throw new NotImplementedException(memberName);
foreach (var node in comment.Nodes())
{
foreach (string line in node.ToString().Split('\n'))
yield return "/// " + line.Trim();
}
}
示例3: New
internal void New(ConstructorInfo constructorInfo)
{
if (_codeGenTrace != CodeGenTrace.None)
EmitSourceInstruction("Newobj " + constructorInfo.ToString() + " on type " + constructorInfo.DeclaringType.ToString());
_ilGen.Emit(OpCodes.Newobj, constructorInfo);
}
示例4: Call
internal void Call(ConstructorInfo ctor)
{
if (_codeGenTrace != CodeGenTrace.None)
EmitSourceInstruction("Call " + ctor.ToString() + " on type " + ctor.DeclaringType.ToString());
_ilGen.Emit(OpCodes.Call, ctor);
}
示例5: OkToUse
public bool OkToUse(ConstructorInfo c, out string message)
{
if (c == null) throw new ArgumentNullException("c");
string toCheckStr = c.DeclaringType.ToString() + "." + c.ToString(); //[email protected]
return OkToUseInternal(toCheckStr, this.require_members, this.forbid_members, out message); //[email protected]
//return OkToUseInternal(c.ToString(), this.require_members, this.forbid_members, out message); //[email protected]
}
示例6: Match
protected virtual bool Match(ConstructorInfo ctor, Type type)
{
switch (type.Name) {
case "MKTileOverlayRenderer":
// NSInvalidArgumentEception Expected a MKTileOverlay
// looks like Apple has not yet added a DI for this type, but it should be `initWithTileOverlay:`
if (ctor.ToString () == "Void .ctor(IMKOverlay)")
return true;
break;
case "MPSImageHistogram":
// Could not initialize an instance of the type 'MetalPerformanceShaders.MPSImageHistogram': the native 'initWithDevice:' method returned nil.
// make sense: there's a `initWithDevice:histogramInfo:` DI
if (ctor.ToString () == "Void .ctor(IMTLDevice)")
return true;
break;
case "NSDataDetector":
// -[NSDataDetector initWithPattern:options:error:]: Not valid for NSDataDetector
if (ctor.ToString () == "Void .ctor(NSString, NSRegularExpressionOptions, NSError&)")
return true;
break;
#if __TVOS__
case "UISearchBar":
// - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER __TVOS_PROHIBITED;
return true;
#endif
}
var expected = ctor.ToString ();
// NonPublic to get `protected` which can be autogenerated for abstract types (subclassing a non-abstract type)
foreach (var candidate in type.GetConstructors (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)) {
if (candidate.ToString () == expected)
return true;
}
return false;
}
示例7: New
internal void New(ConstructorInfo constructor)
{
if (this.codeGenTrace != CodeGenTrace.None)
{
this.EmitSourceInstruction("Newobj " + constructor.ToString() + " on type " + constructor.DeclaringType.ToString());
}
this.ilGen.Emit(OpCodes.Newobj, constructor);
}
示例8: ProcessConstructor
void ProcessConstructor(ConstructorInfo constructorInfo)
{
Debug.WriteLine ("Add constructor " + constructorInfo.ToString ());
}
示例9: OkToUse
public bool OkToUse(ConstructorInfo c, out string message)
{
if (c == null) throw new ArgumentNullException("c");
return OkToUseInternal(c.ToString(), this.require_members, this.forbid_members, out message);
}
示例10: Emit
public void Emit(OpCode opCode, ConstructorInfo ci)
{
ProcessCommand(opCode, 0, ci.ToString());
ilGenerator.Emit(opCode, ci);
}
示例11: OkToUse
/// <summary>
/// Determines of the target constructor is ok to use.
/// </summary>
/// <param name="constructor">
/// The constructor to test
/// </param>
/// <param name="message">
/// A message for the caller.
/// </param>
/// <returns>
/// True if the constructor is ok to use, false otherwise.
/// </returns>
public bool OkToUse(ConstructorInfo constructor, out string message)
{
if (constructor != null)
{
foreach (ForbidExpression fExp in this.forbiddenMembers)
{
if (fExp.IsForbidden(constructor.ToString()))
{
message = string.Format("The Constructor {0} matches the ForbidExpression with pattern {1}. It will not be used.", constructor.ToString(), fExp.Pattern);
return false;
}
}
message = string.Format("The Constructor {0} will be used.", constructor.ToString());
return true;
}
else
{
message = "The passed in Constructor argument was null";
throw new ArgumentNullException(message);
}
}