Exemple #1
0
        private void AddContextDescriptionJSON(Type classType, DocumentBlocks textBlocks)
        {
            var attrib = _library.GetMarkup(classType, ScriptMemberType.Class);

            string name, alias;

            GetNameAndAlias(attrib, classType.Name, out name, out alias);

            var childElement = new XElement(name);

            childElement.Add(new XElement("name", name));
            childElement.Add(new XElement("name_en", alias));

            AppendXmlDocsJSON(childElement, "T:" + classType.FullName);

            AddProperties(classType, childElement, "JSON");
            AddMethodsJSON(classType, childElement);
            AddConstructorsJSON(classType, childElement);

            var JSONNode     = JSon.XmlToJSON(childElement.ToString());
            var separatorPos = JSONNode.IndexOf("\"constructors\":", StringComparison.InvariantCulture);

            if (separatorPos > 0)
            {
                JSONNode = JSONNode.Substring(0, separatorPos) + JSONNode.Substring(separatorPos).Replace("_", " ");
            }

            textBlocks.TextContextDescription.Append(JSONNode.Substring(1, JSONNode.Length - 2) + ",");
        }
        private void AddContextDescriptionJSON(Type classType, StreamWriter sbJSON)
        {
            //var childElement = new XElement("context");

            //childElement.Add(new XAttribute("clr-name", classType.FullName));
            var attrib       = _library.GetMarkup(classType, ScriptMemberType.Class);
            var childElement = new XElement((string)attrib.ConstructorArguments[0].Value);


            childElement.Add(new XElement("name", (string)attrib.ConstructorArguments[0].Value));
            childElement.Add(new XElement("name_en", (string)attrib.ConstructorArguments[1].Value));

            AppendXmlDocsJSON(childElement, "T:" + classType.FullName);

            AddPropertiesJSON(classType, childElement);
            AddMethodsJSON(classType, childElement);
            AddConstructorsJSON(classType, childElement);

            sbJSON.WriteLine(JSon.XmlToJSON(childElement.ToString()) + ",");
        }
        private void AddGlobalContextDescriptionJSON(Type globalContext, StreamWriter sbJSON)
        {
            //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;
            }
            var childElement = new XElement(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(categoryName).Replace(" ", string.Empty));

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

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

            AddPropertiesJSON(globalContext, childElement);
            AddMethodsJSON(globalContext, childElement);

            sbJSON.WriteLine(JSon.XmlToJSON(childElement.ToString()) + ",");
        }
Exemple #4
0
        private void AddEnumsDescriptionJSON(Type sysEnum, DocumentBlocks textBlocks, ScriptMemberType sysType)
        {
            var attrib = _library.GetMarkup(sysEnum, sysType);

            string name, alias;

            GetNameAndAlias(attrib, sysEnum.Name, out name, out alias);

            var childElement = new XElement(name);

            childElement.Add(new XElement("name", name));
            childElement.Add(new XElement("name_en", alias));

            AppendXmlDocsJSON(childElement, "T:" + sysEnum.FullName);

            AddValues(sysEnum, childElement);

            var JSONNode = JSon.XmlToJSON(childElement.ToString());

            textBlocks.TextEnumsDescription.Append(JSONNode.Substring(1, JSONNode.Length - 2) + ",");
        }
Exemple #5
0
        private void AddGlobalContextDescriptionJSON(Type globalContext, DocumentBlocks textBlocks)
        {
            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;
                    var childElement = new XElement(categoryName.Replace(" ", "_"));

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

                    AddProperties(globalContext, childElement, "JSON");
                    AddMethodsJSON(globalContext, childElement);

                    if (!childElement.IsEmpty)
                    {
                        var JSONNode     = JSon.XmlToJSON(childElement.ToString());
                        var separatorPos = JSONNode.IndexOf(":", StringComparison.InvariantCulture);
                        JSONNode = JSONNode.Substring(0, separatorPos).Replace("_", " ") + JSONNode.Substring(separatorPos);
                        textBlocks.TextGlobalContext.Append(JSONNode.Substring(1, JSONNode.Length - 2) + ",");
                    }
                }
            }
            catch (InvalidOperationException)
            {
                return;
            }
        }