当前位置: 首页>>代码示例>>C#>>正文


C# FieldAttributes.HasFlag方法代码示例

本文整理汇总了C#中FieldAttributes.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# FieldAttributes.HasFlag方法的具体用法?C# FieldAttributes.HasFlag怎么用?C# FieldAttributes.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldAttributes的用法示例。


在下文中一共展示了FieldAttributes.HasFlag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ModifyFieldDefProps

        /// <summary>
        /// The backing field of a WinRT enumeration type is not public although the backing fields
        /// of managed enumerations are. To allow managed languages to directly access this field,
        /// it is made public by the metadata adapter.
        /// </summary>
        private void ModifyFieldDefProps(FieldHandle fieldDef, string name, ref FieldAttributes flags)
        {
            if (name == "value__" && flags.HasFlag(FieldAttributes.RTSpecialName))
            {
                TypeHandle typeDef = FindContainingType(fieldDef);
                Debug.Assert(!typeDef.IsNil);

                MetadataToken extendsRef = GetTypeDefExtends(typeDef);
                if (extendsRef.HandleType == HandleType.TypeReference)
                {
                    string extendsName, extendsNamespace;
                    MetadataToken unused;
                    GetTypeRefProps(
                        (TypeReferenceHandle)extendsRef,
                        out extendsName,
                        out extendsNamespace,
                        out unused);
                    if (extendsName == "Enum" && extendsNamespace == "System")
                    {
                        flags = flags & ~FieldAttributes.Private;
                        flags |= FieldAttributes.Public;
                    }
                }
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:30,代码来源:WinMDModule.cs

示例2: DefineField

 /// <summary>
 /// Defines a new field to the type.
 /// </summary>
 /// <param name="name">The name of the field. <paramref name="name"/> cannot contain embedded nulls.</param>
 /// <param name="type">The type of the field/</param>
 /// <param name="attributes">A bitwise combination of the field attributes.</param>
 /// <param name="initializer">The expression which is not reduced to be <see cref="LambdaExpression"/> for the initializer of the field, with a parameter for "this" instance, returns <paramref name="type"/> value.</param>
 /// <returns>The defined field.</returns>
 public FieldBuilder DefineField(
     String name,
     Type type,
     FieldAttributes attributes,
     Expression initializer
 )
 {
     var isStatic = attributes.HasFlag(FieldAttributes.Static);
     return this._type.DefineField(
         name,
         type,
         attributes
     )
         .If(_ => initializer != null, f =>
             this._implType.DefineMethod(
                 GetName(f, "Init"),
                 MethodAttributes.Assembly | MethodAttributes.Static,
                 type,
                 isStatic ? Type.EmptyTypes : this._typeArray
             )
             .Apply(
                 i =>
                     (isStatic
                         ? (this._cctor ?? (this._cctor = this._type.DefineTypeInitializer())).GetILGenerator()
                         : this._prologue.GetILGenerator()
                     )
                     .Apply(
                     g => g.If(_ => !isStatic, _ => LoadArgs(g, 0, 0)),
                     g => g.Emit(OpCodes.Call, i),
                     g => g.Emit(isStatic ? OpCodes.Stsfld : OpCodes.Stfld, f)
                 ),
                 i => this.RequestInitializing(i, initializer, type, isStatic ? this._typeArray : Type.EmptyTypes)
             )
         )
         .Apply(this._members.Add);
 }
开发者ID:takeshik,项目名称:yacq,代码行数:44,代码来源:YacqType.cs

示例3: GetIcons

 string[] GetIcons(string b, FieldAttributes a)
 {
     if (a.HasFlag(FieldAttributes.Private)) return GetIconsStub(b, "Private");
     return GetIconsStub(b, string.Empty);
 }
开发者ID:net-shell,项目名称:quantum-vaginer,代码行数:5,代码来源:NetDasm.cs


注:本文中的FieldAttributes.HasFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。