Ejemplo n.º 1
0
        /// <summary>
        /// See <see cref="System.Attribute.Equals"/>.
        /// </summary>
        public override bool Equals(object obj)
        {
            IdlArrayDimensionAttribute other = obj as IdlArrayDimensionAttribute;

            if (other == null)
            {
                return(false);
            }
            return(m_dimensionSize == other.m_dimensionSize && m_dimensionNr == other.m_dimensionNr &&
                   m_associatedTo == other.m_associatedTo);
        }
Ejemplo n.º 2
0
    private TypeContainer GetTypeContainerForMultiDimArray(TypeContainer elemType, int[] dimensions) {
        string clsArrayRep = "[";
        for (int i = 1; i < dimensions.Length; i++) {
            clsArrayRep = clsArrayRep + ",";
        }
        clsArrayRep = clsArrayRep + "]";
        // create CLS array type with the help of GetType(), otherwise not possible
        Type arrayType;
        // because not fully defined types are possible, use module and not assembly to get type from
        Module declModule = elemType.GetCompactClsType().Module;
        arrayType = declModule.GetType(elemType.GetCompactClsType().FullName + clsArrayRep); // not nice, better solution ?        
        Debug.WriteLine("created array type: " + arrayType);

        // determine the needed attributes: IdlArray is required by the array itself (+optional dimension attrs); 
        // combine with the attribute from the element type
        // possible are: IdlArray (for array of array), IdlSequence (for array of sequence), ObjectIdlType,
        // WideChar, StringValue
        // invariant: boxed value attribute is not among them, because elem type 
        // is in the compact form        
        AttributeExtCollection elemAttributes = elemType.GetCompactTypeAttrInstances();
        long arrayAttrOrderNr = IdlArrayAttribute.DetermineArrayAttributeOrderNr(elemAttributes);
        
        IdlArrayAttribute arrayAttr = new IdlArrayAttribute(arrayAttrOrderNr, dimensions[0]); // at least one dimension available, because of grammar
        AttributeExtCollection arrayAttributes = 
            new AttributeExtCollection(elemAttributes);
        arrayAttributes = arrayAttributes.MergeAttribute(arrayAttr);        
        for (int i = 1; i < dimensions.Length; i++) {
            IdlArrayDimensionAttribute dimAttr = new IdlArrayDimensionAttribute(arrayAttrOrderNr, i, dimensions[i]);
            arrayAttributes = arrayAttributes.MergeAttribute(dimAttr);
        }
        
        return new TypeContainer(arrayType,
                                 arrayAttributes);        
    }