當前位置: 首頁>>代碼示例>>C#>>正文


C# Assembly.CreateInstance方法代碼示例

本文整理匯總了C#中Assembly.CreateInstance方法的典型用法代碼示例。如果您正苦於以下問題:C# Assembly.CreateInstance方法的具體用法?C# Assembly.CreateInstance怎麽用?C# Assembly.CreateInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Assembly的用法示例。


在下文中一共展示了Assembly.CreateInstance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GeneraDibujables

    public virtual ParticulaDibujable[] GeneraDibujables(Particula[] particula,float[] color,bool aleat)
    {
        ArrayList result=new ArrayList();
        for (int i = 0; i < particula.Length; i++)
        {
            if(particula[i]==null)return (ParticulaDibujable[])result.ToArray(Type.GetType("ParticulaDibujable"));
            try
            {
                if(tempInfo==null || tempInfo.Nombre!=particula[i].GetType().Name)
                {
                    tempInfo=pinfo.GetInfoParticulas(particula[i].GetType().Name);
                }

            }
            catch (Exception ex) { throw new Exception("Error al Generar Particulas Dibujables"); }
            assem=GestorEnsamblados.GetAssemblyByName(tempInfo.EnsambladoDibujable,tempInfo.PathDibujable);
            if(aleat)
            {
                result.Add((ParticulaDibujable)assem.CreateInstance(tempInfo.NombreDibujable, true, BindingFlags.CreateInstance, null, new object[] {particula[i]}, null, null));
            }
            else
            {
                result.Add((ParticulaDibujable)assem.CreateInstance(tempInfo.NombreDibujable, true, BindingFlags.CreateInstance, null, new object[] {particula[i], color}, null, null));
            }

        }
        return (ParticulaDibujable[])result.ToArray(Type.GetType("ParticulaDibujable"));
    }
開發者ID:jesantana,項目名稱:RSAGenerator,代碼行數:28,代碼來源:GestorDibujables.cs

示例2: Instantiate

 public static void Instantiate(Assembly a, Interpreter interp)
 {
     Hashtable table = interp.VarTable;
     try {
         CodeChunk chunk = (CodeChunk)a.CreateInstance("CsiChunk");
         chunk.Go(table);
         // vs 0.8 we display the type and value of expressions.  The variable $_ is
         // always set, which is useful if you want to save the result of the last
         // calculation.
         if (interp.returnsValue && DumpingValue) {
             object val = table["_"];
             Type type = val.GetType();
             string stype = type.ToString();
             if (stype.StartsWith("System."))  // to simplify things a little bit...
                 stype = stype.Substring(7);
             stype = "("+stype+")";
             if (val is string) {
                 Print(stype,"'"+val+"'");
             } else
             if (val is IEnumerable) {
                 Print(stype);
                 Dumpl((IEnumerable)val);
             } else
                 Print(stype,val);
         }
     }  catch(Exception ex) {
         Print(ex.GetType() + " was thrown: " + ex.Message);
     }
 }
開發者ID:stevedonovan,項目名稱:cs-repl,代碼行數:29,代碼來源:interpreter.cs

示例3: GeneraAnsysWriter

 public virtual ANSYSWriter GeneraAnsysWriter(string particulaName,RSA owner)
 {
     ANSYSWriter ansysReturn = null;
     tempInfo = pinfo.GetInfoParticulas(particulaName);
     assem = GestorEnsamblados.GetAssemblyByName(tempInfo.EnsambladoDibujable, tempInfo.PathDibujable);
     ansysReturn=(ANSYSWriter)assem.CreateInstance(tempInfo.AnsysWriterName, true, BindingFlags.CreateInstance, null, new object[] {owner}, null, null);
     return ansysReturn;
 }
開發者ID:jesantana,項目名稱:RSAGenerator,代碼行數:8,代碼來源:GestorDibujables.cs

示例4: Instantiate

 public static void Instantiate(Assembly a, Hashtable table, string className, string funName) {
     try {
         CsiFunctionContext dll = (CsiFunctionContext)a.CreateInstance(className);
         dll.V = table;
         table[className] = dll;
     }  catch(Exception ex) {
         Print(ex.GetType() + " was thrown: " + ex.Message);
     }	    
 }    
開發者ID:oleg-shilo,項目名稱:cs-script,代碼行數:9,代碼來源:interpreter.cs

示例5: FindScriptInterface

            public object FindScriptInterface(string interfaceName, Assembly compiledAssembly, string task_class)
            {
                if (compiledAssembly == null)
                   return null;

                Type t = compiledAssembly.GetType(task_class);
                if (t.GetInterface(interfaceName, true) != null)
                   return compiledAssembly.CreateInstance(t.FullName);

                return null;
            }
開發者ID:JauchOnGitHub,項目名稱:csharptoolbox,代碼行數:11,代碼來源:Script.cs


注:本文中的Assembly.CreateInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。