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


C# AMFWriter.WriteAMF3AssociativeArray方法代碼示例

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


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

示例1: WriteData

 public void WriteData(AMFWriter writer, object data)
 {
     if (data is ArrayCollection)
     {
         writer.WriteByte(AMF3TypeCode.Object);
         writer.WriteAMF3Object(data);
         return;
     }
     //TODO: configure somehow Vector support
     /*
     if (CollectionUtils.IsGenericListType(data.GetType()))
     {
         Type itemType = ReflectionUtils.GetListItemType(data.GetType());
         switch (Type.GetTypeCode(itemType))
         {
             case TypeCode.Int32:
                 writer.WriteByte(AMF3TypeCode.IntVector);
                 writer.WriteAMF3IntVector(data as IList<int>);
                 return;
             case TypeCode.UInt32:
                 writer.WriteByte(AMF3TypeCode.UIntVector);
                 writer.WriteAMF3UIntVector(data as IList<uint>);
                 return;
             case TypeCode.Double:
                 writer.WriteByte(AMF3TypeCode.NumberVector);
                 writer.WriteAMF3DoubleVector(data as IList<double>);
                 return;
             case TypeCode.String:
                 writer.WriteByte(AMF3TypeCode.ObjectVector);
                 writer.WriteAMF3ObjectVector(data as IList<string>);
                 return;
             case TypeCode.Boolean:
                 writer.WriteByte(AMF3TypeCode.ObjectVector);
                 writer.WriteAMF3ObjectVector(data as IList<bool>);
                 return;
             default:
                 writer.WriteByte(AMF3TypeCode.ObjectVector);
                 writer.WriteAMF3ObjectVector(data as IList);
                 return;
         }
     }
     */
     var list = data as IList;
     if (list != null )
     {
         //http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001104.html#270405
         //http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001105.html#268711
         if( writer.UseLegacyCollection )
         {
             writer.WriteByte(AMF3TypeCode.Array);
             writer.WriteAMF3Array(list);
         }
         else
         {
             writer.WriteByte(AMF3TypeCode.Object);
             object value = new ArrayCollection(list);
             writer.WriteAMF3Object(value);
         }
         return;
     }
     #if !(SILVERLIGHT)
     var listSource = data as IListSource;
     if (listSource != null)
     {
         if (writer.UseLegacyCollection)
         {
             writer.WriteByte(AMF3TypeCode.Array);
             writer.WriteAMF3Array(listSource.GetList());
         }
         else
         {
             writer.WriteByte(AMF3TypeCode.Object);
             object value = new ArrayCollection(listSource.GetList());
             writer.WriteAMF3Object(value);
         }
         return;
     }
     #endif
     var dictionary = data as IDictionary;
     if (dictionary != null)
     {
         //writer.WriteByte(AMF3TypeCode.Object);
         //writer.WriteAMF3Object(data);
         writer.WriteByte(AMF3TypeCode.Array);
         writer.WriteAMF3AssociativeArray(dictionary);
         return;
     }
     if(data is Exception)
     {
         writer.WriteByte(AMF3TypeCode.Object);
         if (writer.UseLegacyThrowable)
             writer.WriteAMF3Object(new ASExceptionObject(data as Exception) );
         else
             writer.WriteAMF3Object(data);
         return;
     }
     if( data is IExternalizable )
     {
         writer.WriteByte(AMF3TypeCode.Object);
         writer.WriteAMF3Object(data);
//.........這裏部分代碼省略.........
開發者ID:mstaessen,項目名稱:fluorinefx,代碼行數:101,代碼來源:AMF3ObjectWriter.cs


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