/// <summary> /// Finalize instatiator MSIL and return LoaderInvoker delegate /// </summary> public InstanciatorInvoker GetLoader() { if (loader != null) { return(loader); } il.Emit(OpCodes.Ret); loader = (InstanciatorInvoker)dm.CreateDelegate(typeof(InstanciatorInvoker)); return(loader); }
public Instantiator(Stream stream) { #if DEBUG_LOAD Stopwatch loadingTime = new Stopwatch(); loadingTime.Start(); #endif using (IMLReader itr = new IMLReader(stream)){ loader = itr.GetLoader(); RootType = itr.RootType; } #if DEBUG_LOAD loadingTime.Stop(); Debug.WriteLine("IML Instantiator creation '{2}' : {0} ticks, {1} ms", loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, imlPath); #endif }
public Instantiator(string path) { imlPath = path; #if DEBUG_LOAD Stopwatch loadingTime = new Stopwatch(); loadingTime.Start(); #endif try { using (IMLReader itr = new IMLReader(path)){ loader = itr.GetLoader(); RootType = itr.RootType; } } catch (Exception ex) { throw new Exception("Error loading <" + path + ">:\n", ex); } #if DEBUG_LOAD loadingTime.Stop(); Debug.WriteLine("IML Instantiator creation '{2}' : {0} ticks, {1} ms", loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, path); #endif }
public Instantiator(Type _root, InstanciatorInvoker _loader) { RootType = _root; loader = _loader; }
/// <summary> /// Parses IML and build a dynamic method that will be used to instanciate one or multiple occurence of the IML file or fragment /// </summary> void parseIML(XmlTextReader reader) { Context ctx = new Context (findRootType (reader)); ctx.nodesStack.Push (new Node (ctx.RootType)); emitLoader (reader, ctx); ctx.nodesStack.Pop (); foreach (int idx in templateCachedDelegateIndices) ctx.emitCachedDelegateHandlerAddition(idx, CompilerServices.eiLogicalParentChanged); ctx.ResolveNamedTargets (); emitBindingDelegates (ctx); ctx.il.Emit (OpCodes.Ldloc_0);//load root obj to return ctx.il.Emit(OpCodes.Ret); reader.Read ();//close tag RootType = ctx.RootType; loader = (InstanciatorInvoker)ctx.dm.CreateDelegate (typeof (InstanciatorInvoker), this); }
/// <summary> /// Finalize instatiator MSIL and return LoaderInvoker delegate /// </summary> public InstanciatorInvoker GetLoader() { if (loader != null) return loader; il.Emit(OpCodes.Ret); loader = (InstanciatorInvoker)dm.CreateDelegate (typeof(InstanciatorInvoker)); return loader; }
public ItemTemplate(Type _root, InstanciatorInvoker _loader, string _dataType, string _fetchDataMethod) : base(_root, _loader) { strDataType = _dataType; fetchMethodName = _fetchDataMethod; }