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


C# IZetboxContext.Create方法代码示例

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


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

示例1: SetUp

        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();
            var principalResolver = scope.Resolve<IPrincipalResolver>();

            var currentPrincipal = principalResolver.GetCurrent();

            Assert.That(currentPrincipal, Is.Not.Null, "No current identity found - try syncidentities or setup the current identity correctly");

            identity1 = ctx.Find<Identity>(currentPrincipal.ID);
            identity2 = ctx.GetQuery<Identity>().Where(i => i.ID != identity1.ID).First();

            parent = ctx.Create<SecurityTestParent>();
            parent.Name = "MyParent";

            child1 = ctx.Create<SecurityTestChild>();
            child1.Name = "Child1";
            child1.Identity = identity1;
            child1.Parent = parent;

            child2 = ctx.Create<SecurityTestChild>();
            child2.Name = "Child2";
            child2.Identity = identity2;
            child2.Parent = parent;

            ctx.SubmitChanges();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:29,代码来源:AbstractSecurityTest.cs

示例2: InitTestObjects

 public void InitTestObjects()
 {
     ctx = GetContext();
     aSide1 = ctx.Create<N_to_M_relations_A>();
     aSide2 = ctx.Create<N_to_M_relations_A>();
     bSide1 = ctx.Create<N_to_M_relations_B>();
     bSide2 = ctx.Create<N_to_M_relations_B>();
 }
开发者ID:daszat,项目名称:zetbox,代码行数:8,代码来源:should_synchronize.cs

示例3: InitTestObjects

 public virtual void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<One_to_N_relations_One>();
     oneSide2 = ctx.Create<One_to_N_relations_One>();
     oneSide3 = ctx.Create<One_to_N_relations_One>();
     nSide1 = ctx.Create<One_to_N_relations_N>();
     nSide2 = ctx.Create<One_to_N_relations_N>();
 }
开发者ID:daszat,项目名称:zetbox,代码行数:9,代码来源:OneNFixture.cs

示例4: InitTestObjects

 public virtual void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<RequiredParent>();
     oneSide2 = ctx.Create<RequiredParent>();
     oneSide3 = ctx.Create<RequiredParent>();
     nSide1 = ctx.Create<RequiredParentChild>();
     nSide2 = ctx.Create<RequiredParentChild>();
 }
开发者ID:daszat,项目名称:zetbox,代码行数:9,代码来源:RequiredParentFixture.cs

示例5: CreateTestData

        /// <summary>
        /// Creates a few new test objects
        /// </summary>
        /// <param name="ctx">this context is used to create the objects</param>
        public static void CreateTestData(IZetboxContext ctx)
        {
            var kunde = ctx.Create<Kunde>();
            kunde.EMails.Add("[email protected]");
            kunde.EMails.Add("[email protected]");
            kunde.Kundenname = "com Kunde";
            kunde.PLZ = "1111";

            kunde = ctx.Create<Kunde>();
            kunde.EMails.Add("[email protected]");
            kunde.Kundenname = "net Kunde";
            kunde.PLZ = "2222";

            kunde = ctx.Create<Kunde>();
            kunde.Kundenname = "empty Kunde";
            kunde.PLZ = "3333";

            kunde = ctx.Create<Kunde>();
            kunde.EMails.Add("[email protected]");
            kunde.EMails.Add("[email protected]");
            kunde.EMails.Add("[email protected]");
            kunde.EMails.Add("[email protected]");
            kunde.Kundenname = "org Kunde";
            kunde.PLZ = "4444";

            var prj = ctx.Create<Projekt>();
            prj.Name = "Zetbox";

            var task1 = ctx.Create<Task>();
            task1.Name = "task1";
            task1.Projekt = prj;

            var task2 = ctx.Create<Task>();
            task2.Name = "task2";
            task2.Projekt = prj;

            var ma1 = ctx.Create<Mitarbeiter>();
            ma1.Geburtstag = new DateTime(1960, 01, 02);
            ma1.Name = "Mitarbeiter Alpha";
            ma1.SVNr = "123456789";
            ma1.TelefonNummer = "+43664123456789";

            var ma2 = ctx.Create<Mitarbeiter>();
            ma2.Geburtstag = new DateTime(1970, 12, 30);
            ma2.Name = "Mitarbeiter Beta";
            ma2.SVNr = "987654321";
            ma2.TelefonNummer = "+43664987654321";

            // Make nHibernate happy
            ctx.SubmitChanges();

            ma2.Projekte.Add(prj);
            ma1.Projekte.Add(prj);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:58,代码来源:ProjectDataFixture.cs

示例6: SetUp

        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            one = ctx.Create<One_to_N_relations_One>();
            n1 = ctx.Create<One_to_N_relations_N>();
            n2 = ctx.Create<One_to_N_relations_N>();

            one.NSide.Add(n1);
            one.NSide.Add(n2);

            ctx.SubmitChanges();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:15,代码来源:when_deleting_one_to_n.cs

示例7: SetUp

        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            a1 = ctx.Create<N_to_M_relations_A>();
            b1 = ctx.Create<N_to_M_relations_B>();
            b2 = ctx.Create<N_to_M_relations_B>();

            a1.BSide.Add(b1);
            a1.BSide.Add(b2);

            ctx.SubmitChanges();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:15,代码来源:when_deleting_n_m.cs

示例8: SetUp

 public override void SetUp()
 {
     base.SetUp();
     ctx = GetContext();
     obj = ctx.Create<TestObjClass>();
     obj.StringProp = "Some String";
 }
开发者ID:daszat,项目名称:zetbox,代码行数:7,代码来源:when_submitting.cs

示例9: SetUp

 public override void SetUp()
 {
     base.SetUp();
     ctx = scope.Resolve<IZetboxContext>();
     ilvm = vmf.CreateViewModel<InstanceListViewModel.Factory>().Invoke(ctx, null, (ObjectClass)NamedObjects.Base.Classes.Zetbox.App.Test.One_to_N_relations_N.Find(ctx), null);
     obj = ctx.Create<One_to_N_relations_N>();
     ctx.SubmitChanges();
 }
开发者ID:daszat,项目名称:zetbox,代码行数:8,代码来源:InstanceListTests.cs

示例10: SetUp

        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            one1 = ctx.Create<One_to_N_relations_One>();
            one2 = ctx.Create<One_to_N_relations_One>();
            n1 = ctx.Create<One_to_N_relations_N>();
            n2 = ctx.Create<One_to_N_relations_N>();

            one1.Name = "One1";
            one2.Name = "One2";
            n1.Name = "N1";
            n2.Name = "N2";

            one1.NSide.Add(n1);
            one1.NSide.Add(n2);

            ctx.SubmitChanges();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:21,代码来源:when_changing_one_to_n.cs

示例11: InitTestObjects

 public virtual void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<OrderedOneEnd>();
     oneSide2 = ctx.Create<OrderedOneEnd>();
     oneSide3 = ctx.Create<OrderedOneEnd>();
     nSide1 = ctx.Create<OrderedNEnd>();
     nSide2 = ctx.Create<OrderedNEnd>();
     nSide3 = ctx.Create<OrderedNEnd>();
 }
开发者ID:daszat,项目名称:zetbox,代码行数:10,代码来源:OrderedOneNFixture.cs

