本文整理汇总了C#中Mono.CSharp.FixedField.Define方法的典型用法代码示例。如果您正苦于以下问题:C# FixedField.Define方法的具体用法?C# FixedField.Define怎么用?C# FixedField.Define使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.FixedField
的用法示例。
在下文中一共展示了FixedField.Define方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Define
public override bool Define ()
{
if (!base.Define ())
return false;
if (!BuiltinTypeSpec.IsPrimitiveType (MemberType)) {
Report.Error (1663, Location,
"`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double",
GetSignatureForError ());
} else if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
foreach (var d in declarators) {
var f = new FixedField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
f.initializer = d.Initializer;
((ConstInitializer) f.initializer).Name = d.Name.Value;
f.Define ();
Parent.PartialContainer.Members.Add (f);
}
}
// Create nested fixed buffer container
string name = String.Format ("<{0}>__FixedBuffer{1}", Name, GlobalCounter++);
fixed_buffer_type = Parent.TypeBuilder.DefineNestedType (name,
TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit,
Compiler.BuiltinTypes.ValueType.GetMetaInfo ());
var ffield = fixed_buffer_type.DefineField (FixedElementName, MemberType.GetMetaInfo (), FieldAttributes.Public);
FieldBuilder = Parent.TypeBuilder.DefineField (Name, fixed_buffer_type, ModifiersExtensions.FieldAttr (ModFlags));
var element_spec = new FieldSpec (null, this, MemberType, ffield, ModFlags);
spec = new FixedFieldSpec (Parent.Definition, this, FieldBuilder, element_spec, ModFlags);
Parent.MemberCache.AddMember (spec);
return true;
}