Skip to content

Commit

Permalink
fix error when loop cref dotnet#289
Browse files Browse the repository at this point in the history
  • Loading branch information
superyyrrzz committed May 11, 2016
1 parent 4759e41 commit cf766cb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace Microsoft.DocAsCode.Build.ManagedReference.BuildOutputs
public class ApiCrefInfoBuildOutput
{
[YamlMember(Alias = "type")]
[JsonProperty("type")]
[JsonProperty("type", IsReference = true)]
public ApiReferenceBuildOutput Type { get; set; }

[YamlMember(Alias = "description")]
[JsonProperty("description")]
public string Description { get; set; }

private bool _isExpanded = false;
ApiExpandStatus status = ApiExpandStatus.UnExpanded;

public static ApiCrefInfoBuildOutput FromModel(CrefInfo model)
{
Expand All @@ -43,16 +43,17 @@ public static ApiCrefInfoBuildOutput FromModel(CrefInfo model, Dictionary<string
{
Type = ApiBuildOutputUtility.GetReferenceViewModel(model.Type, references, supportedLanguages),
Description = model.Description,
_isExpanded = true,
status = ApiExpandStatus.Expanded,
};
}

public void Expand(Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
{
if (!_isExpanded)
if (status == ApiExpandStatus.UnExpanded)
{
status = ApiExpandStatus.IsExpanding;
Type = ApiBuildOutputUtility.GetReferenceViewModel(Type?.Uid, references, supportedLanguages);
_isExpanded = true;
status = ApiExpandStatus.Expanded;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DocAsCode.Build.ManagedReference.BuildOutputs
{
public enum ApiExpandStatus
{
UnExpanded,
IsExpanding,
Expanded
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ApiParameterBuildOutput
[JsonProperty("description")]
public string Description { get; set; }

private bool _isExpanded = false;
ApiExpandStatus status = ApiExpandStatus.UnExpanded;

public static ApiParameterBuildOutput FromModel(ApiParameter model, Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
{
Expand Down Expand Up @@ -54,10 +54,11 @@ public static ApiParameterBuildOutput FromModel(ApiParameter model)

public void Expand(Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
{
if (!_isExpanded)
if (status == ApiExpandStatus.UnExpanded)
{
status = ApiExpandStatus.IsExpanding;
Type = ApiBuildOutputUtility.GetReferenceViewModel(Type?.Uid, references, supportedLanguages);
_isExpanded = true;
status = ApiExpandStatus.Expanded;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public Dictionary<string, object> MetadataJson
set { }
}

private bool _isExpanded = false;
ApiExpandStatus status = ApiExpandStatus.UnExpanded;

public static ApiReferenceBuildOutput FromUid(string uid)
{
Expand Down Expand Up @@ -231,14 +231,15 @@ public static ApiReferenceBuildOutput FromModel(ItemViewModel vm)

public void Expand(Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
{
if (!_isExpanded)
if (status == ApiExpandStatus.UnExpanded)
{
status = ApiExpandStatus.IsExpanding;
Inheritance = Inheritance?.Select(i => ApiBuildOutputUtility.GetReferenceViewModel(i.Uid, references, supportedLanguages)).ToList();
Syntax?.Expand(references, supportedLanguages);
SeeAlsos?.ForEach(e => e.Expand(references, supportedLanguages));
Sees?.ForEach(e => e.Expand(references, supportedLanguages));
Exceptions?.ForEach(e => e.Expand(references, supportedLanguages));
_isExpanded = true;
status = ApiExpandStatus.Expanded;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ApiSyntaxBuildOutput
[JsonProperty("return")]
public ApiParameterBuildOutput Return { get; set; }

private bool _isExpanded = false;
ApiExpandStatus status = ApiExpandStatus.UnExpanded;

public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
{
Expand All @@ -43,7 +43,7 @@ public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, Dictio
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,
status = ApiExpandStatus.Expanded,
};
}

Expand All @@ -63,12 +63,13 @@ public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, string

public void Expand(Dictionary<string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
{
if (!_isExpanded)
if (status == ApiExpandStatus.UnExpanded)
{
status = ApiExpandStatus.IsExpanding;
Parameters?.ForEach(p => p.Expand(references, supportedLanguages));
TypeParameters?.ForEach(t => t.Expand(references, supportedLanguages));
Return?.Expand(references, supportedLanguages);
_isExpanded = true;
status = ApiExpandStatus.Expanded;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Compile Include="BuildOutputs\ApiBuildOutput.cs" />
<Compile Include="BuildOutputs\ApiBuildOutputUtility.cs" />
<Compile Include="BuildOutputs\ApiCrefInfoBuildOutput.cs" />
<Compile Include="BuildOutputs\ApiExpandStatus.cs" />
<Compile Include="BuildOutputs\ApiLanguageValuePair.cs" />
<Compile Include="BuildOutputs\ApiParameterBuildOutput.cs" />
<Compile Include="Utility.cs" />
Expand Down

0 comments on commit cf766cb

Please sign in to comment.