示例#1
0
        protected WampEventValueTupleConverter()
        {
            Type tupleType = typeof(TTuple);

            if (!tupleType.IsValueTuple())
            {
                throw new ArgumentException("Expected TTuple to be a ValueTuple");
            }

            if (!tupleType.IsValidTupleType())
            {
                throw new ArgumentException("TTuple is an invalid ValueTuple. Expected TRest to be a ValueTuple.");
            }

            mArrayConverter = ValueTupleArrayConverter <TTuple> .Value;

            Type converterType = GetConverterType();

            ValidateConverterType(converterType);

            IList <string> transformNames = GetTransformNames(converterType);

            int tupleLength = tupleType.GetValueTupleLength();

            ValidateTransformNames(transformNames, tupleLength);

            if (transformNames != null)
            {
                if (transformNames.Take(tupleLength).All(x => x != null))
                {
                    mDictionaryConverter =
                        ValueTupleDictionaryConverterBuilder.Build(tupleType, transformNames);
                }
            }

            mArgumentUnpacker =
                ArgumentUnpackerHelper.GetValueTupleArgumentUnpacker
                    (tupleType, transformNames);
        }
 public NamedTupleExtractor(Type tupleType, IList <string> transformNames)
 {
     mConverter =
         ValueTupleDictionaryConverterBuilder.Build(tupleType, transformNames);
 }