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


C# XmlTextWriter.WriteBinHex方法代码示例

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


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

示例1: ExportStrategy

    public static bool ExportStrategy(string fileName, IList strategyList)
    {
        FileStream fileStream = null;
        bool bRet = false;
        try
        {
            fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
            fileStream.SetLength(0L);
            XmlTextWriter writer = new XmlTextWriter(fileStream, Encoding.Default);
            byte[] strategyBytes;

            //声明
            writer.WriteStartDocument();
            writer.WriteWhitespace("\n");

            writer.WriteStartElement("StrategyList");
            foreach (Strategy strategy in strategyList)
            {                
                writer.WriteWhitespace("\n\t");
                writer.WriteStartElement("Strategy");
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Name", strategy.SecurityObject.Name);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Comment", strategy.SecurityObject.Comment);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Event", ((int)strategy.Event).ToString());
                writer.WriteWhitespace("\n\t\t");

                writer.WriteStartElement("Automation");
                strategyBytes = AdminServer.TheInstance.AutomationManager.Save(strategy.Automation);
                writer.WriteBinHex(strategyBytes, 0, strategyBytes.Length);
                writer.WriteEndElement();
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Enable", strategy.Enabled ? "1" : "0");
                writer.WriteWhitespace("\n\t");

                writer.WriteEndElement();
                
            }
            writer.WriteWhitespace("\n");
            writer.WriteEndElement();

            writer.Flush();
            bRet = true;
        }
        catch (Exception)
        {
            bRet = false;
        }
        finally
        {
            if (fileStream != null) fileStream.Close();
        }
        return bRet;
    }
开发者ID:viticm,项目名称:pap2,代码行数:59,代码来源:WebUtil.cs

示例2: ExportScheduledTask

    public static bool ExportScheduledTask(string fileName, IList taskList)
    {
        FileStream fileStream = null;
        bool bRet = false;
        try
        {
            fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
            fileStream.SetLength(0L);
            XmlTextWriter writer = new XmlTextWriter(fileStream, Encoding.Default);            
            IFormatter formatter = new BinaryFormatter();
            MemoryStream taskDataStream;

            //声明
            writer.WriteStartDocument();
            writer.WriteWhitespace("\n");

            writer.WriteStartElement("TaskList");
            foreach (ScheduledTaskUnit taskUnit in taskList)
            {
                taskDataStream = new MemoryStream();
                formatter.Serialize(taskDataStream, taskUnit.Task);

                writer.WriteWhitespace("\n\t");
                writer.WriteStartElement("Task");
                writer.WriteWhitespace("\n\t\t");
                
                writer.WriteElementString("Name", taskUnit.Task.SecurityObject.Name);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Comment", taskUnit.Task.SecurityObject.Comment);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteStartElement("Data");
                writer.WriteBinHex(taskDataStream.ToArray(), 0, (int)taskDataStream.Length);
                writer.WriteEndElement();
                writer.WriteWhitespace("\n\t");

                writer.WriteEndElement();
            }

            writer.WriteWhitespace("\n");
            writer.WriteEndElement();

            writer.Flush();            
        }
        catch (Exception)
        {
            bRet = false;
        }
        finally
        {
            if (fileStream != null) fileStream.Close();
        }
        return bRet;
    }
开发者ID:viticm,项目名称:pap2,代码行数:55,代码来源:WebUtil.cs


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