Beispiel #1
0
        public static SyntaxDetailViewModel ToSyntaxDetailViewModel(this SyntaxDetail model)
        {
            if (model == null)
            {
                return(null);
            }
            var result = new SyntaxDetailViewModel
            {
                Parameters     = model.Parameters,
                TypeParameters = model.TypeParameters,
                Return         = model.Return,
            };

            if (model.Content != null && model.Content.Count > 0)
            {
                result.Content = model.Content.GetLanguageProperty(SyntaxLanguage.Default);
                var contentForCSharp = model.Content.GetLanguageProperty(SyntaxLanguage.CSharp);
                if (result.Content != contentForCSharp)
                {
                    result.ContentForCSharp = contentForCSharp;
                }
                var contentForVB = model.Content.GetLanguageProperty(SyntaxLanguage.VB);
                if (result.Content != contentForVB)
                {
                    result.ContentForVB = contentForVB;
                }
            }
            return(result);
        }
Beispiel #2
0
 protected string TransferSyntax(SyntaxDetailViewModel syntax)
 {
     if (syntax == null)
     {
         return(null);
     }
     return(syntax.Content);
 }
        protected void FillDeclaration(SyntaxDetailViewModel syntax, XElement node, bool isMain)
        {
            string declaration = isMain ? _declarationGenerator.GenerateTypeDeclaration(node) : _declarationGenerator.GenerateMemberDeclaration(node);

            if (!string.IsNullOrEmpty(declaration))
            {
                syntax.Content = declaration;
            }
        }
Beispiel #4
0
        public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, string[] supportedLanguages)
        {
            if (model == null) return null;

            return new ApiSyntaxBuildOutput
            {
                Content = GetContents(model.Content, model.ContentForCSharp, model.ContentForVB, supportedLanguages),
                Parameters = model.Parameters?.Select(s => ApiParameterBuildOutput.FromModel(s)).ToList(),
                TypeParameters = model.TypeParameters?.Select(s => ApiParameterBuildOutput.FromModel(s)).ToList(),
                Return = ApiParameterBuildOutput.FromModel(model.Return),
            };
        }
        protected void FillReturn(SyntaxDetailViewModel syntax, XElement node)
        {
            string typeStr = node.NullableElement("type").NullableValue();

            if (!string.IsNullOrEmpty(typeStr) && (!typeStr.Equals("void", StringComparison.OrdinalIgnoreCase)))
            {
                syntax.Return = new ApiParameter
                {
                    Type        = ParseType(node.NullableElement("type")),
                    Description = ParseReturnDescription(node.NullableElement("detaileddescription"))
                };
            }
        }
Beispiel #6
0
        public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
        {
            if (model == null) return null;

            return new ApiSyntaxBuildOutput
            {
                Content = GetContents(model.Content, model.ContentForCSharp, model.ContentForVB, supportedLanguages),
                Parameters = model.Parameters?.Select(s => ApiParameterBuildOutput.FromModel(s, references, supportedLanguages)).ToList(),
                TypeParameters = model.TypeParameters?.Select(s => ApiParameterBuildOutput.FromModel(s)).ToList(),
                Return = ApiParameterBuildOutput.FromModel(model.Return, references, supportedLanguages),
                _needExpand = false,
            };
        }
Beispiel #7
0
 public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, string[] supportedLanguages)
 {
     if (model == null)
     {
         return(null);
     }
     return(new ApiSyntaxBuildOutput
     {
         Content = ApiBuildOutputUtility.TransformToLanguagePairList(model.Content, model.Contents, supportedLanguages),
         Parameters = model.Parameters?.Select(ApiParameterBuildOutput.FromModel).ToList(),
         TypeParameters = model.TypeParameters?.Select(ApiParameterBuildOutput.FromModel).ToList(),
         Return = ApiParameterBuildOutput.FromModel(model.Return),
     });
 }
 protected void FillParameters(SyntaxDetailViewModel syntax, XElement node)
 {
     if (node.Elements("param").Any())
     {
         syntax.Parameters = node.Elements("param").Select(
             p =>
             new ApiParameter
         {
             Name        = p.NullableElement("declname").NullableValue(),
             Type        = ParseType(p.NullableElement("type")),
             Description = ParseParameterDescription(node.NullableElement("detaileddescription"), p.NullableElement("declname").NullableValue())
         }).ToList();
     }
 }
