private string getAmbitoPropiedad(PropertyInfo atributo)
        {
            String             ambito    = "";
            PropertyAttributes atributos = atributo.Attributes;

            ambito += "[ATRIBUTOS]";
            ambito += atributos.ToString();

            /*
             *          if (atributo.Attributes)
             *          {
             *              ambito = "public";
             *          }
             *          else if (atributo.IsPrivate)
             *          {
             *              ambito = "private";
             *          }
             *
             *          if (atributo.IsStatic)
             *          {
             *              ambito += " static";
             *          }
             */
            return(ambito);
        }
Esempio n. 2
0
    public static int Main(string[] args)
    {
        Console.WriteLine("\nReflection.PropertyAttributes");

        // Determine whether a property exists, and change its value.
        Aproperty Mypropertya = new Aproperty();
        Bproperty Mypropertyb = new Bproperty();
        Cproperty Mypropertyc = new Cproperty();


        Console.Write("\n1. Mypropertya.Caption = " + Mypropertya.Caption);

        Console.Write("\n1. Mypropertyb.Caption = " + Mypropertyb.Caption);

        Console.Write("\n1. Mypropertyc.Caption = " + Mypropertyc.Caption);

        // Only Mypropertya can be changed, as Mypropertyb is read-only.
        Mypropertya.Caption = "A- This is changed.";
        Mypropertyb.Caption = "B- This is changed.";
        // Note that Mypropertyc is not changed because it is read only

        Console.Write("\n\n2. Mypropertya.Caption = " + Mypropertya.Caption);

        Console.Write("\n2. Mypropertyb.Caption = " + Mypropertyb.Caption);

        Console.Write("\n2. Mypropertyc.Caption = " + Mypropertyc.Caption);

        // Get the PropertyAttributes enumeration of the property.
        // Get the type.
        Type MyTypea = Type.GetType("Aproperty");
        Type MyTypeb = Type.GetType("Bproperty");
        Type MyTypec = Type.GetType("Cproperty");

        // Get the property attributes.
        PropertyInfo       Mypropertyinfoa = MyTypea.GetProperty("Caption");
        PropertyAttributes Myattributesa   = Mypropertyinfoa.Attributes;
        PropertyInfo       Mypropertyinfob = MyTypeb.GetProperty("Item");
        PropertyAttributes Myattributesb   = Mypropertyinfob.Attributes;
        PropertyInfo       Mypropertyinfoc = MyTypec.GetProperty("Caption");
        PropertyAttributes Myattributesc   = Mypropertyinfoc.Attributes;

        // Display the property attributes value.

        Console.Write("\n\na- " + Myattributesa.ToString());

        Console.Write("\nb- " + Myattributesb.ToString());

        Console.Write("\nc- " + Myattributesc.ToString());
        return(0);
    }
Esempio n. 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //Foundation.NSKeyedUnarchiver+_NSKeyedUnarchiverDelegate
            // Perform any additional setup after loading the view, typically from a nib.
            foreach (var type in getCustomTypes())
            {
                //Console.WriteLine(""+s);
                var attributes = type.GetCustomAttributes(true);
                foreach (var attr in attributes)
                {
                    var isRegisterAttribute = attr.GetType().Equals(typeof(RegisterAttribute));
                    //Console.WriteLine("" + );
                    if (isRegisterAttribute)
                    {
                        Console.WriteLine("type:" + type.ToString());
                        Console.WriteLine("Attribute:" + attr.ToString());
                        var registerAttr = (RegisterAttribute)attr;
                        Console.WriteLine("Name:" + registerAttr.Name);
                        Console.WriteLine("IsWrapper:" + registerAttr.IsWrapper);
                        Console.WriteLine("SkipRegistration:" + registerAttr.SkipRegistration);
                        Console.WriteLine("TypeId:" + registerAttr.TypeId);
                        //Console.WriteLine("Name" + registerAttr.);
                    }
                }
                MethodInfo [] methods = type.GetMethods(System.Reflection.BindingFlags.Default);

                //methodAttributes.
                foreach (var method in methods)
                {
                    MethodAttributes methodAttributes = method.Attributes;
                    Console.WriteLine("Attributes:" + methodAttributes.ToString());
                }

                ConstructorInfo[] Constructors = type.GetConstructors(System.Reflection.BindingFlags.Default);
                foreach (var constructor in Constructors)
                {
                    MethodAttributes constructorsAttributes = constructor.Attributes;
                    Console.WriteLine("Attributes:" + constructorsAttributes.ToString());
                }
                PropertyInfo[] Propertys = type.GetProperties(System.Reflection.BindingFlags.Default);
                foreach (var property in Propertys)
                {
                    PropertyAttributes propertyAttributes = property.Attributes;
                    Console.WriteLine("Attributes:" + propertyAttributes.ToString());
                }
            }
        }
Esempio n. 4
0
    public static int Main(string[] args)
    {
        Console.WriteLine("\nReflection.PropertyInfo");

        // Define a property.
        Myproperty Myproperty = new Myproperty();

        Console.Write("\nMyproperty.Caption = " + Myproperty.Caption);

        // Get the type and PropertyInfo.
        Type         MyType         = Type.GetType("Myproperty");
        PropertyInfo Mypropertyinfo = MyType.GetProperty("Caption");

        // Get and display the attributes property.
        PropertyAttributes Myattributes = Mypropertyinfo.Attributes;

        Console.Write("\nPropertyAttributes - " + Myattributes.ToString());

        return(0);
    }
        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;
            }
        }