예제 #1
0
 public void MorphismIsFunction()
 {
     Assert.Throws <ArgumentException>(() => Morphism.Create(
                                           Product2.Create(1, true),
                                           Product2.Create(1, false)
                                           ));
 }
예제 #2
0
 public static void TestMorphism(this Morphism m, string name, string source, string target, MorphismType type)
 {
     m.Name.ToTokenString().TestString(name);
     m.Source.ToTokenString().TestString(source);
     m.Target.ToTokenString().TestString(target);
     m.Type.Is(type);
 }
예제 #3
0
 public void IsoMorphismHasUniqueInverse()
 {
     Assert.Throws <ArgumentException>(() => Morphism.CreateIso(
                                           Product2.Create(1, true),
                                           Product2.Create(2, true)
                                           ));
 }
예제 #4
0
        public void ApplyParameter_米田()
        {
            var mor = Morphism.Create(@"\yoneda_{#1?}\colon #1\rightarrow \widehat{#1}").TestSingle();

            mor.Name.AsMathSequence().List.Count.Is(1);
            mor.Name.AsMathSequence().List[0].IsMathToken(@"\yoneda");
            mor.Name.AsMathSequence().Sub.IsMathToken("#1?");
            mor.Source.IsMathToken("#1");
            mor.Target.AsMathSequence().List.Count.Is(2);
            mor.Target.AsMathSequence().List[0].IsMathToken(@"\widehat");
            mor.Target.AsMathSequence().List[1].AsMathSequence().List.Count.Is(1);
            mor.Target.AsMathSequence().List[1].AsMathSequence().List[0].IsMathToken("#1");
            mor.Target.AsMathSequence().List[1].AsMathSequence().LeftBracket.TestToken("{");
            mor.Target.AsMathSequence().List[1].AsMathSequence().RightBracket.TestToken("}");

            var f          = new MathObjectFactory(@"\yoneda_a").CreateSingle();
            var parameters = new Dictionary <string, MathObject>();

            mor.Name.IsSameType(f, parameters).IsTrue();
            mor = mor.ApplyParameter(f, parameters, false).TestSingle();
            mor.Name.AsMathSequence().List.Count.Is(1);
            mor.Name.AsMathSequence().List[0].IsMathToken(@"\yoneda");
            mor.Name.AsMathSequence().Sub.IsMathToken("a");
            mor.Source.IsMathToken("a");
            mor.Target.AsMathSequence().List.Count.Is(2);
            mor.Target.AsMathSequence().List[0].IsMathToken(@"\widehat");
            mor.Target.AsMathSequence().List[1].AsMathSequence().List.Count.Is(1);
            mor.Target.AsMathSequence().List[1].AsMathSequence().List[0].IsMathToken("a");
            mor.Target.AsMathSequence().List[1].AsMathSequence().LeftBracket.TestToken("{");
            mor.Target.AsMathSequence().List[1].AsMathSequence().RightBracket.TestToken("}");
            mor.Target.ToTokenString().TestString(@"\widehat{a}");
        }
