Example #1
0
        public IRepository <T> Create <T>(CreateType createType = CreateType.DynamicProxy)
        {
            IRepository <T> repository = null;

            switch (createType)
            {
            case CreateType.DynamicProxy:
                repository = new DynamicProxy <IRepository <T> >().Create(new Repository <T>(),
                                                                          s => logger.Info($"{s}"),
                                                                          e => logger.Error($"{e}"),
                                                                          o => o?.ToString(),
                                                                          TaskScheduler.Current);
                break;

            case CreateType.AuthenticationProxy:
                repository = new AuthenticationProxy <IRepository <T> >().Create(Create <T>(CreateType.DynamicProxy), TaskScheduler.Current);
                break;

            case CreateType.PerformanceProxy:
                repository = new PerformanceProxy <IRepository <T> >().Create(Create <T>(CreateType.AuthenticationProxy));
                break;

            case CreateType.LoggerRepository:
                repository = new LoggerRepository <T>(new Repository <T>());
                break;
            }
            return(repository);
        }
        /// <summary>
        /// 初始化单选组,将可选单选加入单选组(进制)
        /// </summary>
        private void LoadCreateType()
        {
            this.RadioButtonListCreateTypeEdit.Items.Clear();
            CreateType createTypes = new CreateType();

            foreach (string createType in createTypes.Items)                                                                                  //生成枚举下维护的值的单选
            {
                this.RadioButtonListCreateTypeEdit.Items.Add(new ListItem(this.languageComponent1.GetString(createType.Trim()), createType)); //值为枚举值,显示文本从多语言文件获取
            }
            this.RadioButtonListCreateTypeEdit.SelectedIndex = 0;                                                                             //设定默认选择
        }
Example #3
0
        public async Task <ValueObject> Create([FromBody] CreateType model)
        {
            var value = await _metaDbContext.ValueObjects.AddAsync(new Domain.Meta.ValueObject()
            {
                Id          = Guid.NewGuid(),
                ModuleId    = model.ModuleId,
                Name        = model.Name,
                Description = model.Description
            });

            await _metaDbContext.SaveChangesAsync();

            return(_mapper.Map <ValueObject>(value.Entity));
        }
Example #4
0
        public async Task <Entity> Create([FromBody] CreateType model)
        {
            var entity = await _metaDbContext.Entities.AddAsync(new Domain.Meta.Entity()
            {
                Id          = Guid.NewGuid(),
                ModuleId    = model.ModuleId,
                Name        = model.Name,
                Description = model.Description
            });

            await _metaDbContext.SaveChangesAsync();

            return(_mapper.Map <Entity>(entity.Entity));
        }
Example #5
0
 public CreateTaskLog(int id, CreateType createType, int siteId, int channelId, int contentId, int fileTemplateId, int specialId, string taskName, string timeSpan, bool isSuccess, string errorMessage, DateTime addDate)
 {
     Id             = id;
     CreateType     = createType;
     SiteId         = siteId;
     ChannelId      = channelId;
     ContentId      = contentId;
     FileTemplateId = fileTemplateId;
     SpecialId      = specialId;
     TaskName       = taskName;
     TimeSpan       = timeSpan;
     IsSuccess      = isSuccess;
     ErrorMessage   = errorMessage;
     AddDate        = addDate;
 }