示例12: CreateTypeRef

        private static TypeRef CreateTypeRef(Type t, IZetboxContext ctx)
        {
            var result = ctx.Create<TypeRef>();
            var a = t.Assembly.ToRef(ctx);
            result.Assembly = a;

            if (t.IsGenericType)
            {
                var genericDefinition = t.GetGenericTypeDefinition();
                result.FullName = genericDefinition.FullName;
                result.GenericArguments.Clear();
                foreach (var arg in t.GetGenericArguments())
                {
                    result.GenericArguments.Add(arg.ToRef(ctx));
                }
            }
            else
            {
                result.FullName = t.FullName;
            }

            if (t.BaseType != null)
            {
                result.Parent = t.BaseType.ToRef(ctx);
            }
            return result;
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:27,代码来源:TypeRefExtensions.cs

示例13: ToRef

        /// <summary>
        /// returns a zetbox Assembly for a given CLR-Assembly, creating it if necessary
        /// </summary>
        public static Assembly ToRef(this System.Reflection.Assembly ass, IZetboxContext ctx)
        {
            if (ass == null) { throw new ArgumentNullException("ass"); }
            if (ctx == null) { throw new ArgumentNullException("ctx"); }

            Assembly result = ass.ToRefOrDefault(ctx);
            if (result == null)
            {
                result = ctx.Create<Assembly>();
                result.Name = ass.FullName;
                // Leave module empty. Must be set external
                // result.Module = ctx.GetQuery<Module>().Single(m => m.Name == "ZetboxBase");
                result.DeploymentRestrictions = DeploymentRestriction.ClientOnly;
            }
            return result;
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:19,代码来源:TypeRefExtensions.cs

示例14: CreateTasks

 private void CreateTasks(IZetboxContext ctx, Projekt p)
 {
     for (int i = 0; i < task_projectCount; i++)
     {
         var t = ctx.Create<Task>();
         t.Name = "Task " + i;
         p.Tasks.Add(t);
     }
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:9,代码来源:SecurityDataFixture.cs

示例15: CreateViewDescriptors

        private static void CreateViewDescriptors(IZetboxContext ctx, SR.Assembly srAssembly)
        {
            using (Logging.Log.InfoTraceMethodCallFormat("CreateViewDescriptors", "Creating ViewDescriptors"))
            {
                var liveDescriptors = new HashSet<ViewDescriptor>();

                foreach (var type in GetTypes(srAssembly))
                {
                    object attr;
                    Toolkit? tk = null;
                    // http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
                    if (type.Assembly.ReflectionOnly)
                    {
                        attr = SR.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewDescriptorAttribute).FullName);
                        if (attr != null) tk = (Toolkit)((SR.CustomAttributeData)attr).ConstructorArguments.Single().Value;
                    }
                    else
                    {
                        attr = type.GetCustomAttributes(typeof(ViewDescriptorAttribute), false).FirstOrDefault() as ViewDescriptorAttribute;
                        if (attr != null) tk = ((ViewDescriptorAttribute)attr).Toolkit;
                    }
                    if (attr != null)
                    {
                        var typeName = type.GetSimpleName();

                        // if a view can be used under multiple ControlKinds, it needs to have multiple ViewDescriptors
                        var descrList = ctx.GetQuery<ViewDescriptor>().Where(i => i.ControlTypeRef == typeName).ToList();
                        if (descrList.Count == 0)
                        {
                            var descr = ctx.Create<ViewDescriptor>();
                            descr.ControlTypeRef = typeName;
                            if (tk != null) descr.Toolkit = tk.Value;
                            liveDescriptors.Add(descr);
                        }
                        else
                        {
                            foreach (var descr in descrList)
                            {
                                descr.Deleted = false;
                                liveDescriptors.Add(descr);
                            }
                        }
                    }
                }

                var simpleAssemblyName = srAssembly.GetSimpleName();
                var deadDescriptors = ctx
                    .GetQuery<ViewDescriptor>()
                    .ToList()
                    .Where(vmd => TypeSpec.Parse(vmd.ControlTypeRef).AssemblyName.IfNullOrWhiteSpace(string.Empty).Split(',').FirstOrDefault().IfNullOrWhiteSpace(string.Empty).Trim() == simpleAssemblyName)
                    .Except(liveDescriptors);
                foreach (var d in deadDescriptors)
                {
                    d.Deleted = true;
                }
            }
        }
开发者ID:daszat,项目名称:zetbox,代码行数:57,代码来源:AssemblyActions.cs


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