/// <summary>
        ///		Trata un bucle
        /// </summary>
        private void TreatLoop(MLNode objMLSource, MLNode objMLParentTarget, LanguageStructModel objStruct, string strStructType)
        {
            if (strStructType.EqualsIgnoreCase(cnstStrTagAttributeParameter))
            {
                if (objStruct is BaseMethodModel)
                {
                    BaseMethodModel objMethod = objStruct as BaseMethodModel;

                    if (objMethod.Arguments != null && objMethod.Arguments.Count > 0)
                    {
                        foreach (ArgumentModel objArgument in objMethod.Arguments)
                        {
                            TreatChilds(objMLSource.Nodes, objMLParentTarget, objStruct, objArgument);
                        }
                    }
                }
            }
            else
            {
                LanguageStructModel.StructType intIDType     = GetLanguageStruct(strStructType);
                LanguageStructModelCollection  objColStructs = SelectItemsForGeneration(objStruct, intIDType);

                // Crea los nodos hijo
                foreach (LanguageStructModel objChild in objColStructs)
                {                                                 // Si hay que añadirla a la colección de estructuras por referencia, se añade
                    if (objMLSource.Attributes[cnstStrTagAttributeAddToReferences].Value.GetBool())
                    {
                        Document.StructsReferenced.Add(objChild);
                    }
                    // Ytata los nodos hijo
                    TreatChilds(objMLSource.Nodes, objMLParentTarget, objChild);
                }
            }
        }
        /// <summary>
        ///		Comprueba si existe un tipo de estructura hija
        /// </summary>
        private bool CheckIfExistsChild(LanguageStructModel objStruct, string strStructType)
        {
            bool blnExists = false;

            // Comprueba si existe
            if (strStructType.EqualsIgnoreCase(cnstStrTagAttributeParameter))
            {
                if (objStruct is BaseMethodModel)
                {
                    BaseMethodModel objMethod = objStruct as BaseMethodModel;

                    if (objMethod.Arguments != null && objMethod.Arguments.Count > 0)
                    {
                        blnExists = true;
                    }
                }
            }
            else
            {
                LanguageStructModel.StructType intIDType     = GetLanguageStruct(strStructType);
                LanguageStructModelCollection  objColStructs = SelectItemsForGeneration(objStruct, intIDType);

                if (objColStructs != null && objColStructs.Count > 0)
                {
                    blnExists = true;
                }
            }
            // Devuelve el valor que indica si existe
            return(blnExists);
        }
Exemplo n.º 3
0
        /// <summary>
        ///		Obtiene una lista de argumentos
        /// </summary>
        private MLNodesCollection GetListArguments(BaseMethodModel objMethod)
        {
            MLNodesCollection objColMLNodes = new MLNodesCollection();

            // Añade los elementos a la lista
            if (objMethod.Arguments != null && objMethod.Arguments.Count > 0)
            {
                MLNode objMLList;

                // Cabecera
                objColMLNodes.Add("h4", "Argumentos");
                // Lista de elementos
                objMLList = objColMLNodes.Add("ul");
                foreach (ArgumentModel objArgument in objMethod.Arguments)
                {
                    objMLList.Nodes.Add(MLBuilder.GetListItem(MLBuilder.GetSpan(objArgument.Name, true),
                                                              MLBuilder.GetSpan("(" + MLBuilderHelper.GetTypeName(objArgument.Type) + ")", false, true),
                                                              MLBuilder.GetSpan(":", true),
                                                              MLBuilder.GetSpan(objMethod.RemarksXml.GetParameterRemarks(objArgument.Name))));
                }
            }
            else
            {
                objColMLNodes.Add("h4", "Sin argumentos");
            }
            // Devuelve la colección de nodos
            return(objColMLNodes);
        }
Exemplo n.º 4
0
        /// <summary>
        ///		Obtiene el prototipo de una función
        /// </summary>
        internal string GetMethodPrototype(BaseMethodModel objMethod, bool blnIsAsync = false, TypedModel objReturnType = null)
        {
            string strPrototype = GetMethodPrototypeDefinition(objMethod, blnIsAsync, objReturnType);

            // Añade los argumentos
            strPrototype += "(" + GetArgumentsPrototype(objMethod) + ")";
            // Devuelve el prototipo
            return(strPrototype);
        }
