Exemplo n.º 1
0
        private ArgumentMapping DetermineReturnParamMapping(MethodInfo method, SerializerFactory serFactory)
        {
            ArgumentMapping returnMapping;

            // return value
            if (!method.ReturnType.Equals(ReflectionHelper.VoidType))
            {
                AttributeExtCollection returnAttrs =
                    ReflectionHelper.CollectReturnParameterAttributes(method);
                Serializer retMappingSer = serFactory.Create(method.ReturnType, returnAttrs);
                returnMapping = new ArgumentMapping(retMappingSer, ArgumentsKind.Return);
            }
            else
            {
                // no retrun value to serialise/deserialise
                returnMapping = new ArgumentMapping();
            }
            return(returnMapping);
        }
Exemplo n.º 2
0
        private void DetermineMapping(Type forType, SerializerFactory serFactory)
        {
            MethodInfo[] methods =
                forType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < methods.Length; i++)
            {
                if (methods[i].IsSpecialName)
                {
                    continue;
                }
                if (IgnoreMethod(methods[i]))
                {
                    // don't support remote calls for method
                    continue;
                }
                string operationName = DetermineOperationName(methods[i]);
                StoreMethodMappingFor(methods[i], operationName, serFactory);
            }

            PropertyInfo[] properties =
                forType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < properties.Length; i++)
            {
                if (IgnoreProperty(properties[i]))
                {
                    // don't support remote calls for this property
                    continue;
                }
                MethodInfo getter = properties[i].GetGetMethod();
                MethodInfo setter = properties[i].GetSetMethod();
                if (getter != null)
                {
                    string operationName = IdlNaming.GetPropertyRequestOperationName(properties[i], false);
                    StoreMethodMappingFor(getter, operationName, serFactory);
                }
                if (setter != null)
                {
                    string operationName = IdlNaming.GetPropertyRequestOperationName(properties[i], true);
                    StoreMethodMappingFor(setter, operationName, serFactory);
                }
            }
        }
        private void DetermineMapping(Type forType, SerializerFactory serFactory) {
            MethodInfo[] methods =
                forType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < methods.Length; i++) {
                if (methods[i].IsSpecialName) {
                    continue;
                }
                if (IgnoreMethod(methods[i])) {
                    // don't support remote calls for method
                    continue;
                }
                string operationName = DetermineOperationName(methods[i]);
                StoreMethodMappingFor(methods[i], operationName, serFactory);
            }

            PropertyInfo[] properties =
                forType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < properties.Length; i++) {
                if (IgnoreProperty(properties[i])) {
                    // don't support remote calls for this property
                    continue;
                }
                MethodInfo getter = properties[i].GetGetMethod();
                MethodInfo setter = properties[i].GetSetMethod();
                if (getter != null) {
                    string operationName = IdlNaming.GetPropertyRequestOperationName(properties[i], false);
                    StoreMethodMappingFor(getter, operationName, serFactory);
                }
                if (setter != null) {
                    string operationName = IdlNaming.GetPropertyRequestOperationName(properties[i], true);
                    StoreMethodMappingFor(setter, operationName, serFactory);
                }
            }
        }
 private void StoreMethodMappingFor(MethodInfo info, string idlOperationName,
                                    SerializerFactory serFactory) {
     m_methodMappings[idlOperationName] =
         DetermineMethodMapping(info, serFactory);
     m_methodInfoForName[idlOperationName] = info;
     m_nameForMethodInfo[info] = idlOperationName;
 }
Exemplo n.º 5
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
     encap.WriteString(m_id);
     encap.WriteString(m_name);
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     ser.Serialize(m_aliased, encap);
     encap.WriteToTargetStream();
 }
Exemplo n.º 6
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
     encap.WriteString(m_id);
     encap.WriteString(m_name);
     encap.WriteToTargetStream();
 }