Example #6
0
        public void AddCreatCodeType(CreateType type)
        {
            switch (type)
            {
            case CreateType.CPP:
                CodeCreater.Add(new CPPCodeCreater(FilePath, ACodeCreater._namespace));
                break;

            case CreateType.CSharp:
                CodeCreater.Add(new CSharpCodeCreater(FilePath, ACodeCreater._namespace));
                break;

            default:
                break;
            }
        }
        private void fCreateOpenDatabase_Load(object sender, EventArgs e)
        {
            switch (Type)
            {
                case CreateType.Create:
                    Text = "Create New Database";
                    break;

                case CreateType.Open:
                    if (!File.Exists(Path))
                    {
                        Type = CreateType.Create;
                        Text = "Create New Database";
                    }
                    else
                    {
                        Text = "Open Database";
                    }
                    break;
            }
        }
        public static void PrepareOpen(
            ModelDialectRevision clientDialect,
            AppInstanceIdType appInstanceIdType,
            CreateType createType)
        {
            Condition.IsTrue(State == ModelState.Initialized);

            // appInstanceIdType should not be Invalid or None when preparing.
            Condition.IsFalse(appInstanceIdType == AppInstanceIdType.InvalidAppInstanceId || appInstanceIdType == AppInstanceIdType.NoAppInstanceId);
            Condition.IsFalse(createType == CreateType.ReconnectDurable);

            Combination.Isolated(clientDialect == ModelDialectRevision.Smb2002);
            Combination.Isolated(clientDialect == ModelDialectRevision.Smb21);

            // If the server doesn't support Dialect 3.x family, then createdurablev2 will not work and CreateDurableThenDisconnect will result in Open is null.
            Condition.IfThen(!ModelUtility.IsSmb3xFamily(MaxSmbVersionSupported), createType != CreateType.CreateDurableThenDisconnect);

            State = ModelState.Connected;
            Open = new AppInstanceIdModelOpen();
            Open.CreateTypeWhenPrepare = createType;
            Open.AppInstanceId = AppInstanceIdType.NoAppInstanceId;

            if (!ModelUtility.IsSmb3xFamily(MaxSmbVersionSupported))
            {
                ModelHelper.Log(LogType.TestInfo,
                    "Connection.Dialect does not belong to SMB 3.x dialect family. So Open.AppInstanceId is not set.");
                return;
            }

            ModelHelper.Log(LogType.Requirement,
                "3.3.5.9: If the server implements the SMB 3.x dialect family,  the server MUST initialize the following:");
            ModelHelper.Log(LogType.TestInfo, "Server supports dialect {0}.", MaxSmbVersionSupported);

            if (createType == CreateType.CreateDurable)
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9: Open.AppInstanceId MUST be set to AppInstanceId in the SMB2_CREATE_APP_INSTANCE_ID create context request " +
                    "if the create request includes the SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 and SMB2_CREATE_APP_INSTANCE_ID create contexts.");
                Open.AppInstanceId = appInstanceIdType;
                ModelHelper.Log(LogType.TestInfo,
                    "The create request includes the SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 and SMB2_CREATE_APP_INSTANCE_ID create contexts.");
            }
        }
