@@ -6,6 +6,7 @@ This Source Code Form is subject to the terms of the
66----------------------------------------------------------*/
77
88using System ;
9+ using System . Collections ;
910using System . Collections . Generic ;
1011using System . IO ;
1112using System . Linq ;
@@ -14,6 +15,8 @@ This Source Code Form is subject to the terms of the
1415using System . Xml . Linq ;
1516using OneScript . Contexts ;
1617using OneScript . Localization ;
18+ using OneScript . Types ;
19+ using OneScript . Values ;
1720using OneScriptDocumenter . Model ;
1821using OneScriptDocumenter . Primary ;
1922using ArgumentException = System . ArgumentException ;
@@ -136,10 +139,37 @@ private IDocument MakeSystemEnumNode(PrimaryBslDocument primaryDoc)
136139 Owner = primaryDoc . Owner ,
137140 Name = new BilingualString ( typeMarkup . Name , typeMarkup . Alias ) ,
138141 Description = XmlSummary ( primaryDoc . SelfDoc ) ,
142+ Items = LoadSystemEnumItems ( primaryDoc . Owner ) ,
139143 Example = XmlTextBlock ( primaryDoc . SelfDoc , "example" )
140144 } ;
141145 }
142146
147+ private List < EnumItemModel > LoadSystemEnumItems ( Type enumType )
148+ {
149+ var items = new List < EnumItemModel > ( ) ;
150+ var instantiator = enumType . GetMethod ( "CreateInstance" , BindingFlags . Static | BindingFlags . Public ) ;
151+ if ( instantiator == null )
152+ return items ;
153+
154+ var enumInstance = ( IEnumerable ) instantiator . Invoke ( null , new [ ] { new FakeTypeManager ( ) } ) ;
155+ if ( enumInstance == null )
156+ return items ;
157+
158+
159+ foreach ( var unknownTypeItem in enumInstance )
160+ {
161+ if ( unknownTypeItem is EnumerationValue enumValue )
162+ {
163+ items . Add ( new EnumItemModel
164+ {
165+ Name = new BilingualString ( enumValue . Name , enumValue . Alias )
166+ } ) ;
167+ }
168+ }
169+
170+ return items ;
171+ }
172+
143173 private IDocument MakeSimpleEnumNode ( PrimaryBslDocument primaryDoc )
144174 {
145175 var typeMarkup = MarkupProvider . GetEnumMarkup ( primaryDoc . Owner ) ;
@@ -372,5 +402,58 @@ private string XmlTextBlock(XElement docs, string nodeName, bool isCode = false)
372402 return stringValue == "" ? null : // Чтобы свойство не писал сериализатор JSON
373403 stringValue ;
374404 }
405+
406+ private class FakeTypeManager : ITypeManager
407+ {
408+ public TypeDescriptor GetTypeByName ( string name )
409+ {
410+ throw new NotImplementedException ( ) ;
411+ }
412+
413+ public TypeDescriptor GetTypeByFrameworkType ( Type type )
414+ {
415+ throw new NotImplementedException ( ) ;
416+ }
417+
418+ public bool TryGetType ( string name , out TypeDescriptor type )
419+ {
420+ throw new NotImplementedException ( ) ;
421+ }
422+
423+ public bool TryGetType ( Type frameworkType , out TypeDescriptor type )
424+ {
425+ throw new NotImplementedException ( ) ;
426+ }
427+
428+ public TypeDescriptor RegisterType ( string name , string alias , Type implementingClass )
429+ {
430+ return default ;
431+ }
432+
433+ public void RegisterType ( TypeDescriptor typeDescriptor )
434+ {
435+
436+ }
437+
438+ public ITypeFactory GetFactoryFor ( TypeDescriptor type )
439+ {
440+ throw new NotImplementedException ( ) ;
441+ }
442+
443+ public bool IsKnownType ( Type type )
444+ {
445+ throw new NotImplementedException ( ) ;
446+ }
447+
448+ public bool IsKnownType ( string typeName )
449+ {
450+ throw new NotImplementedException ( ) ;
451+ }
452+
453+ public IReadOnlyList < TypeDescriptor > RegisteredTypes ( )
454+ {
455+ throw new NotImplementedException ( ) ;
456+ }
457+ }
375458 }
376459}
0 commit comments