Exemplo n.º 7
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
     encap.WriteString(m_id);
     encap.WriteString(m_name);
     encap.WriteShort(m_typeMod);
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     // ser baseclass type
     ser.Serialize(m_baseClass, encap);
     // ser members
     encap.WriteULong((uint)m_members.Length);
     foreach (ValueMember member in m_members)
     {
         encap.WriteString(member.name);
         ser.Serialize(member.type, encap);
         encap.WriteShort(member.access);
     }
     encap.WriteToTargetStream();
 }
Exemplo n.º 8
0
        internal override void WriteToStream(CdrOutputStream cdrStream,
                                             SerializerFactory serFactory)
        {
            // write common part: typecode nr
            base.WriteToStream(cdrStream, serFactory);
            // complex type-code: in encapsulation
            CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
            encap.WriteString(m_id);
            encap.WriteString(m_name);
            TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
            Type discrTypeCls = ((TypeCodeImpl)m_discriminatorType).GetClsForTypeCode();
            ser.Serialize(m_discriminatorType, encap);
            encap.WriteLong(m_defaultCase);

            encap.WriteULong((uint)m_members.Length);
            Serializer serDisc =
                serFactory.Create(discrTypeCls,
                                  AttributeExtCollection.EmptyCollection);
            for (int i = 0; i < m_members.Length; i++)
            {
                serDisc.Serialize(m_members[i].DiscriminatorValue, encap);
                encap.WriteString(m_members[i].ElementName);
                ser.Serialize(m_members[i].ElementType, encap);
            }

            encap.WriteToTargetStream();
        }
Exemplo n.º 9
0
 /// <summary>reads the type-code content from the stream, without the TCKind at the beginning</summary>
 /// <remarks>helper which is used by the constructor with arg CdrInputStream</remarks>
 internal virtual void ReadFromStream(CdrInputStream cdrStream,
                                      SerializerFactory serFactory) { }
Exemplo n.º 10
0
        public void Setup()
        {
            m_version = new GiopVersion(1, 2);
            m_hostName = "localhost";
            m_port = 8089;
            m_objectKey = new byte[] { 65 };
            m_profile = new InternetIiopProfile(m_version, m_hostName, m_port, m_objectKey);

            m_serFactory =
                new SerializerFactory();
            CodecFactory codecFactory =
                new Ch.Elca.Iiop.Interception.CodecFactoryImpl(m_serFactory);
            m_codec =
                codecFactory.create_codec(
                    new omg.org.IOP.Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
            IiopUrlUtil iiopUrlUtil =
                IiopUrlUtil.Create(m_codec, new object[] {
                    Services.CodeSetService.CreateDefaultCodesetComponent(m_codec)});
            m_serFactory.Initalize(new SerializerFactoryConfig(), iiopUrlUtil);
        }
Exemplo n.º 11
0
 public void SetUp()
 {
     m_serFactory =
         new SerializerFactory();
     CodecFactory codecFactory =
         new Ch.Elca.Iiop.Interception.CodecFactoryImpl(m_serFactory);
     m_codec =
         codecFactory.create_codec(
             new omg.org.IOP.Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
     IiopUrlUtil iiopUrlUtil =
         IiopUrlUtil.Create(m_codec, new object[] {
             Services.CodeSetService.CreateDefaultCodesetComponent(m_codec)});
     m_serFactory.Initalize(new SerializerFactoryConfig(), iiopUrlUtil);
 }
Exemplo n.º 12
0
 public void SetUp() {
     m_serFactory = new SerializerFactory();
     CodecFactory codecFactory =
         new CodecFactoryImpl(m_serFactory);
     Codec codec =
         codecFactory.create_codec(
             new Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
     m_serFactory.Initalize(new SerializerFactoryConfig(), IiopUrlUtil.Create(codec));
 }
Exemplo n.º 13
0
 public DataInputStreamImpl(CdrInputStream cdrIn, SerializerFactory serFactory) {
     m_cdrIn = cdrIn;
     m_serFactory = serFactory;
 }
Exemplo n.º 14
0
 public DataOutputStreamImpl(CdrOutputStream cdrOut, SerializerFactory serFactory) {
     m_cdrOut = cdrOut;
     m_serFactory = serFactory;
 }
 private ArgumentMapping DetermineReturnParamMapping(MethodInfo method, SerializerFactory serFactory) {
     ArgumentMapping returnMapping;
     // return value
     if (!method.ReturnType.Equals(ReflectionHelper.VoidType)) {
         AttributeExtCollection returnAttrs =
             ReflectionHelper.CollectReturnParameterAttributes(method);
         Serializer retMappingSer = serFactory.Create(method.ReturnType, returnAttrs);
         returnMapping = new ArgumentMapping(retMappingSer, ArgumentsKind.Return);
     } else {
         // no retrun value to serialise/deserialise
         returnMapping = new ArgumentMapping();
     }
     return returnMapping;
 }
Exemplo n.º 16
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     m_length = (int)cdrStream.ReadULong();
 }
Exemplo n.º 17
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     cdrStream.WriteULong((uint)m_length);
 }
Exemplo n.º 18
0
        internal override void ReadFromStream(CdrInputStream cdrStream,
                                              SerializerFactory serFactory)
        {
            CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
            m_id = ReadRepositoryId(encap);
            m_name = encap.ReadString();
            TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
            m_discriminatorType = (omg.org.CORBA.TypeCode)ser.Deserialize(encap);
            Type discrTypeCls = ((TypeCodeImpl)m_discriminatorType).GetClsForTypeCode();
            m_defaultCase = encap.ReadLong();

            uint length = encap.ReadULong();
            m_members = new UnionSwitchCase[length];
            Serializer serDisc =
                serFactory.Create(discrTypeCls,
                                  AttributeExtCollection.EmptyCollection);
            for (int i = 0; i < length; i++)
            {
                object discrLabel = serDisc.Deserialize(encap);
                string memberName = encap.ReadString();
                omg.org.CORBA.TypeCode memberType =
                    (omg.org.CORBA.TypeCode)ser.Deserialize(encap);
                UnionSwitchCase member = new UnionSwitchCase(discrLabel, memberName, memberType);
                m_members[i] = member;
            }
        }
Exemplo n.º 19
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     m_id = ReadRepositoryId(encap);
     m_name = encap.ReadString();
     uint length = encap.ReadULong();
     m_members = new string[length];
     for (int i = 0; i < length; i++)
     {
         m_members[i] = encap.ReadString();
     }
 }