Example #9
0
 /// <summary>
 /// 生成迷宫
 /// </summary>
 /// <param name = "type">生成迷宫算法</param>
 /// <param name="startX">起点X坐标</param>
 /// <param name="startY">起点Y坐标</param>
 private void CreateMaze(CreateType type, int startX = -1, int startY = -1)
 {
     Stopwatch createStopwatch=new Stopwatch();
     createStopwatch.Start();
     //迷宫尺寸合法化
     if (MazeWidth < 1)
         MazeWidth = 1;
     if (MazeHeight < 1)
         MazeHeight = 1;
     //迷宫起点合法化
     if (startX < 0 || startX >= MazeWidth)
         startX = _r.Next(0, MazeWidth);
     if (startY < 0 || startY >= MazeHeight)
         startY = _r.Next(0, MazeHeight);
     //减去边框所占的格子
     if (!HaveBorder)
     {
         MazeWidth--;
         MazeHeight--;
     }
     //迷宫尺寸换算成带墙尺寸
     MazeWidth *= 2;
     MazeHeight *= 2;
     //迷宫起点换算成带墙起点
     startX *= 2;
     startY *= 2;
     if (HaveBorder)
     {
         startX++;
         startY++;
     }
     //产生空白迷宫
     MazeMap = new int[MazeWidth + 1, MazeHeight + 1];
     for (int x = 0; x <= MazeWidth; x++)
     {
         //mazeMap.Add(new BitArray(mazeHeight + 1));
         for (int y = 0; y <= MazeHeight; y++)
         {
             MazeMap[x, y] = Block;
         }
     }
     //初始化剧本
     CreateScript = new List<ScriptPoint>();
     //产生迷宫
     switch (type)
     {
         case CreateType.Prim:
             PreviewMaze = CopyInts(MazeMap);
             Prim(startX, startY, MazeWidth - 1, MazeHeight - 1);
             break;
         case CreateType.RecursiveBacktrack:
             PreviewMaze = CopyInts(MazeMap);
             RecursiveBacktrack(startX, startY, MazeWidth - 1, MazeHeight - 1);
             break;
         case CreateType.RecursiveDivision:
             for (int x = 0; x <= MazeWidth; x++)
             {
                 for (int y = 0; y <= MazeHeight; y++)
                 {
                     if (HaveBorder && (x == 0 || x == MazeWidth || y == 0 || y == MazeHeight))
                     {
                         MazeMap[x, y] = Block;
                     }
                     else
                     {
                         MazeMap[x, y] = UnBlock;
                     }
                 }
             }
             if (HaveBorder)
             {
                 PreviewMaze = CopyInts(MazeMap);
                 RecursiveDivision(1, MazeWidth - 1, 1, MazeHeight - 1);
             }
             else
             {
                 PreviewMaze = CopyInts(MazeMap);
                 RecursiveDivision(0, MazeWidth, 0, MazeHeight);
             }
             break;
         case CreateType.DfsGraph:
             PreviewMaze = CopyInts(MazeMap);
             DfsGraph(startX, startY, MazeWidth - 1, MazeHeight - 1);
             break;
     }
     createStopwatch.Stop();
     CreateTime = createStopwatch.Elapsed;
 }
Example #10
0
 /// <summary>
 /// 初始化迷宫数组
 /// </summary>
 /// <param name="type">生成所使用的算法</param>
 /// <param name="start">起点</param>
 public void CreateMaze(CreateType type, Point start)
 {
     CreateMaze(type, start.X, start.Y);
 }
        public void OpenRequest(
            ClientGuidType clientGuidType,
            PathNameType pathNameType,
            CreateType createType,
            ShareType shareType,
            AppInstanceIdType appInstanceIdType)
        {
            Smb2FunctionalClient testClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);
            uint treeId;
            string share;
            switch (shareType)
            {
                case ShareType.SameShare:
                    share = testConfig.BasicFileShare;
                    break;
                case ShareType.DifferentShareSameLocal:
                    share = testConfig.SameWithSMBBasic;
                    break;
                case ShareType.DifferentShareDifferentLocal:
                    share = testConfig.DifferentFromSMBBasic;
                    cleanFileInDifferentShare = true;
                    break;
                default:
                    throw new ArgumentException("shareType");
            }

            ConnectToShare(
                clientDialect,
                testClient,
                clientGuidType == ClientGuidType.SameClientGuid ? this.connection_ClientGuid : Guid.NewGuid(),
                share,
                out treeId);

            FILEID fileId;
            Smb2CreateContextResponse[] createContextResponse;
            uint status;
            string fileNameInOpen;
            if (pathNameType == PathNameType.SamePathName)
            {
                fileNameInOpen = fileName;
            }
            else
            {
                fileNameInOpen = fileName + different;
                cleanFileWithDifferentName = true;
            }

            status = testClient.Create(
                treeId,
                fileNameInOpen,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileId,
                out createContextResponse,
                createContexts: CreateContexts(appInstanceIdType, createType, false),
                shareAccess: ShareAccess_Values.NONE,
                checker: (header, response) => { });

            // The file is not created, no need to delete.
            if (status != Smb2Status.STATUS_SUCCESS)
            {
                cleanFileInDifferentShare = false;
                cleanFileWithDifferentName = false;
            }

            testClient.Disconnect();
            testClient = null;

            // Check if the Open is closed.
            // If status is success, and fileId is the same with the previous one, then the Open is not closed.
            // Otherwise, use some other way to check if the Open is closed.
            bool ifClosed;
            if (status == Smb2Status.STATUS_SUCCESS && fileId.Persistent == this.open_FileId.Persistent)
                ifClosed = false;
            else
                ifClosed = CheckIfOpenClosed(clientDialect, createType);
            this.OpenResponse(ifClosed ? OpenStatus.OpenClosed : OpenStatus.OpenNotClosed);
        }
        private Smb2CreateContextRequest[] CreateContexts(AppInstanceIdType appInstanceIdType, CreateType createType, bool prepare)
        {
            List<Smb2CreateContextRequest> contexts = new List<Smb2CreateContextRequest>();

            // Construct other context besides appInstanceId context.
            switch (createType)
            {
                case CreateType.CreateDurable:
                case CreateType.CreateDurableThenDisconnect:
                    this.createGuid = Guid.NewGuid();

                    testConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2);

                    contexts.Add(
                        new Smb2CreateDurableHandleRequestV2
                        {
                            CreateGuid = this.createGuid,
                        });

                    if (createType == CreateType.CreateDurableThenDisconnect)
                    {
                        testConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_REQUEST_LEASE);

                        this.leaseKey = Guid.NewGuid();
                        contexts.Add(
                            new Smb2CreateRequestLease
                            {
                                LeaseKey = this.leaseKey,
                                LeaseState = LeaseStateValues.SMB2_LEASE_READ_CACHING | LeaseStateValues.SMB2_LEASE_HANDLE_CACHING | LeaseStateValues.SMB2_LEASE_WRITE_CACHING,
                            });
                    }
                    break;

                case CreateType.NoContext:
                    break;

                case CreateType.OtherContext:
                    testConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_QUERY_ON_DISK_ID);

                    contexts.Add(new Smb2CreateQueryOnDiskId());
                    break;
                case CreateType.ReconnectDurable:
                    testConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2, CreateContextTypeValue.SMB2_CREATE_REQUEST_LEASE);

                    contexts.Add(
                        new Smb2CreateDurableHandleReconnectV2
                        {
                            CreateGuid = this.createGuid,
                            FileId = new FILEID { Persistent = this.open_FileId.Persistent },
                        });
                    contexts.Add(
                        new Smb2CreateRequestLease
                        {
                            LeaseKey = this.leaseKey,
                            LeaseState = LeaseStateValues.SMB2_LEASE_READ_CACHING | LeaseStateValues.SMB2_LEASE_HANDLE_CACHING | LeaseStateValues.SMB2_LEASE_WRITE_CACHING,
                        });

                    break;
                default:
                    throw new ArgumentException("createType");
            }

            Guid appInstanceGuid = default(Guid);
            switch (appInstanceIdType)
            {
                case AppInstanceIdType.NoAppInstanceId:
                    if (prepare)
                    {
                        Site.Assert.Fail("appInstanceIdType should not be None when preparing open.");
                    }
                    break;
                case AppInstanceIdType.AppInstanceIdIsZero:
                    appInstanceGuid = Guid.Empty;
                    break;
                case AppInstanceIdType.ValidAppInstanceId:
                    appInstanceGuid = prepare ? Guid.NewGuid() : this.appInstanceId;
                    break;
                case AppInstanceIdType.InvalidAppInstanceId:
                    if (prepare)
                    {
                        Site.Assert.Fail("appInstanceIdType should not be Invalid when preparing open.");
                    }
                    appInstanceGuid = Guid.NewGuid();
                    break;
                default:
                    throw new ArgumentException("appInstanceIdType");
            }

            if (prepare)
            {
                this.appInstanceId = appInstanceGuid;
            }

            if (appInstanceIdType != AppInstanceIdType.NoAppInstanceId)
            {
                contexts.Add(new Smb2CreateAppInstanceId { AppInstanceId = appInstanceGuid });
            }
            return contexts.ToArray();
        }
        private bool CheckIfOpenClosed(ModelDialectRevision dialect, CreateType createType)
        {
            if (createType == CreateType.ReconnectDurable)
            {
                /// prepareClient is disconnected, so
                /// Reconnect to the share and try to get the open, if the durable open can be reconnected, then it's not closed.
                Smb2FunctionalClient reconnectClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);
                uint treeId;
                ConnectToShare(
                    dialect,
                    reconnectClient,
                    this.connection_ClientGuid,
                    testConfig.BasicFileShare,
                    out treeId);
                FILEID fileId;
                Smb2CreateContextResponse[] createContextResponse;
                uint status = reconnectClient.Create(
                    treeId,
                    this.fileName,
                    CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                    out fileId,
                    out createContextResponse,
                    createContexts: CreateContexts(AppInstanceIdType.NoAppInstanceId, createType, false),
                    shareAccess:ShareAccess_Values.NONE,
                    checker: (header, response) => {});

                Site.Log.Add(LogEntryKind.Debug, "CheckIfOpenClosed: status of reconnectClient.Create is " + Smb2Status.GetStatusCode(status));

                reconnectClient.Close(treeId, fileId, (header, response) => { });
                reconnectClient.Disconnect();
                return !(status == Smb2Status.STATUS_SUCCESS);
            }
            else
            {
                /// Write (using the FileID got from the create response of PrepareOpen) to check if the Open is closed.
                uint status = prepareClient.Write(this.treeConnect_TreeId, this.open_FileId, "AppInstanceId", checker: (header, response) => { });
                Site.Log.Add(LogEntryKind.Debug, "CheckIfOpenClosed: status of Write is " + Smb2Status.GetStatusCode(status));
                prepareClient.Close(this.treeConnect_TreeId, this.open_FileId, (header, response) => { });
                return status == Smb2Status.STATUS_FILE_CLOSED;
            }
        }
        public static void OpenRequest(
            ClientGuidType clientGuidType,
            PathNameType pathNameType,
            CreateType createType,
            ShareType shareType,
            AppInstanceIdType appInstanceIdType)
        {
            Condition.IsTrue(State == ModelState.Connected);
            Condition.IsNotNull(Open);

            // Isolate below params to limite the expanded test cases.
            Combination.Isolated(clientGuidType == ClientGuidType.SameClientGuid);
            Combination.Isolated(pathNameType == PathNameType.DifferentPathName);
            Combination.Isolated(shareType == ShareType.DifferentShareDifferentLocal);
            Combination.Isolated(shareType == ShareType.DifferentShareSameLocal);
            Combination.Isolated(appInstanceIdType == AppInstanceIdType.InvalidAppInstanceId);
            Combination.Isolated(appInstanceIdType == AppInstanceIdType.NoAppInstanceId);

            // "AppInstanceId is zero" is only applicable for the first Create Request.
            // For the second Create Request, only valid/notvalid/none make sense.
            Condition.IsFalse(appInstanceIdType == AppInstanceIdType.AppInstanceIdIsZero);

            // CreateDurableThenDisconnect is only applicable for the first Create Request.
            Condition.IsFalse(createType == CreateType.CreateDurableThenDisconnect);

            // If the client doesn't disconnect from the server after sending the first Create Request,
            // then the second Create Request does not need to contain reconnect context.
            // And vice versa.
            Condition.IfThen(Open.CreateTypeWhenPrepare != CreateType.CreateDurableThenDisconnect, createType != CreateType.ReconnectDurable);
            Condition.IfThen(Open.CreateTypeWhenPrepare == CreateType.CreateDurableThenDisconnect, createType == CreateType.ReconnectDurable);

            if (createType == CreateType.ReconnectDurable)
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9.13: If the create request also includes the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context, " +
                    "the server MUST process the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context as specified in section 3.3.5.9.12, " +
                    "and this section MUST be skipped.");
                ModelHelper.Log(LogType.TestInfo, "SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context is included.");
                return;
            }

            if (!ModelUtility.IsSmb3xFamily(MaxSmbVersionSupported))
            {
                ModelHelper.Log(LogType.Requirement,
                    "2.2.13.2.13: The SMB2_CREATE_APP_INSTANCE_ID context is valid only for the SMB 3.x dialect family.");
                ModelHelper.Log(LogType.TestInfo, "The dialect version of the server is {0}.", MaxSmbVersionSupported);
                return;
            }

            if (appInstanceIdType == AppInstanceIdType.ValidAppInstanceId && Open.AppInstanceId != AppInstanceIdType.NoAppInstanceId
                && pathNameType == PathNameType.SamePathName
                && shareType == ShareType.SameShare
                && clientGuidType == ClientGuidType.DifferentClientGuid)
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9.13: The server MUST attempt to locate an Open in GlobalOpenTable where:");
                ModelHelper.Log(LogType.Requirement,
                    "\tAppInstanceId in the request is equal to Open.AppInstanceId.");
                ModelHelper.Log(LogType.Requirement,
                    "\tTarget path name is equal to Open.PathName.");
                ModelHelper.Log(LogType.Requirement,
                    "\tOpen.TreeConnect.Share is equal to TreeConnect.Share.");
                ModelHelper.Log(LogType.Requirement,
                    "\tOpen.Session.Connection.ClientGuid is not equal to the current Connection.ClientGuid.");
                ModelHelper.Log(LogType.TestInfo, "All the above conditions are met.");

                ModelHelper.Log(LogType.Requirement,
                    "If an Open is found, the server MUST calculate the maximal access that the user, " +
                    "identified by Session.SecurityContext, has on the file being opened<277>. " +
                    "If the maximal access includes GENERIC_READ access, the server MUST close the open as specified in 3.3.4.17.");
                // The user used in this model is administrator, so maximal access always includes GENERIC_READ access.
                ModelHelper.Log(LogType.TestInfo, "The maximal access includes GENERIC_READ access. So open is closed.");

                // close open
                Open = null;
            }
            else
            {
                ModelHelper.Log(LogType.TestInfo, "appInstanceIdType is {0}.", appInstanceIdType.ToString());
                ModelHelper.Log(LogType.TestInfo, "pathNameType is {0}.", pathNameType.ToString());
                ModelHelper.Log(LogType.TestInfo, "shareType is {0}.", shareType.ToString());
                ModelHelper.Log(LogType.TestInfo, "clientGuidType is {0}.", clientGuidType.ToString());
                ModelHelper.Log(LogType.TestInfo, "All the above conditions do not match the requirement, so open will not be closed.");

                ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields);
            }
        }
        public void PrepareOpen(
            ModelDialectRevision dialect,
            AppInstanceIdType appInstanceIdType,
            CreateType createType)
        {
            // Connect, Negotiate, SessionSetup, TreeConnect
            prepareClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site);
            this.connection_ClientGuid = Guid.NewGuid();
            clientDialect = dialect;
            ConnectToShare(clientDialect, prepareClient, connection_ClientGuid, testConfig.BasicFileShare, out treeConnect_TreeId);

            // Create
            this.fileName = "AppInstanceIdModel_" + Guid.NewGuid();
            Smb2CreateContextResponse[] createContextResponse;

            prepareClient.Create(
                this.treeConnect_TreeId,
                this.fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out this.open_FileId,
                out createContextResponse,
                createContexts: CreateContexts(appInstanceIdType, createType, true),
                shareAccess:ShareAccess_Values.NONE);

            if (createType == CreateType.CreateDurableThenDisconnect)
            {
                prepareClient.Disconnect();
            }
        }
Example #16
0
		public CaTypeCreate() {
			m_bs = CreateType.None;
		}
Example #17
0
 public ShowCreate(CreateType type, Identifier id)
 {
     CreateType = type;
     Id = id;
 }