예제 #5
0
        public void ApplyParameter_通常()
        {
            var mor = Morphism.Create(@"\theta^{#1}\colon F(#1)\rightarrow G#1").TestSingle();

            mor.Name.AsMathSequence().List.Count.Is(1);
            mor.Name.AsMathSequence().List[0].IsMathToken(@"\theta");
            mor.Name.AsMathSequence().Sup.IsMathToken("#1");
            mor.Source.AsMathSequence().List.Count.Is(2);
            mor.Source.AsMathSequence().List[0].IsMathToken("F");
            mor.Source.AsMathSequence().List[1].AsMathSequence().List.Count.Is(1);
            mor.Source.AsMathSequence().List[1].AsMathSequence().List[0].IsMathToken("#1");
            mor.Source.AsMathSequence().List[1].AsMathSequence().LeftBracket.TestToken("(");
            mor.Source.AsMathSequence().List[1].AsMathSequence().RightBracket.TestToken(")");
            mor.Target.AsMathSequence().List.Count.Is(2);
            mor.Target.AsMathSequence().List[0].IsMathToken("G");
            mor.Target.AsMathSequence().List[1].IsMathToken("#1");

            var f          = new MathObjectFactory(@"\theta^i").CreateSingle();
            var parameters = new Dictionary <string, MathObject>();

            mor.Name.IsSameType(f, parameters).IsTrue();
            mor = mor.ApplyParameter(f, parameters, false).TestSingle();
            mor.Name.AsMathSequence().List.Count.Is(1);
            mor.Name.AsMathSequence().List[0].IsMathToken(@"\theta");
            mor.Name.AsMathSequence().Sup.IsMathToken("i");
            mor.Source.AsMathSequence().List.Count.Is(2);
            mor.Source.AsMathSequence().List[0].IsMathToken("F");
            mor.Source.AsMathSequence().List[1].AsMathSequence().List.Count.Is(1);
            mor.Source.AsMathSequence().List[1].AsMathSequence().List[0].IsMathToken("i");
            mor.Source.AsMathSequence().List[1].AsMathSequence().LeftBracket.TestToken("(");
            mor.Source.AsMathSequence().List[1].AsMathSequence().RightBracket.TestToken(")");
            mor.Target.AsMathSequence().List.Count.Is(2);
            mor.Target.AsMathSequence().List[0].IsMathToken("G");
            mor.Target.AsMathSequence().List[1].IsMathToken("i");

            f          = new MathObjectFactory(@"\theta^{i}").CreateSingle();
            parameters = new Dictionary <string, MathObject>();
            mor.Name.IsSameType(f, parameters).IsTrue();
            mor = mor.ApplyParameter(f, parameters, false).TestSingle();
            mor.Name.AsMathSequence().List.Count.Is(1);
            mor.Name.AsMathSequence().List[0].IsMathToken(@"\theta");
            mor.Name.AsMathSequence().Sup.IsMathToken("i");
            mor.Source.AsMathSequence().List.Count.Is(2);
            mor.Source.AsMathSequence().List[0].IsMathToken("F");
            mor.Source.AsMathSequence().List[1].AsMathSequence().List.Count.Is(1);
            mor.Source.AsMathSequence().List[1].AsMathSequence().List[0].IsMathToken("i");
            mor.Source.AsMathSequence().List[1].AsMathSequence().LeftBracket.TestToken("(");
            mor.Source.AsMathSequence().List[1].AsMathSequence().RightBracket.TestToken(")");
            mor.Target.AsMathSequence().List.Count.Is(2);
            mor.Target.AsMathSequence().List[0].IsMathToken("G");
            mor.Target.AsMathSequence().List[1].IsMathToken("i");
        }
예제 #6
0
        public void IsoMorphism()
        {
            var m = Morphism.CreateIso(
                Product2.Create(0, false),
                Product2.Create(1, true)
                );

            Assert.Equal(false.ToOption(), m.Apply(0));
            Assert.Equal(true.ToOption(), m.Apply(1));

            Assert.Equal(0.ToOption(), m.Inverse.Apply(false));
            Assert.Equal(1.ToOption(), m.Inverse.Apply(true));
        }
예제 #7
0
        public void Apply()
        {
            var m = Morphism.Create(
                Product2.Create("foo", 123),
                Product2.Create("bar", 456),
                Product2.Create("baz", 789)
                );

            Assert.Equal(123.ToOption(), m.Apply("foo"));
            Assert.Equal(456.ToOption(), m.Apply("bar"));
            Assert.Equal(789.ToOption(), m.Apply("baz"));
            Assert.True(m.Apply("xyz").IsEmpty);
        }
예제 #8
0
        public void CreateThreeMorphism()
        {
            var xs = Morphism.Create(@"\Gamma, \Sigma\colon\theta\Rrightarrow\rho\colon f\Rightarrow g\colon a\rightarrow b").ToList();

            xs.Count.Is(8);
            xs[0].TestMorphism("f", "a", "b", MorphismType.OneMorphism);
            xs[1].TestMorphism("g", "a", "b", MorphismType.OneMorphism);
            xs[2].TestMorphism(@"\theta", "f", "g", MorphismType.TwoMorphism);
            xs[3].TestMorphism("f", "a", "b", MorphismType.OneMorphism);
            xs[4].TestMorphism("g", "a", "b", MorphismType.OneMorphism);
            xs[5].TestMorphism(@"\rho", "f", "g", MorphismType.TwoMorphism);
            xs[6].TestMorphism(@"\Gamma", @"\theta", @"\rho", MorphismType.ThreeMorphism);
            xs[7].TestMorphism(@"\Sigma", @"\theta", @"\rho", MorphismType.ThreeMorphism);
        }