Exemplo n.º 20
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     m_id = ReadRepositoryId(encap);
     m_name = encap.ReadString();
     m_typeMod = encap.ReadShort();
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     m_baseClass = (TypeCode)ser.Deserialize(encap);
     // deser members
     uint length = encap.ReadULong();
     m_members = new ValueMember[length];
     for (int i = 0; i < length; i++)
     {
         string memberName = encap.ReadString();
         TypeCode memberType = (TypeCode)ser.Deserialize(encap);
         short visibility = encap.ReadShort();
         ValueMember member = new ValueMember(memberName, memberType, visibility);
         m_members[i] = member;
     }
 }
Exemplo n.º 21
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
     encap.WriteString(m_id);
     encap.WriteString(m_name);
     encap.WriteULong((uint)m_members.Length);
     foreach (string member in m_members)
     {
         encap.WriteString(member);
     }
     encap.WriteToTargetStream();
 }
Exemplo n.º 22
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     m_id = ReadRepositoryId(encap);
     m_name = encap.ReadString();
 }
Exemplo n.º 23
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     m_innerDimension = (TypeCode)ser.Deserialize(encap);
     m_length = (int)encap.ReadULong();
 }
Exemplo n.º 24
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     m_id = ReadRepositoryId(encap);
     m_name = encap.ReadString();
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     m_aliased = (TypeCode)ser.Deserialize(encap);
 }
Exemplo n.º 25
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     ser.Serialize(m_innerDimension, encap);
     encap.WriteULong((uint)m_length);
     encap.WriteToTargetStream();
 }
        private Serializer m_contextElementSer; // for performance reasons: expensive to create

        #endregion IFields
        #region IConstructors

        internal ArgumentsSerializer(Type forType, SerializerFactory serFactory) {
            m_contextElementSer =
                serFactory.Create(typeof(string[]),
                                  new AttributeExtCollection(new Attribute[] { new IdlSequenceAttribute(0L),
                                                                               new StringValueAttribute(),
                                                                               new WideCharAttribute(false) }));
            DetermineTypeMapping(forType, serFactory);
        }
