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


C# TypeWrapper.GetFieldRawTypeAnnotations方法代码示例

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


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

示例1: WriteClass


//.........这里部分代码省略.........
							}
							if (throws.types != null)
							{
								foreach (Type ex in throws.types)
								{
									attrib.Add(ClassLoaderWrapper.GetWrapperFromType(ex).Name.Replace('.', '/'));
								}
							}
							m.AddAttribute(attrib);
						}
						if (mb.IsDefined(JVM.Import(typeof(ObsoleteAttribute)), false)
							// HACK the instancehelper methods are marked as Obsolete (to direct people toward the ikvm.extensions methods instead)
							// but in the Java world most of them are not deprecated (and to keep the Japi results clean we need to reflect this)
							&& (!mb.Name.StartsWith("instancehelper_")
								|| mb.DeclaringType.FullName != "java.lang.String"
							// the Java deprecated methods actually have two Obsolete attributes
								|| GetObsoleteCount(mb) == 2))
						{
							m.AddAttribute(new DeprecatedAttribute(writer));
						}
						CustomAttributeData attr = GetAnnotationDefault(mb);
						if (attr != null)
						{
							m.AddAttribute(new AnnotationDefaultClassFileAttribute(writer, GetAnnotationDefault(writer, attr.ConstructorArguments[0])));
						}
						if (includeParameterNames)
						{
							MethodParametersEntry[] mp = tw.GetMethodParameters(mw);
							if (mp == MethodParametersEntry.Malformed)
							{
								m.AddAttribute(new MethodParametersAttribute(writer, null, null));
							}
							else if (mp != null)
							{
								ushort[] names = new ushort[mp.Length];
								ushort[] flags = new ushort[mp.Length];
								for (int i = 0; i < names.Length; i++)
								{
									if (mp[i].name != null)
									{
										names[i] = writer.AddUtf8(mp[i].name);
									}
									flags[i] = mp[i].flags;
								}
								m.AddAttribute(new MethodParametersAttribute(writer, names, flags));
							}
						}
					}
					string sig = tw.GetGenericMethodSignature(mw);
					if (sig != null)
					{
						m.AddAttribute(writer.MakeStringAttribute("Signature", sig));
					}
					AddAnnotations(writer, m, mw.GetMethod());
					AddParameterAnnotations(writer, m, mw.GetMethod());
					AddTypeAnnotations(writer, m, tw, tw.GetMethodRawTypeAnnotations(mw));
				}
			}
			bool hasSerialVersionUID = false;
			foreach (FieldWrapper fw in tw.GetFields())
			{
				if (!fw.IsHideFromReflection)
				{
					bool isSerialVersionUID = includeSerialVersionUID && fw.Name == "serialVersionUID" && fw.FieldTypeWrapper == PrimitiveTypeWrapper.LONG;
					hasSerialVersionUID |= isSerialVersionUID;
					if (fw.IsPublic || fw.IsProtected || isSerialVersionUID || includeNonPublicMembers)
					{
						object constant = null;
						if (fw.GetField() != null && fw.GetField().IsLiteral && (fw.FieldTypeWrapper.IsPrimitive || fw.FieldTypeWrapper == CoreClasses.java.lang.String.Wrapper))
						{
							constant = fw.GetField().GetRawConstantValue();
							if (fw.GetField().FieldType.IsEnum)
							{
								constant = EnumHelper.GetPrimitiveValue(EnumHelper.GetUnderlyingType(fw.GetField().FieldType), constant);
							}
						}
						FieldOrMethod f = writer.AddField(fw.Modifiers, fw.Name, fw.Signature.Replace('.', '/'), constant);
						string sig = tw.GetGenericFieldSignature(fw);
						if (sig != null)
						{
							f.AddAttribute(writer.MakeStringAttribute("Signature", sig));
						}
						if (fw.GetField() != null && fw.GetField().IsDefined(JVM.Import(typeof(ObsoleteAttribute)), false))
						{
							f.AddAttribute(new DeprecatedAttribute(writer));
						}
						AddAnnotations(writer, f, fw.GetField());
						AddTypeAnnotations(writer, f, tw, tw.GetFieldRawTypeAnnotations(fw));
					}
				}
			}
			if (includeSerialVersionUID && !hasSerialVersionUID && IsSerializable(tw))
			{
				// class is serializable but doesn't have an explicit serialVersionUID, so we add the field to record
				// the serialVersionUID as we see it (mainly to make the Japi reports more realistic)
				writer.AddField(Modifiers.Private | Modifiers.Static | Modifiers.Final, "serialVersionUID", "J", SerialVersionUID.Compute(tw));
			}
			AddMetaAnnotations(writer, tw);
			writer.Write(stream);
		}
开发者ID:Semogj,项目名称:ikvm-fork,代码行数:101,代码来源:StubGenerator.cs


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