예제 #9
0
        public void DomainRange()
        {
            var m = Morphism.Create(
                Product2.Create(1, true),
                Product2.Create(2, true),
                Product2.Create(3, false)
                );

            Assert.Equal(3, m.Domain.Count());
            Assert.Contains(1, m.Domain);
            Assert.Contains(2, m.Domain);
            Assert.Contains(3, m.Domain);

            Assert.Equal(2, m.Range.Count());
            Assert.Contains(true, m.Range);
            Assert.Contains(false, m.Range);
        }
예제 #10
0
        public void Create関手()
        {
            Morphism.Create(@"F\colon\cat{C}\rightarrow\cat{D}").TestSingle().TestMorphism("F", @"\cat{C}", @"\cat{D}", MorphismType.Functor);
            Morphism.Create(@"U\colon\Ab\rightarrow\Set").TestSingle().TestMorphism("U", @"\Ab", @"\Set", MorphismType.Functor);
            Morphism.Create(@"U\colon\Mod[R]\rightarrow\Ab").TestSingle().TestMorphism("U", @"\Mod[R]", @"\Ab", MorphismType.Functor);

            var xs = Morphism.Create(@"\theta\colon F\Rightarrow G\colon\cat{C}\rightarrow\cat{D}").ToList();

            xs.Count.Is(3);
            xs[0].TestMorphism("F", @"\cat{C}", @"\cat{D}", MorphismType.Functor);
            xs[1].TestMorphism("G", @"\cat{C}", @"\cat{D}", MorphismType.Functor);
            xs[2].TestMorphism(@"\theta", "F", "G", MorphismType.TwoMorphism);

            Morphism.Create(@"F\colon\opp{\cat{C}}\rightarrow\cat{D}").TestSingle().TestMorphism("F", @"\opp{\cat{C}}", @"\cat{D}", MorphismType.ContravariantFunctor);
            Morphism.Create(@"G\colon\opp{\Set}\rightarrow\opp{\Cat}").TestSingle().TestMorphism("G", @"\opp{\Set}", @"\opp{\Cat}", MorphismType.Functor);

            Morphism.Create(@"\Hom_{\cat{C}}(a, -)\colon \cat{C}\rightarrow\Set").TestSingle()
            .TestMorphism(@"\Hom_{\cat{C}}(a,-)", @"\cat{C}", @"\Set", MorphismType.Functor);
        }
        public void  数二項演算_省略しない()
        {
            var dic = new Dictionary <TokenString, Morphism>()
            {
                { "f".ToTokenString(), Morphism.Create(@"f\colon u\rightarrow v").TestSingle() },
                { "g".ToTokenString(), Morphism.Create(@"g\colon s\rightarrow t").TestSingle() },
            };

            var tikz = CreateTikZDiagram(dic);

            tikz.CreateMorphism(@"f\otimes g", @"us", @"vt")
            .All(m =>
            {
                Console.WriteLine(m.ToString());
                return(!m.Item1.Name.ToTokenString().Equals(@"f\otimes g") ||
                       !m.Item1.Source.ToTokenString().Equals(@"us") ||
                       !m.Item1.Target.ToTokenString().Equals(@"vt"));
            }).IsTrue();
        }
        public void  数二項演算_省略3()
        {
            var dic  = new Dictionary <TokenString, Morphism>();
            var list = ExtensionsInTest.CreateDefaultMorphisms();

            list.Add(Morphism.Create(@"\alpha^{#1?}_{#2?#3?#4?}\colon (#2#3)#4\rightarrow #2(#3#4)").TestSingle());

            var tikz = new TikZDiagram("", -1, false, true, true, dic, list, Array.Empty <Functor>());

            tikz.CreateMorphism(@"\alpha",
                                @"((\encat{C}_{cd}\encat{D}_{c'd'})(\encat{C}_{bc}\encat{D}_{b'c'}))(\encat{C}_{ab}\encat{D}_{a'b'})",
                                @"(\encat{C}_{cd}\encat{D}_{c'd'})((\encat{C}_{bc}\encat{D}_{b'c'})(\encat{C}_{ab}\encat{D}_{a'b'}))"
                                ).TestMorphism(@"\alpha",
                                               @"((\encat{C}_{cd}\encat{D}_{c'd'})(\encat{C}_{bc}\encat{D}_{b'c'}))(\encat{C}_{ab}\encat{D}_{a'b'})",
                                               @"(\encat{C}_{cd}\encat{D}_{c'd'})((\encat{C}_{bc}\encat{D}_{b'c'})(\encat{C}_{ab}\encat{D}_{a'b'}))",
                                               MorphismType.Functor,
                                               true
                                               );
        }
        public void  数二項演算_省略1()
        {
            var dic = new Dictionary <TokenString, Morphism>()
            {
                { "f".ToTokenString(), Morphism.Create(@"f\colon u\rightarrow v").TestSingle() },
                { "g".ToTokenString(), Morphism.Create(@"g\colon s\rightarrow t").TestSingle() },
            };

            var tikz = new TikZDiagram("", -1, false, true, true, dic, ExtensionsInTest.CreateDefaultMorphisms(), Array.Empty <Functor>());

            tikz.CreateMorphism(@"f\otimes g")
            .TestMorphism(@"f\otimes g", @"u\otimes s", @"v\otimes t", MorphismType.OneMorphism);

            tikz.CreateMorphism(@"f\otimes g", @"u\otimes s", @"v\otimes t")
            .TestMorphism(@"f\otimes g", @"u\otimes s", @"v\otimes t", MorphismType.OneMorphism, true);

            tikz.CreateMorphism(@"f\otimes g", @"us", @"vt")
            .TestMorphism(@"f\otimes g", @"us", @"vt", MorphismType.OneMorphism, true);
        }
        public void  数st()
        {
            var dic = new Dictionary <TokenString, Morphism>()
            {
                { "F".ToTokenString(), Morphism.Create(@"F\colon\encat{A}\rightarrow\encat{B}").TestSingle() }
            };
            var list = new List <Morphism>()
            {
                ToMorphismHelp(@"#1_{#2#3}", @"#1s(#2, #3)", @"#1t(#1#2, #1#3)", MorphismType.OneMorphism)
            };
            var func = ExtensionsInTest.CreateDefaultFunctors().ToList();

            var tikz = new TikZDiagram("", -1, false, false, true, dic, list, func);

            tikz.CreateMorphism(@"F_{ab}")
            .TestMorphism(@"F_{ab}", @"\encat{A}(a, b)", @"\encat{B}(Fa, Fb)", MorphismType.Functor);

            tikz.CreateMorphism(@"F_{ab}", @"\encat{A}(a, b)", @"\encat{B}(Fa, Fb)")
            .TestMorphism(@"F_{ab}", @"\encat{A}(a, b)", @"\encat{B}(Fa, Fb)", MorphismType.Functor, true);
        }
예제 #15
0
        public void Create随伴()
        {
            var xs = Morphism.Create(@"F\dashv G\colon\cat{C}\rightarrow\cat{D}").ToList();

            xs.Count.Is(2);
            xs[0].TestMorphism("F", @"\cat{C}", @"\cat{D}", MorphismType.Functor);
            xs[1].TestMorphism("G", @"\cat{D}", @"\cat{C}", MorphismType.Functor);

            xs = Morphism.Create(@"f\dashv g\dashv h\dashv k\colon a\rightarrow b").ToList();
            xs.Count.Is(4);
            xs[0].TestMorphism("f", "a", "b", MorphismType.OneMorphism);
            xs[1].TestMorphism("g", "b", "a", MorphismType.OneMorphism);
            xs[2].TestMorphism("h", "a", "b", MorphismType.OneMorphism);
            xs[3].TestMorphism("k", "b", "a", MorphismType.OneMorphism);

            xs = Morphism.Create(@"L_0\dashv R^1\colon\cat{C}\rightarrow\cat{D}").ToList();
            xs.Count.Is(2);
            xs[0].TestMorphism("L_{0}", @"\cat{C}", @"\cat{D}", MorphismType.Functor);
            xs[1].TestMorphism("R^{1}", @"\cat{D}", @"\cat{C}", MorphismType.Functor);
        }
        public void  数2()
        {
            var dic  = new Dictionary <TokenString, Morphism>();
            var list = new List <Morphism>()
            {
                Morphism.Create(@"m_{#1#2} \colon \encat{A}(#1, #2) \rightarrow \encat{B}(G#1, G#2)").TestSingle()
            };
            var tikz = new TikZDiagram("", -1, false, false, true, dic, list, Array.Empty <Functor>());

            tikz.CreateMorphism(@"m_{ab}")
            .TestMorphism(@"m_{ab}", @"\encat{A}(a, b)", @"\encat{B}(Ga, Gb)", MorphismType.Functor);

            tikz.CreateMorphism(@"m_{ab}", @"\encat{A}(a, b)", @"\encat{B}(Ga, Gb)")
            .TestMorphism(@"m_{ab}", @"\encat{A}(a, b)", @"\encat{B}(Ga, Gb)", MorphismType.Functor, true);

            tikz.CreateMorphism(@"m_{{Fa}{Fb}}")
            .TestMorphism(@"m_{{Fa}{Fb}}", @"\encat{A}(Fa, Fb)", @"\encat{B}(GFa, GFb)", MorphismType.Functor);

            tikz.CreateMorphism(@"m_{{Fa}{Fb}}", @"\encat{A}(Fa, Fb)", @"\encat{B}(GFa, GFb)")
            .TestMorphism(@"m_{{Fa}{Fb}}", @"\encat{A}(Fa, Fb)", @"\encat{B}(GFa, GFb)", MorphismType.Functor, true);
        }
