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


C# AMFWriter.WriteAMF3Object方法代码示例

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


在下文中一共展示了AMFWriter.WriteAMF3Object方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
			writer.WriteByte(AMF3TypeCode.Object);
			writer.WriteAMF3Object(data);
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:4,代码来源:AMF3ASObjectWriter.cs

示例3: WriteData

		public void WriteData(AMFWriter writer, object data)
		{
            ASObject aso = TypeHelper.ConvertDataSetToASO(data as DataSet, false);
			writer.WriteByte(AMF3TypeCode.Object);
			writer.WriteAMF3Object(aso);
		}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:6,代码来源:AMF3DataSetWriter.cs

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