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


C# AttributeEncoder.EncodeNamedPropertyArgument方法代碼示例

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


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

示例1: Emit

		public void Emit ()
		{
			if (RootContext.Target == Target.Module) {
				module_target_attrs = new AssemblyAttributesPlaceholder (module, name);
				module_target_attrs.CreateType ();
				module_target_attrs.DefineType ();
				module_target_attrs.Define ();
				module.AddCompilerGeneratedClass (module_target_attrs);
			} else if (added_modules != null) {
				ReadModulesAssemblyAttributes ();
			}

			module.Emit ();

			if (module.HasExtensionMethod) {
				var pa = Compiler.PredefinedAttributes.Extension;
				if (pa.IsDefined) {
					SetCustomAttribute (pa.Constructor, AttributeEncoder.Empty);
				}
			}

			if (!wrap_non_exception_throws_custom) {
				PredefinedAttribute pa = Compiler.PredefinedAttributes.RuntimeCompatibility;
				if (pa.IsDefined && pa.ResolveBuilder ()) {
					var prop = pa.GetProperty ("WrapNonExceptionThrows", TypeManager.bool_type, Location.Null);
					if (prop != null) {
						AttributeEncoder encoder = new AttributeEncoder (false);
						encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (true, Location.Null));
						SetCustomAttribute (pa.Constructor, encoder.ToArray ());
					}
				}
			}

			if (declarative_security != null) {

				MethodInfo add_permission = typeof (AssemblyBuilder).GetMethod ("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic);
				object builder_instance = Builder;

				try {
					// Microsoft runtime hacking
					if (add_permission == null) {
						var assembly_builder = typeof (AssemblyBuilder).Assembly.GetType ("System.Reflection.Emit.AssemblyBuilderData");
						add_permission = assembly_builder.GetMethod ("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic);

						FieldInfo fi = typeof (AssemblyBuilder).GetField ("m_assemblyData", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
						builder_instance = fi.GetValue (Builder);
					}

					var args = new PermissionSet [3];
					declarative_security.TryGetValue (SecurityAction.RequestMinimum, out args [0]);
					declarative_security.TryGetValue (SecurityAction.RequestOptional, out args [1]);
					declarative_security.TryGetValue (SecurityAction.RequestRefuse, out args [2]);
					add_permission.Invoke (builder_instance, args);
				} catch {
					Report.RuntimeMissingSupport (Location.Null, "assembly permission setting");
				}
			}

			CheckReferencesPublicToken ();

			SetEntryPoint ();
		}
開發者ID:Tak,項目名稱:monodevelop-novell,代碼行數:62,代碼來源:assembly.cs


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