Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static System.Collections.Generic.IDictionary<System.String, Type> GetInitialDictionary( System.IO.TextReader file ) {
- var output = new System.Collections.Generic.Dictionary<System.String, Type>( System.StringComparer.Ordinal );
- var headers = new System.Collections.Generic.Dictionary<System.String, System.Int32>( System.StringComparer.OrdinalIgnoreCase );
- System.Int32 i = 0;
- foreach ( var header in file.ReadRecord( "\r\n", '\"', ',' ) ) {
- headers.Add( header, i++ );
- }
- while ( -1 != file.Peek() ) {
- var row = file.ReadRecord( "\r\n", '\"', ',' ).ToArray();
- if ( row.Length <= 3 ) {
- continue;
- }
- var assembly = System.Reflection.Assembly.Load( row[ headers[ "Assembly" ] ] );
- var type = assembly.GetType( row[ headers[ "Type" ] ], true, true );
- var method = type.GetMethod(
- row[ headers[ "Method" ] ],
- 0,
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public,
- null,
- System.Reflection.CallingConventions.Standard,
- new System.Type[ 1 ] { typeof( Icod.Collections.Immutable.IStack<Type> ) },
- null
- );
- if ( method.ReturnType != typeof( Icod.Collections.Immutable.IStack<Type> ) ) {
- throw new System.InvalidOperationException( "Intrinsic operator misconfigured" );
- }
- var code = method.CreateDelegate(
- typeof( System.Func<Icod.Collections.Immutable.IStack<Type>, Icod.Collections.Immutable.IStack<Type>> )
- );
- var name = row[ headers[ "Name" ] ];
- var @operator = new Type(
- name,
- row[ headers[ "Ancestry" ] ],
- null,
- (System.Func<Icod.Collections.Immutable.IStack<Type>, Icod.Collections.Immutable.IStack<Type>>)code
- );
- output.Add( name, @operator );
- }
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement