当前位置: 首页>>代码示例>>C#>>正文


C# Interface.WriteMessage方法代码示例

本文整理汇总了C#中Interface.WriteMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Interface.WriteMessage方法的具体用法?C# Interface.WriteMessage怎么用?C# Interface.WriteMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Interface的用法示例。


在下文中一共展示了Interface.WriteMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Work

 /// <summary>
 /// Write the configuration on a file
 /// </summary>
 /// <returns>True if it succesfull or false otherwise</returns>
 public override bool Work(Interface inter, Options option)
 {
     bool res = false;
     System.IO.Directory.CreateDirectory("./" + Name);
     string filename = "./" + Name + "/reader.cfg";
     IntPtr ptr_c = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RplethReaderStructure)));
     FileStream file = null;
     try
     {
         file = new FileStream(filename, FileMode.Create);
         Marshal.StructureToPtr(struc, ptr_c, false);
         for (int i = 0; i < Marshal.SizeOf(typeof(RplethReaderStructure)); i++)
         {
             file.WriteByte(Marshal.ReadByte(ptr_c, i));
         }
         inter.WriteMessage("\n\t\t\t***********************");
         inter.WriteMessage("\tThe configuration file has been successfully writing.");
         inter.WriteMessage("\t\t\t***********************\n");
         res = true;
     }
     catch (Exception ex)
     {
         inter.WriteError(ex.Message);
         inter.WriteMessage("\n\t\t\t***********************");
         inter.WriteMessage("\tThe configuration file hasn't been successfully writing.");
         inter.WriteMessage("\t\t\t***********************\n");
     }
     finally
     {
         if (file != null)
             file.Flush();
         file.Close();
         Marshal.FreeHGlobal(ptr_c);
     }
     return res;
 }
开发者ID:mbahar94,项目名称:rpleth-relay,代码行数:40,代码来源:RplethReaderConfiguration.cs

示例2: GetConfiguration

        /// <summary>
        /// Get the configuration from interface
        /// </summary>
        /// <returns>True if it successfull or false otherwise</returns>
        public override bool GetConfiguration(Options options, Interface inter)
        {
            bool res = true;
            try
            {
                inter.WriteMessage("\n*** Ethernet configuration ***\n");
                if (options.Mac == null)
                    struc.Mac = inter.GetByteTab("Enter the mac address of Rpleth", 6, ':', 16, false);
                else
                {
                    try
                    {
                        struc.Mac = StringHelper.StringToByteTab(options.Mac, 6, ':', 16);
                    }
                    catch (Exception)
                    {
                        struc.Mac = inter.GetByteTab("Enter the mac address of Rpleth", 6, ':', 16, false);
                    }
                }
                if (options.Dhcp == -1)
                    struc.Dhcp = inter.GetByte("Disable the dhcp ?\nEnter 0 to disable or 1 to enable.", false);
                else
                    struc.Dhcp = Convert.ToByte(options.Dhcp);
                if (struc.Dhcp == 0)
                {
                    if (options.Ip == null)
                        struc.Ip = inter.GetByteTab("Enter the ip address of Rpleth", 4, '.', false);
                    else
                    {
                        try
                        {
                            struc.Ip = StringHelper.StringToByteTab(options.Ip, 4, '.');
                        }
                        catch (Exception)
                        {
                            struc.Ip = inter.GetByteTab("Enter the ip address of Rpleth", 4, '.', false);
                        }
                    }

                    if (options.Subnet == null)
                        struc.Subnet = inter.GetByteTab("Enter the subnet address for Rpleth", 4, '.', false);
                    else
                    {
                        try
                        {
                            struc.Subnet = StringHelper.StringToByteTab(options.Subnet, 4, '.');
                        }
                        catch (Exception)
                        {
                            struc.Subnet = inter.GetByteTab("Enter the subnet address for Rpleth", 4, '.', false);
                        }
                    }
                    if (options.Gateway == null)
                        struc.Gateway = inter.GetByteTab("Enter the gateway address for Rpleth", 4, '.', false);
                    else
                    {
                        try
                        {
                            struc.Gateway = StringHelper.StringToByteTab(options.Gateway, 4, '.');
                        }
                        catch (Exception)
                        {
                            struc.Gateway = inter.GetByteTab("Enter the gateway address for Rpleth", 4, '.', false);
                        }
                    }
                }
                if (options.Port == -1)
                    struc.Port = Convert.ToUInt16(inter.GetUint("Enter the port number that listen Rpleth", false));
                else
                    struc.Port = Convert.ToUInt16(options.Port);
                inter.WriteMessage("\n*** Rpleth configuration ***\n");
                if (options.Welcome == null)
                    struc.Message = inter.GetMessage("Enter the welcome message of Rpleth", false);
                else
                    struc.Message = options.Welcome;
            }
            catch (Exception)
            {
                res = false;
            }

            return res;
        }