예제 #17
0
        public void Create通常()
        {
            Morphism.Create(@"f\colon a\rightarrow b").TestSingle().TestMorphism("f", "a", "b", MorphismType.OneMorphism);

            Morphism.Create(@" g \colon u \rightarrow v ").TestSingle().TestMorphism("g", "u", "v", MorphismType.OneMorphism);

            Morphism.Create(@"\test\colon \test\rightarrow\testtest").TestSingle()
            .TestMorphism(@"\test", @"\test", @"\testtest", MorphismType.OneMorphism);

            Morphism.Create(@"\test^{\test}\colon \test\test\rightarrow\testtest\test").TestSingle()
            .TestMorphism(@"\test ^{\test }", @"\test\test", @"\testtest\test", MorphismType.OneMorphism);

            var xs = Morphism.Create(@"f, g\colon a\rightarrow b").ToList();

            xs.Count.Is(2);
            xs[0].TestMorphism("f", "a", "b", MorphismType.OneMorphism);
            xs[1].TestMorphism("g", "a", "b", MorphismType.OneMorphism);

            Morphism.Create(@"\eta_a\colon \id_{\cat{C}}(a)\rightarrow GF(a)").TestSingle()
            .TestMorphism(@"\eta_a", @"\id_{\cat{C}}(a)", "GF(a)", MorphismType.OneMorphism);
        }
예제 #18
0
        public void Create変数()
        {
            var mor = Morphism.Create(@"\theta^{#1}\colon F(#1)\rightarrow G#1").TestSingle();

            mor.Name.AsMathSequence().List.Count.Is(1);
            mor.Name.AsMathSequence().List[0].IsMathToken(@"\theta");
            mor.Name.AsMathSequence().Sup.IsMathToken("#1");
            mor.Source.AsMathSequence().List.Count.Is(2);
            mor.Source.AsMathSequence().List[0].IsMathToken("F");
            mor.Source.AsMathSequence().List[1].AsMathSequence().List.Count.Is(1);
            mor.Source.AsMathSequence().List[1].AsMathSequence().List[0].IsMathToken("#1");
            mor.Source.AsMathSequence().List[1].AsMathSequence().LeftBracket.TestToken("(");
            mor.Source.AsMathSequence().List[1].AsMathSequence().RightBracket.TestToken(")");
            mor.Target.AsMathSequence().List.Count.Is(2);
            mor.Target.AsMathSequence().List[0].IsMathToken("G");
            mor.Target.AsMathSequence().List[1].IsMathToken("#1");

            var xs = Morphism.Create(@"\test{#1}{#2s}\colon F#1\rightarrow G#1").ToArray();

            xs.Length.Is(0);
        }