Exemplo n.º 5
0
        /// <summary>
        ///		Obtiene el prototipo de una función
        /// </summary>
        private string GetMethodPrototype(BaseMethodModel method, bool isAsync = false, TypedModel returnType = null)
        {
            string prototype = GetMethodPrototypeDefinition(method, isAsync, returnType);

            // Añade los argumentos
            prototype += "(" + GetArgumentsPrototype(method) + ")";
            // Devuelve el prototipo
            return(prototype);
        }
        /// <summary>
        ///		Obtiene el prototipo de una función
        /// </summary>
        private MLNodesCollection GetMethodPrototype(BaseMethodModel objMethod, bool blnIsAsync = false, TypedModel objReturnType = null)
        {
            MLNodesCollection objColMLNodes = GetMethodPrototypeDefinition(objMethod, blnIsAsync, objReturnType);

            // Añade los argumentos
            objColMLNodes.Add(Document.MLBuilder.GetSpan("("));
            objColMLNodes.AddRange(GetArgumentsPrototype(objMethod));
            objColMLNodes.Add(Document.MLBuilder.GetSpan(")"));
            // Devuelve el prototipo
            return(objColMLNodes);
        }
Exemplo n.º 7
0
        /// <summary>
        ///		Obtiene los argumentos para un prototipo
        /// </summary>
        private string GetArgumentsPrototype(BaseMethodModel objMethod)
        {
            string strArguments = "";

            // Añade la cadena con los argumentos
            for (int intIndex = 0; intIndex < objMethod.Arguments.Count; intIndex++)
            {
                strArguments = strArguments.AddWithSeparator(GetArgumentData(objMethod.Arguments[intIndex]), ",");
            }
            // Devuelve los argumentos
            return(strArguments);
        }
Exemplo n.º 8
0
        /// <summary>
        ///		Obtiene el MLNode del valor devuelto
        /// </summary>
        private MLNode GetListReturnData(BaseMethodModel objMethod, TypedModel objReturnType)
        {
            MLNode objMLNode = new MLNode("ul");

            // Añade los datos al nodo
            objMLNode.Nodes.Add(MLBuilder.GetListItem(MLBuilder.GetSpan("Valor de retorno", true),
                                                      MLBuilder.GetSpan(MLBuilderHelper.GetTypeName(objReturnType))));
            if (!objMethod.RemarksXml.Returns.IsEmpty())
            {
                objMLNode.Nodes.Add("li").Nodes.AddRange(MLBuilderHelper.GetTagsRemarksXml(objMethod.RemarksXml.Returns));
            }
            // Devuelve el nodo
            return(objMLNode);
        }
        /// <summary>
        ///		Obtiene los argumentos para un prototipo
        /// </summary>
        private MLNodesCollection GetArgumentsPrototype(BaseMethodModel objMethod)
        {
            MLNodesCollection objColMLNodes = new MLNodesCollection();

            // Añade la cadena con los argumentos
            for (int intIndex = 0; intIndex < objMethod.Arguments.Count; intIndex++)
            {                                     // Añade los nodos de los argumentos
                objColMLNodes.AddRange(GetArgumentData(objMethod.Arguments[intIndex]));
                // Añade un nodo de separación
                if (intIndex < objMethod.Arguments.Count - 1)
                {
                    objColMLNodes.Add(Document.MLBuilder.GetSpan(","));
                }
            }
            // Devuelve los argumentos
            return(objColMLNodes);
        }
        /// <summary>
        ///		Obtiene los argumentos para un prototipo
        /// </summary>
        private string GetArgumentsPrototype(BaseMethodModel objMethod)
        {
            string strPrototype = "";

            // Añade la cadena con los argumentos
            for (int intIndex = 0; intIndex < objMethod.Arguments.Count; intIndex++)
            {                                     // Añade los nodos de los argumentos
                strPrototype += GetArgumentData(objMethod.Arguments[intIndex]);
                // Añade un nodo de separación
                if (intIndex < objMethod.Arguments.Count - 1)
                {
                    strPrototype += ", ";
                }
            }
            // Devuelve los argumentos
            return(strPrototype);
        }
