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


C# Services.New方法代码示例

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


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

示例1: CreateTestProject

 private static void CreateTestProject(bool useOAuthEndpoints)
 {
     V1Connector connector;
     if (useOAuthEndpoints)
     {
         connector = V1Connector.WithInstanceUrl(ConfigurationManager.AppSettings.Get("V1Url"))
             .WithUserAgentHeader("IntegrationTests", "1.0")
             .WithAccessToken(ConfigurationManager.AppSettings.Get("V1AccessToken"))
             .UseOAuthEndpoints()
             .Build();
     }
     else
     {
         connector = V1Connector.WithInstanceUrl(ConfigurationManager.AppSettings.Get("V1Url"))
             .WithUserAgentHeader("IntegrationTests", "1.0")
             .WithAccessToken(ConfigurationManager.AppSettings.Get("V1AccessToken"))
             .Build();
     }
     var services = new Services(connector);
     var assetType = services.Meta.GetAssetType("Scope");
     var nameAttribute = assetType.GetAttributeDefinition("Name");
     var projectId = services.GetOid("Scope:0");
     var newAsset = services.New(assetType, projectId);
     newAsset.SetAttributeValue(nameAttribute, TestProjectName);
     services.Save(newAsset);
     _testProjectId = newAsset.Oid.Momentless;
 }
开发者ID:xtremeRacer,项目名称:VersionOne.SDK.NET.APIClient,代码行数:27,代码来源:IntegrationTestsHelper.cs

示例2: NewMultiValueRelationLoads

		[Test] public void NewMultiValueRelationLoads()
		{
			var subject = new Services(Meta, DataConnector);
			var storyType = Meta.GetAssetType("Story");
			var storyRequests = storyType.GetAttributeDefinition("Requests");
			var contextOid = Oid.FromToken("Request:6075", Meta);
			var storyAsset = subject.New(storyType, contextOid);

			Assert.IsTrue(storyAsset.GetAttribute(storyRequests).HasChanged,"Story Requests has changed");

			var x = storyAsset.GetAttribute(storyRequests).NewValues.Cast<object>().ToList();

			Assert.Contains(contextOid, x, "Story Requests contains " + contextOid.Token);
		}
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:14,代码来源:ServicesTester.cs

示例3: ReOpenAnAssetTest

        public void ReOpenAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story
            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var story = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            story.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(story);

            // closes the story
            var closeOperation = metaModel.GetOperation("Story.Inactivate");
            var closeId = services.ExecuteOperation(closeOperation, story.Oid);

            //reopens the story
            var activateOperation = metaModel.GetOperation("Story.Reactivate");
            var activeId = services.ExecuteOperation(activateOperation, story.Oid);

            var query = new Query(activeId.Momentless);
            var assetState = metaModel.GetAttributeDefinition("Story.AssetState");
            query.Selection.Add(assetState);
            var result = services.Retrieve(query);
            Asset activeStory = result.Assets[0];

            Assert.AreEqual("Active", activeStory.GetAttribute(assetState).Value.ToString());
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:31,代码来源:GettingStartedTests.cs

示例4: DeleteAnAssetTest

        public void DeleteAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story so we can delete it
            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var newStory = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            newStory.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(newStory);
            // delete the story
            var deleteOperation = metaModel.GetOperation("Story.Delete");
            var deletedId = services.ExecuteOperation(deleteOperation, newStory.Oid);
            var query = new Query(deletedId.Momentless);
            QueryResult result = services.Retrieve(query);

            Assert.AreEqual(0, result.TotalAvaliable);

            // The delete operation returns the Oid with the new Moment of the deleted asset. 
            // Future queries will automatically exclude deleted assets from results.
            // Currently there is no support for undeleting a deleted asset.
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:26,代码来源:GettingStartedTests.cs

示例5: AddNewAssetTest

        public void AddNewAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var newStory = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            newStory.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(newStory);

            Assert.False(newStory.Oid.IsNull);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:16,代码来源:GettingStartedTests.cs


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