예제 #1
0
        /// <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);
        }
예제 #2
0
 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
 }
예제 #3
0
        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
        }
예제 #4
0
 public Instantiator(Type _root, InstanciatorInvoker _loader)
 {
     RootType = _root;
     loader   = _loader;
 }
예제 #5
0
 public Instantiator(Type _root, InstanciatorInvoker _loader)
 {
     RootType = _root;
     loader = _loader;
 }
예제 #6
0
        /// <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);
        }
예제 #7
0
파일: Reader.cs 프로젝트: jpbruyere/Crow
        /// <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;
        }
예제 #8
0
 public ItemTemplate(Type _root, InstanciatorInvoker _loader, string _dataType, string _fetchDataMethod)
     : base(_root, _loader)
 {
     strDataType     = _dataType;
     fetchMethodName = _fetchDataMethod;
 }