public SqlCommandGenerateContext Build()
            {
                var parser = new DefaultCommandParser();

                this.context.QueryAttributes = this.context.Method.GetCustomAttributes <SqlAttribute>();

                this.context.HasAnyQueryAttribute = this.context.QueryAttributes != null && this.context.QueryAttributes.Any();

                if (!this.context.HasAnyQueryAttribute)
                {
                    this.context.CommandInfo = parser.Parse(this.context.Method.Name);
                }

                this.context.IDaoType = this.context.Method.DeclaringType;

                IEntityTypeProvider entityTypeProvider = NpiServicesCollection.GetService <IEntityTypeProvider>();

                this.context.EntityType = entityTypeProvider.Provide(this.context.Method);

                ITableNameProvider tableNameProvider = NpiServicesCollection.GetService <ITableNameProvider>();

                this.context.TableName = tableNameProvider.Provide(this.context.EntityType);

                this.context.Properties = this.context.EntityType.GetProperties();


                return(this.context);
            }
Exemple #2
0
        private DeviceState DefaultState()
        {
            var deviceManager = new DeviceManager();
            var commandParser = new DefaultCommandParser();

            return(new DeviceState()
            {
                DeviceManager = deviceManager,
                Parser = commandParser,
                SelectedDevice = null
            });
        }
        public void DetaultCommandParse(string command, bool hasError, CommandInfoTypes commandInfoType)
        {
            ICommandParser parser = new DefaultCommandParser();

            if (hasError)
            {
                Assert.ThrowsException <NotSupportActionException>(() => parser.Parse(command));
            }
            else
            {
                ICommandInfo info = parser.Parse(command);
                Assert.AreEqual(commandInfoType, info.Type);
            }
        }