Ejemplo n.º 1
0
 protected override void VisitCreate(CreateBuilder item)
 {
     GuardCreateBuilder(item);
     item.CreateObject.Accept(this);
     Request       = EntityBuilder.ToCreateEntityRequest();
     EntityBuilder = null;
 }
        protected override void VisitCreate(CreateBuilder item)
        {
            var visitor = new CreateEntityRequestBuilderVisitor(Parameters, CrmMetadataProvider, Settings);
            IVisitableBuilder visitable = item;

            visitable.Accept(visitor);
            SetOperation(visitor.GetCommand());
        }
Ejemplo n.º 3
0
        public void ShouldCreateCharColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[7]);

            sql.Should().Be("[Char] [char(10)]  NOT NULL,");
        }
Ejemplo n.º 4
0
        public void ShouldCreateCustomColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[10]);

            sql.Should().Be("[Custom] [varchar(50)] IDENTITY(1,1) NULL,");
        }
Ejemplo n.º 5
0
        public void ShouldCreateDateTimeColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[2]);

            sql.Should().Be("[DateTime] [datetime]  NOT NULL,");
        }
Ejemplo n.º 6
0
        public void ShouldCreateDecimalColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[6]);

            sql.Should().Be("[Decimal] [decimal(18, 0)]  NOT NULL,");
        }
Ejemplo n.º 7
0
        public void ShouldCreateBigIntColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[9]);

            sql.Should().Be("[Int64] [bigint]  NOT NULL,");
        }
Ejemplo n.º 8
0
        public void ShouldCreateBoolColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[4]);

            sql.Should().Be("[Boolean] [bit]  NOT NULL,");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 生成实体、服务、Api
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <ApiResult <string> > CreateCode(CreateBuilder model)
        {
            await Task.Run(() => _toolService.CreateModel(model));

            await Task.Run(() => _toolService.CreateService(model));

            await Task.Run(() => _toolService.CreateApi(model));

            return(new ApiResult <string>());
        }
Ejemplo n.º 10
0
 private void GuardCreateBuilder(CreateBuilder builder)
 {
     if (builder == null)
     {
         throw new ArgumentNullException("builder");
     }
     if (builder.CreateObject == null)
     {
         throw new ArgumentException("The create statement must specify a supported object to create, i.e a database or a table.");
     }
     // could check if the create object is database and make sure it has a name,
     // could check if the create object is a table and make sure it has the id columnd and name column specified.
 }
Ejemplo n.º 11
0
 /// <summary>Create a directory.</summary>
 /// <remarks>Create a directory. It is not an error if it already exists</remarks>
 /// <param name="path">path to create</param>
 /// <param name="mode">mode for path</param>
 /// <param name="createParents">flag to trigger parent creation</param>
 /// <param name="acls">ACL for path</param>
 /// <exception cref="System.IO.IOException">any problem</exception>
 public virtual bool ZkMkPath(string path, CreateMode mode, bool createParents, IList
                              <ACL> acls)
 {
     CheckServiceLive();
     path = CreateFullPath(path);
     if (acls == null || acls.IsEmpty())
     {
         throw new NoPathPermissionsException(path, "Empty ACL list");
     }
     try
     {
         RegistrySecurity.AclListInfo aclInfo = new RegistrySecurity.AclListInfo(acls);
         if (Log.IsDebugEnabled())
         {
             Log.Debug("Creating path {} with mode {} and ACL {}", path, mode, aclInfo);
         }
         CreateBuilder createBuilder = curator.Create();
         createBuilder.WithMode(mode).WithACL(acls);
         if (createParents)
         {
             createBuilder.CreatingParentsIfNeeded();
         }
         createBuilder.ForPath(path);
     }
     catch (KeeperException.NodeExistsException e)
     {
         if (Log.IsDebugEnabled())
         {
             Log.Debug("path already present: {}", path, e);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw OperationFailure(path, "mkdir() ", e, acls);
     }
     return(true);
 }
Ejemplo n.º 12
0
        public JsonAstBuilder()
        {
            var token = new CreateBuilder <JsonToken>();

            var jobject = Create("object", () => new JsonObject());

            jobject.Children().HasKeyValue <JsonObject, string, JsonToken>(
                new ValueBuilder {
                Name = "name"
            },
                token
                );

            var jarray = Create("array", () => new JsonArray());

            jarray.Children().HasMany <JsonArray, JsonToken>().Builders.Add(token);

            token.Create("string", () => new JsonValue()).Property <string>((o, v) => o.Value = v);
            token.Builders.Add(jobject);
            token.Builders.Add(jarray);
            token.Create("number", () => new JsonValue()).Property <decimal>((o, v) => o.Value = v);
            token.Create("bool", () => new JsonValue()).Property <bool>((o, v) => o.Value      = v);
            token.Create(() => (JsonToken)null);
        }
Ejemplo n.º 13
0
 internal static T CreateObject <T>(TypeInfo typeInfo, CommandService commands, IServiceProvider services = null)
 => CreateBuilder <T>(typeInfo, commands)(services);
Ejemplo n.º 14
0
 internal static T CreateObject <T>(TypeInfo typeInfo, CommandService service, IDependencyMap map = null)
 => CreateBuilder <T>(typeInfo, service)(map);
Ejemplo n.º 15
0
 public async Task <ApiResult <string> > Get([FromQuery] CreateBuilder param)
 => await _builderService.CreateCode(param);
Ejemplo n.º 16
0
        public void ShouldCreateGuidColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[3]);

            sql.Should().Be("[Guid] [uniqueidentifier]  NOT NULL,");
        }
Ejemplo n.º 17
0
 internal static T CreateObject(TypeInfo typeInfo, InteractionService commandService, IServiceProvider services = null) =>
 CreateBuilder(typeInfo, commandService)(services);
Ejemplo n.º 18
0
        public void ShouldCreateIntColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[0]);

            sql.Should().Be("[Id] [int] IDENTITY(1,1) NOT NULL,");
        }
Ejemplo n.º 19
0
        public void ShouldCreateFloatColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[5]);

            sql.Should().Be("[Float] [float]  NOT NULL,");
        }
Ejemplo n.º 20
0
        public void ShouldCreateStringColumn()
        {
            var properties = new AllTypes().GetProperties().ToArray();

            var builder = new CreateBuilder();
            var sql = builder.GetColumnDetails(properties[1]);

            sql.Should().Be("[Name] [varchar](max)  NULL,");
        }
Ejemplo n.º 21
0
        public void ShouldReturnFalseForNonPrimaryKey()
        {
            var builder = new CreateBuilder();
            builder.CreateTable<NoKey>();

            builder.ToString().Should().NotContain("CLUSTERED ");
        }
Ejemplo n.º 22
0
        public void ShouldReturnTrueForPrimaryKey()
        {
            var builder = new CreateBuilder();
            builder.CreateTable<Person>();

            builder.ToString().Should().Contain("CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED ");
        }
 protected override void VisitCreate(CreateBuilder item)
 {
     var visitor = new CreateEntityRequestBuilderVisitor(Parameters, CrmMetadataProvider, Settings);
     IVisitableBuilder visitable = item;
     visitable.Accept(visitor);
     SetOperation(visitor.GetCommand());
 }
Ejemplo n.º 24
0
        public void ShouldThrowIfPrimaryKeyNotInt()
        {
            var builder = new CreateBuilder();
            Action action = builder.CreateTable<InvalidKey>;

            action.ShouldThrow<InvalidKeyException>();
        }