本文整理汇总了C#中Container.DeleteObject方法的典型用法代码示例。如果您正苦于以下问题:C# Container.DeleteObject方法的具体用法?C# Container.DeleteObject怎么用?C# Container.DeleteObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.DeleteObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
//instruct client side library to insert token as Authorization value into each request
container = new Container(new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/"));
var token = GetToken();
container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", token);
//check if our app package exists
AppPackage package = null;
try { package = container.AppPackages.ByKey(PackageName).GetValue(); } catch {}
string res = null;
if (package!=null)
res = Prompts.PromptForKeyword(string.Format("AppPackage '{0}' already exists. What do you want to do? [Recreate/Update/Leave]<Update>", PackageName));
if (res == "Recreate")
{
container.DeleteObject(package);
container.SaveChanges();
package = null;
}
if (res!="Leave")
package = CreateOrUpdatePackage(CreateZip(), package);
//check if our activity already exist
Activity activity = null;
try { activity = container.Activities.ByKey(ActivityName).GetValue(); }
catch { }
if (activity != null)
{
if (Prompts.PromptForKeyword(string.Format("Activity '{0}' already exists. Do you want to recreate it? [Yes/No]<No>", ActivityName)) == "Yes")
{
container.DeleteObject(activity);
container.SaveChanges();
activity = null;
}
}
if (activity == null)
activity = CreateActivity(package);
//save outstanding changes if any
container.SaveChanges();
//finally submit workitem against our activity
SubmitWorkItem(activity);
// demo new features in V2 -- version control
DemoVersionControl();
}
示例2: Delete_ProductFamily
private static void Delete_ProductFamily()
{
Container ctx = new Container();
Console.WriteLine("\t<< delete productfamily >>");
//NOTE: WE ARE DOING A GET HERE
ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == 4).FirstOrDefault();
if (family != null)
{
//DELETE HERE
ctx.DeleteObject(family);
ctx.SaveChanges();
}
}
示例3: DelPackage
static void DelPackage(Container container, string packId = "")
{
if (packId == "")
{
foreach (var pack in container.AppPackages)
{
if (!pack.IsPublic)
container.DeleteObject(pack);
}
container.SaveChanges();
}
else
{
try
{
var pack = container.AppPackages.ByKey(packId).GetValue();
if (pack != null)
{
container.DeleteObject(pack);
container.SaveChanges();
}
}
catch { }// the package does not exist. will throw the exception.
}
}
示例4: DelActivity
static void DelActivity(Container container, string actId = "")
{
if (actId == "")
{
//delete all actvities
foreach (var act in container.Activities)
{
if (!act.IsPublic)
container.DeleteObject(act);
}
container.SaveChanges();
}
else
{
try
{
var act = container.Activities.ByKey(actId).GetValue();
if (act != null)
{
container.DeleteObject(act);
container.SaveChanges();
}
}
catch { } // the activity does not exist. will throw exception
}
}
示例5: Delete_ProductFamily
private static void Delete_ProductFamily()
{
Container ctx = new Container();
Console.WriteLine("\n\t<< delete productfamily >>");
int key = 4;
ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == key).FirstOrDefault();
if (family != null)
{
Console.WriteLine("\tDeleting ProductFamily with Id={0}, Name={1}", family.ID, family.Name);
ctx.DeleteObject(family);
ctx.SaveChanges();
}
else
{
Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
}
}