⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vsnetcollector.cs

📁 UML设计相关的源码。作UML相关开发的不容错过。
💻 CS
📖 第 1 页 / 共 4 页
字号:
					classData.ElementType      = enumElementType.elementTypeClass;
					classData.DocComment       = codeClass.DocComment;
					classData.IsAbstract       = codeClass.IsAbstract;
					classData.Name             = codeClass.Name;
					classData.ParentNameSpaceName = codeClass.Namespace.Name;
				
					// Bulid parent class name to ClassData.BaseList
					if( codeClass.Bases.Count > 0 )
					{
						for( int i = 0; i < codeClass.Bases.Count; i ++ )
						{
							classData.BaseList.Add( codeClass.Bases.Item(i+1).Name );
						}
					}

					// Check weather this class contain members
					if( codeClass.Members.Count > 0 )
					{
						for( int i = 0; i < codeClass.Members.Count; i ++ )
						{
							CollectElementData( codeClass.Members.Item(i+1), classData );
						}
					}
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementDelegate )
				{
					///
					/// Delegate Type
					///

					// If code element isn't code type, it's cann't be parsed ...
					if( codeElement.IsCodeType == false ) return;

					EnvDTE.CodeDelegate codeDelegate = (EnvDTE.CodeDelegate) codeElement;

					// Save Data
					DelegateData delegateData     = new DelegateData();
					delegateData.Parent           = parentElementData;
					delegateData.VSObjectReference= codeDelegate;

					// Save this object
					parentElementData.AddMember( delegateData );

					delegateData.AccessType    = (Data.enumElementAccessType) codeDelegate.Access;
					delegateData.ElementType    = enumElementType.elementTypeDelegate;
					delegateData.DocComment    = codeDelegate.DocComment;
					delegateData.Name          = codeDelegate.Name;
					delegateData.ParentNameSpaceName = codeDelegate.Namespace.Name;

					// Get the parameter data
					if( codeDelegate.Parameters.Count > 0 )
					{
						for( int i = 0 ; i < codeDelegate.Parameters.Count ; i ++ )
						{
							CollectElementData( codeDelegate.Parameters.Item(i+1), delegateData );
						}
					}

					// Save the Phototypes data 
					EnvDTE.CodeDelegate source      = codeDelegate;
					DelegateData        destination = delegateData;
				{
					destination.PhotoType.className         = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeClassName );
					destination.PhotoType.fullName          = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeFullname );
					destination.PhotoType.noName            = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeNoName );
					destination.PhotoType.paramDefaultValus = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamDefaultValues );
					destination.PhotoType.paramNames        = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamNames );
					destination.PhotoType.paramTypes        = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamTypes );
					destination.PhotoType.phototypeInitExpression = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeInitExpression );
					destination.PhotoType.phototypeType     = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeType );
					destination.PhotoType.uniqueSignature   = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeUniqueSignature );
				}
				
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementEnum )
				{
					///
					/// Enum Type
					/// 
					// If code element isn't code type, it's cann't be parsed ...
					if( codeElement.IsCodeType == false ) return;

					EnvDTE.CodeEnum codeEnum = (EnvDTE.CodeEnum) codeElement;

					// Save Data
					EnumData enumData         = new EnumData();
					enumData.Parent           = parentElementData;
					enumData.VSObjectReference= codeEnum;

					// Save this object
					parentElementData.AddMember( enumData );

					enumData.AccessType = (Data.enumElementAccessType) codeEnum.Access;
					enumData.ElementType= enumElementType.elementTypeEnum;
					enumData.DocComment = codeEnum.DocComment;
					enumData.Name       = codeEnum.Name;
					enumData.ParentNameSpaceName = codeEnum.Namespace.Name;
				
					// Get the members data
					if( codeEnum.Members.Count > 0 )
					{
						for( int i = 0 ; i < codeEnum.Members.Count ; i ++ )
						{
							CollectElementData( codeEnum.Members.Item(i+1), enumData );
						}
					}
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementFunction )
				{
					///
					/// Function Type
					///
					EnvDTE.CodeFunction codeFunction = (EnvDTE.CodeFunction) codeElement;

					// Save Data
					FunctionData functionData     = new FunctionData();
					functionData.Parent           = parentElementData;
					functionData.VSObjectReference= codeFunction;

					// Save this object
					parentElementData.AddMember( functionData );

					functionData.AccessType   = (Data.enumElementAccessType) codeFunction.Access;
					functionData.ElementType  = enumElementType.elementTypeFunction;
					functionData.DocComment   = codeFunction.DocComment;
					functionData.Name         = codeFunction.Name;
					functionData.CanOverride  = codeFunction.CanOverride;
					functionData.FunctionType = (Data.enumFunctionType) codeFunction.FunctionKind;
					functionData.IsOverloaded = codeFunction.IsOverloaded;
					functionData.IsShared     = codeFunction.IsShared;
				
					// Get the parameter data
					if( codeFunction.Parameters.Count > 0 )
					{
						for( int i = 0 ; i < codeFunction.Parameters.Count ; i ++ )
						{
							CollectElementData( codeFunction.Parameters.Item(i+1), functionData );
						}
					}

					// Save the Phototypes data 
					EnvDTE.CodeFunction source      = codeFunction;
					FunctionData        destination = functionData;
				{
					destination.PhotoType.className         = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeClassName );
					destination.PhotoType.fullName          = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeFullname );
					destination.PhotoType.noName            = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeNoName );
					destination.PhotoType.paramDefaultValus = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamDefaultValues );
					destination.PhotoType.paramNames        = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamNames );
					destination.PhotoType.paramTypes        = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamTypes );
					destination.PhotoType.phototypeInitExpression = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeInitExpression );
					destination.PhotoType.phototypeType     = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeType );
					destination.PhotoType.uniqueSignature   = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeUniqueSignature );
				}
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementInterface )
				{
					///
					/// Interface Type
					///
					// If code element isn't code type, it's cann't be parsed ...
					if( codeElement.IsCodeType == false ) return;

					EnvDTE.CodeInterface codeInterface = (EnvDTE.CodeInterface) codeElement;

					//////// Might be Error here .... ////////
					///Because I have used a enum conversion
					InterfaceData interfaceData    = new InterfaceData();
					interfaceData.Parent           = parentElementData;
					interfaceData.VSObjectReference= codeInterface;

					// Save this object
					parentElementData.AddMember( interfaceData );

					interfaceData.AccessType    = (Data.enumElementAccessType) codeInterface.Access;
					interfaceData.ElementType   = enumElementType.elementTypeInterface;
					interfaceData.DocComment    = codeInterface.DocComment;
					interfaceData.Name          = codeInterface.Name;
					interfaceData.ParentNameSpaceName = codeInterface.Namespace.Name;
								
					// Bulid parent Interface name to InterfaceData.BaseList
					if( codeInterface.Bases.Count > 0 )
					{
						for( int i = 0; i < codeInterface.Bases.Count; i ++ )
						{
							interfaceData.BaseList.Add( codeInterface.Bases.Item(i+1).Name );
						}
					}

					// Check weather this Interface contain members
					if( codeInterface.Members.Count > 0 )
					{
						for( int i = 0; i < codeInterface.Members.Count; i ++ )
						{
							CollectElementData( codeInterface.Members.Item(i+1), interfaceData );
						}
					}
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementProperty )
				{
					///
					/// Property Type
					/// 
					EnvDTE.CodeProperty codeProperty = (EnvDTE.CodeProperty) codeElement;

					// Save Data
					PropertyData propertyData     = new PropertyData();
					propertyData.Parent           = parentElementData;
					propertyData.VSObjectReference= codeProperty;

					// Save this object
					parentElementData.AddMember( propertyData );


					propertyData.AccessType  = (Data.enumElementAccessType) codeProperty.Access;
					propertyData.ElementType = enumElementType.elementTypeProperty;
					propertyData.DocComment  = codeProperty.DocComment;
					propertyData.Name        = codeProperty.Name;
				
					// Change those two function to the members
					// Modify 06/10/2002.
					// Getter property and Setter property
					try
					{
						FunctionData SetFunctionData = new FunctionData();
						SetFunctionData.Parent = codeProperty;
						CollectFunctionData( codeProperty.Setter, SetFunctionData );
						propertyData.AddMember( SetFunctionData );
					}
					catch ( Exception e )
					{
					}

					try
					{

						FunctionData GetFunctionData = new FunctionData();
						GetFunctionData.Parent = codeProperty;
						CollectFunctionData( codeProperty.Getter, GetFunctionData );
						propertyData.AddMember( GetFunctionData );
					}
					catch ( Exception e )
					{
					}
				

					// Save the Phototypes data 
					EnvDTE.CodeProperty source      = codeProperty;
					PropertyData        destination = propertyData;
					{
						destination.PhotoType.className         = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeClassName );
						destination.PhotoType.fullName          = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeFullname );
						destination.PhotoType.noName            = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeNoName );
						destination.PhotoType.paramDefaultValus = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamDefaultValues );
						destination.PhotoType.paramNames        = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamNames );
						destination.PhotoType.paramTypes        = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeParamTypes );
						destination.PhotoType.phototypeInitExpression = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeInitExpression );
						destination.PhotoType.phototypeType     = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeType );
						destination.PhotoType.uniqueSignature   = source.get_Prototype((int) vsCMPrototype.vsCMPrototypeUniqueSignature );
					}
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementStruct )
				{
					///
					/// Struct Type
					///
					// If code element isn't code type, it's cann't be parsed ...
					if( codeElement.IsCodeType == false ) return;

					EnvDTE.CodeStruct codeStruct = (EnvDTE.CodeStruct) codeElement;

					//////// Might be Error here .... ////////
					///Because I have used a enum conversion
					StructData structData       = new StructData();
					structData.Parent           = parentElementData;
					structData.VSObjectReference= codeStruct;

					// Save this object
					parentElementData.AddMember( structData );

					structData.AccessType          = (Data.enumElementAccessType) codeStruct.Access;
					structData.ElementType         = enumElementType.elementTypeStruct;
					structData.DocComment          = codeStruct.DocComment;
					structData.Name                = codeStruct.Name;
					structData.IsAbstract          = codeStruct.IsAbstract;
					structData.ParentNameSpaceName = codeStruct.Namespace.Name;
								
					// Bulid parent Struct name to InterfaceData.BaseList
					if( codeStruct.Bases.Count > 0 )
					{
						for( int i = 0; i < codeStruct.Bases.Count; i ++ )
						{
							structData.BaseList.Add( codeStruct.Bases.Item(i+1).Name );
						}
					}

					// Check weather this Struct contain members
					if( codeStruct.Members.Count > 0 )
					{
						for( int i = 0; i < codeStruct.Members.Count; i ++ )
						{
							CollectElementData( codeStruct.Members.Item(i+1), structData );
						}
					}
				}
				else if( codeElement.Kind == vsCMElement.vsCMElementParameter )
				{
					///
					/// Parameter Type
					/// 
					EnvDTE.CodeParameter codeParameter = (EnvDTE.CodeParameter) codeElement;

					// Save Data
					ParameterData parameterData     = new ParameterData();
					parameterData.Parent            = parentElementData;
					parameterData.VSObjectReference = codeParameter;

					// Save this object
					parentElementData.AddMember( parameterData );
					parameterData.ElementType = enumElementType.elementTypeParameter;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -