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


C# IEngine.GetService方法代码示例

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


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

示例1: Evaluate

        public static CreateObjectCommand Evaluate(IEngine engine, Command command)
        {
            if (command.Parameters.Count < 2)
                return null;

            if (command.Parameters[0].Name.ToLower() != "create")
                return null;
            if (command.Parameters[0].Value != null)
                return null;

            string name = command.Parameters[1].Name;
            if (string.IsNullOrEmpty(name))
                return null;

            ISchemaService schemaService = engine.GetService<ISchemaService>();
            if (!schemaService.HasClass(name))
                return null;

            CreateObjectCommand createObjectCommand = new CreateObjectCommand(name);

            IList<Parameter> parameters = command.Parameters[1].Value as IList<Parameter>;
            if (parameters != null)
            {
                foreach (Parameter parameter in parameters)
                {
                    if (schemaService.HasProperty(name, parameter.Name))
                    {
                        createObjectCommand.Values[parameter.Name] = parameter.Value;
                    }
                }
            }

            return createObjectCommand;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:34,代码来源:CreateObjectCommand.cs

示例2: Initialize

        protected override void Initialize(IEngine engine)
        {
            base.Initialize(engine);

            var testFrameworkService = engine.GetService<IPexTestFrameworkManager>();
            var host = testFrameworkService as IPexComponent;

            testFrameworkService.AddTestFramework(new XunitTestFramework_2_0(host));
        }
开发者ID:xunit,项目名称:testextensions.xunit,代码行数:9,代码来源:XunitTestFrameworkPackageAttribute.cs

示例3: Evaluate

        public static UpdateObjectsCommand Evaluate(IEngine engine, Command command)
        {
            if (command.Parameters.Count < 3)
                return null;

            if (command.Parameters[0].Name.ToLower() != "update")
                return null;
            if (command.Parameters[0].Value != null)
                return null;

            string name = command.Parameters[1].Name;
            if (string.IsNullOrEmpty(name))
                return null;

            ISchemaService schemaService = engine.GetService<ISchemaService>();
            if (!schemaService.HasClass(name))
                return null;

            if (command.Parameters[2].Name.ToLower() != "match")
                return null;
            IList<Parameter> match = command.Parameters[2].Value as IList<Parameter>;

            UpdateObjectsCommand updateObjectsCommand = new UpdateObjectsCommand(name);

            IList<Parameter> parameters = command.Parameters[1].Value as IList<Parameter>;
            if (parameters != null)
            {
                foreach (Parameter parameter in parameters)
                {
                    if (schemaService.HasProperty(name, parameter.Name))
                    {
                        updateObjectsCommand.Values[parameter.Name] = parameter.Value;
                    }
                }
            }

            if (match != null)
            {
                foreach (Parameter parameter in match)
                {
                    if (schemaService.HasProperty(name, parameter.Name))
                    {
                        updateObjectsCommand.Match[parameter.Name] = parameter.Value;
                    }
                }
            }

            return updateObjectsCommand;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:49,代码来源:UpdateObjectsCommand.cs

示例4: Evaluate

        public static DeleteObjectsCommand Evaluate(IEngine engine, Command command)
        {
            if (command.Parameters.Count < 2)
                return null;

            if (command.Parameters[0].Name.ToLower() != "delete")
                return null;
            if (command.Parameters[0].Value != null)
                return null;

            string name = command.Parameters[1].Name;
            if (string.IsNullOrEmpty(name))
                return null;

            ISchemaService schemaService = engine.GetService<ISchemaService>();
            if (!schemaService.HasClass(name))
                return null;

            DeleteObjectsCommand deleteObjectsCommand = new DeleteObjectsCommand(name);

            EvaluateMatch(command.Parameters[1].Value, name, schemaService, deleteObjectsCommand);

            if (command.Parameters.Count > 2)
            {
                switch (command.Parameters[2].Name.ToLower())
                {
                    case "match":
                    case "where":
                        EvaluateMatch(command.Parameters[2].Value, name, schemaService, deleteObjectsCommand);
                        break;
                    case "query":
                        if (command.Parameters[2].Value != null)
                            deleteObjectsCommand.Where = command.Parameters[2].Value.ToString();
                        break;
                }
            }
            return deleteObjectsCommand;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:38,代码来源:DeleteObjectsCommand.cs

示例5: Evaluate

        public static CreatePropertyCommand Evaluate(IEngine engine, Command command)
        {
            if (command.Parameters.Count < 3)
                return null;

            if (command.Parameters[0].Name.ToLower() != "create")
                return null;
            if (command.Parameters[0].Value != null)
                return null;

            Multiplicity multiplicity = Multiplicity.None;

            switch (command.Parameters[1].Name.ToLower())
            {
                case "property":
                case "relationship":
                    break;
                case "one-one":
                case "oneone":
                case "one-to-one":
                case "onetoone":
                    multiplicity = Multiplicity.OneToOne;
                    break;
                case "one-many":
                case "onemany":
                case "one-to-many":
                case "onetomany":
                case "reference":
                    multiplicity = Multiplicity.OneToMany;
                    break;
                case "many-one":
                case "manyone":
                case "many-to-one":
                case "manytoone":
                case "list":
                    multiplicity = Multiplicity.ManyToOne;
                    break;
                case "many-many":
                case "manymany":
                case "many-to-many":
                case "manytomany":
                    multiplicity = Multiplicity.ManyToMany;
                    break;
                default:
                    return null;
            }
            if (command.Parameters[1].Value != null)
                return null;

            string name = command.Parameters[2].Name;
            if (string.IsNullOrEmpty(name))
                return null;  // register exception...

            string[] parts = name.Split(".".ToCharArray());
            if (parts.Length != 2)
                return null;  // register exception...

            string className = parts[0];
            string propertyName = parts[1];

            if (string.IsNullOrEmpty(className))
                return null;  // register exception...

            if (string.IsNullOrEmpty(propertyName))
                return null;  // register exception...

            ISchemaService schemaService = engine.GetService<ISchemaService>();
            IObjectService objectService = engine.GetService<IObjectService>();

            CreatePropertyCommand createPropertyCommand = new CreatePropertyCommand(className, propertyName);
            createPropertyCommand.Multiplicity = multiplicity;
            createPropertyCommand.Type = typeof(string);
            createPropertyCommand.StringLength = 255;

            bool list = false;

            IList<Parameter> parameters = command.Parameters[2].Value as IList<Parameter>;
            if (parameters != null)
            {
                foreach (Parameter parameter in parameters)
                {
                    if (parameter.Value != null)
                    {
                        switch (parameter.Name.ToLower())
                        {
                            case "type":
                                if (schemaService.HasClass(parameter.Value.ToString()))
                                    createPropertyCommand.Type = objectService.GetTypeByName(parameter.Value.ToString());
                                else
                                    createPropertyCommand.Type = Type.GetType(parameter.Value.ToString());
                                break;
                            case "list":
                                list = true;
                                break;
                            case "multiplicity":
                            case "ref":
                            case "reference":
                            case "referencetype":
                                if (createPropertyCommand.Multiplicity == Multiplicity.None)
                                {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:101,代码来源:CreatePropertyCommand.cs

示例6: Evaluate

        public static DisplayObjectsCommand Evaluate(IEngine engine, Command command)
        {
            if (command.Parameters.Count < 2)
                return null;

            bool list = false;

            switch (command.Parameters[0].Name.ToLower())
            {
                case "display":
                case "show":
                    break;
                case "list":
                    list = true;
                    break;
                default:
                    return null;
            }
            if (command.Parameters[0].Value != null)
                return null;

            string name = command.Parameters[1].Name;
            if (string.IsNullOrEmpty(name))
                return null;

            ISchemaService schemaService = engine.GetService<ISchemaService>();
            if (!schemaService.HasClass(name))
                return null;

            DisplayObjectsCommand displayObjectsCommand = new DisplayObjectsCommand(name, list);

            EvaluateMatch(command.Parameters[1].Value, name, schemaService, displayObjectsCommand);

            if (command.Parameters.Count > 2)
            {
                switch (command.Parameters[2].Name.ToLower())
                {
                    case "match":
                    case "where":
                        EvaluateMatch(command.Parameters[2].Value, name, schemaService, displayObjectsCommand);
                        break;
                    case "query":
                        if (command.Parameters[2].Value != null)
                            displayObjectsCommand.Where = command.Parameters[2].Value.ToString();
                        break;
                }
            }
            return displayObjectsCommand;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:49,代码来源:DisplayObjectsCommand.cs


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