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); }
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); }
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); }
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; }
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; }
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(); }
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; } }
internal CodecImplEncap(GiopVersion version, SerializerFactory serFactory) { m_version = version; m_serFactory = serFactory; m_serializerForAnyType = m_serFactory.Create(ReflectionHelper.ObjectType, AttributeExtCollection.EmptyCollection); }