コード例 #1
0
        public MethodInfo GetConversion(TypeModel model, bool toTail)
        {
            Type       to   = (!toTail) ? this.forType : this.declaredType;
            Type       from = (!toTail) ? this.declaredType : this.forType;
            MethodInfo result;

            if (SurrogateSerializer.HasCast(model, this.declaredType, from, to, out result) || SurrogateSerializer.HasCast(model, this.forType, from, to, out result))
            {
                return(result);
            }
            throw new InvalidOperationException("No suitable conversion operator found for surrogate: " + this.forType.get_FullName() + " / " + this.declaredType.get_FullName());
        }
コード例 #2
0
        public MethodInfo GetConversion(bool toTail)
        {
            MethodInfo methodInfo;
            Type       type  = (toTail ? this.declaredType : this.forType);
            Type       type1 = (toTail ? this.forType : this.declaredType);

            if (!SurrogateSerializer.HasCast(this.declaredType, type1, type, out methodInfo) && !SurrogateSerializer.HasCast(this.forType, type1, type, out methodInfo))
            {
                throw new InvalidOperationException(string.Concat("No suitable conversion operator found for surrogate: ", this.forType.FullName, " / ", this.declaredType.FullName));
            }
            return(methodInfo);
        }