Beispiel #9
0
 public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
 {
     if (model == null)
     {
         return(null);
     }
     return(new ApiSyntaxBuildOutput
     {
         Content = ApiBuildOutputUtility.TransformToLanguagePairList(model.Content, model.Contents, supportedLanguages),
         Parameters = model.Parameters?.Select(s => ApiParameterBuildOutput.FromModel(s, references, supportedLanguages)).ToList(),
         TypeParameters = model.TypeParameters?.Select(ApiParameterBuildOutput.FromModel).ToList(),
         Return = ApiParameterBuildOutput.FromModel(model.Return, references, supportedLanguages),
         _needExpand = false,
     });
 }
Beispiel #10
0
        public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, string[] supportedLanguages)
        {
            if (model == null)
            {
                return(null);
            }

            return(new ApiSyntaxBuildOutput
            {
                Content = GetContents(model.Content, model.ContentForCSharp, model.ContentForVB, supportedLanguages),
                Parameters = model.Parameters?.Select(s => ApiParameterBuildOutput.FromModel(s)).ToList(),
                TypeParameters = model.TypeParameters?.Select(s => ApiParameterBuildOutput.FromModel(s)).ToList(),
                Return = ApiParameterBuildOutput.FromModel(model.Return),
            });
        }
Beispiel #11
0
        public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
        {
            if (model == null)
            {
                return(null);
            }

            return(new ApiSyntaxBuildOutput
            {
                Content = GetContents(model.Content, model.ContentForCSharp, model.ContentForVB, supportedLanguages),
                Parameters = model.Parameters?.Select(s => ApiParameterBuildOutput.FromModel(s, references, supportedLanguages)).ToList(),
                TypeParameters = model.TypeParameters?.Select(s => ApiParameterBuildOutput.FromModel(s)).ToList(),
                Return = ApiParameterBuildOutput.FromModel(model.Return, references, supportedLanguages),
                _isExpanded = true,
            });
        }
Beispiel #12
0
        protected Return TransferReturns(SyntaxDetailViewModel syntax)
        {
            if (syntax == null || syntax.Return == null)
            {
                return(null);
            }


            var returns = new Return()
            {
                Description = syntax.Return.Description,
                Type        = ConvertStringToInlineMD(syntax.Return.Type)
            };

            return(returns);
        }
        protected void FillTypeParameters(SyntaxDetailViewModel syntax, XElement node)
        {
            var templateParamList = node.NullableElement("templateparamlist");

            if (templateParamList.IsNull())
            {
                return;
            }
            if (templateParamList.Elements("param").Any())
            {
                syntax.TypeParameters = templateParamList.Elements("param").Select(
                    p =>
                    new ApiParameter
                {
                    Type        = ParseType(p.NullableElement("type")),
                    Description = ParseParameterDescription(node.NullableElement("detaileddescription"), "<" + p.NullableElement("type").NullableValue() + ">")
                }).ToList();
            }
        }
Beispiel #14
0
        protected IEnumerable <Parameter> TransferParameters(SyntaxDetailViewModel syntax)
        {
            if (syntax == null || syntax.Parameters == null || syntax.Parameters.Count == 0)
            {
                return(null);
            }

            var parameters = syntax.Parameters.Select(p => new Parameter()
            {
                Description = p.Description, Name = p.Name, Type = p.Type
            }).ToArray();

            if (parameters.Length == 0)
            {
                return(null);
            }

            return(parameters);
        }