示例#1
0
        /// <summary>
        /// Deserializes a string expression for the inferred type. This type should contain a "string name" parameter that will come from the expression: "A" + "B"
        /// </summary>
        /// <param name="expression">Expressin as string</param>
        /// <param name="factory">This factory is necessary for the creation of entities. You can inherit this class and add new methods to be used in the string expression: "A" + NewMethod()</param>
        /// <returns>Return a circular entity</returns>
        public async Task <T> DeserializeAsync(string expression, CircularEntityFactory <T> factory)
        {
            var roslyn = new RoslynExpressionDeserializer <T>();
            var runner = roslyn.GetDelegateExpression(expression, factory.GetType());

            return(await runner(factory));
        }
示例#2
0
        /// <summary>
        /// Deserializes a string expression with custom complex entity factory
        /// </summary>
        /// <param name="expression">Expressin as string</param>
        /// <param name="factory">This factory is util to customize entity creation</param>
        /// <returns>Return a complety entity</returns>
        public async Task <object> DeserializeAsync(string expression, ComplexEntityFactory factory)
        {
            var roslyn = new RoslynExpressionDeserializer <Entity>();
            var runner = roslyn.GetDelegateExpression(expression, factory.GetType());
            var root   = await runner(factory);

            factory.Root = root;
            return(factory.Build().Value);
        }