private void AddGlobalContextDescription(Type globalContext, XElement xElement)
        {
            var childElement = new XElement("global-context");

            childElement.Add(new XAttribute("clr-name", globalContext.FullName));

            var attrib = _library.GetMarkup(globalContext, ScriptMemberType.GlobalContext);

            if (attrib == null)
            {
                return;
            }

            string categoryName = null;

            try
            {
                if (attrib.NamedArguments != null)
                {
                    var categoryMember = attrib.NamedArguments.First(x => x.MemberName == "Category");
                    categoryName = (string)categoryMember.TypedValue.Value;
                }
            }
            catch (InvalidOperationException)
            {
                return;
            }

            if (categoryName != null)
            {
                childElement.Add(new XElement("category", categoryName));
            }

            AppendXmlDocs(childElement, "T:" + globalContext.FullName);

            AddProperties(globalContext, childElement);
            AddMethods(globalContext, childElement);

            xElement.Add(childElement);
        }
        public AssemblyDocumenter(string library, string xmldoc)
        {
            using (var reader = new StreamReader(xmldoc))
            {
                _xmlDoc = XDocument.Load(reader);
            }

            var dir = Path.GetDirectoryName(library);

            var loader = new AssemblyLoader(dir);

            _library = loader.Load(Path.GetFileName(library));

            // add to dictinary

            _typesDict = new TypesDictionary();


            // Пока топорное заполнение...
            var globalContexts = _library.GetMarkedTypes(ScriptMemberType.GlobalContext);

            foreach (var globalContext in globalContexts)
            {
                var attrib = _library.GetMarkup(globalContext, ScriptMemberType.GlobalContext);

                if (attrib == null)
                {
                    continue;
                }

                TypeInfo curTypeInfo = new TypeInfo();
                curTypeInfo.fullName  = globalContext.FullName;
                curTypeInfo.ShortName = globalContext.Name;
                if (attrib.ConstructorArguments.Count > 0)
                {
                    curTypeInfo.nameEng = (string)attrib.ConstructorArguments[1].Value;
                    curTypeInfo.nameRus = (string)attrib.ConstructorArguments[0].Value;
                }
                _typesDict.add(curTypeInfo);
            }

            var contextTypes = _library.GetMarkedTypes(ScriptMemberType.Class);

            foreach (var classType in contextTypes)
            {
                var attrib = _library.GetMarkup(classType, ScriptMemberType.Class);

                if (attrib == null)
                {
                    continue;
                }

                TypeInfo curTypeInfo = new TypeInfo();
                curTypeInfo.fullName  = classType.FullName;
                curTypeInfo.ShortName = classType.Name;
                if (attrib.ConstructorArguments.Count > 0)
                {
                    curTypeInfo.nameEng = (string)attrib.ConstructorArguments[1].Value;
                    curTypeInfo.nameRus = (string)attrib.ConstructorArguments[0].Value;
                }
                _typesDict.add(curTypeInfo);
            }

            _typesDict.save();
        }
Beispiel #3
0
        public void FillTypesDictionary()
        {
            ScriptMemberType[] contexts = { ScriptMemberType.GlobalContext, ScriptMemberType.Class, ScriptMemberType.SystemEnum, ScriptMemberType.EnumerationType };
            foreach (ScriptMemberType context in contexts)
            {
                var conts = _library.GetMarkedTypes(context);
                foreach (var cont in conts)

                {
                    var attrib = _library.GetMarkup(cont, context);

                    if (attrib == null)
                    {
                        continue;
                    }

                    TypeInfo curTypeInfo = new TypeInfo();
                    curTypeInfo.fullName  = cont.FullName;
                    curTypeInfo.ShortName = cont.Name;
                    if (attrib.ConstructorArguments.Count > 0)
                    {
                        GetNameAndAlias(attrib, cont.Name, out curTypeInfo.nameRus, out curTypeInfo.nameEng);
                    }
                    _typesDict.add(curTypeInfo);
                }
            }

            _typesDict.save();
        }