Example #1
0
        public static PropVariant Create(ref object value, ComInterfaceType interfaceType)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            var result = new PropVariant();

            switch (interfaceType)
            {
            case ComInterfaceType.InterfaceIsIDispatch:
                result.SetByRefValue(Marshal.GetIDispatchForObject(value), VarType.Dispatch);
                break;

            case ComInterfaceType.InterfaceIsIUnknown:
                result.SetByRefValue(Marshal.GetIUnknownForObject(value), VarType.Unknown);
                break;

            default:
                throw new NotSupportedException("Only IDispatch and IUnknown objects are supported.");
            }

            return(result);
        }
Example #2
0
        internal void DecodeInterfaceTypeAttribute(AttributeSyntax node, DiagnosticBag diagnostics)
        {
            Debug.Assert(!this.HasErrors);

            TypedConstant ctorArgument = this.CommonConstructorArguments[0];

            Debug.Assert(ctorArgument.Kind == TypedConstantKind.Enum || ctorArgument.Kind == TypedConstantKind.Primitive);

            ComInterfaceType interfaceType = ctorArgument.Kind == TypedConstantKind.Enum ?
                                             ctorArgument.DecodeValue <ComInterfaceType>(SpecialType.System_Enum) :
                                             (ComInterfaceType)ctorArgument.DecodeValue <short>(SpecialType.System_Int16);

            switch (interfaceType)
            {
            case Cci.Constants.ComInterfaceType_InterfaceIsDual:
            case Cci.Constants.ComInterfaceType_InterfaceIsIDispatch:
            case ComInterfaceType.InterfaceIsIInspectable:
            case ComInterfaceType.InterfaceIsIUnknown:
                break;

            default:
                // CS0591: Invalid value for argument to '{0}' attribute
                CSharpSyntaxNode attributeArgumentSyntax = this.GetAttributeArgumentSyntax(0, node);
                diagnostics.Add(ErrorCode.ERR_InvalidAttributeArgument, attributeArgumentSyntax.Location, node.GetErrorDisplayName());
                break;
            }
        }
Example #3
0
        public static CustomAttributeBuilder GetBuilderForInterfaceType(ComInterfaceType interfaceType)
        {
            ConstructorInfo ctorInterfaceType = typeof(InterfaceTypeAttribute).GetConstructor(
                BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                null,
                new Type[] { typeof(ComInterfaceType) },
                null);

            return(new CustomAttributeBuilder(ctorInterfaceType, new Object[] { interfaceType }));
        }
        private ComInterfaceType GetInterfaceTypeAndProcs(NdrComProxyDefinition proxy, List <NdrProcedureDefinition> procs)
        {
            ComInterfaceType type = ComInterfaceType.InterfaceIsIUnknown;

            if (proxy.BaseIid == COMInterfaceEntry.IID_IDispatch)
            {
                type = ComInterfaceType.InterfaceIsIDispatch;
            }
            else if (proxy.BaseIid == COMInterfaceEntry.IID_IInspectable)
            {
                type = ComInterfaceType.InterfaceIsIInspectable;
            }
            else if (m_proxies.ContainsKey(proxy.BaseIid))
            {
                type = GetInterfaceTypeAndProcs(m_proxies[proxy.BaseIid], procs);
            }

            procs.AddRange(proxy.Procedures);
            return(type);
        }
Example #5
0
 // Constructors
 public InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
 }
        public void Ctor_ComInterfaceType(ComInterfaceType interfaceType)
        {
            var attribute = new InterfaceTypeAttribute(interfaceType);

            Assert.Equal(interfaceType, attribute.Value);
        }
Example #7
0
 public InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
     _val = interfaceType;
 }
Example #8
0
 public InterfaceTypeAttribute(short interfaceType)
 {
     _val = (ComInterfaceType)interfaceType;
 }
	public InterfaceTypeAttribute(short interfaceType)
	{
		this.type=(ComInterfaceType)interfaceType;
	}
	// Constructors
	public InterfaceTypeAttribute(ComInterfaceType interfaceType) {}
 public static CustomAttributeBuilder GetBuilderForInterfaceType(ComInterfaceType interfaceType)
 {
     ConstructorInfo ctorInterfaceType = typeof(InterfaceTypeAttribute).GetConstructor(
         BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
         null,
         new Type[] { typeof(ComInterfaceType) },
         null);
     return new CustomAttributeBuilder(ctorInterfaceType, new Object[] { interfaceType });
 }
	public InterfaceTypeAttribute(ComInterfaceType interfaceType)
	{
		this.type=interfaceType;
	}
Example #13
0
 public InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
     this._val = interfaceType;
 }
Example #14
0
 internal InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
     _val = interfaceType;
 }
Example #15
0
		public InterfaceTypeAttribute (ComInterfaceType interfaceType){
			intType = interfaceType;
		}
Example #16
0
 public InterfaceTypeAttribute(short interfaceType)
 {
     intType = (ComInterfaceType)interfaceType;
 }
Example #17
0
 public InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
     intType = interfaceType;
 }
Example #18
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.InteropServices.InterfaceTypeAttribute" /> class with the specified <see cref="T:System.Runtime.InteropServices.ComInterfaceType" /> enumeration member.</summary><param name="interfaceType">One of the <see cref="T:System.Runtime.InteropServices.ComInterfaceType" /> values that describes how the interface should be exposed to COM clients. </param>
 public InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
     throw new NotImplementedException();
 }
Example #19
0
 internal InterfaceTypeAttribute(short interfaceType)
 {
     _val = (ComInterfaceType)interfaceType;
 }
Example #20
0
 public InterfaceTypeAttribute(short interfaceType)
 {
     this._val = (ComInterfaceType)interfaceType;
 }
 public InterfaceTypeAttribute(ComInterfaceType interfaceType)
 {
     Value = interfaceType;
 }