當前位置: 首頁>>代碼示例>>C#>>正文


C# DataRequests.DataObjectDefinitionRequest類代碼示例

本文整理匯總了C#中Syncano.Net.DataRequests.DataObjectDefinitionRequest的典型用法代碼示例。如果您正苦於以下問題:C# DataObjectDefinitionRequest類的具體用法?C# DataObjectDefinitionRequest怎麽用?C# DataObjectDefinitionRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataObjectDefinitionRequest類屬於Syncano.Net.DataRequests命名空間,在下文中一共展示了DataObjectDefinitionRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddChild_ByCollectionKey

        public async Task AddChild_ByCollectionKey(DataObjectSyncanoClient client)
        {
            //given
            var newParentRequest = new DataObjectDefinitionRequest();
            newParentRequest.ProjectId = TestData.ProjectId;
            newParentRequest.CollectionId = TestData.CollectionId;
            var parentObject = await client.New(newParentRequest);

            var newChildRequest = new DataObjectDefinitionRequest();
            newChildRequest.ProjectId = TestData.ProjectId;
            newChildRequest.CollectionId = TestData.CollectionId;
            var childObject = await client.New(newChildRequest);

            //when
            var result =
                await
                    client.AddChild(TestData.ProjectId, parentObject.Id, childObject.Id,
                        collectionKey: TestData.CollectionKey);

            var getResult =
                await
                    client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId: parentObject.Id,
                        includeChildren: true);

            //then
            result.ShouldBeTrue();
            getResult.Children.ShouldNotBeEmpty();
            getResult.Children[0].Id.ShouldEqual(childObject.Id);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:35,代碼來源:DataObjectSyncanoClientAddChildRemoveChildTests.cs

