コード例 #1
0
    public static void Main(string[] args)
    {
        CSharpCodeProvider provider = new CSharpCodeProvider();

        CompilerParameters parameters = new CompilerParameters();

        parameters.GenerateExecutable = false;
        parameters.GenerateInMemory   = true;
        parameters.OutputAssembly     = "MyImpl";
        parameters.ReferencedAssemblies.Add(typeof(IInterface).Assembly.Location);

        CompilerResults results = provider.CompileAssemblyFromSource(
            parameters,
            @"
                        public class MyImpl : IInterface
                        {
                            public string GetName()
                            {
                                return ""test"";
                            }
                        }
                    "
            );

        var        myImplType = results.CompiledAssembly.GetType("MyImpl");
        IInterface impl       = (IInterface)Activator.CreateInstance(myImplType);


        System.Diagnostics.Debug.WriteLine(impl.GetName());
    }
コード例 #2
0
        /// <summary>
        /// This method is called by the Target in a separate thread
        /// </summary>
        public virtual void Execute(resend myRerun)
        {
            m_TransmitTelegram = new ProtocolFrame(m_DestinationAddress, m_Command, m_Data);
            {
                m_Latch.Reset();
                IsTimeout = false;
                m_Interface.RegisterListener(this);
                m_CommandResult = WcaInterfaceCommandResult.InProgress;

                m_Interface.Send(m_TransmitTelegram.Telegram);
                try
                {
                    if (!m_Latch.WaitOne(Timeout))
                    {
                        //timeout
                        IsTimeout       = true;
                        m_CommandResult = WcaInterfaceCommandResult.ExecutionTimeout;

                        if (myRerun != null)
                        {
                            myRerun(m_Interface.GetName(), m_Command, m_Data, m_Name);
                        }
                    }
                    else if (Validate(m_ReceivedTelegrams))
                    {
                        m_CommandResult = WcaInterfaceCommandResult.PosAck;
                    }
                    else
                    {
                        m_CommandResult = WcaInterfaceCommandResult.NegAck;
                        if (myRerun != null)
                        {
                            myRerun(m_Interface.GetName(), m_Command, m_Data, m_Name);
                        }
                    }

                    m_Latch.Reset();
                }
                catch (System.Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                m_Interface.UnregisterListener(this);

                NotifyListener(this);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Excalib88/KonstantinLesson
 public void SetName(int id)
 {
     Name = _person.GetName(id);
 }