예제 #19
0
        public void CreateTwoMorphism()
        {
            Morphism.Create(@"\theta\colon F\Rightarrow G").TestSingle().TestMorphism(@"\theta", "F", "G", MorphismType.TwoMorphism);
            Morphism.Create(@"\theta_i\colon Fi\rightarrow Gi").TestSingle().TestMorphism(@"\theta _{i}", "Fi", "Gi", MorphismType.OneMorphism);

            Morphism.Create(@"\theta\colon F\Rightarrow G").TestSingle().TestMorphism(@"\theta", "F", "G", MorphismType.TwoMorphism);
            Morphism.Create(@"\Gamma\colon\theta\Rrightarrow\rho").TestSingle().TestMorphism(@"\Gamma", @"\theta", @"\rho", MorphismType.ThreeMorphism);

            var xs = Morphism.Create(@"\alpha, \beta, \gamma\colon F\Rightarrow G\colon A\rightarrow B").ToList();

            xs.Count.Is(5);
            xs[0].TestMorphism("F", "A", "B", MorphismType.OneMorphism);
            xs[1].TestMorphism("G", "A", "B", MorphismType.OneMorphism);
            xs[2].TestMorphism(@"\alpha", "F", "G", MorphismType.TwoMorphism);
            xs[3].TestMorphism(@"\beta", "F", "G", MorphismType.TwoMorphism);
            xs[4].TestMorphism(@"\gamma", "F", "G", MorphismType.TwoMorphism);

            xs = Morphism.Create(@"\theta\colon F\Rightarrow G\colon C\rightarrow D").ToList();
            xs.Count.Is(3);
            xs[0].TestMorphism("F", @"C", @"D", MorphismType.OneMorphism);
            xs[1].TestMorphism("G", @"C", @"D", MorphismType.OneMorphism);
            xs[2].TestMorphism(@"\theta", "F", "G", MorphismType.TwoMorphism);
        }
예제 #20
0
        public void CreateHom()
        {
            Morphism.Create(@"f\in\Hom(a,b)").TestSingle().TestMorphism("f", "a", "b", MorphismType.OneMorphism);
            Morphism.Create(@"f\in\Hom_{\cat{C}}(a,b)").TestSingle().TestMorphism("f", "a", "b", MorphismType.OneMorphism);
            Morphism.Create(@" g \in \Hom _{\cat{C}} ( c , d )").TestSingle().TestMorphism("g", "c", "d", MorphismType.OneMorphism);

            Morphism.Create(@"\test\in\Hom(a, b)").TestSingle().TestMorphism(@"\test", "a", "b", MorphismType.OneMorphism);
            Morphism.Create(@"\test\test\in\Hom_{\cat{C}}(a, b)").TestSingle().TestMorphism(@"\test \test", "a", "b", MorphismType.OneMorphism);
            Morphism.Create(@"\mor{f}\in\Hom(a, b)").TestSingle().TestMorphism(@"\mor {f}", "a", "b", MorphismType.OneMorphism);

            var xs = Morphism.Create(@"K, L\in\Hom_{\Cat[\moncat{V}]}(\encat{C}, \encat{D})").ToList();

            xs.Count.Is(2);
            xs[0].TestMorphism(@"K", @"\encat {C}", @"\encat {D}", MorphismType.Functor);
            xs[1].TestMorphism(@"L", @"\encat {C}", @"\encat {D}", MorphismType.Functor);

            xs = Morphism.Create(@"s, t\in\Hom_{\Cat}(\Set, \Mod[R])").ToList();
            xs.Count.Is(2);
            xs[0].TestMorphism("s", "\\Set", "\\Mod [R]", MorphismType.Functor);
            xs[1].TestMorphism("t", "\\Set", "\\Mod [R]", MorphismType.Functor);

            Morphism.Create(@"f\in\Hom(a_i, c^b)").TestSingle().TestMorphism("f", "a_{i}", "c^{b}", MorphismType.OneMorphism);
        }