示例2: Get_ByCollectionId_WithStateModerated

        public async Task Get_ByCollectionId_WithStateModerated(DataObjectSyncanoClient client)
        {
            //given
            var newRequest = new DataObjectDefinitionRequest();
            newRequest.ProjectId = TestData.ProjectId;
            newRequest.CollectionId = TestData.CollectionId;
            newRequest.State = DataObjectState.Moderated;
            var dataObject = await client.New(newRequest);

            var getRequest = new DataObjectRichQueryRequest();
            getRequest.ProjectId = TestData.ProjectId;
            getRequest.CollectionId = TestData.CollectionId;
            getRequest.State = DataObjectState.Moderated;

            //when
            var result =
                await client.Get(getRequest);

            //then
            result.ShouldNotBeNull();
            result.Any(d => d.Id == dataObject.Id).ShouldBeTrue();

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:28,代碼來源:DataObjectSyncanoClientTests.cs

示例3: Update_ByCollectionId_WithUserName_CreatesNewDataObject

        public async Task Update_ByCollectionId_WithUserName_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            var dataObject = await client.New(request);

            request.UserName = TestData.UserName;

            //when
            var result = await client.Update(request, dataObject.Id);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(request.Folder);
            result.User.Name.ShouldEqual(request.UserName);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = result.Id;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:25,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例4: New_ByCollectionKey_CreatesNewDataObject

        public async Task New_ByCollectionKey_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionKey = TestData.CollectionKey;

            //when
            var result = await client.New(request);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(request.Folder);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = result.Id;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:21,代碼來源:DataObjectSyncanoClientNewDeleteTests.cs

示例5: Get_Data2_OrderBy

        public async Task Get_Data2_OrderBy(DataObjectSyncanoClient client)
        {
            //given
            var newData1 = new DataObjectDefinitionRequest();
            newData1.ProjectId = TestData.ProjectId;
            newData1.CollectionId = TestData.CollectionId;
            newData1.DataTwo = 1;

            var newData2 = new DataObjectDefinitionRequest();
            newData2.ProjectId = TestData.ProjectId;
            newData2.CollectionId = TestData.CollectionId;
            newData2.DataTwo = 2;

            var dataObject1 = await client.New(newData1);
            var dataObject2 = await client.New(newData2);

            var getRequest = new DataObjectRichQueryRequest();
            getRequest.ProjectId = TestData.ProjectId;
            getRequest.CollectionId = TestData.CollectionId;
            getRequest.OrderBy = DataObjectOrderBy.DataOne;
            getRequest.Order = DataObjectOrder.Ascending;
            getRequest.AddDataFieldFilter(DataObjectSpecialField.DataTwo, DataObjectOperator.LowerThanOrEquals, 2);
            getRequest.AddDataFieldFilter(DataObjectSpecialField.DataTwo, DataObjectOperator.GreaterThanOrEquals, 1);

            //when
            var result =
                await client.Get(getRequest);

            //then
            result.ShouldNotBeNull();
            result.Count.ShouldEqual(2);
            result[0].Id.ShouldEqual(dataObject1.Id);
            result[1].Id.ShouldEqual(dataObject2.Id);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:40,代碼來源:DataObjectSyncanoClientQueryTests.cs

示例6: New

        /// <summary>
        /// Creates a new Data Object.
        /// <remarks>The collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.</remarks>
        /// <remarks>User API key usage permitted. Requires create_data permission added through folder.authorize(), collection.authorize() or project.authorize(). user_name field is automatically filled in with current user's info.</remarks>
        /// </summary>
        /// <param name="request">Request defining new object.</param>
        /// <returns>New DataObject object.</returns>
        public Task<DataObject> New(DataObjectDefinitionRequest request)
        {
            if(request.ProjectId == null)
                throw new ArgumentNullException();

            if(request.CollectionId == null && request.CollectionKey == null)
                throw new ArgumentNullException();

            if(request.Text != null && request.Text.Length > MaxTextLenght)
                throw new ArgumentException();

            if(request.Title != null && request.Title.Length > MaxTitleLenght)
                throw new ArgumentException();

            AssertAditionals(request.Additional);

            return _syncanoClient.PostAsync<DataObject>("data.new",
                new
                {
                    project_id = request.ProjectId,
                    collection_id = request.CollectionId,
                    collection_key = request.CollectionKey,
                    data_key = request.DataKey,
                    user_name = request.UserName,
                    source_url = request.SourceUrl,
                    title = request.Title,
                    text = request.Text,
                    link = request.Link,
                    image = request.ImageBase64,
                    image_url = request.ImageUrl,
                    folder = request.Folder,
                    state = request.State.ToString(),
                    parent_id = request.ParentId,
                    data1 = request.DataOne,
                    data2 = request.DataTwo,
                    data3 = request.DataThree,
                    additionals = request.Additional
                }, "data");
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:46,代碼來源:DataObjectSyncanoClient.cs

示例7: Update_WithNullCollectionIdAndKey_ThrowsException

        public async Task Update_WithNullCollectionIdAndKey_ThrowsException(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;

            try
            {
                //when
                await client.Update(request, "dataId");
                throw new Exception("Update should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentNullException>();
            }
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:18,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例8: Update_ByCollectionId_WithFolderName_CreatesNewDataObject

        public async Task Update_ByCollectionId_WithFolderName_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var folderClient =
                new FolderSyncanoClient(new SyncanoHttpClient(TestData.InstanceName, TestData.BackendAdminApiKey));
            var newFolder = await folderClient.New(TestData.ProjectId, "NewFolder", TestData.CollectionId);
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            var dataObject = await client.New(request);
            await client.New(request);

            request.Folder = newFolder.Name;

            //when
            var result = await client.Update(request, dataObject.Id);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(newFolder.Name);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = result.Id;
            await client.Delete(deleteRequest);
            await folderClient.Delete(TestData.ProjectId, newFolder.Name, TestData.CollectionId);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:29,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例9: GetOne_ByCollectionId_IncludeChildren_CreatesNewDataObject

        public async Task GetOne_ByCollectionId_IncludeChildren_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;

            var parentRequest = new DataObjectDefinitionRequest();
            parentRequest.ProjectId = TestData.ProjectId;
            parentRequest.CollectionId = TestData.CollectionId;
            var parentResult = await client.New(parentRequest);

            request.ParentId = parentResult.Id;
            var childResult = await client.New(request);

            //when
            var result =
                await
                    client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId: parentResult.Id,
                        includeChildren: true);

            //then
            result.ShouldNotBeNull();
            result.Id.ShouldEqual(parentResult.Id);
            result.Children.ShouldNotBeEmpty();
            result.Children.Any(d => d.Id == childResult.Id).ShouldBeTrue();

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = childResult.Id;
            await client.Delete(deleteRequest);

            var parentDeleteRequest = new DataObjectSimpleQueryRequest();
            parentDeleteRequest.ProjectId = TestData.ProjectId;
            parentDeleteRequest.CollectionId = TestData.CollectionId;
            parentDeleteRequest.DataId = parentResult.Id;
            await client.Delete(parentDeleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:40,代碼來源:DataObjectSyncanoClientTests.cs

示例10: Merge_ByCollectionId_WithStateModerated_CreatesNewDataObject

        public async Task Merge_ByCollectionId_WithStateModerated_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var link = "custom link";
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            request.Link = link;
            var dataObject = await client.New(request);

            request.State = DataObjectState.Moderated;
            request.Link = null;

            //when
            var result = await client.Merge(request, dataObject.Id);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(request.Folder);
            result.State.ShouldEqual(request.State);
            result.Link.ShouldEqual(link);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = result.Id;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:29,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例11: Merge_ByCollectionId_WithImage_CreatesNewDataObject

        public async Task Merge_ByCollectionId_WithImage_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var link = "custom link";
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            request.Link = link;
            var dataObject = await client.New(request);

            request.ImageBase64 = TestData.ImageToBase64("smallSampleImage.png");
            request.Link = null;

            //when
            var result = await client.Merge(request, dataObject.Id);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(request.Folder);
            result.Image.ShouldNotBeNull();
            result.Image.ImageWidth.ShouldEqual(300);
            result.Image.ImageHeight.ShouldEqual(300);
            result.Link.ShouldEqual(link);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = result.Id;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:31,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例12: Merge_ByCollectionId_WithAdditionals_CreatesNewDataObject

        public async Task Merge_ByCollectionId_WithAdditionals_CreatesNewDataObject(DataObjectSyncanoClient client)
        {
            //given
            var additionals = new Dictionary<string, string>();
            additionals.Add("param1", "value1");
            additionals.Add("param2", "value2");
            additionals.Add("param3", "value3");
            var link = "custom link";
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            request.Link = link;
            var dataObject = await client.New(request);

            request.Link = null;
            request.Additional = additionals;

            //when
            var result = await client.Merge(request, dataObject.Id);

            //then
            result.ShouldNotBeNull();
            result.Folder.ShouldEqual(request.Folder);
            result.Link.ShouldEqual(link);
            result.Additional.ShouldNotBeNull();
            result.Additional.Count.ShouldEqual(additionals.Count);

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            deleteRequest.DataId = result.Id;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:34,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例13: Update_WithTooLongText_ThrowsException

        public async Task Update_WithTooLongText_ThrowsException(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            request.Text = new String('a', DataObjectSyncanoClient.MaxTextLenght + 1);

            try
            {
                //when
                await client.Update(request);
                throw new Exception("Update should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentException>();
            }
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:20,代碼來源:DataObjectSyncanoClientUpdateMergeTests.cs

示例14: RemoveChild_ByCollectionKey_WithOtherChildren

        public async Task RemoveChild_ByCollectionKey_WithOtherChildren(DataObjectSyncanoClient client)
        {
            //given
            var newParentRequest = new DataObjectDefinitionRequest();
            newParentRequest.ProjectId = TestData.ProjectId;
            newParentRequest.CollectionId = TestData.CollectionId;
            var parentObject = await client.New(newParentRequest);

            var newOtherRequest = new DataObjectDefinitionRequest();
            newOtherRequest.ProjectId = TestData.ProjectId;
            newOtherRequest.CollectionId = TestData.CollectionId;
            newOtherRequest.ParentId = parentObject.Id;
            var otherObject = await client.New(newOtherRequest);

            var newChildRequest = new DataObjectDefinitionRequest();
            newChildRequest.ProjectId = TestData.ProjectId;
            newChildRequest.CollectionId = TestData.CollectionId;
            var childObject = await client.New(newChildRequest);

            await client.AddChild(TestData.ProjectId, parentObject.Id, childObject.Id, TestData.CollectionId);

            //when
            var result =
                await
                    client.RemoveChild(TestData.ProjectId, parentObject.Id, childObject.Id,
                        TestData.CollectionId);

            var getResult =
                await
                    client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId: parentObject.Id,
                        includeChildren: true);

            //then
            result.ShouldBeTrue();
            getResult.Children.ShouldNotBeEmpty();
            getResult.Children.Count.ShouldEqual(1);
            getResult.Children.Any(d => d.Id == otherObject.Id).ShouldBeTrue();
            getResult.Children.Any(d => d.Id == childObject.Id).ShouldBeFalse();

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:45,代碼來源:DataObjectSyncanoClientAddChildRemoveChildTests.cs

示例15: Copy_WithNullProjectId_ThrowsException

        public async Task Copy_WithNullProjectId_ThrowsException(DataObjectSyncanoClient client)
        {
            //given
            var request = new DataObjectDefinitionRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            var dataObject = await client.New(request);

            var copyRequest = new CopyDataObjectRequest();
            copyRequest.ProjectId = null;
            copyRequest.CollectionId = TestData.CollectionId;
            copyRequest.DataId = dataObject.Id;

            try
            {
                //when
                await client.Copy(copyRequest);
                throw new Exception("New should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentNullException>();
            }

            //cleanup
            var deleteRequest = new DataObjectSimpleQueryRequest();
            deleteRequest.ProjectId = TestData.ProjectId;
            deleteRequest.CollectionId = TestData.CollectionId;
            await client.Delete(deleteRequest);
        }
開發者ID:Syncano,項目名稱:syncano-dotnet,代碼行數:31,代碼來源:DataObjectSyncanoClientTests.cs


注:本文中的Syncano.Net.DataRequests.DataObjectDefinitionRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。