开发者ID:mbahar94,项目名称:rpleth-relay,代码行数:87,代码来源:RplethReaderConfiguration.cs

示例3: GetConfiguration

        /// <summary>
        /// Get the configuration from interface
        /// </summary>
        /// <returns>True if it successfull or false otherwise</returns>
        public override bool GetConfiguration(Options options, Interface inter)
        {
            bool res = true;
            try
            {
                inter.WriteMessage("\n*** Rpleth Target Information ***\n");

                while (struc.TargetIp == null)
                {
                    try
                    {
                        if (options.TargetIp == null)
                            struc.TargetIp = inter.GetByteTab("Enter the ip address of Rpleth", 4, '.', false, ref TargetIp);
                        else
                        {
                            struc.TargetIp = StringHelper.StringToByteTab(options.TargetIp, 4, '.');
                            options.TargetIp = null;
                        }
                    }
                    catch (Exception)
                    { }
                }

                while (struc.TargetPort == 0)
                {
                    try
                    {
                        if (options.TargetPort == -1)
                            struc.TargetPort = Convert.ToUInt16(inter.GetUint("Enter the port number that listen the Target Rpleth", false));
                        else
                        {

                            struc.TargetPort = Convert.ToUInt16(options.TargetPort);
                            options.TargetPort = -1;

                        }
                    }
                    catch (Exception)
                    { }

                    options.TargetPort = struc.TargetPort;
                }

                inter.WriteMessage("\n*** Rpleth configuration ***\n");

                if (options.Mac == null)
                    struc.Mac = inter.GetByteTab("Enter the mac address of Rpleth", 6, ':', 16, true);
                else
                {
                    try
                    {
                        struc.Mac = StringHelper.StringToByteTab(options.Mac, 6, ':', 16);
                    }
                    catch (Exception)
                    {
                        struc.Mac = inter.GetByteTab("Enter the mac address of Rpleth", 6, ':', 16, true);
                    }
                }

                if (options.Dhcp == -1)
                    struc.Dhcp = inter.GetByte("Disable the dhcp ?\nEnter 0 to disable or 1 to enable", true);
                else
                    struc.Dhcp = Convert.ToByte(options.Dhcp);

                if (options.Ip == null)
                    struc.Ip = inter.GetByteTab("Enter the ip address of Rpleth", 4, '.', true);
                else
                {
                    try
                    {
                        struc.Ip = StringHelper.StringToByteTab(options.Ip, 4, '.');
                    }
                    catch (Exception)
                    {
                        struc.Ip = inter.GetByteTab("Enter the ip address of Rpleth", 4, '.', true);
                    }
                }

                if (options.Subnet == null)
                    struc.Subnet = inter.GetByteTab("Enter the subnet address for Rpleth", 4, '.', true);
                else
                {
                    try
                    {
                        struc.Subnet = StringHelper.StringToByteTab(options.Subnet, 4, '.');
                    }
                    catch (Exception)
                    {
                        struc.Subnet = inter.GetByteTab("Enter the subnet address for Rpleth", 4, '.', true);
                    }
                }

                if (options.Gateway == null)
                    struc.Gateway = inter.GetByteTab("Enter the gateway address for Rpleth", 4, '.', true);
                else
                {
//.........这里部分代码省略.........
开发者ID:mbahar94,项目名称:rpleth-relay,代码行数:101,代码来源:RplethReaderConfigurationEthernet.cs


注:本文中的Interface.WriteMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。