Ejemplo n.º 1
0
        public static MethodAttributes GetMethodAttributes(RMethodAttributes rAttributes, bool constructor)
        {
            MethodAttributes attrs = MethodAttributes.Public;

            if (rAttributes.HasFlag(RMethodAttributes.Private))
            {
                attrs = MethodAttributes.Private;
            }

            if (rAttributes.HasFlag(RMethodAttributes.Protected))
            {
                attrs = MethodAttributes.Family;
            }

            // always virtual, even for statics but not for property accessors :)
            if (!constructor && !rAttributes.HasFlag(RMethodAttributes.Final))
            {
                attrs |= MethodAttributes.Virtual;
            }

            attrs |= MethodAttributes.HideBySig;

            if (!rAttributes.HasFlag(RMethodAttributes.Override))
            {
                if (!constructor && !rAttributes.HasFlag(RMethodAttributes.Final))
                {
                    attrs |= MethodAttributes.NewSlot;
                }
            }

            if (rAttributes.HasFlag(RMethodAttributes.Abstract))
            {
                attrs |= MethodAttributes.Abstract;
            }

            return attrs;
        }
Ejemplo n.º 2
0
        private static string ToString(RMethodAttributes attrs)
        {
            List<string> res = new List<string>();

            _attrToStr.Aggregate(res, (list, tuple) =>
                {
                    if (attrs.HasFlag(tuple.Item1))
                    {
                        list.Add(tuple.Item2);
                    }
                    return list;
                });

            return string.Join(" ", res);
        }