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


C# Container.DeleteObject方法代码示例

本文整理汇总了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();
        }
开发者ID:CADblokeCADforks,项目名称:autocad.io-custom-activity-apppackage-CSharp,代码行数:47,代码来源:Program.cs

示例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();
            }
        }
开发者ID:seattlekiran,项目名称:OdataSample,代码行数:14,代码来源:Program.cs

示例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.
            }
        }
开发者ID:xiaodongliang,项目名称:adnxddwgsigature,代码行数:26,代码来源:Program.cs

示例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
                }

            } 
开发者ID:xiaodongliang,项目名称:adnxddwgsigature,代码行数:28,代码来源:Program.cs

示例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);
            }
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:19,代码来源:Program.cs


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