Ejemplo n.º 1
0
        public void CreationTest(string name, EncapsulationLevel encapsulationLevel)
        {
            var fb = new MetaFieldBuilder(name);
            fb.EncapsulationLevel = encapsulationLevel;
            fb.SetType(MetaType.Boolean);

            var field = fb.Build();
            Assert.AreEqual(field.Name, name);
            Assert.AreEqual(field.EncapsulationLevel, encapsulationLevel);
            Assert.AreEqual(field.Type, MetaType.Boolean);
            Assert.AreEqual(field.Module, null);
        }
Ejemplo n.º 2
0
 public WrapsAndChangesAttribute(
     Type wrappedType, 
     WrappedItemsKind wrappedItemsKind,
     string name,
     string wrapperName = null,
     EncapsulationLevel wrapperEncapsulationLevel = EncapsulationLevel.Unknown
 )
 {
     this.WrappedType = wrappedType;
     this.TheWrapItemsKind = wrappedItemsKind;
     this.Name = name;
     this.WrapperName = wrapperName;
     this.WrapperEncapsulationLevel = wrapperEncapsulationLevel;
 }
Ejemplo n.º 3
0
        public static MemberAttributes GetFlags(this ISymbol symbol, EncapsulationLevel encapsulationLevel)
        {
            MemberAttributes attrs = MemberAttributes.Final;

            if (symbol.IsVirtual)
                attrs = MemberAttributes.VTableMask;
            else if (symbol.IsAbstract)
                attrs = MemberAttributes.Abstract;

            if (symbol.IsStatic)
                attrs |= MemberAttributes.Static;

            //if (symbol.IsOverride)
            //    attrs |= MemberAttributes.Override;

            // if encapsulationLevel is unknown, we set the
            // generated encapsulationLevel to that of the wrapped symbol
            if (encapsulationLevel == EncapsulationLevel.Unknown)
            {
                switch (symbol.DeclaredAccessibility)
                {
                    case Accessibility.Internal:
                        attrs |= MemberAttributes.Assembly;
                        break;
                    case Accessibility.Private:
                        attrs |= MemberAttributes.Private;
                        break;
                    case Accessibility.Protected:
                        attrs |= MemberAttributes.Family;
                        break;
                    case Accessibility.Public:
                        attrs |= MemberAttributes.Public;
                        break;
                    case Accessibility.ProtectedAndInternal:
                        attrs |= MemberAttributes.FamilyAndAssembly;
                        break;
                    case Accessibility.ProtectedOrInternal:
                        attrs |= MemberAttributes.FamilyOrAssembly;
                        break;
                }
            }
            else
            {
                attrs |= encapsulationLevel.GetFlags();
            }

            return attrs;
        }