예제 #21
0
 public void Morphismでない()
 {
     Morphism.Create(@"a").Count().Is(0);
     Morphism.Create(@"\cat{C}").Count().Is(0);
 }
예제 #22
0
        static InMemoryDatabase()
        {
            // Contact
            var contactSchema = new SchemaModel.Schema("contact");

            contactSchema.Publish();

            contactSchema.Update(new SchemaProperties
            {
                Label = "Contact",
                Hints = "Contact entity in CRM-Core."
            });

            contactSchema.AddField(new StringField(
                                       Guid.NewGuid(),
                                       "firstName",
                                       new StringFieldProperties
            {
                Label        = "FirstName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input first name.",
                Placeholder  = "Input first name...",
                DefaultValue = "Phuong"
            }));

            contactSchema.AddField(new StringField(
                                       Guid.NewGuid(),
                                       "lastName",
                                       new StringFieldProperties
            {
                Label        = "LastName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input last name.",
                Placeholder  = "Input last name...",
                DefaultValue = "Le"
            }));

            var contact = new Morphism("contact", contactSchema);

            // Customer
            var customerSchema = new SchemaModel.Schema("customer");

            customerSchema.Publish();

            customerSchema.Update(new SchemaProperties
            {
                Label = "Customer",
                Hints = "Customer entity in CRM-Core."
            });

            customerSchema.AddField(new StringField(
                                        Guid.NewGuid(),
                                        "firstName",
                                        new StringFieldProperties
            {
                Label        = "FirstName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input first name.",
                Placeholder  = "Input first name...",
                DefaultValue = "Lena"
            }));

            customerSchema.AddField(new StringField(
                                        Guid.NewGuid(),
                                        "lastName",
                                        new StringFieldProperties
            {
                Label        = "LastName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input last name.",
                Placeholder  = "Input last name...",
                DefaultValue = "Cao"
            }));

            var customer = new Morphism("customer", customerSchema);

            // init
            SchemaItems.Add(Guid.NewGuid(), contact);
            SchemaItems.Add(Guid.NewGuid(), customer);
        }
예제 #23
0
        private IEnumerable <Morphism> GetDefaultMorphisms()
        {
            // Account
            var accountSchema = new Schema("account");

            accountSchema.Publish();

            accountSchema.Update(new SchemaProperties
            {
                Label = "Account",
                Hints = "Account entity in CRM-Core."
            });

            var account = new Morphism("account", accountSchema);

            // Contact
            var contactSchema = new Schema("contact");

            contactSchema.Publish();

            contactSchema.Update(new SchemaProperties
            {
                Label = "Contact",
                Hints = "Contact entity in CRM-Core."
            });

            contactSchema.AddField(new StringField(
                                       Guid.NewGuid(),
                                       "firstName",
                                       new StringFieldProperties
            {
                Label        = "FirstName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input first name.",
                Placeholder  = "Input first name...",
                DefaultValue = "Phuong"
            }));

            contactSchema.AddField(new StringField(
                                       Guid.NewGuid(),
                                       "lastName",
                                       new StringFieldProperties
            {
                Label        = "LastName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input last name.",
                Placeholder  = "Input last name...",
                DefaultValue = "Le"
            }));

            var contact = new Morphism("contact", contactSchema);

            // Customer
            var customerSchema = new Schema("customer");

            customerSchema.Publish();

            customerSchema.Update(new SchemaProperties
            {
                Label = "Customer",
                Hints = "Customer entity in CRM-Core."
            });

            customerSchema.AddField(new StringField(
                                        Guid.NewGuid(),
                                        "firstName",
                                        new StringFieldProperties
            {
                Label        = "FirstName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input first name.",
                Placeholder  = "Input first name...",
                DefaultValue = "Lena"
            }));

            customerSchema.AddField(new StringField(
                                        Guid.NewGuid(),
                                        "lastName",
                                        new StringFieldProperties
            {
                Label        = "LastName",
                IsRequired   = true,
                FieldType    = StringFieldType.Input,
                Hints        = "Please input last name.",
                Placeholder  = "Input last name...",
                DefaultValue = "Cao"
            }));

            var customer = new Morphism("customer", customerSchema);

            return(new[] { account, contact, customer });
        }