Esempio n. 1
0
File: Shell.cs Progetto: Gefix/Ilnet
        /// <summary>
        /// Create a new instance of the specified type
        /// </summary>
        /// <returns></returns>
        public static iliClassProxy CreateObjectFactory(Type t)
        {
            iliClassProxy c = creatorCache[t] as iliClassProxy;

            if (c == null)
            {
                lock (creatorCache.SyncRoot)
                {
                    c = creatorCache[t] as iliClassProxy;
                    if (c != null)
                    {
                        return(c);
                    }

                    Type[] types = new Type[] { typeof(FunctionExit), typeof(FunctionQueue), typeof(EventQueue) };

                    DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_" + t.Name, typeof(object), types, t);
                    ILGenerator   ilGen     = dynMethod.GetILGenerator();

                    ilGen.Emit(OpCodes.Ldarg_0);
                    ilGen.Emit(OpCodes.Ldarg_1);
                    ilGen.Emit(OpCodes.Ldarg_2);
                    ilGen.Emit(OpCodes.Newobj, t.GetConstructor(types));
                    ilGen.Emit(OpCodes.Ret);
                    c = (iliClassProxy)dynMethod.CreateDelegate(coType);
                    creatorCache.Add(t, c);
                }
            }
            return(c);
        }
Esempio n. 2
0
File: Shell.cs Progetto: Gefix/Ilnet
        /*/cnodeisexternal*/
        public void /*cnodefnname*/ fn_start/*/cnodefnname*/ ()
        {
            l["node"] = (FunctionExit)/*cnodefnnamecb*/ fn_start_cb /*/cnodefnnamecb*/;

            /*cnodeisfn*/
            l["break"] = false;

            // do something
            try
            {
                /*cnodefncode*/
                g["x"] = (int)g["x"] + 2;
                if ((int)g["x"] > 5)
                {
                    return;
                }
                /*/cnodefncode*/
                // /*fname*//*cnodefnname*/;/*/cnodefnname*//*/fname*/
            }
            catch (Exception ex)
            {
                error(ex.Message);
                error(ex.StackTrace);
                error("- - - - -");

                return;
            }

            if ((bool)l["break"])
            {
                return;
            }
            /*/cnodeisfn*/

            /*cnodeissubprocess*/
            /*csubname*/
            dynamic /*/csubname*/ c;

            /*cnodeisexternal*/
            if (/*cnodefnproxy*/ c_c1_proxy /*/cnodefnproxy*/ == null)
            {
                Hashtable data = new Hashtable();
                data.Add("systemEvent", "systemLoad");
                data.Add("projectName", "/*csubprojectname*/path.to.project/*/csubprojectname*/");
                ((EventQueue)i["eventqueue"])(data, /*cnodefnnamecb*/ fn_start_cb /*/cnodefnnamecb*/);
                if (!data.ContainsKey("assembly"))
                {
                    return;
                }
                Assembly asm = (Assembly)data["assembly"];
                /*cnodefnproxy*/
                c_c1_proxy /*/cnodefnproxy*/ = FastObjectFactory.CreateObjectFactory(asm.GetType("ILNET.Runtime.c_/*csubprocessname*/process/*/csubprocessname*/"));
            }

            c = /*cnodefnproxy*/ c_c1_proxy/*/cnodefnproxy*/ (/*cnodefnnamecb*/ fn_start_cb /*/cnodefnnamecb*/, (FunctionQueue)i["queue"], (EventQueue)i["eventqueue"]);
            /*/cnodeisexternal*/
            /*cnodeisinternal*/
            c = new /*csubname*/ c_c1/*/csubname*/ (/*cnodefnnamecb*/ fn_start_cb /*/cnodefnnamecb*/, (FunctionQueue)i["queue"], (EventQueue)i["eventqueue"]);
            /*/cnodeisinternal*/
            /*csubparam*/
            c./*cparamscope*/ i /*/cparamscope*/["/*cparamname*/x/*/cparamname*/"] = /*cparamvalue*/ 1 /*/cparamvalue*/;
            /*/csubparam*/
            c.run();
            /*/cnodeissubprocess*/

            /*cnodeisfn*/
            this./*cnodefnnamecb*/ fn_start_cb/*/cnodefnnamecb*/ (null);
            /*/cnodeisfn*/
        }