当前位置: 首页>>代码示例>>C#>>正文


C# IContext.ResolveService方法代码示例

本文整理汇总了C#中IContext.ResolveService方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.ResolveService方法的具体用法?C# IContext.ResolveService怎么用?C# IContext.ResolveService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContext的用法示例。


在下文中一共展示了IContext.ResolveService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        private void Configure(IContext context)
        {
            var configuration = context.ResolveService<IConfiguration>();
            if (configuration == null)
                throw new DatabaseConfigurationException("No configuration found in context.");

            BasePath = configuration.GetString("store.dataFactory.scattering.basePath");
            if (String.IsNullOrEmpty(BasePath))
                BasePath = configuration.GetString("database.path");
            if (String.IsNullOrEmpty(BasePath))
                throw new DatabaseConfigurationException("No base path was set for the data factory.");

            FileExtension = configuration.GetString("store.dataFactory.scattering.fileExtension", ".db");

            // 1Gb by default
            const int defaultMaxSliceSize = 16384*65536;
            MaxSliceSize = configuration.GetInt32("store.dataFactory.scattering.maxSliceSize", defaultMaxSliceSize);

            var fileSystemName = configuration.GetString("store.dataFactory.scattering.fileSystem");
            if (String.IsNullOrEmpty(fileSystemName)) {
                fileSystemName = configuration.GetString("store.fileSystem", "local");
            }

            FileSystem = context.ResolveService<IFileSystem>(fileSystemName);
            if (FileSystem == null)
                throw new DatabaseConfigurationException(String.Format("File system '{0}' was not found in context.", fileSystemName));
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:27,代码来源:ScatteringFileStoreDataFactory.cs

示例2: Parse

        public static IEnumerable<SqlStatement> Parse(IContext context, SqlQuery query)
        {
            if (query == null)
                throw new ArgumentNullException("query");

            var compiler = DefaultCompiler;

            if (context != null) {
                compiler = context.ResolveService<ISqlCompiler>();
            }

            try {
                var compileContext = new SqlCompileContext(context, query.Text);
                var result = compiler.Compile(compileContext);
                if (result.HasErrors)
                {
                    var messages = new StringBuilder();
                    messages.AppendFormat("SqlParseException for '{0}'" + Environment.NewLine, query.Text);
                    foreach (var m in result.Messages)
                    {
                        messages.AppendFormat("Level: {0}", m.Level);
                        if (null != m.Location)
                        {
                            messages.AppendFormat(", Line: {0}, Column: {1}", m.Location.Line, m.Location.Column);
                        }
                        messages.AppendFormat(", Message: {0}", m.Text);
                        messages.AppendLine();
                    }
                    throw new SqlParseException(messages.ToString());
                }

                var statements = result.Statements.Cast<SqlStatement>();

                foreach (var statement in statements) {
                    if (statement != null)
                        statement.SetSource(query);
                }

                return statements;
            } catch (SqlParseException) {
                throw;
            } catch (Exception ex) {
                var messages = new StringBuilder();
                messages.AppendFormat ("The input string '{0}'" + Environment.NewLine, query.Text);
                messages.AppendFormat (" cannot be parsed into SQL Statements, because of {0}" + Environment.NewLine, ex.ToString());
                throw new SqlParseException(messages.ToString(), ex);
            }
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:48,代码来源:SqlStatement.cs

示例3: Parse

        /// <summary>
        /// Parses the given SQL string to an expression that can be evaluated.
        /// </summary>
        /// <param name="s">The string to parse.</param>
        /// <param name="context"></param>
        /// <returns>
        /// Returns an instance of <seealso cref="SqlExpression"/> that represents
        /// the given SQL string parsed.
        /// </returns>
        public static SqlExpression Parse(string s, IContext context)
        {
            // TODO: Get the expression compiler from the context
            var parser = context.ResolveService<IExpressionParser>();

            if (parser == null)
                parser = new ExpressionParser();

            return Parse(s, parser);
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:19,代码来源:SqlExpression.cs


注:本文中的IContext.ResolveService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。