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


C# LLSD.AsString方法代码示例

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


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

示例1: SerializeXmlElement

        public static void SerializeXmlElement(XmlTextWriter writer, LLSD data)
        {
            switch (data.Type)
            {
                case LLSDType.Unknown:
                    writer.WriteStartElement(String.Empty, "undef", String.Empty);
                    writer.WriteEndElement();
                    break;
                case LLSDType.Boolean:
                    writer.WriteStartElement(String.Empty, "boolean", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.Integer:
                    writer.WriteStartElement(String.Empty, "integer", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.Real:
                    writer.WriteStartElement(String.Empty, "real", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.String:
                    writer.WriteStartElement(String.Empty, "string", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.UUID:
                    writer.WriteStartElement(String.Empty, "uuid", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.Date:
                    writer.WriteStartElement(String.Empty, "date", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.URI:
                    writer.WriteStartElement(String.Empty, "uri", String.Empty);
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.Binary:
                    writer.WriteStartElement(String.Empty, "binary", String.Empty);
                        writer.WriteStartAttribute(String.Empty, "encoding", String.Empty);
                        writer.WriteString("base64");
                        writer.WriteEndAttribute();
                    writer.WriteString(data.AsString());
                    writer.WriteEndElement();
                    break;
                case LLSDType.Map:
                    LLSDMap map = (LLSDMap)data;
                    writer.WriteStartElement(String.Empty, "map", String.Empty);
                    foreach (KeyValuePair<string, LLSD> kvp in map)
                    {
                        writer.WriteStartElement(String.Empty, "key", String.Empty);
                        writer.WriteString(kvp.Key);
                        writer.WriteEndElement();

                        SerializeXmlElement(writer, kvp.Value);
                    }
                    writer.WriteEndElement();
                    break;
                case LLSDType.Array:
                    LLSDArray array = (LLSDArray)data;
                    writer.WriteStartElement(String.Empty, "array", String.Empty);
                    for (int i = 0; i < array.Count; i++)
                    {
                        SerializeXmlElement(writer, array[i]);
                    }
                    writer.WriteEndElement();
                    break;
            }
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:75,代码来源:XmlLLSD.cs

示例2: SerializeNotationElementFormatted

        private static void SerializeNotationElementFormatted(StringWriter writer, string intend, LLSD llsd)
        {
            switch (llsd.Type)
            {
                case LLSDType.Unknown:
                    writer.Write(undefNotationValue);
                    break;
                case LLSDType.Boolean:
                    if (llsd.AsBoolean())
                        writer.Write(trueNotationValueTwo);
                    else
                        writer.Write(falseNotationValueTwo);
                    break;
                case LLSDType.Integer:
                    writer.Write(integerNotationMarker);
                    writer.Write(llsd.AsString());
                    break;
                case LLSDType.Real:
                    writer.Write(realNotationMarker);
                    writer.Write(llsd.AsString());
                    break;
                case LLSDType.UUID:
                    writer.Write(uuidNotationMarker);
                    writer.Write(llsd.AsString());
                    break;
                case LLSDType.String:
                    writer.Write(singleQuotesNotationMarker);
                    writer.Write(EscapeCharacter(llsd.AsString(), singleQuotesNotationMarker));
                    writer.Write(singleQuotesNotationMarker);
                    break;
                case LLSDType.Binary:
                    writer.Write(binaryNotationMarker);
                    writer.Write("64");
                    writer.Write(doubleQuotesNotationMarker);
                    writer.Write(llsd.AsString());
                    writer.Write(doubleQuotesNotationMarker);
                    break;
                case LLSDType.Date:
                    writer.Write(dateNotationMarker);
                    writer.Write(doubleQuotesNotationMarker);
                    writer.Write(llsd.AsString());
                    writer.Write(doubleQuotesNotationMarker);
                    break;
                case LLSDType.URI:
                    writer.Write(uriNotationMarker);
                    writer.Write(doubleQuotesNotationMarker);
                    writer.Write(EscapeCharacter(llsd.AsString(), doubleQuotesNotationMarker));
                    writer.Write(doubleQuotesNotationMarker);
                    break;
                case LLSDType.Array:
                    SerializeNotationArrayFormatted(writer, intend + baseIntend, (LLSDArray)llsd);
                    break;
                case LLSDType.Map:
                    SerializeNotationMapFormatted(writer, intend + baseIntend, (LLSDMap)llsd);
                    break;
                default:
                    throw new LLSDException("Notation serialization: Not existing element discovered.");

            }
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:60,代码来源:NotationLLSD.cs


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