Beispiel #1
0
        private static string CantBeArsed(FieldAttributes attributes)
        {
            string attr = attributes.ToString();

            if (attr == "Public")
            {
                return("public");
            }
            else if (attr == "Family")
            {
                return("protected");
            }
            else
            {
                return("private");
            }
        }
Beispiel #2
0
        public override string ConvertToString(int att)
        {
            FieldAttributes fa = (FieldAttributes)att;

            return(fa.ToString());
        }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Check the Int32 value of the enumeration");

        try
        {
            FieldAttributes fieldAttributes = (FieldAttributes)32768;
            if (fieldAttributes != FieldAttributes.HasDefault)
            {
                TestLibrary.TestFramework.LogError("001", "Result is not the value as expected,fieldAttributes is: " + fieldAttributes.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
        public void Attributes(FieldAttributes attributes, FieldAttributes expected)
        {
            FieldInfo field = s_type.DefineField(attributes.ToString(), typeof(object), attributes);

            Assert.Equal(expected, field.Attributes);
        }
 public void Attributes(FieldAttributes attributes, FieldAttributes expected)
 {
     FieldInfo field = s_type.DefineField(attributes.ToString(), typeof(object), attributes);
     Assert.Equal(expected, field.Attributes);
 }
        public void Investigate()
        {
            Printer.Write(Assembly.GetName().Name);


            try
            {
                foreach (Module module in Assembly.GetModules())
                {
                    Printer.Write("\t" + module.Name);
                }

                foreach (Type Type in Assembly.GetTypes())
                {
                    TypeAttributes tAttributes = Type.Attributes;
                    Printer.Write($"\n\t\t{tAttributes.ToString()} {Type.Name}");

                    Printer.Write("\n\t\t\tFields: \n");

                    foreach (FieldInfo field in Type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
                    {
                        FieldAttributes fAttributes = field.Attributes;
                        Printer.Write($"\t\t\t{fAttributes.ToString()} {field.FieldType} {field.Name}");
                    }

                    Printer.Write("\n\t\t\tProperties: \n");

                    foreach (PropertyInfo prop in Type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
                    {
                        PropertyAttributes pAttributes = prop.Attributes;
                        Printer.Write($"\t\t\t{pAttributes.ToString()} {prop.PropertyType} {prop.Name}");
                    }

                    Printer.Write("\n\t\t\tConstructors: \n");

                    foreach (ConstructorInfo ctor in Type.GetConstructors())
                    {
                        string parametrs = "";

                        foreach (ParameterInfo param in ctor.GetParameters())
                        {
                            parametrs += $"{param.ParameterType} {param.Name} ";
                        }

                        Printer.Write($"\t\t\t{Type.Name} ({parametrs})");
                    }

                    Printer.Write("\n\t\t\tMethods: \n");

                    foreach (MethodInfo method in Type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic |
                                                                  BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly))
                    {
                        string parametrs = "";

                        foreach (ParameterInfo param in method.GetParameters())
                        {
                            parametrs += $" {param.ParameterType} {param.Name} ";
                        }

                        MethodAttributes mAttributes = method.Attributes;
                        Printer.Write($"\t\t\t{mAttributes.ToString()} {method.ReturnType} {method.Name} ({parametrs})");
                    }
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                throw;
            }
            catch (ReflectionTypeLoadException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }