當前位置: 首頁>>代碼示例>>C#>>正文


C# AMFWriter類代碼示例

本文整理匯總了C#中AMFWriter的典型用法代碼示例。如果您正苦於以下問題:C# AMFWriter類的具體用法?C# AMFWriter怎麽用?C# AMFWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AMFWriter類屬於命名空間,在下文中一共展示了AMFWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteData

        public void WriteData(AMFWriter writer, object data)
        {
            NameObjectCollectionBase collection = data as NameObjectCollectionBase;
            object[] attributes = collection.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), false);
            if (attributes != null  && attributes.Length > 0)
            {
                DefaultMemberAttribute defaultMemberAttribute = attributes[0] as DefaultMemberAttribute;
                PropertyInfo pi = collection.GetType().GetProperty(defaultMemberAttribute.MemberName, new Type[] { typeof(string) });
                if (pi != null)
                {
                    ASObject aso = new ASObject();
                    for (int i = 0; i < collection.Keys.Count; i++)
                    {
                        string key = collection.Keys[i];
                        object value = pi.GetValue(collection, new object[]{ key });
                        aso.Add(key, value);
                    }
                    writer.WriteByte(AMF3TypeCode.Object);
                    writer.WriteAMF3Object(aso);
                    return;
                }
            }

            //We could not access an indexer so write out as it is.
            writer.WriteByte(AMF3TypeCode.Object);
            writer.WriteAMF3Object(data);
        }
開發者ID:apakian,項目名稱:fluorinefx,代碼行數:27,代碼來源:AMF3NameObjectCollectionWriter.cs

示例2: WriteData

		public void WriteData(AMFWriter writer, object data) {
			if (data is INullable) {
				if ((data as INullable).IsNull) {
					writer.WriteAMF3Null();
					return;
				}
			}
			if (data is SqlByte) {
				writer.WriteAMF3Data(((SqlByte)data).Value);
				return;
			}
			if (data is SqlInt16) {
				writer.WriteAMF3Data(((SqlInt16)data).Value);
				return;
			}
			if (data is SqlInt32) {
				writer.WriteAMF3Data(((SqlInt32)data).Value);
				return;
			}
			if (data is SqlInt64) {
				writer.WriteAMF3Data(((SqlInt64)data).Value);
				return;
			}
			if (data is SqlSingle) {
				writer.WriteAMF3Data(((SqlSingle)data).Value);
				return;
			}
			if (data is SqlDouble) {
				writer.WriteAMF3Data(((SqlDouble)data).Value);
				return;
			}
			if (data is SqlDecimal) {
				writer.WriteAMF3Data(((SqlDecimal)data).Value);
				return;
			}
			if (data is SqlMoney) {
				writer.WriteAMF3Data(((SqlMoney)data).Value);
				return;
			}
			if (data is SqlDateTime) {
				writer.WriteAMF3Data(((SqlDateTime)data).Value);
				return;
			}
			if (data is SqlString) {
				writer.WriteAMF3String(((SqlString)data).Value);
				return;
			}
			if (data is SqlGuid) {
				writer.WriteAMF3Data(((SqlGuid)data).Value.ToString("D"));
				return;
			}
			if (data is SqlBoolean) {
				writer.WriteAMF3Bool(((SqlBoolean)data).Value);
				return;
			}
			string msg = string.Format("Could not find serializer for type {0}", data.GetType().FullName);
			if (_log.IsErrorEnabled)
				_log.Error(msg);
			throw new FluorineException(msg);
		}
開發者ID:GodLesZ,項目名稱:svn-dump,代碼行數:60,代碼來源:AMF3SqlTypesWriter.cs

示例3: WriteData

        public void WriteData(AMFWriter writer, object data)
        {
            var collection = data as NameObjectCollectionBase;
            var attributes = collection.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), false);
            if (attributes != null  && attributes.Length > 0)
            {
                var defaultMemberAttribute = attributes[0] as DefaultMemberAttribute;
                var pi = collection.GetType().GetProperty(defaultMemberAttribute.MemberName, new[] { typeof(string) });
                if (pi != null)
                {
                    var aso = new ASObject();
                    for (var i = 0; i < collection.Keys.Count; i++)
                    {
                        var key = collection.Keys[i];
                        var value = pi.GetValue(collection, new object[]{ key });
                        aso.Add(key, value);
                    }
                    writer.WriteASO(ObjectEncoding.AMF0, aso);
                    return;
                }
            }

            //We could not access an indexer so write out as it is.
            writer.WriteObject(ObjectEncoding.AMF0, data);
        }
開發者ID:mstaessen,項目名稱:fluorinefx,代碼行數:25,代碼來源:AMF0NameObjectCollectionWriter.cs

示例4: FlvWriter

        public FlvWriter(Stream stream, bool append)
        {
            _writer = new AMFWriter(stream);
            _append = append;
            if (_append)
            {
                if (stream.Length > 9 + 15)
                {
                    try
                    {
                        //Skip header
                        stream.Position = 9;
                        byte[] tagBuffer = new byte[15];
                        //previousTagSize
                        stream.Read(tagBuffer, 0, 4);
                        //start of flv tag
                        byte dataType = (byte)stream.ReadByte();
                        if (dataType == IOConstants.TYPE_METADATA)
                        {
                            _metaPosition = stream.Position - 1;
                            //body size
                            stream.Read(tagBuffer, 5, 3);
                            int bodySize = tagBuffer[5] << 16 | tagBuffer[6] << 8 | tagBuffer[7];
                            //timestamp
                            stream.Read(tagBuffer, 8, 4);
                            //streamid
                            stream.Read(tagBuffer, 12, 3);
                            byte[] buffer = new byte[bodySize];
                            stream.Read(buffer, 0, buffer.Length);
                            MemoryStream ms = new MemoryStream(buffer);
                            AMFReader input = new AMFReader(ms);
                            string onMetaData = input.ReadData() as string;//input.ReadString();
                            IDictionary properties = input.ReadData() as IDictionary;
                            if (properties.Contains("duration"))
                                _duration = System.Convert.ToInt32(properties["duration"]);
                            else
                            {
#if !SILVERLIGHT
                                log.Warn("Could not read Flv duration from metadata");
#endif
                            }
                        }
                        else
                        {
#if !SILVERLIGHT
                            log.Warn("Could not read Flv duration");
#endif
                        }
                    }
                    catch (Exception ex)
                    {
#if !SILVERLIGHT
                        log.Warn("Error reading Flv duration", ex);
#endif
                    }
                }
                stream.Seek(0, SeekOrigin.End);//Appending
            }
        }
開發者ID:Nicholi,項目名稱:fluorinefx-mod,代碼行數:59,代碼來源:FlvWriter.cs

示例5: WriteData

		public void WriteData(AMFWriter writer, object data) {
			if (data is byte[])
				data = new ByteArray(data as byte[]);

			if (data is ByteArray) {
				writer.WriteByteArray(data as ByteArray);
			}
		}
開發者ID:GodLesZ,項目名稱:svn-dump,代碼行數:8,代碼來源:AMF3ByteArrayWriter.cs

示例6: ByteArray

		/// <summary>
		/// Initializes a new instance of the ByteArray class.
		/// </summary>
		public ByteArray() {
			_memoryStream = new MemoryStream();
			AMFReader amfReader = new AMFReader(_memoryStream);
			AMFWriter amfWriter = new AMFWriter(_memoryStream);
			_dataOutput = new DataOutput(amfWriter);
			_dataInput = new DataInput(amfReader);
			_objectEncoding = ObjectEncoding.AMF3;
		}
開發者ID:GodLesZ,項目名稱:svn-dump,代碼行數:11,代碼來源:ByteArray.cs

示例7: WriteData

		public void WriteData(AMFWriter writer, object data)
		{
			if( data is IList )
			{
				IList list = data as IList;
				object[] array = new object[list.Count];
				list.CopyTo(array, 0);
				writer.WriteArray(ObjectEncoding.AMF0, array);
				return;
			}
#if !(SILVERLIGHT)
            IListSource listSource = data as IListSource;
            if (listSource != null)
            {
                IList list = listSource.GetList();
                object[] array = new object[list.Count];
                list.CopyTo(array, 0);
                writer.WriteArray(ObjectEncoding.AMF0, array);
                return;
            }
#endif
			if(data is IDictionary)
			{
				writer.WriteAssociativeArray(ObjectEncoding.AMF0, data as IDictionary);
				return;
			}
			if(data is Exception)
			{
				writer.WriteASO(ObjectEncoding.AMF0, new ExceptionASO(data as Exception) );
				return;
			}
            if (data is IEnumerable)
            {
                List<object> tmp = new List<object>();
                foreach (object element in (data as IEnumerable))
                {
                    tmp.Add(element);
                }
                writer.WriteArray(ObjectEncoding.AMF0, tmp.ToArray());
                return;
            }
			writer.WriteObject(ObjectEncoding.AMF0, data);
		}
