public StringEncoderDataTypeTransform(Net.Vpc.Upa.Types.StringEncoder stringEncoder, Net.Vpc.Upa.Types.DataType sourceType, int?max, Net.Vpc.Upa.Types.ByteArrayEncoder serializer) { this.serializer = serializer; this.stringEncoder = stringEncoder; this.sourceType = sourceType; this.targetType = new Net.Vpc.Upa.Types.StringType(null, 0, max == null ? ((Net.Vpc.Upa.Types.DataType)(255)) : max, sourceType.IsNullable()); }
public virtual object TransformValue(object @value) { Net.Vpc.Upa.Types.ByteArrayEncoder ss = byteArrayEncoder; return(ss.Encode(@value)); }
public ByteArrayEncoderDataTypeTransform(Net.Vpc.Upa.Types.ByteArrayEncoder byteArrayEncoder, Net.Vpc.Upa.Types.DataType sourceType, int?max) { this.byteArrayEncoder = byteArrayEncoder; this.sourceType = sourceType; this.targetType = new Net.Vpc.Upa.Types.ByteArrayType(null, max == null ? ((Net.Vpc.Upa.Types.DataType)(255)) : max, sourceType.IsNullable()); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateByteArrayEncoderTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig(); } int baseSize = 0; Net.Vpc.Upa.Types.ByteArrayEncoder enc = null; if (source is Net.Vpc.Upa.Types.IntType) { enc = Net.Vpc.Upa.Impl.Transform.IntToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.LongType) { enc = Net.Vpc.Upa.Impl.Transform.LongToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.DoubleType) { enc = Net.Vpc.Upa.Impl.Transform.DoubleToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.FloatType) { enc = Net.Vpc.Upa.Impl.Transform.FloatToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.StringType) { enc = Net.Vpc.Upa.Impl.Transform.StringToByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.ByteArrayType) { enc = null; baseSize = 255; Net.Vpc.Upa.Types.EnumType et = (Net.Vpc.Upa.Types.EnumType)source; enc = new Net.Vpc.Upa.Impl.Transform.EnumToStringByteArrayEncoder(source.GetPlatformType()); //should we baseSize = 3; foreach (object @value in et.GetValues()) { if (@value != null) { int cs = (System.Convert.ToString(@value)).Length; if (cs > baseSize) { baseSize = cs; } } } } else { throw new System.ArgumentException("Unsupported"); } object postEncoderObject = p.GetEncoder(); Net.Vpc.Upa.Types.ByteArrayEncoder postEncoder = null; if (postEncoderObject == null) { } else if (postEncoderObject is string) { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty((string)postEncoderObject)) { postEncoder = pu.GetFactory().CreateObject <T>((string)postEncoderObject); } } else if (postEncoderObject is System.Type) { postEncoder = (Net.Vpc.Upa.Types.ByteArrayEncoder)pu.GetFactory().CreateObject <object>((System.Type)postEncoderObject); } else if (postEncoderObject is Net.Vpc.Upa.Types.ByteArrayEncoder) { postEncoder = (Net.Vpc.Upa.Types.ByteArrayEncoder)postEncoderObject; } else { throw new System.ArgumentException("Unsupported"); } if (p.GetSize() <= 0) { p.SetSize(baseSize); } Net.Vpc.Upa.Types.ByteArrayEncoder finalEncoder = null; if (enc == null) { finalEncoder = postEncoder; } else if (postEncoder == null) { finalEncoder = enc; } else { finalEncoder = new Net.Vpc.Upa.Impl.Transform.ChainByteArrayEncoder(enc, postEncoder); } if (finalEncoder == null) { finalEncoder = Net.Vpc.Upa.Impl.Transform.IdentityByteArrayEncoder.INSTANCE; } return(new Net.Vpc.Upa.Impl.Transform.ByteArrayEncoderDataTypeTransform(finalEncoder, source, p.GetSize())); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateStringEncoderTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.StringEncoderTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.StringEncoderTransformConfig(); } Net.Vpc.Upa.Types.ByteArrayEncoder toStringEncoder = null; int baseSize = 0; object encoderObject = p.GetEncoder(); if (encoderObject == null) { encoderObject = Net.Vpc.Upa.Config.StringEncoderType.DEFAULT; } if (source is Net.Vpc.Upa.Types.IntType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.IntToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.LongType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.LongToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.DoubleType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.DoubleToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.FloatType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.FloatToStringByteArrayEncoder.INSTANCE; baseSize = 255; } else if (source is Net.Vpc.Upa.Types.ByteArrayType) { toStringEncoder = Net.Vpc.Upa.Impl.Transform.IdentityByteArrayEncoder.INSTANCE; baseSize = ((Net.Vpc.Upa.Types.ByteArrayType)source).GetMaxSize() == null ? ((int)(0)) : (((Net.Vpc.Upa.Types.ByteArrayType)source).GetMaxSize()).Value; if (encoderObject == Net.Vpc.Upa.Config.StringEncoderType.DEFAULT) { encoderObject = Net.Vpc.Upa.Config.StringEncoderType.HEXADECIMAL; } } else if (source is Net.Vpc.Upa.Types.EnumType) { Net.Vpc.Upa.Types.EnumType et = (Net.Vpc.Upa.Types.EnumType)source; toStringEncoder = new Net.Vpc.Upa.Impl.Transform.EnumToStringByteArrayEncoder(source.GetPlatformType()); //should we baseSize = 3; foreach (object @value in et.GetValues()) { if (@value != null) { int cs = (System.Convert.ToString(@value)).Length; if (cs > baseSize) { baseSize = cs; } } } } else { throw new System.ArgumentException("Unsupported"); } if (baseSize <= 0) { baseSize = 255; } Net.Vpc.Upa.Types.StringEncoder encoder = null; if (encoderObject is Net.Vpc.Upa.Config.StringEncoderType) { Net.Vpc.Upa.Config.StringEncoderType set = (Net.Vpc.Upa.Config.StringEncoderType)encoderObject; if (set == Net.Vpc.Upa.Config.StringEncoderType.DEFAULT) { set = Net.Vpc.Upa.Config.StringEncoderType.PLAIN; } if (set == Net.Vpc.Upa.Config.StringEncoderType.CUSTOM) { throw new System.ArgumentException("Unsupported"); } switch (set) { case Net.Vpc.Upa.Config.StringEncoderType.BASE64: { encoder = Net.Vpc.Upa.Impl.Transform.Base64Encoder.INSTANCE; if (p.GetSize() <= 0) { p.SetSize(baseSize * 4 / 3 + 2); } break; } case Net.Vpc.Upa.Config.StringEncoderType.HEXADECIMAL: { encoder = Net.Vpc.Upa.Impl.Transform.HexaEncoder.INSTANCE; if (p.GetSize() <= 0) { p.SetSize(baseSize * 2); } break; } case Net.Vpc.Upa.Config.StringEncoderType.PLAIN: { encoder = Net.Vpc.Upa.Impl.Transform.PlainStringEncoder.INSTANCE; if (p.GetSize() <= 0) { p.SetSize(baseSize); } break; } case Net.Vpc.Upa.Config.StringEncoderType.XML: { if (p.GetSize() <= 0) { p.SetSize(baseSize); } throw new System.ArgumentException("Unsupported yet " + set + " Encoder"); } case Net.Vpc.Upa.Config.StringEncoderType.JSON: { if (p.GetSize() <= 0) { p.SetSize(baseSize); } throw new System.ArgumentException("Unsupported yet " + set + " Encoder"); } default: { throw new System.ArgumentException("Unsupported yet " + set + " Encoder"); } } } else if (encoderObject is string) { return(pu.GetFactory().CreateObject <T>((string)encoderObject)); } else if (encoderObject is System.Type) { return((Net.Vpc.Upa.Types.DataTypeTransform)pu.GetFactory().CreateObject <object>((System.Type)encoderObject)); } else { throw new System.ArgumentException("Unsupported Encoder " + encoderObject); } return(new Net.Vpc.Upa.Impl.Transform.StringEncoderDataTypeTransform(encoder, source, p.GetSize(), toStringEncoder)); }
public virtual void SetEncoder(Net.Vpc.Upa.Types.ByteArrayEncoder encoder) { SetEncoderObject(encoder); }
public ChainByteArrayEncoder(Net.Vpc.Upa.Types.ByteArrayEncoder a, Net.Vpc.Upa.Types.ByteArrayEncoder b) { this.a = a; this.b = b; }