本文整理汇总了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;
}
示例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);
}
示例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());
}
示例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.
}
示例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);
}