예제 #1
0
        private PSClassInfo ConvertToClassInfo(PSModuleInfo module, ScriptBlockAst ast, TypeDefinitionAst statement)
        {
            PSClassInfo classInfo = new PSClassInfo(statement.Name);

            Dbg.Assert(statement.Name != null, "statement should have a name.");
            classInfo.Module = module;
            Collection <PSClassMemberInfo> properties = new Collection <PSClassMemberInfo>();

            foreach (var member in statement.Members)
            {
                PropertyMemberAst propAst = member as PropertyMemberAst;
                if (propAst != null)
                {
                    Dbg.Assert(propAst.Name != null, "PropName cannot be null");
                    Dbg.Assert(propAst.PropertyType != null, "PropertyType cannot be null");
                    Dbg.Assert(propAst.PropertyType.TypeName != null, "Property TypeName cannot be null");
                    Dbg.Assert(propAst.Extent != null, "Property Extent cannot be null");
                    Dbg.Assert(propAst.Extent.Text != null, "Property ExtentText cannot be null");

                    PSClassMemberInfo classProperty = new PSClassMemberInfo(propAst.Name,
                                                                            propAst.PropertyType.TypeName.FullName,
                                                                            propAst.Extent.Text);
                    properties.Add(classProperty);
                }
            }

            classInfo.UpdateMembers(properties);

            string mamlHelpFile = null;

            if (ast.GetHelpContent() != null)
            {
                mamlHelpFile = ast.GetHelpContent().MamlHelpFile;
            }

            if (!String.IsNullOrEmpty(mamlHelpFile))
            {
                classInfo.HelpFile = mamlHelpFile;
            }

            return(classInfo);
        }