Ejemplo n.º 1
0
        /// <summary>
        /// Thiashd iahsd haishd iashd ihasih iqwhei hqie hwqih eoqwh eoqwihe oashd
        /// oasihd o oiahsd oihasd oihawoidh aowihd oaihd oiahsoid had asd .as.d as. d
        /// as.d a sd as.
        /// </summary>
        /// <param name="fieldDefinition"></param>
        /// <param name="declaringType"></param>
        public MyFieldInfo(FieldDefinition fieldDefinition, MyClassInfo declaringType)
            : base()
        {
            this.name = fieldDefinition.Name;

            string[] readableForms = Tools.GetHumanReadableForms(fieldDefinition.FieldType);

            this.typeFullName = readableForms[0];
            this.typeFullNameWithoutRevArrayStrings = readableForms[1];
            this.attributes    = GetMyFieldAttributes(fieldDefinition);
            this.declaringType = declaringType;

            if ((fieldDefinition.Attributes & FieldAttributes.HasDefault) != 0)
            {
                try
                {
                    object rawConstant = fieldDefinition.Constant;

                    defaultValue = rawConstant == null ? null : rawConstant.ToString();
                }
                catch (Exception)
                {
                    Logger.Warning("Couldn't obtain default value for field '{0}'.", name);
                }
            }

            this.CheckSupport(fieldDefinition.Attributes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Thiashd iahsd haishd iashd ihasih iqwhei hqie hwqih eoqwh eoqwihe oashd   
        /// oasihd o oiahsd oihasd oihawoidh aowihd oaihd oiahsoid had asd .as.d as. d  
        /// as.d a sd as.
        /// </summary>
        /// <param name="fieldDefinition"></param>
        /// <param name="declaringType"></param>
        public MyFieldInfo(FieldDefinition fieldDefinition, MyClassInfo declaringType)
            : base()
        {
            this.name = fieldDefinition.Name;

            string[] readableForms = Tools.GetHumanReadableForms(fieldDefinition.FieldType);

            this.typeFullName = readableForms[0];
            this.typeFullNameWithoutRevArrayStrings = readableForms[1];
            this.attributes = GetMyFieldAttributes(fieldDefinition);
            this.declaringType = declaringType;

            if ((fieldDefinition.Attributes & FieldAttributes.HasDefault) != 0)
            {
                try
                {
                    object rawConstant = fieldDefinition.Constant;

                    defaultValue = rawConstant == null ? null : rawConstant.ToString();
                }
                catch (Exception)
                {
                    Logger.Warning("Couldn't obtain default value for field '{0}'.", name);
                }
            }

            this.CheckSupport(fieldDefinition.Attributes);
        }
Ejemplo n.º 3
0
        private static string MyFieldAttributesToString(MyFieldAttributes myFieldAttributes)
        {
            StringBuilder sb = new StringBuilder();

            if ((myFieldAttributes & MyFieldAttributes.Public) != 0)
            {
                sb.Append("public ");
            }
            if ((myFieldAttributes & MyFieldAttributes.Private) != 0)
            {
                sb.Append("private ");
            }

            if ((myFieldAttributes & MyFieldAttributes.Protected) != 0 && (myFieldAttributes & MyFieldAttributes.Internal) != 0)
            {
                sb.Append("protected internal ");
            }
            else if ((myFieldAttributes & MyFieldAttributes.Protected) != 0)
            {
                sb.Append("protected ");
            }
            else if ((myFieldAttributes & MyFieldAttributes.Internal) != 0)
            {
                sb.Append("internal ");
            }

            if ((myFieldAttributes & MyFieldAttributes.Const) != 0)
            {
                sb.Append("const ");
            }
            else if ((myFieldAttributes & MyFieldAttributes.Static) != 0)
            {
                sb.Append("static ");
            }

            if ((myFieldAttributes & MyFieldAttributes.ReadOnly) != 0)
            {
                sb.Append("readonly ");
            }

            if (sb.Length > 0)
            {
                sb.Length = sb.Length - 1;
            }

            return(sb.ToString());
        }
Ejemplo n.º 4
0
        private static MyFieldAttributes GetMyFieldAttributes(FieldDefinition fieldDefinition)
        {
            MyFieldAttributes myFieldAttributes = MyFieldAttributes.None;

            if (fieldDefinition.IsPublic)
            {
                myFieldAttributes |= MyFieldAttributes.Public;
            }
            if (fieldDefinition.IsFamily)
            {
                myFieldAttributes |= MyFieldAttributes.Protected;
            }
            if (fieldDefinition.IsPrivate)
            {
                myFieldAttributes |= MyFieldAttributes.Private;
            }
            if (fieldDefinition.IsAssembly)
            {
                myFieldAttributes |= MyFieldAttributes.Internal;
            }
            if (fieldDefinition.IsFamilyOrAssembly)
            {
                myFieldAttributes |= MyFieldAttributes.Protected | MyFieldAttributes.Internal;
            }

            if (fieldDefinition.IsLiteral)
            {
                myFieldAttributes |= MyFieldAttributes.Const;
            }
            else if (fieldDefinition.IsStatic)
            {
                myFieldAttributes |= MyFieldAttributes.Static;
            }

            if (fieldDefinition.IsInitOnly)
            {
                myFieldAttributes |= MyFieldAttributes.ReadOnly;
            }

            return(myFieldAttributes);
        }
Ejemplo n.º 5
0
        private static string MyFieldAttributesToString(MyFieldAttributes myFieldAttributes)
        {
            StringBuilder sb = new StringBuilder();

            if ((myFieldAttributes & MyFieldAttributes.Public) != 0) { sb.Append("public "); }
            if ((myFieldAttributes & MyFieldAttributes.Private) != 0) { sb.Append("private "); }
            
            if ((myFieldAttributes & MyFieldAttributes.Protected) != 0 && (myFieldAttributes & MyFieldAttributes.Internal) != 0) { sb.Append("protected internal "); }
            else if ((myFieldAttributes & MyFieldAttributes.Protected) != 0) { sb.Append("protected "); }
            else if ((myFieldAttributes & MyFieldAttributes.Internal) != 0) { sb.Append("internal "); }

            if ((myFieldAttributes & MyFieldAttributes.Const) != 0) { sb.Append("const "); }
            else if ((myFieldAttributes & MyFieldAttributes.Static) != 0) { sb.Append("static "); }

            if ((myFieldAttributes & MyFieldAttributes.ReadOnly) != 0) { sb.Append("readonly "); }

            if (sb.Length > 0)
            {
                sb.Length = sb.Length - 1;
            }

            return sb.ToString();
        }