public ClassHierarchyPage() { InitializeComponent(); List <TypeInformation> classList = new List <TypeInformation>(); // Get types in Xamarin.Forms.Core assembly. GetPublicTypes(typeof(View).GetTypeInfo().Assembly, classList); // Get types in Xamarin.Forms.Xaml assembly. GetPublicTypes(typeof(Extensions).GetTypeInfo().Assembly, classList); // Ensure that all classes have a base type in the list. // (i.e., add Attribute, ValueType, Enum, EventArgs, etc.) int index = 0; // Watch out! Loops through expanding classList! do { // Get a child type from the list. TypeInformation childType = classList[index]; if (childType.Type != typeof(Object)) { bool hasBaseType = false; // Loop through the list looking for a base type. foreach (TypeInformation parentType in classList) { if (childType.IsDerivedDirectlyFrom(parentType.Type)) { hasBaseType = true; } } // If there's no base type, add it. if (!hasBaseType && childType.BaseType != typeof(Object)) { classList.Add(new TypeInformation(childType.BaseType, false)); } } index++; }while (index < classList.Count); // Now sort the list. classList.Sort((t1, t2) => { return(String.Compare(t1.Type.Name, t2.Type.Name)); }); // Start the display with System.Object. ClassAndSubclasses rootClass = new ClassAndSubclasses(typeof(Object), false); // Recursive method to build the hierarchy tree. AddChildrenToParent(rootClass, classList); // Recursive method for adding items to StackLayout. AddItemToStackLayout(rootClass, 0); }
public ClassHierarchyPage() { // Get Xamarin.Forms assembly. xamarinFormsAssembly = typeof(View).GetTypeInfo().Assembly; // Loop through all the types. foreach (Type type in xamarinFormsAssembly.ExportedTypes) { TypeInfo typeInfo = type.GetTypeInfo(); // Public types only but exclude interfaces if (typeInfo.IsPublic && !typeInfo.IsInterface) { // Add type to list. classList.Add(new TypeInformation(type)); } } // Ensure that all classes have a base type in the list. // (i.e., add Attribute, ValueType, Enum, EventArgs, etc.) int index = 0; // Watch out! Loops through expanding classList! do { // Get a child type from the list. TypeInformation childType = classList[index]; if (childType.Type != typeof(Object)) { bool hasBaseType = false; // Loop through the list looking for a base type. foreach (TypeInformation parentType in classList) { if (childType.IsDerivedDirectlyFrom(parentType.Type)) { hasBaseType = true; } } // If there's no base type, add it. if (!hasBaseType && childType.BaseType != typeof(Object)) { classList.Add( new TypeInformation(childType.BaseType)); } } index++; }while (index < classList.Count); // Now sort the list. classList.Sort((t1, t2) => { return(String.Compare(t1.Type.Name, t2.Type.Name)); }); // Start the display with System.Object. ClassAndSubclasses rootClass = new ClassAndSubclasses(typeof(Object)); // Recursive method to build the hierarchy tree. AddChildrenToParent(rootClass, classList); // Create the StackLayout for displaying the list. stackLayout = new StackLayout { Spacing = 0 }; // Recursive method for adding items to StackLayout. AddItemToStackLayout(rootClass, 0); // Put the StackLayout in a ScrollView. this.Padding = new Thickness(0, Device.RuntimePlatform == Device.iOS ? 20 : 0, 0, 0); this.Content = new ScrollView { Content = stackLayout }; }