開發者ID:ByteSempai,項目名稱:Ubiquitous,代碼行數:43,代碼來源:AMF0ObjectWriter.cs

示例8: WriteData

 public void WriteData(AMFWriter writer, object data)
 {
     writer.WriteByte(AMF0TypeCode.String);
     writer.WriteUTF( new String( (char)data, 1)  );
 }
開發者ID:mstaessen,項目名稱:fluorinefx,代碼行數:5,代碼來源:AMF0CharWriter.cs

示例9: WriteData

		public void WriteData(AMFWriter writer, object data) {
			writer.WriteByte(AMF3TypeCode.Object);
			writer.WriteAMF3Object(data);
		}
開發者ID:GodLesZ,項目名稱:svn-dump,代碼行數:4,代碼來源:AMF3ASObjectWriter.cs

示例10: WriteData

		public void WriteData(AMFWriter writer, object data)
		{
			writer.WriteAMF3String(data as string);
		}
開發者ID:Boreeas,項目名稱:LoLNotes,代碼行數:4,代碼來源:AMF3StringWriter.cs

示例11: WriteData

		public void WriteData(AMFWriter writer, object data)
		{
			writer.WriteByte(AMF0TypeCode.Number);
			double dbl = (double)Convert.ToInt32(data);
			writer.WriteDouble(dbl);
		}
開發者ID:ByteSempai,項目名稱:Ubiquitous,代碼行數:6,代碼來源:AMF0EnumWriter.cs

示例12: Serialize

        public void Serialize(AMFWriter writer)
		{
            writer.WriteString(this.Name);
            writer.WriteString(this.Path);
            writer.WriteData(ObjectEncoding.AMF0, _attributes);
		}
開發者ID:Nicholi,項目名稱:fluorinefx-mod,代碼行數:6,代碼來源:SharedObject.cs

示例13: ByteArray

		/// <summary>
		/// Initializes a new instance of the ByteArray class.
		/// </summary>
        /// <param name="buffer">The array of unsigned bytes from which to create the current ByteArray.</param>
        public ByteArray(byte[] buffer)
		{
			_memoryStream = new MemoryStream();
			_memoryStream.Write(buffer, 0, buffer.Length);
			_memoryStream.Position = 0;
			AMFReader amfReader = new AMFReader(_memoryStream);
			AMFWriter amfWriter = new AMFWriter(_memoryStream);
			_dataOutput = new DataOutput(amfWriter);
			_dataInput = new DataInput(amfReader);
            _objectEncoding = ObjectEncoding.AMF3;
		}
開發者ID:ResQue1980,項目名稱:LoLTeamChecker,代碼行數:15,代碼來源:ByteArray.cs

示例14: InjectMetaData

		/// <summary>
		/// Injects metadata (other than Cue points) into a tag.
		/// </summary>
		/// <param name="meta">Metadata.</param>
		/// <param name="tag">Tag.</param>
		/// <returns></returns>
		private ITag InjectMetaData(MetaData meta, ITag tag) {
			MemoryStream ms = new MemoryStream();
			AMFWriter writer = new AMFWriter(ms);
			writer.WriteData(ObjectEncoding.AMF0, "onMetaData");
			writer.WriteData(ObjectEncoding.AMF0, meta);
			byte[] buffer = ms.ToArray();
			return new Tag(IOConstants.TYPE_METADATA, 0, buffer.Length, buffer, tag.PreviousTagSize);
		}
開發者ID:GodLesZ,項目名稱:svn-dump,代碼行數:14,代碼來源:MetaService.cs

示例15: WriteData

		public void WriteData(AMFWriter writer, object data)
		{
			int value = Convert.ToInt32(data);
			writer.WriteAMF3Int(value);
		}
開發者ID:DarkActive,項目名稱:daFluorineFx,代碼行數:5,代碼來源:AMF3IntWriter.cs


注:本文中的AMFWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。