You've already forked linux-packaging-mono
Imported Upstream version 6.6.0.89
Former-commit-id: b39a328747c2f3414dc52e009fb6f0aa80ca2492
This commit is contained in:
parent
cf815e07e0
commit
95fdb59ea6
34
external/api-doc-tools/mdoc/Mono.Documentation/Updater/Formatters/StandardFlagsEnumFormatter.cs
vendored
Normal file
34
external/api-doc-tools/mdoc/Mono.Documentation/Updater/Formatters/StandardFlagsEnumFormatter.cs
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Linq;
|
||||
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace Mono.Documentation.Updater
|
||||
{
|
||||
/// <summary>Flags enum formatter that assumes powers of two values.</summary>
|
||||
/// <remarks>As described here: https://msdn.microsoft.com/en-us/library/vstudio/ms229062(v=vs.100).aspx</remarks>
|
||||
class StandardFlagsEnumFormatter : AttributeValueFormatter
|
||||
{
|
||||
public override bool TryFormatValue (object v, ResolvedTypeInfo type, out string returnvalue)
|
||||
{
|
||||
TypeReference valueType = type.Reference;
|
||||
TypeDefinition valueDef = type.Definition;
|
||||
if (valueDef.CustomAttributes.Any (ca => ca.AttributeType.FullName == "System.FlagsAttribute"))
|
||||
{
|
||||
|
||||
string typename = MDocUpdater.GetDocTypeFullName (valueType);
|
||||
var values = MDocUpdater.GetEnumerationValues (valueDef);
|
||||
long c = MDocUpdater.ToInt64 (v);
|
||||
returnvalue = string.Join (" | ",
|
||||
(from i in values.Keys
|
||||
where (c & i) == i && i != 0
|
||||
select typename + "." + values[i])
|
||||
.DefaultIfEmpty (c.ToString ()).ToArray ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
returnvalue = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user