public AssemblyReference ToReference(Assembly ownerAssembly) { switch (_knownCode) { case BamlKnownAssemblyCode.MsCorLib: return(AssemblyReference.GetMscorlib(ownerAssembly)); case BamlKnownAssemblyCode.System: return(AssemblyReference.GetSystem(ownerAssembly)); case BamlKnownAssemblyCode.PresentationCore: return(ToReference("PresentationCore", ownerAssembly)); case BamlKnownAssemblyCode.PresentationFramework: return(ToReference("PresentationFramework", ownerAssembly)); case BamlKnownAssemblyCode.WindowsBase: return(ToReference("WindowsBase", ownerAssembly)); default: return(null); } }
public override void Build(CustomAttribute customAttribute) { var arguments = new List <TypeSignature>(2); // Ctor arguments var ctorArguments = customAttribute.CtorArguments; ctorArguments.Clear(); // Bindable arguments.Add(TypeReference.GetPrimitiveType(PrimitiveTypeCode.Boolean, customAttribute.Assembly)); ctorArguments.Add( new CustomAttributeTypedArgument( _bindable, TypeReference.GetPrimitiveType(PrimitiveTypeCode.Boolean, customAttribute.Assembly))); // Direction if (_direction.HasValue) { arguments.Add(new TypeReference("BindingDirection", "System.ComponentModel", AssemblyReference.GetSystem(customAttribute.Assembly), true)); ctorArguments.Add( new CustomAttributeTypedArgument( (int)_direction, TypeReference.GetPrimitiveType(PrimitiveTypeCode.Int32, customAttribute.Assembly))); } // Named arguments customAttribute.NamedArguments.Clear(); // Constructor customAttribute.Constructor = new MethodReference( ".ctor", new TypeReference( "BindableAttribute", "System.ComponentModel", AssemblyReference.GetMscorlib(customAttribute.Assembly)), new CallSite( true, false, MethodCallingConvention.Default, TypeReference.GetPrimitiveType(PrimitiveTypeCode.Void, customAttribute.Assembly), ReadOnlyList <TypeSignature> .Create(arguments), 0, 0)); }