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


C# IActionScriptSerializer类代码示例

本文整理汇总了C#中IActionScriptSerializer的典型用法代码示例。如果您正苦于以下问题:C# IActionScriptSerializer类的具体用法?C# IActionScriptSerializer怎么用?C# IActionScriptSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AMFDataOutput

        /// <summary>
        /// Creates an AMF data output writer.
        /// Initially uses the <see cref="AMFObjectEncoding.AMF0" /> object encoding.
        /// </summary>
        /// <param name="stream">The output stream</param>
        /// <param name="serializer">The ActionScript serializer to use for object serialization</param>
        public AMFDataOutput(Stream stream, IActionScriptSerializer serializer)
        {
            this.stream = stream;
            this.serializer = serializer;

            objectEncoding = AMFObjectEncoding.AMF0;
            utf8Encoding = new UTF8Encoding(false, false);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:14,代码来源:AMFDataOutput.cs

示例2: SetUp

        public override void SetUp()
        {
            base.SetUp();

            stream = new MemoryStream();
            serializer = Mocks.CreateMock<IActionScriptSerializer>();
            input = new AMFDataInput(stream, serializer);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:8,代码来源:AMFDataInputTest.cs

示例3: AMFDataInput

        /// <summary>
        /// Creates an AMF data input reader.
        /// Initially uses the <see cref="AMFObjectEncoding.AMF0" /> object encoding,
        /// switches modes automatically if <see cref="AMFObjectEncoding.AMF3" /> data is encountered.
        /// </summary>
        /// <param name="stream">The input stream</param>
        /// <param name="serializer">The ActionScript serializer to use for object serialization</param>
        public AMFDataInput(Stream stream, IActionScriptSerializer serializer)
        {
            this.stream = stream;
            this.serializer = serializer;

            objectReader = new AMF0ObjectReader(this);
            utf8Encoding = new UTF8Encoding(false, false);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:15,代码来源:AMFDataInput.cs

示例4: WriteStringData

 void IASValueVisitor.VisitXml(IActionScriptSerializer serializer, string xmlString)
 {
     output.WriteByte((byte)AMF3ObjectTypeCode.Xml);
     WriteStringData(xmlString);
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:5,代码来源:AMF3ObjectWriter.cs

示例5: AMFException

        void IASValueVisitor.VisitObject(IActionScriptSerializer serializer, ASClass @class, IEnumerable<IASValue> memberValues,
            IEnumerable<KeyValuePair<string, IASValue>> dynamicProperties,
            IExternalizable externalizableValue)
        {
            int objectReferenceId = AddCurrentValueToCache(AMF3ObjectTypeCode.Object);

            output.WriteByte((byte)AMF3ObjectTypeCode.Object);

            // Look for a suitable existing class definition in the cache.
            int classDefinitionId;
            if (classDefinitionCache.TryGetValue(@class, out classDefinitionId))
            {
                // Use class definition reference.
                output.WriteVWInt29(classDefinitionId * 4 + 1);
            }
            else
            {
                // Include class definition inline and add it to the cache.
                classDefinitionCache.Add(@class, objectReferenceId);

                output.WriteVWInt29(@class.MemberNames.Count * 16 + (int)@class.Layout * 4 + 3);
                WriteStringData(@class.ClassAlias);

                foreach (string memberName in @class.MemberNames)
                {
                    if (String.IsNullOrEmpty(memberName))
                        throw new AMFException(ExceptionPrefix + "Cannot serialize an object with a null or empty member name.");

                    WriteStringData(memberName);
                }
            }

            if (@class.Layout == ASClassLayout.Externalizable)
            {
                if (externalizableValue == null)
                    throw new AMFException(ExceptionPrefix + "The class layout is Externalizable but the object does not provide an ExternalizableValue.");

                externalizableValue.WriteExternal(output);
            }
            else
            {
                // Write the members first as a sequence of values.
                int memberCount = @class.MemberNames.Count;
                int memberIndex = 0;
                foreach (IASValue memberValue in memberValues)
                {
                    if (memberIndex == memberCount)
                        throw new AMFException(ExceptionPrefix + "The number of member values provided by the object is greater than was indicated by its class.");

                    WriteObject(memberValue);
                    memberIndex += 1;
                }

                if (memberIndex != memberCount)
                    throw new AMFException(ExceptionPrefix + "The number of member values provided by the object is less than was indicated by its class.");

                if (@class.Layout == ASClassLayout.Dynamic)
                {
                    // Write dynamic key/value pairs.
                    foreach (KeyValuePair<string, IASValue> pair in dynamicProperties)
                    {
                        if (String.IsNullOrEmpty(pair.Key))
                            throw new AMFException(ExceptionPrefix + "Cannot serialize an object with a null or empty string key.");

                        WriteStringData(pair.Key);
                        WriteObject(pair.Value);
                    }

                    // Terminate with empty string.
                    WriteStringData("");
                }
            }
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:73,代码来源:AMF3ObjectWriter.cs

示例6: AMFException

        void IASValueVisitor.VisitByteArray(IActionScriptSerializer serializer, int length, IEnumerable<ArraySegment<byte>> segments)
        {
            // Serialize the value as a plain old array of numbers for AMF0.
            AddCurrentValueToCache();

            output.WriteByte((byte)AMF0ObjectTypeCode.Array);
            output.WriteInt(length);

            if (length != 0)
            {
                int bytesRemaining = length;

                foreach (ArraySegment<byte> bytes in segments)
                {
                    if (bytesRemaining < bytes.Count)
                        throw new AMFException(ExceptionPrefix + "The byte array provided more bytes than were indicated by its length.");

                    bytesRemaining -= bytes.Count;

                    int offset = bytes.Offset;
                    int count = bytes.Count;
                    byte[] array = bytes.Array;

                    while (count-- > 0)
                        WriteNumber(array[offset++]);
                }

                if (bytesRemaining != 0)
                    throw new AMFException(ExceptionPrefix + "The byte array did not provide as many bytes as were indicated by its length.");
            }
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:31,代码来源:AMF0ObjectWriter.cs

示例7: AcceptVisitor

 /// <inheritdoc />
 public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
 {
     visitor.VisitInt29(serializer, value);
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:5,代码来源:ASInt29.cs

示例8: GetServiceForMessage

        /// <inheritdoc />
        public IService GetServiceForMessage(IActionScriptSerializer serializer, IMessage message)
        {
            if (serializer == null)
                throw new ArgumentNullException("serializer");
            if (message == null)
                throw new ArgumentNullException("message");

            return UncheckedGetServiceForMessage(serializer, message);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:10,代码来源:DefaultMessageBroker.cs

示例9:

 void IASValueVisitor.VisitBoolean(IActionScriptSerializer serializer, bool value)
 {
     output.WriteByte(value ? (byte)AMF3ObjectTypeCode.True : (byte)AMF3ObjectTypeCode.False);
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:AMF3ObjectWriter.cs

示例10: AcceptVisitor

 /// <inheritdoc />
 public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
 {
     ArraySegment<byte>[] segments = new ArraySegment<byte>[] { bytes };
     visitor.VisitByteArray(serializer, bytes.Count, segments);
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:6,代码来源:ASByteArray.cs

示例11: AcceptVisitor

        /// <inheritdoc />
        public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
        {
            ThrowIfNotInitialized();

            mapper.AcceptVisitor(serializer, nativeArray, visitor);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:ASNativeArray.cs

示例12: AcceptVisitor

        /// <inheritdoc />
        public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
        {
            ThrowIfNotInitialized();

            visitor.VisitObject(serializer, @class, memberValues, dynamicProperties, null);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:ASObject.cs

示例13:

 void IASValueVisitor.VisitBoolean(IActionScriptSerializer serializer, bool value)
 {
     output.WriteByte((byte)AMF0ObjectTypeCode.Boolean);
     output.WriteBoolean(value);
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:5,代码来源:AMF0ObjectWriter.cs

示例14: WriteNull

 void IASValueVisitor.VisitNull(IActionScriptSerializer serializer)
 {
     WriteNull();
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:AMF3ObjectWriter.cs

示例15: AcceptVisitor

        /// <inheritdoc />
        public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
        {
            ThrowIfNotInitialized();

            visitor.VisitObject(serializer, @class,
                EmptyArray<IASValue>.Instance, EmptyDictionary<string, IASValue>.Instance,
                externalizableValue);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:9,代码来源:ASExternalizableObject.cs


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