예제 #1
0
        public void Build()
        {
            if (!isSetup)
            {
                throw new InvalidOperationException();
            }

            if (obj is ScriptXml && (obj as ScriptXml).Language == LanguageType.CSharp)
            {
                args = new CSharpScalarResolverArgs((obj as ScriptXml).Code);
            }

            else if (obj is QueryXml)
            {
                var builder = new QueryResolverArgsBuilder(serviceLocator);
                builder.Setup((QueryXml)obj);
                builder.Setup(settings);
                builder.Setup(globalVariables);
                builder.Build();
                args = new QueryScalarResolverArgs(builder.GetArgs());
            }

            else if (obj is ProjectionXml)
            {
                var builder = new ResultSetResolverArgsBuilder(serviceLocator);
                builder.Setup(((ProjectionXml)obj).ResultSet);
                builder.Setup(settings);
                builder.Setup(globalVariables);
                builder.Build();
                args = new RowCountResultSetScalarResolverArgs(builder.GetArgs());
            }

            else if (obj is EnvironmentXml)
            {
                args = new EnvironmentScalarResolverArgs((obj as EnvironmentXml).Name);
            }

            else if (obj is string && !string.IsNullOrEmpty((string)obj) && ((string)obj).Trim().StartsWith("@"))
            {
                var variableName = ((string)obj).Trim().Substring(1);
                args = new GlobalVariableScalarResolverArgs(variableName, globalVariables);
            }

            else if (obj is string && !string.IsNullOrEmpty((string)obj) && ((string)obj).Trim().StartsWith("~"))
            {
                var formatText = ((string)obj).Trim().Substring(1);
                args = new FormatScalarResolverArgs(formatText, globalVariables);
            }

            else if (obj is object && obj != null)
            {
                args = new LiteralScalarResolverArgs(obj);
            }

            if (args == null)
            {
                throw new ArgumentException();
            }
        }
예제 #2
0
        public IResultSetResolver InstantiateResolver(ResultSetSystemXml resultSetXml)
        {
            var argsBuilder = new ResultSetResolverArgsBuilder(serviceLocator);

            argsBuilder.Setup(resultSetXml);
            argsBuilder.Setup(resultSetXml.Settings);
            argsBuilder.Setup(variables);
            argsBuilder.Build();

            var factory  = serviceLocator.GetResultSetResolverFactory();
            var resolver = factory.Instantiate(argsBuilder.GetArgs());

            return(resolver);
        }