public T DecodeFunctionOutput <T>(T functionOutputResult, string output) { if (output == "0x") { return(functionOutputResult); } var type = typeof(T); var function = FunctionOutputAttribute.GetAttribute <T>(); if (function == null) { throw new ArgumentException("Generic Type should have a Function Ouput Attribute"); } #if DOTNET35 var properties = type.GetTypeInfo().GetProperties(); #else var properties = type.GetRuntimeProperties(); #endif DecodeAttributes(output, functionOutputResult, properties.ToArray()); return(functionOutputResult); }
///<summary> /// Decodes the output of a function using either a FunctionOutputAttribute (T) /// or the parameter casted to the type T, only one outputParameter should be used in this scenario. /// </summary> /// public T DecodeOutput <T>(string output, params Parameter[] outputParameter) where T : new() { if (output == "0x") { return(default(T)); } var function = FunctionOutputAttribute.GetAttribute <T>(); if (function == null) { if (outputParameter != null) { if (outputParameter.Length > 1) { throw new Exception( "Only one output parameter supported to be decoded this way, use a FunctionOutputAttribute or define each outputparameter"); } return(DecodeSimpleTypeOutput <T>(outputParameter[0], output)); } return(default(T)); } else { return(DecodeFunctionOutput <T>(output)); } }
public TReturn DecodeTypeOutput <TReturn>(string output) { var function = FunctionOutputAttribute.GetAttribute <TReturn>(); if (function != null) { var instance = Activator.CreateInstance(typeof(TReturn)); return(DecodeDTOTypeOutput <TReturn>((TReturn)instance, output)); } else { return(FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>( GetFirstParameterOrNull(FunctionABI.OutputParameters), output)); } }
public T DecodeFunctionOutput <T>(T functionOutputResult, string output) { if (output == "0x") { return(functionOutputResult); } var type = typeof(T); var function = FunctionOutputAttribute.GetAttribute <T>(); if (function == null) { throw new ArgumentException("Generic Type should have a Function Ouput Attribute"); } var properties = PropertiesExtractor.GetPropertiesWithParameterAttribute(type); DecodeAttributes(output, functionOutputResult, properties.ToArray()); return(functionOutputResult); }
public T DecodeFunctionOutput <T>(T functionOutputResult, string output) { if (output == "0x") { return(functionOutputResult); } var type = typeof(T); var function = FunctionOutputAttribute.GetAttribute <T>(); if (function == null) { throw new ArgumentException($"Unable to decode to '{typeof(T).Name}' because the type does not apply attribute '[{nameof(FunctionOutputAttribute)}]'."); } var properties = PropertiesExtractor.GetPropertiesWithParameterAttribute(type); DecodeAttributes(output, functionOutputResult, properties.ToArray()); return(functionOutputResult); }
///<summary> /// Decodes the output of a function using either a FunctionOutputAttribute (T) /// or the parameter casted to the type T, only one outputParameter should be used in this scenario. /// </summary> /// public T DecodeOutput <T>(string output, params Parameter[] outputParameter) where T : new() { if (output == "0x") { return(default(T)); } var function = FunctionOutputAttribute.GetAttribute <T>(); if (function == null) { if (outputParameter != null) { if (outputParameter.Length > 1) { throw new Exception( "Only one output parameter supported to be decoded this way, use a FunctionOutputAttribute or define each outputparameter"); } var parmeterOutput = new ParameterOutput() { DecodedType = typeof(T), Parameter = outputParameter[0] }; var results = DecodeOutput(output, parmeterOutput); if (results.Any()) { return((T)results[0].Result); } } return(default(T)); } else { return(DecodeOutput <T>(output)); } }
public T DecodeOutput <T>(string output) where T : new() { if (output == "0x") { return(default(T)); } var type = typeof(T); var function = FunctionOutputAttribute.GetAttribute <T>(); if (function == null) { throw new ArgumentException("Generic Type should have a Function Ouput Attribute"); } var properties = type.GetProperties(); var result = new T(); DecodeAttributes(output, result, properties); return(result); }