本文整理汇总了C#中Mono.CSharp.Constructor.Define方法的典型用法代码示例。如果您正苦于以下问题:C# Constructor.Define方法的具体用法?C# Constructor.Define怎么用?C# Constructor.Define使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.Constructor
的用法示例。
在下文中一共展示了Constructor.Define方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoDefineMembers
protected override bool DoDefineMembers ()
{
var builtin_types = Compiler.BuiltinTypes;
var ctor_parameters = ParametersCompiled.CreateFullyResolved (
new [] {
new Parameter (new TypeExpression (builtin_types.Object, Location), "object", Parameter.Modifier.NONE, null, Location),
new Parameter (new TypeExpression (builtin_types.IntPtr, Location), "method", Parameter.Modifier.NONE, null, Location)
},
new [] {
builtin_types.Object,
builtin_types.IntPtr
}
);
Constructor = new Constructor (this, Constructor.ConstructorName,
Modifiers.PUBLIC, null, ctor_parameters, Location);
Constructor.Define ();
//
// Here the various methods like Invoke, BeginInvoke etc are defined
//
// First, call the `out of band' special method for
// defining recursively any types we need:
//
var p = parameters;
if (!p.Resolve (this))
return false;
//
// Invoke method
//
// Check accessibility
foreach (var partype in p.Types) {
if (!IsAccessibleAs (partype)) {
Report.SymbolRelatedToPreviousError (partype);
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
partype.GetSignatureForError (), GetSignatureForError ());
}
}
var ret_type = ReturnType.ResolveAsType (this);
if (ret_type == null)
return false;
//
// We don't have to check any others because they are all
// guaranteed to be accessible - they are standard types.
//
if (!IsAccessibleAs (ret_type)) {
Report.SymbolRelatedToPreviousError (ret_type);
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
ret_type.GetSignatureForError () + "' is less " +
"accessible than delegate `" + GetSignatureForError () + "'");
return false;
}
CheckProtectedModifier ();
if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType) {
Method.Error1599 (Location, ret_type, Report);
return false;
}
VarianceDecl.CheckTypeVariance (ret_type, Variance.Covariant, this);
var resolved_rt = new TypeExpression (ret_type, Location);
InvokeBuilder = new Method (this, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
InvokeBuilder.Define ();
//
// Don't emit async method for compiler generated delegates (e.g. dynamic site containers)
//
if (!IsCompilerGenerated) {
DefineAsyncMethods (resolved_rt);
}
return true;
}
示例2: DoDefineMembers
protected override bool DoDefineMembers ()
{
var ctor_parameters = ParametersCompiled.CreateFullyResolved (
new [] {
new Parameter (new TypeExpression (TypeManager.object_type, Location), "object", Parameter.Modifier.NONE, null, Location),
new Parameter (new TypeExpression (TypeManager.intptr_type, Location), "method", Parameter.Modifier.NONE, null, Location)
},
new [] {
TypeManager.object_type,
TypeManager.intptr_type
}
);
Constructor = new Constructor (this, System.Reflection.ConstructorInfo.ConstructorName,
Modifiers.PUBLIC, null, ctor_parameters, null, Location);
Constructor.Define ();
//
// Here the various methods like Invoke, BeginInvoke etc are defined
//
// First, call the `out of band' special method for
// defining recursively any types we need:
//
var p = Parameters;
if (!p.Resolve (this))
return false;
//
// Invoke method
//
// Check accessibility
foreach (var partype in p.Types) {
if (!IsAccessibleAs (partype)) {
Report.SymbolRelatedToPreviousError (partype);
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
TypeManager.CSharpName (partype), GetSignatureForError ());
}
}
ReturnType = ReturnType.ResolveAsTypeTerminal (this, false);
if (ReturnType == null)
return false;
var ret_type = ReturnType.Type;
//
// We don't have to check any others because they are all
// guaranteed to be accessible - they are standard types.
//
if (!IsAccessibleAs (ret_type)) {
Report.SymbolRelatedToPreviousError (ret_type);
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (ret_type) + "' is less " +
"accessible than delegate `" + GetSignatureForError () + "'");
return false;
}
CheckProtectedModifier ();
if (RootContext.StdLib && TypeManager.IsSpecialType (ret_type)) {
Method.Error1599 (Location, ret_type, Report);
return false;
}
TypeManager.CheckTypeVariance (ret_type, Variance.Covariant, this);
InvokeBuilder = new Method (this, null, ReturnType, MethodModifiers, new MemberName (InvokeMethodName), p, null);
InvokeBuilder.Define ();
//
// Don't emit async method for compiler generated delegates (e.g. dynamic site containers)
//
if (TypeManager.iasyncresult_type != null && TypeManager.asynccallback_type != null && !IsCompilerGenerated) {
DefineAsyncMethods (Parameters.CallingConvention);
}
return true;
}