Exemplo n.º 27
0
 /// <summary>serialize the whole type-code to the stream</summary>
 /// <param name="cdrStream"></param>
 internal virtual void WriteToStream(CdrOutputStream cdrStream,
                                     SerializerFactory serFactory)
 {
     uint val = Convert.ToUInt32(kind());
     StreamPosition indirPos = cdrStream.WriteIndirectableInstanceTag(val);
     cdrStream.StoreIndirection(this,
                                new IndirectionInfo(indirPos.GlobalPosition,
                                                    IndirectionType.TypeCode,
                                                    IndirectionUsage.TypeCode));
 }
        private void DetermineTypeMapping(Type forType, SerializerFactory serFactory) {
            DetermineMapping(forType, serFactory);

            // Lets also check implemented interfaces that might be explicitely implemented
            // making methods/properties invisible to previous research
            foreach (Type interfaceType in forType.GetInterfaces())
            {
                DetermineMapping(interfaceType, serFactory);
            }
        }
Exemplo n.º 29
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     m_id = ReadRepositoryId(encap);
     m_name = encap.ReadString();
     uint length = encap.ReadULong();
     m_members = new StructMember[length];
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     for (int i = 0; i < length; i++)
     {
         string memberName = encap.ReadString();
         TypeCode memberType = (TypeCode)ser.Deserialize(encap);
         StructMember member = new StructMember(memberName, memberType);
         m_members[i] = member;
     }
 }
 private ArgumentsMapping DetermineMethodMapping(MethodInfo method, SerializerFactory serFactory) {
     ArgumentMapping returnMapping =
         DetermineReturnParamMapping(method, serFactory);
     ArgumentMapping[] paramMappings =
         DetermineParamMappings(method, serFactory);
     string[] contextElementNames = DetermineContextElements(method);
     return new ArgumentsMapping(returnMapping, paramMappings, contextElementNames);
 }
Exemplo n.º 31
0
 internal override void WriteToStream(CdrOutputStream cdrStream,
                                      SerializerFactory serFactory)
 {
     base.WriteToStream(cdrStream, serFactory);
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream);
     encap.WriteString(m_id);
     encap.WriteString(m_name);
     encap.WriteULong((uint)m_members.Length);
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     foreach (StructMember member in m_members)
     {
         encap.WriteString(member.name);
         ser.Serialize(member.type, encap);
     }
     encap.WriteToTargetStream();
 }
 private ArgumentMapping[] DetermineParamMappings(MethodInfo method, SerializerFactory serFactory) {
     ParameterInfo[] parameters = method.GetParameters();
     ArgumentMapping[] paramMappings = new ArgumentMapping[parameters.Length];
     for (int actualParamNr = 0; actualParamNr < parameters.Length; actualParamNr++) {
         ParameterInfo paramInfo = parameters[actualParamNr];
         // iterate through the parameters to determine mapping for each
         ArgumentsKind argKind = ArgumentsKind.Unknown;
         if (ReflectionHelper.IsInParam(paramInfo)) {
             argKind = ArgumentsKind.InArg;
         } else if (ReflectionHelper.IsOutParam(paramInfo)) {
             argKind = ArgumentsKind.OutArg;
         } else if (ReflectionHelper.IsRefParam(paramInfo)) {
             argKind = ArgumentsKind.RefArg;
         }
         AttributeExtCollection paramAttrs =
             ReflectionHelper.CollectParameterAttributes(paramInfo,
                                                         method);
         Serializer paramSer = serFactory.Create(paramInfo.ParameterType, paramAttrs);
         paramMappings[actualParamNr] = new ArgumentMapping(paramSer, argKind);
     }
     return paramMappings;
 }
 internal ArgumentsSerializerFactory(SerializerFactory serFactory)
 {
     m_serFactory = serFactory;
 }