private void InjectReflectedData(ClassShape newShape) { Random rnd = new Random(); Type type = sampleTypes[rnd.Next(0, sampleTypes.Length)]; MethodInfo[] meths = type.GetMethods(); PropertyInfo[] props = type.GetProperties(); ObservableCollection<ClassMember> methods = new ObservableCollection<ClassMember>(); for (int i = 0; i < meths.Length && i<10; i++) { methods.Add(new ClassMember(meths[i].Name, "PublicMethod")); } ClassCategory methodSection = new ClassCategory("Methods", methods); ObservableCollection<ClassMember> properties = new ObservableCollection<ClassMember>(); for (int i = 0; i < props.Length && i<10; i++) { properties.Add(new ClassMember(props[i].Name, "PublicProperty")); } ; ClassCategory propertySection = new ClassCategory("Properties", properties); ObservableCollection<ClassCategory> categories = new ObservableCollection<ClassCategory>(); categories.Add(propertySection); categories.Add(methodSection); newShape.Title = type.Name; if (type.IsPublic) newShape.SubTitle += "public "; //if (type.IsSealed) // newShape.SubTitle += "sealed "; if(type.IsAbstract) newShape.SubTitle += "abstract "; if(type.IsInterface) newShape.SubTitle += "interface "; newShape.SubTitle += "class"; newShape.TreeData = categories; }
public UIElement Create(Rect rect) { ClassShape shape = new ClassShape(); //shape.Width = rect.Width; //shape.Height = rect.Height; shape.ShapeColor = RandomLowSaturationColor; Canvas.SetLeft(shape, rect.X); Canvas.SetTop(shape, rect.Y); return shape; }