Exemplo n.º 11
0
        public MethodModel MapUp(BaseMethodModel model)
        {
            MethodModel methodModel = new MethodModel();

            methodModel.Name      = model.Name;
            methodModel.Extension = model.Extension;
            Type         type = model.GetType();
            PropertyInfo genericArgumentsProperty = type.GetProperty("GenericArguments",
                                                                     BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            if (genericArgumentsProperty?.GetValue(model) != null)
            {
                List <BaseTypeModel> genericArguments =
                    (List <BaseTypeModel>)HelperClass.ConvertList(typeof(BaseTypeModel),
                                                                  (IList)genericArgumentsProperty?.GetValue(model));
                methodModel.GenericArguments =
                    genericArguments.Select(g => TypeModelMapper.EmitType(g)).ToList();
            }

            methodModel.Modifiers = model.Modifiers;

            PropertyInfo parametersProperty = type.GetProperty("Parameters",
                                                               BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            if (parametersProperty?.GetValue(model) != null)
            {
                List <BaseParameterModel> parameters =
                    (List <BaseParameterModel>)HelperClass.ConvertList(typeof(BaseParameterModel),
                                                                       (IList)parametersProperty?.GetValue(model));

                methodModel.Parameters = parameters
                                         .Select(p => new ParameterModelMapper().MapUp(p)).ToList();
            }

            PropertyInfo returnTypeProperty = type.GetProperty("ReturnType",
                                                               BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            BaseTypeModel returnType = (BaseTypeModel)returnTypeProperty?.GetValue(model);

            if (returnType != null)
            {
                methodModel.ReturnType = TypeModelMapper.EmitType(returnType);
            }
            return(methodModel);
        }
Exemplo n.º 12
0
        /// <summary>
        ///		Añade una tabla de argumentos
        /// </summary>
        private void AddTableArguments(MLNode objMLRoot, BaseMethodModel objMethod)
        {
            if (objMethod.Arguments != null && objMethod.Arguments.Count > 0)
            {
                MLNode objMLTable;

                // Cabecera
                objMLRoot.Nodes.Add("h3", "Parámetros");
                // Cabecera de tabla
                objMLTable = MLBuilder.AddTable(objMLRoot, "Nombre", "Tipo", "Descripción");
                // Añade los argumentos
                foreach (ArgumentModel objArgument in objMethod.Arguments)
                {
                    MLBuilder.AddRowTable(objMLTable, objArgument.Name,
                                          MLBuilderHelper.GetTypeName(objArgument.Type),
                                          objMethod.RemarksXml.GetParameterRemarks(objArgument.Name));
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///		Obtiene la definición (el prefijo) de un prototipo de un método
        /// </summary>
        private string GetMethodPrototypeDefinition(BaseMethodModel method, bool isAsync, TypedModel returnType)
        {
            string prototype = "";

            // Añade los modificadores
            prototype += GetModifierText(method.Modifier);
            if (isAsync)
            {
                prototype += " async";
            }
            if (method.IsAbstract)
            {
                prototype += " abstract";
            }
            if (method.IsOverride)
            {
                prototype += " override";
            }
            if (method.IsSealed)
            {
                prototype += " sealed";
            }
            if (method.IsStatic)
            {
                prototype += " static";
            }
            if (method.IsVirtual)
            {
                prototype += " virtual";
            }
            // Añade el valor de retorno
            if (returnType != null)
            {
                prototype += " " + GetLinkTypeName(returnType);
            }
            // Añade el nombre del método
            prototype += " " + method.Name;
            // Añade los genéricos
            prototype += GetMethodPrototypeGenerics(method.TypeParameters);
            // Devuelve la definición de prototipo
            return(prototype);
        }
        /// <summary>
        ///		Obtiene la definición (el prefijo) de un prototipo de un método
        /// </summary>
        private MLNodesCollection GetMethodPrototypeDefinition(BaseMethodModel objMethod, bool blnIsAsync, TypedModel objReturnType)
        {
            MLNodesCollection objColMLNodes = new MLNodesCollection();

            // Añade los modificadores
            objColMLNodes.Add(Document.MLBuilder.GetSpan(GetModifierText(objMethod.Modifier)));
            if (blnIsAsync)
            {
                objColMLNodes.Add(Document.MLBuilder.GetSpan("async"));
            }
            if (objMethod.IsAbstract)
            {
                objColMLNodes.Add(Document.MLBuilder.GetSpan("abstract"));
            }
            if (objMethod.IsOverride)
            {
                objColMLNodes.Add(Document.MLBuilder.GetSpan("override"));
            }
            if (objMethod.IsSealed)
            {
                objColMLNodes.Add(Document.MLBuilder.GetSpan("sealed"));
            }
            if (objMethod.IsStatic)
            {
                objColMLNodes.Add(Document.MLBuilder.GetSpan("static"));
            }
            if (objMethod.IsVirtual)
            {
                objColMLNodes.Add(Document.MLBuilder.GetSpan("virtual"));
            }
            // Añade el valor de retorno
            if (objReturnType != null)
            {
                objColMLNodes.Add(GetLinkTypeName(objReturnType));
            }
            // Añade el nombre del método
            objColMLNodes.Add(Document.MLBuilder.GetSpan(objMethod.Name));
            // Añade los genéricos
            objColMLNodes.AddRange(GetMethodPrototypeGenerics(objMethod.TypeParameters));
            // Devuelve la definición de prototipo
            return(objColMLNodes);
        }
Exemplo n.º 15
0
        /// <summary>
        ///		Obtiene la definición (el prefijo) de un prototipo de un método
        /// </summary>
        private string GetMethodPrototypeDefinition(BaseMethodModel objMethod, bool blnIsAsync, TypedModel objReturnType)
        {
            string strPrototype = GetModifierText(objMethod.Modifier);

            // Añade los modificadores
            if (blnIsAsync)
            {
                strPrototype = strPrototype.AddWithSeparator("async", " ", false);
            }
            if (objMethod.IsAbstract)
            {
                strPrototype = strPrototype.AddWithSeparator("abstract", " ", false);
            }
            if (objMethod.IsOverride)
            {
                strPrototype = strPrototype.AddWithSeparator("override", " ", false);
            }
            if (objMethod.IsSealed)
            {
                strPrototype = strPrototype.AddWithSeparator("sealed", " ", false);
            }
            if (objMethod.IsStatic)
            {
                strPrototype = strPrototype.AddWithSeparator("static", " ", false);
            }
            if (objMethod.IsVirtual)
            {
                strPrototype = strPrototype.AddWithSeparator("virtual", " ", false);
            }
            // Añade el valor de retorno
            if (objReturnType != null)
            {
                strPrototype = strPrototype.AddWithSeparator(GetTypeName(objReturnType), " ", false);
            }
            // Añade el nombre del método
            strPrototype = strPrototype.AddWithSeparator(objMethod.Name, " ", false);
            // Añade los genéricos
            strPrototype += GetMethodPrototypeGenerics(objMethod.TypeParameters);
            // Devuelve la definición de prototipo
            return(strPrototype);
        }
Exemplo n.º 16
0
        /// <summary>
        ///		Añade un parámetro con la lista de argumentos
        /// </summary>
        private void AddListArguments(StructDocumentationModel parent, BaseMethodModel method, List <ArgumentModel> arguments)
        {
            if (arguments != null && arguments.Count > 0)
            {
                foreach (ArgumentModel argument in arguments)
                {
                    StructDocumentationModel structDoc = new StructDocumentationModel(parent, StructDocumentationModel.ScopeType.Global, argument.Name, "Argument", 0);

                    // Añade el tipo
                    structDoc.Childs.Add(GetTypeStruct(structDoc, "TypeStruct", argument.Type));
                    // Añade los parámetros del argumento
                    structDoc.Parameters.Add(GetTypeStructShort("Type", argument.Type));
                    structDoc.Parameters.Add("RefType", argument.RefType.ToString());
                    structDoc.Parameters.Add("IsOptional", argument.IsOptional);
                    structDoc.Parameters.Add("IsParams", argument.IsParams);
                    structDoc.Parameters.Add("IsThis", argument.IsThis);
                    structDoc.Parameters.Add("Default", argument.Default);
                    structDoc.Parameters.Add("Summary", ConvertRemarks(method.RemarksXml.GetParameterRemarks(argument.Name)));
                    // Añade la estrucutra al padre
                    parent.Childs.Add(structDoc);
                }
            }
        }
Exemplo n.º 17
0
 /// <summary>
 ///		Obtiene el MLNode del valor devuelto
 /// </summary>
 private void GetMLReturn(MLNode objMLRoot, BaseMethodModel objMethod, TypedModel objReturnType)
 {
     objMLRoot.Nodes.Add("h3", "Valor devuelto");
     objMLRoot.Nodes.Add("p", MLBuilderHelper.GetTypeName(objReturnType));
     objMLRoot.Nodes.AddRange(MLBuilderHelper.GetTagsRemarksXml(objMethod.RemarksXml.Returns));
 }