void AddMember(TypeNodeItem node, ULMemberInfo memberInfo) { var classNode = new MemberNodeItem(memberInfo); var bm = new BitmapImage(new Uri("Images/func.png", UriKind.RelativeOrAbsolute)); classNode.Icon = bm; node.Items.Add(classNode); }
private void contextMenuStrip_TreeView_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem == tsmi_AddType) { var form = new Form_AddType(); if (form.ShowDialog() == DialogResult.OK) { var type = new ULTypeInfo(); type.Name = form.InputName; type.Namespace = form.InputNamespace; if (Data.types.ContainsKey(type.ID)) { return; } Data.types[type.ID] = type; ResetView(); } } else if (e.ClickedItem == tsmi_AddMember && _selectedType != null) { var form = new Form_AddMember(); if (form.ShowDialog() == DialogResult.OK) { var member = new ULMemberInfo(); member.Name = form.InputName; member.TypeID = form.InputTypeID; member.DeclareTypeID = _selectedType.ID; _selectedType.Members.Add(member); ResetView(); } } else if (e.ClickedItem == tsmi_Delete) { if (treeViewTypes.SelectedNode != null) { var selectedType = treeViewTypes.SelectedNode.Tag as ULTypeInfo; if (selectedType != null) { Data.types.Remove(selectedType.ID); treeViewTypes.Nodes.Remove(treeViewTypes.SelectedNode); } else { var selectMethod = treeViewTypes.SelectedNode.Tag as ULMemberInfo; if (selectMethod != null) { Data.GetType(selectMethod.DeclareTypeID).Members.Remove(selectMethod); treeViewTypes.Nodes.Remove(treeViewTypes.SelectedNode); } } } } else if (e.ClickedItem == tsmi_Refresh) { ResetView(); } }
void ExportProperty(BasePropertyDeclarationSyntax v) { var v_type = GetTypeInfo(v.Type); if (v_type == null) { Console.Error.WriteLine("无法识别的类型 " + v); return; } string name = ""; if (v is PropertyDeclarationSyntax) { name = ((PropertyDeclarationSyntax)v).Identifier.Text; } else if (v is EventDeclarationSyntax) { name = ((EventDeclarationSyntax)v).Identifier.Text; } else if (v is IndexerDeclarationSyntax) { name = "Index"; } //if (step == ECompilerStet.ScanMember) //{ var property = new ULMemberInfo(); property.Name = name; property.DeclareTypeID = type.ID; property.MemberType = ULMemberInfo.EMemberType.Property; property.IsStatic = ContainModifier(v.Modifiers, "static") || ContainModifier(v.Modifiers, "const"); property.Modifier = GetModifier(v.Modifiers); property.TypeID = v_type.ID; type.Members.Add(property); // foreach (var ve in v.AccessorList.Accessors) // { // var dB_Member = new ULMemberInfo(); // dB_Member.DeclareTypeName = currentType.FullName; // dB_Member.TypeName = v_type.FullName; // dB_Member.IsStatic = property.IsStatic; // dB_Member.Modifier = property.Modifier; // //dB_Member.method_abstract = ContainModifier(v.Modifiers, "abstract"); // //dB_Member.method_virtual = ContainModifier(v.Modifiers, "virtual"); // //dB_Member.method_override = ContainModifier(v.Modifiers, "override"); // if (ve.Keyword.Text == "get") // { // dB_Member.MemberType = ULMemberInfo.EMemberType.PropertyGet; // dB_Member.Name = property.Name_PropertyGet; // if (v is IndexerDeclarationSyntax) // { // IndexerDeclarationSyntax indexerDeclarationSyntax = v as IndexerDeclarationSyntax; // dB_Member.Args = new List<ULMemberInfo.MethodArg>(); // foreach (var a in indexerDeclarationSyntax.ParameterList.Parameters) // { // dB_Member.Args.Add(GetArgument(a)); // } // } // } // else if (ve.Keyword.Text == "set") // { // dB_Member.MemberType = ULMemberInfo.EMemberType.PropertySet; // dB_Member.Name = property.Name_PropertySet; // if (v is IndexerDeclarationSyntax) // { // IndexerDeclarationSyntax indexerDeclarationSyntax = v as IndexerDeclarationSyntax; // dB_Member.Args = new List<ULMemberInfo.MethodArg>(); // foreach (var a in indexerDeclarationSyntax.ParameterList.Parameters) // { // dB_Member.Args.Add(GetArgument(a)); // } // var arg = new ULMemberInfo.MethodArg(); // arg.ArgName = "value"; // arg.TypeName = v_type.FullName; // dB_Member.Args.Add(arg); // } // else // { // var arg = new ULMemberInfo.MethodArg(); // arg.ArgName = "value"; // arg.TypeName = v_type.FullName; // dB_Member.Args.Add(arg); // } // } // else if (ve.Keyword.Text == "add") // { // dB_Member.MemberType = ULMemberInfo.EMemberType.PropertyAdd; // dB_Member.Name = property.Name_PropertyAdd; // var arg = new ULMemberInfo.MethodArg(); // arg.ArgName = "value"; // arg.TypeName = v_type.FullName; // dB_Member.Args.Add(arg); // } // else if (ve.Keyword.Text == "remove") // { // dB_Member.MemberType = ULMemberInfo.EMemberType.PropertyRemove; // dB_Member.Name = property.Name_PropertyRemove; // var arg = new ULMemberInfo.MethodArg(); // arg.ArgName = "value"; // arg.TypeName = v_type.FullName; // dB_Member.Args.Add(arg); // } // currentType.Members.Add(dB_Member); // } //} //else if (step == ECompilerStet.Compile) //{ // currentMember = currentType.Members.Find(m => m.Name == name); // foreach (var ve in v.AccessorList.Accessors) // { // if (ve.Keyword.Text == "get") // { // currentMember = currentType.Members.Find(m => m.Name == currentMember.Name_PropertyGet); // ExportBody(ve.Body); // } // else if(ve.Keyword.Text == "set") // { // currentMember = currentType.Members.Find(m => m.Name == currentMember.Name_PropertySet); // ExportBody(ve.Body); // } // else if(ve.Keyword.Text == "add") // { // currentMember = currentType.Members.Find(m => m.Name == currentMember.Name_PropertyAdd); // ExportBody(ve.Body); // } // else if (ve.Keyword.Text == "remove") // { // currentMember = currentType.Members.Find(m => m.Name == currentMember.Name_PropertyRemove); // ExportBody(ve.Body); // } // } //} }
public MemberNodeItem(ULMemberInfo t) { member = t; textBlock.Text = member.Name; }