Exemplo n.º 1
0
        public void SchemaWriter_DeleteContentListType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var contentListTypeCountBefore = ed.ContentListTypes.Count;
                var contentListTypeName1       = "LT1-" + Guid.NewGuid();
                var contentListTypeName2       = "LT2-" + Guid.NewGuid();
                var contentListTypeName3       = "LT3-" + Guid.NewGuid();
                var contentListTypeName4       = "LT4-" + Guid.NewGuid();
                ed.CreateContentListType(contentListTypeName1);
                ed.CreateContentListType(contentListTypeName2);
                ed.CreateContentListType(contentListTypeName3);
                ed.CreateContentListType(contentListTypeName4);
                ed.Register();
                Assert.AreEqual(contentListTypeCountBefore + 4, StorageSchema.ContentListTypes.Count);

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                ed.DeleteContentListType(ed.ContentListTypes[contentListTypeName4]); // last
                ed.DeleteContentListType(ed.ContentListTypes[contentListTypeName2]); // middle
                ed.DeleteContentListType(ed.ContentListTypes[contentListTypeName1]); // first
                ed.Register();

                // ASSERT
                Assert.AreEqual(contentListTypeCountBefore + 1, StorageSchema.ContentListTypes.Count);
                var listType = StorageSchema.ContentListTypes[contentListTypeName3];
                Assert.AreEqual(contentListTypeName3, listType.Name);
            });
        }
Exemplo n.º 2
0
        public void SchemaWriter_ModifyNodeType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var nodeTypeName = "NT1-" + Guid.NewGuid();
                ed.CreateNodeType(null, nodeTypeName, "NT1Class");
                ed.Register();
                var nodeTypeCountBefore = StorageSchema.NodeTypes.Count;
                var nodeTypeId          = StorageSchema.NodeTypes[nodeTypeName].Id;

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                var nt = ed.NodeTypes[nodeTypeName];
                ed.ModifyNodeType(nt, "NT1Class_modified");
                ed.Register();

                // ASSERT
                Assert.AreEqual(nodeTypeCountBefore, StorageSchema.NodeTypes.Count);
                var nodeType = StorageSchema.NodeTypes[nodeTypeName];
                Assert.AreEqual(nodeTypeId, nodeType.Id);
                Assert.AreEqual(nodeTypeName, nodeType.Name);
                Assert.AreEqual("NT1Class_modified", nodeType.ClassName);
            });
        }
Exemplo n.º 3
0
        public void SchemaWriter_DeleteNodeType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var nodeTypeName = "NT1-" + Guid.NewGuid();
                ed.CreateNodeType(null, nodeTypeName, "NT1Class");
                ed.Register();
                var nodeTypeCountBefore = StorageSchema.NodeTypes.Count;
                var nodeTypeId          = StorageSchema.NodeTypes[nodeTypeName].Id;

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                var nt = ed.NodeTypes[nodeTypeName];
                ed.DeleteNodeType(nt);
                ed.Register();

                // ASSERT
                Assert.AreEqual(nodeTypeCountBefore - 1, StorageSchema.NodeTypes.Count);
                Assert.IsNull(StorageSchema.NodeTypes[nodeTypeName]);
                Assert.IsNull(StorageSchema.NodeTypes.GetItemById(nodeTypeId));
            });
        }
Exemplo n.º 4
0
        /* ============================================================================== NodeType */

        public void SchemaWriter_CreateRootNodeType_WithoutClassName()
        {
            IntegrationTest(() =>
            {
                try
                {
                    var ed = new SchemaEditor();
                    ed.Load();

                    // ACTION
                    ed.CreateNodeType(null, "NT1-" + Guid.NewGuid(), null);
                    ed.Register();

                    Assert.Fail();
                }
                catch (Exception e)
                {
                    while (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                    Assert.IsTrue(e.Message.Contains("ClassName"));
                    // ignored
                }
            });
        }
Exemplo n.º 5
0
        public void SchemaWriter_CreateNodeType_WithParent()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var nodeTypeCountBefore = StorageSchema.NodeTypes.Count;
                var lastNodeTypeId      = StorageSchema.NodeTypes.Max(x => x.Id);
                var nodeTypeName1       = "NT1-" + Guid.NewGuid();
                var nodeTypeName2       = "NT2-" + Guid.NewGuid();
                var className1          = "NT0Class";
                var className2          = "NT1Class";

                // ACTION
                var nt1 = ed.CreateNodeType(null, nodeTypeName1, className1);
                ed.CreateNodeType(nt1, nodeTypeName2, className2);
                ed.Register();

                // ASSERT
                Assert.AreEqual(nodeTypeCountBefore + 2, StorageSchema.NodeTypes.Count);
                var nodeType1 = StorageSchema.NodeTypes[nodeTypeName1];
                Assert.AreEqual(lastNodeTypeId + 1, nodeType1.Id);
                Assert.AreEqual(nodeTypeName1, nodeType1.Name);
                Assert.AreEqual(null, nodeType1.Parent);
                Assert.AreEqual(className1, nodeType1.ClassName);
                var nodeType2 = StorageSchema.NodeTypes[nodeTypeName2];
                Assert.AreEqual(lastNodeTypeId + 2, nodeType2.Id);
                Assert.AreEqual(nodeTypeName2, nodeType2.Name);
                Assert.AreEqual(nodeType1, nodeType2.Parent);
                Assert.AreEqual(className2, nodeType2.ClassName);
            });
        }
Exemplo n.º 6
0
        public void SchemaWriter_RemovePropertyTypeFromContentListType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var lt  = ed.CreateContentListType("LT1-" + Guid.NewGuid());
                var pt0 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                var pt1 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                var pt2 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                var pt3 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                var pt4 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                lt.AddPropertyType(pt0);
                lt.AddPropertyType(pt1);
                lt.AddPropertyType(pt2);
                lt.AddPropertyType(pt3);
                lt.AddPropertyType(pt4);
                ed.Register();

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                lt = ed.ContentListTypes[lt.Name];
                lt.RemovePropertyType(ed.PropertyTypes[pt4.Name]); // last
                lt.RemovePropertyType(ed.PropertyTypes[pt2.Name]); // middle
                lt.RemovePropertyType(ed.PropertyTypes[pt0.Name]); // first
                ed.Register();

                // ASSERT
                var schema = DP.LoadSchemaAsync(CancellationToken.None).GetAwaiter().GetResult();
                var ltData = schema.ContentListTypes.First(x => x.Name == lt.Name);
                AssertSequenceEqual(new[] { pt1.Name, pt3.Name }, ltData.Properties);
            });
        }
Exemplo n.º 7
0
        public void SchemaWriter_AddPropertyTypeToContentListType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var lt = ed.CreateContentListType("LT0" + Guid.NewGuid());

                // ACTION
                var pt0 = ed.CreateContentListPropertyType(DataType.String, GetNextMapping(ed, true));
                var pt1 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                var pt2 = ed.CreateContentListPropertyType(DataType.String, GetNextMapping(ed, true));
                var pt3 = ed.CreateContentListPropertyType(DataType.Int, GetNextMapping(ed, true));
                ed.AddPropertyTypeToPropertySet(pt0, lt);
                ed.AddPropertyTypeToPropertySet(pt1, lt);
                ed.AddPropertyTypeToPropertySet(pt2, lt);
                ed.AddPropertyTypeToPropertySet(pt3, lt);
                ed.Register();

                // ASSERT
                var schema = DP.LoadSchemaAsync(CancellationToken.None).GetAwaiter().GetResult();
                var ltData = schema.ContentListTypes.First(x => x.Name == lt.Name);
                AssertSequenceEqual(new[] { pt0.Name, pt1.Name, pt2.Name, pt3.Name }, ltData.Properties);
            });
        }
Exemplo n.º 8
0
        public void SchemaWriter_CreateContentListPropertyType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var propertyTypeCountBefore = ed.PropertyTypes.Count;
                var lastPropertyTypeId      = ed.PropertyTypes.Max(x => x.Id);
                var mapping = GetNextMapping(ed, true);

                // ACTION
                var created          = ed.CreateContentListPropertyType(DataType.String, mapping);
                var propertyTypeName = created.Name;
                ed.Register();

                // ASSERT
                Assert.AreEqual(propertyTypeCountBefore + 1, StorageSchema.PropertyTypes.Count);
                var propType = StorageSchema.PropertyTypes[propertyTypeName];
                Assert.AreEqual(lastPropertyTypeId + 1, propType.Id);
                Assert.AreEqual(propertyTypeName, propType.Name);
                Assert.AreEqual(DataType.String, propType.DataType);
                Assert.AreEqual(800000000 + mapping, propType.Mapping);
                Assert.AreEqual(true, propType.IsContentListProperty);
            });
        }
Exemplo n.º 9
0
        public void SchemaWriter_RemovePropertyTypeFromBaseNodeType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var nt0 = ed.CreateNodeType(null, "NT0-" + Guid.NewGuid(), "ClassName1");
                var nt1 = ed.CreateNodeType(nt0, "NT1-" + Guid.NewGuid(), "ClassName2");
                var pt0 = ed.CreatePropertyType("PT0-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                var pt1 = ed.CreatePropertyType("PT1-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                var pt2 = ed.CreatePropertyType("PT2-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                nt0.AddPropertyType(pt0);
                nt0.AddPropertyType(pt1);
                nt1.AddPropertyType(pt2);
                ed.Register();
                Assert.AreEqual(3, StorageSchema.NodeTypes[nt1.Name].PropertyTypes.Count);

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                nt0 = ed.NodeTypes[nt0.Name];
                nt0.RemovePropertyType(ed.PropertyTypes[pt0.Name]);
                ed.Register();

                // ASSERT
                Assert.AreEqual(2, StorageSchema.NodeTypes[nt1.Name].PropertyTypes.Count);
            });
        }
Exemplo n.º 10
0
        public void TypeCollection_IndexOf()
        {
            SchemaEditor ed = new SchemaEditor();

            ed.Load();
            int id = ed.NodeTypes[1].Id;
            var tc = TypeCollectionAccessor <NodeType> .Create(ed);

            foreach (NodeType nt in ed.NodeTypes)
            {
                tc.Add(nt);
            }
            tc.RemoveAt(0);
            for (int i = 1; i < tc.Count; i++)
            {
                if (tc.IndexOf(ed.NodeTypes[i]) != i - 1)
                {
                    Assert.Fail();
                }
            }
            if (tc.IndexOf(ed.NodeTypes[0]) != -1)
            {
                Assert.Fail();
            }
            Assert.IsTrue(true);
        }
Exemplo n.º 11
0
        public void SchEd_WriterCalling_RemoveOverriddenPropertyFromNodeType()
        {
            Test(() =>
            {
                SchemaEditor ed1            = new SchemaEditor();
                SchemaEditor ed2            = new SchemaEditor();
                SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
                TestSchemaWriter wr         = new TestSchemaWriter();

                //-- create original
                PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
                NodeType nt1     = CreateNodeType(ed1, null, "NT1", "NT1", 1);
                NodeType nt2     = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
                NodeType nt3     = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
                NodeType nt4     = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
                NodeType nt5     = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);
                ed1.AddPropertyTypeToPropertySet(pt1, nt4);
                ed1.AddPropertyTypeToPropertySet(pt1, nt2);

                //-- create current
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(ed1.ToXml());
                ed2.Load(xd);

                //-- edit
                ed2.RemovePropertyTypeFromPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT4"]);

                //-- register
                ed2Acc.RegisterSchema(ed1, wr);

                //-- test
                string log = wr.Log.Replace("\r\n", "");
                Assert.IsTrue(log == "Open();UpdatePropertyTypeDeclarationState(propType=<PT1>, newSet=<NT4>, isDeclared=<False>);Close();");
            });
        }
Exemplo n.º 12
0
        public static ContentTypeInstaller CreateBatchContentTypeInstaller()
        {
            SchemaEditor editor = new SchemaEditor();

            editor.Load();
            return(CreateBatchContentTypeInstaller(editor));
        }
Exemplo n.º 13
0
        /* ============================================================================== PropertyType assignment */

        public void SchemaWriter_AddPropertyTypeToNodeType_Declared()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var nodeTypeName = "NT1-" + Guid.NewGuid();
                var ptName1      = "PT1-" + Guid.NewGuid();
                var ptName2      = "PT2-" + Guid.NewGuid();
                ed.CreateNodeType(null, nodeTypeName, "NT0Class");
                ed.Register();

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                var pt1 = ed.CreatePropertyType(ptName1, DataType.String, GetNextMapping(ed, false));
                var pt2 = ed.CreatePropertyType(ptName2, DataType.String, GetNextMapping(ed, false));
                var nt  = ed.NodeTypes[nodeTypeName];
                nt.AddPropertyType(pt1);
                nt.AddPropertyType(pt2);
                ed.Register();

                // ASSERT
                nt = StorageSchema.NodeTypes[nodeTypeName];
                AssertSequenceEqual(
                    new[] { ptName1, ptName2 },
                    nt.PropertyTypes.Select(x => x.Name));
            });
        }
Exemplo n.º 14
0
        public void SchemaWriter_DeletePropertyType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var propertyTypeCountBefore = ed.PropertyTypes.Count;
                var propertyTypeName        = "PT1-" + Guid.NewGuid();
                var mapping = GetNextMapping(ed, false);

                ed.CreatePropertyType(propertyTypeName, DataType.String, mapping);
                ed.Register();
                Assert.AreEqual(propertyTypeCountBefore + 1, StorageSchema.PropertyTypes.Count);
                Assert.IsNotNull(StorageSchema.PropertyTypes[propertyTypeName]);

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                ed.DeletePropertyType(ed.PropertyTypes[propertyTypeName]);
                ed.Register();

                // ASSERT
                Assert.AreEqual(propertyTypeCountBefore, StorageSchema.PropertyTypes.Count);
                Assert.IsNull(StorageSchema.PropertyTypes[propertyTypeName]);
            });
        }
Exemplo n.º 15
0
        private ContentListType ManageContentListTypeOneAttempt(Dictionary <string, FieldDescriptor> fieldInfoList, Dictionary <string, List <string> > oldBindings, bool modify, out List <FieldSetting> fieldSettings)
        {
            fieldSettings = new List <FieldSetting>();
            if (!modify)
            {
                // Load
                foreach (string name in fieldInfoList.Keys)
                {
                    fieldSettings.Add(FieldSetting.Create(fieldInfoList[name], oldBindings[name], null));
                }
                return(this.ContentListType);
            }

            SchemaEditor editor = new SchemaEditor();

            editor.Load();
            bool hasChanges = false;
            var  listType   = this.ContentListType;
            Dictionary <string, List <string> > newBindings = new Dictionary <string, List <string> >();
            SlotTable slotTable = new SlotTable(oldBindings);

            if (listType == null)
            {
                // new
                listType = editor.CreateContentListType(Guid.NewGuid().ToString());
                foreach (string name in fieldInfoList.Keys)
                {
                    fieldSettings.Add(CreateNewFieldType(fieldInfoList[name], newBindings, listType, slotTable, editor));
                }
                hasChanges = true;
            }
            else
            {
                // merge
                listType    = editor.ContentListTypes[listType.Name];
                hasChanges |= RemoveUnusedFields(fieldInfoList, oldBindings, listType, editor);
                foreach (string name in fieldInfoList.Keys)
                {
                    FieldSetting origField = GetFieldTypeByName(name, _fieldSettings);
                    if (origField == null)
                    {
                        fieldSettings.Add(CreateNewFieldType(fieldInfoList[name], newBindings, listType, slotTable, editor));
                        hasChanges = true;
                    }
                    else
                    {
                        List <string> bindList = new List <string>(origField.Bindings.ToArray());
                        fieldSettings.Add(FieldSetting.Create(fieldInfoList[name], bindList, null));
                        newBindings.Add(name, bindList);
                    }
                }
            }
            if (hasChanges)
            {
                editor.Register();
            }
            this.ContentListBindings = newBindings;
            return(ActiveSchema.ContentListTypes[listType.Name]);
        }
Exemplo n.º 16
0
		public void TypeCollection_Add_NodeTypeToSchema()
		{
			SchemaEditor ed = new SchemaEditor();
			var nodeTypes = TypeCollectionAccessor<NodeType>.Create(ed);
			ed.Load();
			nodeTypes.Add(ed.NodeTypes[0]);
			nodeTypes.Add(ed.NodeTypes[1]);

			Assert.IsTrue(nodeTypes.Count == 2 && nodeTypes[0] == ed.NodeTypes[0] && nodeTypes[1] == ed.NodeTypes[1]);
		}
Exemplo n.º 17
0
        public void TypeCollection_Contains_ANodeType()
        {
            SchemaEditor ed        = new SchemaEditor();
            var          nodeTypes = TypeCollectionAccessor <NodeType> .Create(ed);

            ed.Load();
            nodeTypes.Add(ed.NodeTypes[0]);
            nodeTypes.Add(ed.NodeTypes[1]);

            Assert.IsTrue(nodeTypes.Contains(ed.NodeTypes[0]) && !nodeTypes.Contains(ed.NodeTypes[2]));
        }
Exemplo n.º 18
0
        internal static void ApplyChanges(ContentType settings)
        {
            SchemaEditor editor = new SchemaEditor();

            editor.Load();
            ApplyChangesInEditor(settings, editor);
            editor.Register();

            // The ContentTypeManager distributes its reset, no custom DistributedAction call needed
            ContentTypeManager.Reset();
        }
Exemplo n.º 19
0
        public void TypeCollection_Add_NodeTypeToSchema()
        {
            SchemaEditor ed        = new SchemaEditor();
            var          nodeTypes = TypeCollectionAccessor <NodeType> .Create(ed);

            ed.Load();
            nodeTypes.Add(ed.NodeTypes[0]);
            nodeTypes.Add(ed.NodeTypes[1]);

            Assert.IsTrue(nodeTypes.Count == 2 && nodeTypes[0] == ed.NodeTypes[0] && nodeTypes[1] == ed.NodeTypes[1]);
        }
Exemplo n.º 20
0
        public void TypeCollection_GetItemById()
        {
            SchemaEditor ed = new SchemaEditor();

            ed.Load();
            int id = ed.NodeTypes[1].Id;
            var tc = TypeCollectionAccessor <NodeType> .Create(ed.NodeTypes);

            NodeType nt = tc.GetItemById(id);

            Assert.IsTrue(nt.Id == id);
        }
Exemplo n.º 21
0
        public void TypeCollection_CopyTo()
        {
            SchemaEditor ed        = new SchemaEditor();
            var          nodeTypes = TypeCollectionAccessor <NodeType> .Create(ed);

            ed.Load();
            nodeTypes.Add(ed.NodeTypes[0]);
            nodeTypes.Add(ed.NodeTypes[1]);
            nodeTypes.Add(ed.NodeTypes[2]);
            NodeType[] copy = nodeTypes.CopyTo(1);
            Assert.IsTrue(copy.Length == 4 && copy[1] == ed.NodeTypes[0] && copy[2] == ed.NodeTypes[1] && copy[3] == ed.NodeTypes[2]);
        }
Exemplo n.º 22
0
 public void TypeCollection_Count()
 {
     Test(() =>
     {
         SchemaEditor ed = new SchemaEditor();
         var nodeTypes   = TypeCollectionAccessor <NodeType> .Create(ed);
         ed.Load();
         nodeTypes.Add(ed.NodeTypes[0]);
         nodeTypes.Add(ed.NodeTypes[1]);
         nodeTypes.Add(ed.NodeTypes[2]);
         Assert.IsTrue(nodeTypes.Count == 3);
     });
 }
Exemplo n.º 23
0
        internal static void ApplyChanges(ContentType settings, bool reset)
        {
            SchemaEditor editor = new SchemaEditor();

            editor.Load();
            ApplyChangesInEditor(settings, editor);
            editor.Register();

            // The ContentTypeManager distributes its reset, no custom DistributedAction call needed
            if (reset)
            {
                ContentTypeManager.Reset(); // necessary (ApplyChanges) calls ContentType.Save
            }
        }
Exemplo n.º 24
0
 internal void RemoveContentType(string name)
 {
     // Caller: ContentType.Delete()
     lock (_syncRoot)
     {
         ContentType contentType;
         if (_contentTypes.TryGetValue(name, out contentType))
         {
             SchemaEditor editor = new SchemaEditor();
             editor.Load();
             RemoveContentType(contentType, editor);
             editor.Register();
         }
     }
 }
Exemplo n.º 25
0
 public void TypeCollection_CopyTo_1()
 {
     Test(() =>
     {
         SchemaEditor ed = new SchemaEditor();
         var nodeTypes   = TypeCollectionAccessor <NodeType> .Create(ed);
         ed.Load();
         nodeTypes.Add(ed.NodeTypes[0]);
         nodeTypes.Add(ed.NodeTypes[1]);
         nodeTypes.Add(ed.NodeTypes[2]);
         NodeType[] copy = new NodeType[4];
         nodeTypes.CopyTo(copy, 1);
         Assert.IsTrue(copy[1] == ed.NodeTypes[0] && copy[2] == ed.NodeTypes[1] && copy[3] == ed.NodeTypes[2]);
     });
 }
Exemplo n.º 26
0
		public void SchemaEditor_LoadSchema()
		{
			SchemaEditor editor1 = new SchemaEditor();
			editor1.Load();

			editor1.CreatePermissionType("PermA");

			string s = editor1.ToXml();
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(s);

			SchemaEditor editor2 = new SchemaEditor();
			editor2.Load(xd);
			string ss = editor2.ToXml();
		}
Exemplo n.º 27
0
        public void SchemaEditor_LoadSchema()
        {
            Test(() =>
            {
                SchemaEditor editor1 = new SchemaEditor();
                editor1.Load();

                editor1.CreatePropertyType("NewProperty", DataType.String); //.CreatePermissionType("PermA");

                string s       = editor1.ToXml();
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(s);

                SchemaEditor editor2 = new SchemaEditor();
                editor2.Load(xd);
                string ss = editor2.ToXml();
            });
        }
Exemplo n.º 28
0
        internal void RemoveContentType(string name)
        {
            // Caller: ContentType.Delete()
            lock (_syncRoot)
            {
                ContentType contentType;
                if (_contentTypes.TryGetValue(name, out contentType))
                {
                    SchemaEditor editor = new SchemaEditor();
                    editor.Load();
                    RemoveContentType(contentType, editor);
                    editor.Register();

                    // The ContentTypeManager distributes its reset, no custom DistributedAction call needed
                    ContentTypeManager.Reset();
                }
            }
        }
Exemplo n.º 29
0
        public void SchemaEditor_LoadSchema()
        {
            SchemaEditor editor1 = new SchemaEditor();

            editor1.Load();

            editor1.CreatePermissionType("PermA");

            string      s  = editor1.ToXml();
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(s);

            SchemaEditor editor2 = new SchemaEditor();

            editor2.Load(xd);
            string ss = editor2.ToXml();
        }
Exemplo n.º 30
0
        public void TypeCollection_Add_AlienNodeTypeToSchema()
        {
            SchemaEditor ed1 = new SchemaEditor();
            SchemaEditor ed2 = new SchemaEditor();

            ed1.Load();
            ed2.Load();
            var nodeTypes = TypeCollectionAccessor <NodeType> .Create(ed1);

            try
            {
                nodeTypes.Add(ed2.NodeTypes[0]);
            }
            catch (Exception e)
            {
                //  :)
                throw e.InnerException;
            }
        }
Exemplo n.º 31
0
        public void SchEd_WriterCalling_Complex_01()
        {
            Test(() =>
            {
                SchemaEditor ed1            = new SchemaEditor();
                SchemaEditor ed2            = new SchemaEditor();
                SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
                TestSchemaWriter wr         = new TestSchemaWriter();

                //-- create original
                PropertyType ptX = CreatePropertyType(ed1, "X", DataType.String, 1);
                PropertyType ptY = CreatePropertyType(ed1, "Y", DataType.String, 2);
                PropertyType ptZ = CreatePropertyType(ed1, "Z", DataType.String, 3);
                NodeType ntA     = CreateNodeType(ed1, null, "A", null, 1);
                NodeType ntB     = CreateNodeType(ed1, ntA, "B", null, 2);
                NodeType ntC     = CreateNodeType(ed1, ntB, "C", null, 3);
                ed1.AddPropertyTypeToPropertySet(ptX, ntB);
                ed1.AddPropertyTypeToPropertySet(ptY, ntC);
                ed1.AddPropertyTypeToPropertySet(ptX, ntA);

                //-- create current
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(ed1.ToXml());
                ed2.Load(xd);
                ptX = ed2.PropertyTypes["X"];
                ptY = ed2.PropertyTypes["Y"];
                ptZ = ed2.PropertyTypes["Z"];
                ntA = ed2.NodeTypes["A"];
                ntB = ed2.NodeTypes["B"];
                ntC = ed2.NodeTypes["C"];

                //-- edit
                ed2.RemovePropertyTypeFromPropertySet(ptX, ntA);

                //-- register
                ed2Acc.RegisterSchema(ed1, wr);

                //-- test
                string log = wr.Log.Replace("\r\n", "");
                Assert.IsTrue(log == "Open();RemovePropertyTypeFromPropertySet(propertyType=<X>, owner=<A>);Close();");
            });
        }
Exemplo n.º 32
0
        public void SchemaWriter_RemovePropertyTypeFromNodeType()
        {
            IntegrationTest(() =>
            {
                var ed = new SchemaEditor();
                ed.Load();
                var nt  = ed.CreateNodeType(null, "NT1-" + Guid.NewGuid(), "ClassName1");
                var pt0 = ed.CreatePropertyType("PT0-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                var pt1 = ed.CreatePropertyType("PT1-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                var pt2 = ed.CreatePropertyType("PT2-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                var pt3 = ed.CreatePropertyType("PT3-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                var pt4 = ed.CreatePropertyType("PT4-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                nt.AddPropertyType(pt0);
                nt.AddPropertyType(pt1);
                nt.AddPropertyType(pt2);
                nt.AddPropertyType(pt3);
                nt.AddPropertyType(pt4);
                ed.Register();

                // ACTION
                ed = new SchemaEditor();
                ed.Load();
                nt      = ed.NodeTypes[nt.Name];
                pt0     = ed.PropertyTypes[pt0.Name];
                pt1     = ed.PropertyTypes[pt1.Name];
                pt2     = ed.PropertyTypes[pt2.Name];
                pt3     = ed.PropertyTypes[pt3.Name];
                pt4     = ed.PropertyTypes[pt4.Name];
                var ptX = ed.CreatePropertyType("PTX-" + Guid.NewGuid(), DataType.String, GetNextMapping(ed, false));
                ed.RemovePropertyTypeFromPropertySet(pt4, nt); // last
                ed.RemovePropertyTypeFromPropertySet(pt2, nt); // middle
                ed.RemovePropertyTypeFromPropertySet(pt0, nt); // first
                ed.RemovePropertyTypeFromPropertySet(pt0, nt); // first
                ed.RemovePropertyTypeFromPropertySet(ptX, nt); // not a member (without error)
                ed.Register();

                // ASSERT
                var schema = DP.LoadSchemaAsync(CancellationToken.None).GetAwaiter().GetResult();
                var ltData = schema.NodeTypes.First(x => x.Name == nt.Name);
                AssertSequenceEqual(new[] { pt1.Name, pt3.Name }, ltData.Properties);
            });
        }
Exemplo n.º 33
0
		public void SchEd_WriterCalling_RemoveAncestorOfOverriddenPropertyFromNodeType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
			NodeType nt1 = CreateNodeType(ed1, null, "NT1", "NT1", 1);
			NodeType nt2 = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
			NodeType nt3 = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
			NodeType nt4 = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
			NodeType nt5 = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);
			ed1.AddPropertyTypeToPropertySet(pt1, nt4);
			ed1.AddPropertyTypeToPropertySet(pt1, nt2);

			//-- create current
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(ed1.ToXml());
			ed2.Load(xd);

			//-- edit
			ed2.RemovePropertyTypeFromPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT2"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string expectedLog = @"
				Open();
				RemovePropertyTypeFromPropertySet(propertyType=<PT1>, owner=<NT2>);
				RemovePropertyTypeFromPropertySet(propertyType=<PT1>, owner=<NT3>);
				Close();".Replace("\r\n", "").Replace("\t", "").Replace(" ", "");
			string log = wr.Log.Replace("\r\n", "").Replace(" ", "");
			Assert.IsTrue(log == expectedLog);
		}
Exemplo n.º 34
0
		private string InstallContentType(string contentTypeDefInstall, string contentTypeDefModify)
		{
			XmlDocument schema = new XmlDocument();
			schema.LoadXml(@"<?xml version='1.0' encoding='utf-8' ?>
<StorageSchema xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/Storage/Schema'>
	<UsedPropertyTypes>
		<PropertyType itemID='1' name='Binary' dataType='Binary' mapping='0' />
		<PropertyType itemID='2' name='VersioningMode' dataType='Int' mapping='0' />
		<PropertyType itemID='3' name='Make' dataType='String' mapping='0' />
		<PropertyType itemID='4' name='Model' dataType='String' mapping='1' />
		<PropertyType itemID='5' name='Style' dataType='String' mapping='2' />
		<PropertyType itemID='6' name='Color' dataType='String' mapping='3' />
		<PropertyType itemID='7' name='EngineSize' dataType='String' mapping='4' />
		<PropertyType itemID='8' name='Power' dataType='String' mapping='5' />
		<PropertyType itemID='9' name='Price' dataType='String' mapping='6' />
		<PropertyType itemID='10' name='Description' dataType='Text' mapping='0' />
		<PropertyType itemID='11' name='Enabled' dataType='Int' mapping='1' />
		<PropertyType itemID='12' name='Domain' dataType='String' mapping='7' />
		<PropertyType itemID='13' name='Email' dataType='String' mapping='8' />
		<PropertyType itemID='14' name='FullName' dataType='String' mapping='9' />
		<PropertyType itemID='15' name='PasswordHash' dataType='String' mapping='10' />
		<PropertyType itemID='16' name='Memberships' dataType='Binary' mapping='1' />
		<PropertyType itemID='17' name='PendingUserLang' dataType='String' mapping='11' />
		<PropertyType itemID='18' name='Language' dataType='Int' mapping='2' />
		<PropertyType itemID='19' name='Url' dataType='String' mapping='12' />
		<PropertyType itemID='20' name='AuthenticationType' dataType='String' mapping='13' />
		<PropertyType itemID='21' name='StartPage' dataType='String' mapping='14' />
		<PropertyType itemID='22' name='LoginPage' dataType='String' mapping='15' />
		<PropertyType itemID='23' name='StatisticalLog' dataType='Int' mapping='3' />
		<PropertyType itemID='24' name='AuditLog' dataType='Int' mapping='4' />
		<PropertyType itemID='26' name='PageNameInMenu' dataType='String' mapping='16' />
		<PropertyType itemID='27' name='Hidden' dataType='Int' mapping='6' />
		<PropertyType itemID='28' name='Keywords' dataType='String' mapping='17' />
		<PropertyType itemID='29' name='MetaDescription' dataType='String' mapping='18' />
		<PropertyType itemID='30' name='MetaTitle' dataType='String' mapping='19' />
		<PropertyType itemID='31' name='PageTemplateNode' dataType='Reference' mapping='0' />
		<PropertyType itemID='32' name='DefaultPortletSkin' dataType='String' mapping='20' />
		<PropertyType itemID='33' name='HiddenPageFrom' dataType='String' mapping='21' />
		<PropertyType itemID='34' name='Authors' dataType='String' mapping='22' />
		<PropertyType itemID='35' name='CustomMeta' dataType='String' mapping='23' />
		<PropertyType itemID='36' name='Comment' dataType='String' mapping='24' />
		<PropertyType itemID='37' name='PersonalizationSettings' dataType='Binary' mapping='2' />
		<PropertyType itemID='38' name='Title' dataType='String' mapping='25' />
		<PropertyType itemID='39' name='Subtitle' dataType='String' mapping='26' />
		<PropertyType itemID='40' name='Header' dataType='Text' mapping='1' />
		<PropertyType itemID='41' name='Body' dataType='Text' mapping='2' />
		<PropertyType itemID='42' name='Links' dataType='Text' mapping='3' />
		<PropertyType itemID='43' name='ContentLanguage' dataType='String' mapping='27' />
		<PropertyType itemID='44' name='Author' dataType='String' mapping='28' />
		<PropertyType itemID='45' name='ContractId' dataType='String' mapping='29' />
		<PropertyType itemID='46' name='Project' dataType='String' mapping='30' />
		<PropertyType itemID='47' name='Responsee' dataType='String' mapping='31' />
		<PropertyType itemID='48' name='Lawyer' dataType='String' mapping='32' />
		<PropertyType itemID='49' name='MasterPageNode' dataType='Reference' mapping='1' />
		<PropertyType itemID='50' name='Members' dataType='Reference' mapping='2' />
		<PropertyType itemID='51' name='Manufacturer' dataType='String' mapping='33' />
		<PropertyType itemID='52' name='Driver' dataType='String' mapping='34' />
		<PropertyType itemID='53' name='InheritableVersioningMode' dataType='Int' mapping='35' />
		<PropertyType itemID='54' name='HasApproving' dataType='Int' mapping='36' />
	</UsedPropertyTypes>
	<NodeTypeHierarchy>
		<NodeType itemID='7' name='PersonalizationFile' className='SenseNet.ContentRepository.PersonalizationFile'>
			<PropertyType name='Binary' />
			<PropertyType name='VersioningMode' />
			<PropertyType name='InheritableVersioningMode' />
			<PropertyType name='HasApproving' />
		</NodeType>
		<NodeType itemID='5' name='GenericContent' className='SenseNet.ContentRepository.GenericContent'>
			<PropertyType name='VersioningMode' />
			<PropertyType name='InheritableVersioningMode' />
			<PropertyType name='HasApproving' />
			<NodeType itemID='3' name='User' className='SenseNet.ContentRepository.User'>
				<PropertyType name='VersioningMode' />
				<PropertyType name='Enabled' />
				<PropertyType name='Domain' />
				<PropertyType name='Email' />
				<PropertyType name='FullName' />
				<PropertyType name='PasswordHash' />
				<PropertyType name='Memberships' />
			</NodeType>
			<NodeType itemID='1' name='Folder' className='SenseNet.ContentRepository.Folder'>
				<PropertyType name='VersioningMode' />
				<NodeType itemID='16' name='Page' className='SenseNet.Portal.Page'>
					<PropertyType name='Binary' />
					<PropertyType name='PageNameInMenu' />
					<PropertyType name='Hidden' />
					<PropertyType name='Keywords' />
					<PropertyType name='MetaDescription' />
					<PropertyType name='MetaTitle' />
					<PropertyType name='PageTemplateNode' />
					<PropertyType name='DefaultPortletSkin' />
					<PropertyType name='HiddenPageFrom' />
					<PropertyType name='Authors' />
					<PropertyType name='CustomMeta' />
					<PropertyType name='Comment' />
					<PropertyType name='PersonalizationSettings' />
				</NodeType>
				<NodeType itemID='15' name='OrganizationalUnit' className='SenseNet.ContentRepository.OrganizationalUnit'>
				</NodeType>
				<NodeType itemID='14' name='Site' className='SenseNet.Portal.Site'>
					<PropertyType name='Description' />
					<PropertyType name='PendingUserLang' />
					<PropertyType name='Language' />
					<PropertyType name='Url' />
					<PropertyType name='AuthenticationType' />
					<PropertyType name='StartPage' />
					<PropertyType name='LoginPage' />
					<PropertyType name='StatisticalLog' />
					<PropertyType name='AuditLog' />
				</NodeType>
			</NodeType>
			<NodeType itemID='10' name='WebContentDemo' className='SenseNet.ContentRepository.GenericContent'>
				<PropertyType name='Keywords' />
				<PropertyType name='Title' />
				<PropertyType name='Subtitle' />
				<PropertyType name='Header' />
				<PropertyType name='Body' />
				<PropertyType name='Links' />
				<PropertyType name='ContentLanguage' />
				<PropertyType name='Author' />
			</NodeType>
			<NodeType itemID='9' name='File' className='SenseNet.ContentRepository.File'>
				<PropertyType name='Binary' />
				<NodeType itemID='13' name='PageTemplate' className='SenseNet.Portal.PageTemplate'>
					<PropertyType name='MasterPageNode' />
				</NodeType>
				<NodeType itemID='12' name='Contract' className='SenseNet.ContentRepository.File'>
					<PropertyType name='Description' />
					<PropertyType name='Language' />
					<PropertyType name='Keywords' />
					<PropertyType name='ContractId' />
					<PropertyType name='Project' />
					<PropertyType name='Responsee' />
					<PropertyType name='Lawyer' />
				</NodeType>
				<NodeType itemID='11' name='MasterPage' className='SenseNet.Portal.MasterPage' />
			</NodeType>
			<NodeType itemID='8' name='Car' className='SenseNet.ContentRepository.GenericContent'>
				<PropertyType name='Make' />
				<PropertyType name='Model' />
				<PropertyType name='Style' />
				<PropertyType name='Color' />
				<PropertyType name='EngineSize' />
				<PropertyType name='Power' />
				<PropertyType name='Price' />
				<PropertyType name='Description' />
			</NodeType>
		</NodeType>
		<NodeType itemID='4' name='ContentType' className='SenseNet.ContentRepository.Schema.ContentType'>
			<PropertyType name='Binary' />
		</NodeType>
		<NodeType itemID='2' name='Group' className='SenseNet.ContentRepository.Group'>
			<PropertyType name='VersioningMode' />
			<PropertyType name='Members' />
		</NodeType>
	</NodeTypeHierarchy>
	<PermissionTypes>
		<PermissionType itemID='1' name='See' />
		<PermissionType itemID='2' name='Open' />
		<PermissionType itemID='3' name='OpenMinor' />
		<PermissionType itemID='4' name='Save' />
		<PermissionType itemID='5' name='Publish' />
		<PermissionType itemID='6' name='ForceCheckin' />
		<PermissionType itemID='7' name='AddNew' />
		<PermissionType itemID='8' name='Approve' />
		<PermissionType itemID='9' name='Delete' />
		<PermissionType itemID='10' name='RecallOldVersion' />
		<PermissionType itemID='11' name='DeleteOldVersion' />
		<PermissionType itemID='12' name='SeePermissions' />
		<PermissionType itemID='13' name='SetPermissions' />
		<PermissionType itemID='14' name='RunApplication' />
	</PermissionTypes>
</StorageSchema>
");

			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			ed1.Load(schema);
			ed2.Load(schema);

			ContentTypeManagerAccessor ctmAcc = new ContentTypeManagerAccessor(ContentTypeManager.Current);
			ContentType cts = ctmAcc.LoadOrCreateNew(contentTypeDefInstall);
			ctmAcc.ApplyChangesInEditor(cts, ed2);

			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();
			ed2Acc.RegisterSchema(ed1, wr);

			if (contentTypeDefModify != null)
			{
				XmlDocument schema2 = new XmlDocument();
				schema2.LoadXml(ed2.ToXml());
				SchemaEditor ed3 = new SchemaEditor();
				ed3.Load(schema2);
				SchemaEditorAccessor ed3Acc = new SchemaEditorAccessor(ed3);


				cts = ctmAcc.LoadOrCreateNew(contentTypeDefModify);
				ctmAcc.ApplyChangesInEditor(cts, ed3);
				wr = new TestSchemaWriter();
				ed3Acc.RegisterSchema(ed2, wr);
			}

			return wr.Log;
		}
Exemplo n.º 35
0
		public void TypeCollection_GetItemById()
		{
			SchemaEditor ed = new SchemaEditor();
			ed.Load();
			int id = ed.NodeTypes[1].Id;
			var tc = TypeCollectionAccessor<NodeType>.Create(ed.NodeTypes);
			NodeType nt = tc.GetItemById(id);

			Assert.IsTrue(nt.Id == id);
		}
Exemplo n.º 36
0
		internal static void ApplyChanges(ContentType settings)
		{
			SchemaEditor editor = new SchemaEditor();
			editor.Load();
			ApplyChangesInEditor(settings, editor);
			editor.Register();

			// The ContentTypeManager distributes its reset, no custom DistributedAction call needed
			ContentTypeManager.Reset();
		}
Exemplo n.º 37
0
		public void SchEd_WriterCalling_OverridePropertyOnNodeType()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			PropertyType pt1 = CreatePropertyType(ed1, "PT1", DataType.String, 1);
			NodeType nt1 = CreateNodeType(ed1, null, "NT1", "NT1", 1);
			NodeType nt2 = CreateNodeType(ed1, nt1, "NT2", "NT2", 2);
			NodeType nt3 = CreateNodeType(ed1, nt2, "NT3", "NT3", 3);
			NodeType nt4 = CreateNodeType(ed1, nt3, "NT4", "NT4", 4);
			NodeType nt5 = CreateNodeType(ed1, nt4, "NT5", "NT5", 5);
			ed1.AddPropertyTypeToPropertySet(pt1, nt2);

			//-- create current
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(ed1.ToXml());
			ed2.Load(xd);

			//-- edit
			ed2.AddPropertyTypeToPropertySet(ed2.PropertyTypes["PT1"], ed2.NodeTypes["NT4"]);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();UpdatePropertyTypeDeclarationState(propType=<PT1>, newSet=<NT4>, isDeclared=<True>);Close();");
		}
Exemplo n.º 38
0
		public void TypeCollection_Add_AlienNodeTypeToSchema()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			ed1.Load();
			ed2.Load();
			var nodeTypes = TypeCollectionAccessor<NodeType>.Create(ed1);
			try
			{
				nodeTypes.Add(ed2.NodeTypes[0]);
			}
			catch (Exception e)
			{
				//  :)
				throw e.InnerException;
			}
		}
Exemplo n.º 39
0
		public void TypeCollection_IndexOf()
		{
			SchemaEditor ed = new SchemaEditor();
			ed.Load();
			int id = ed.NodeTypes[1].Id;
			var tc = TypeCollectionAccessor<NodeType>.Create(ed);
			foreach (NodeType nt in ed.NodeTypes)
				tc.Add(nt);
			tc.RemoveAt(0);
			for (int i = 1; i < tc.Count; i++)
				if (tc.IndexOf(ed.NodeTypes[i]) != i - 1)
					Assert.Fail();
			if (tc.IndexOf(ed.NodeTypes[0]) != -1)
				Assert.Fail();
			Assert.IsTrue(true);
		}
Exemplo n.º 40
0
		private ContentListType ManageContentListType(Dictionary<string, FieldDescriptor> fieldInfoList, Dictionary<string, List<string>> oldBindings, bool modify, out List<FieldSetting> fieldSettings)
		{
			fieldSettings = new List<FieldSetting>();
			if (!modify)
			{
				//-- Load
                foreach (string name in fieldInfoList.Keys)
                    fieldSettings.Add(FieldSetting.Create(fieldInfoList[name], oldBindings[name]));
                return this.ContentListType;
			}

			SchemaEditor editor = new SchemaEditor();
			editor.Load();
			bool hasChanges = false;
            var listType = this.ContentListType;
			Dictionary<string, List<string>> newBindings = new Dictionary<string, List<string>>();
			SlotTable slotTable = new SlotTable(oldBindings);
			if (listType == null)
			{
				//-- new
				listType = editor.CreateContentListType(Guid.NewGuid().ToString());
				foreach (string name in fieldInfoList.Keys)
					fieldSettings.Add(CreateNewFieldType(fieldInfoList[name], newBindings, listType, slotTable, editor));
				hasChanges = true;
			}
			else
			{
				//-- merge
				listType = editor.ContentListTypes[listType.Name];
				hasChanges |= RemoveUnusedFields(fieldInfoList, oldBindings, listType, editor);
				foreach (string name in fieldInfoList.Keys)
				{
					FieldSetting origField = GetFieldTypeByName(name, _fieldSettings);
					if (origField == null)
					{
						fieldSettings.Add(CreateNewFieldType(fieldInfoList[name], newBindings, listType, slotTable, editor));
						hasChanges = true;
					}
					else
					{
						List<string> bindList = new List<string>(origField.Bindings.ToArray());
                        fieldSettings.Add(FieldSetting.Create(fieldInfoList[name], bindList));
                        newBindings.Add(name, bindList);
					}
				}
			}
			if (hasChanges)
				editor.Register();
            this.ContentListBindings = newBindings;
			return ActiveSchema.ContentListTypes[listType.Name];
		}
Exemplo n.º 41
0
		public void TypeCollection_GetEnumerator()
		{
			SchemaEditor ed = new SchemaEditor();
			var nodeTypes = TypeCollectionAccessor<NodeType>.Create(ed);
			ed.Load();
			nodeTypes.Add(ed.NodeTypes[0]);
			nodeTypes.Add(ed.NodeTypes[1]);
			nodeTypes.Add(ed.NodeTypes[2]);
			IEnumerator<NodeType> enumerator = nodeTypes.GetEnumerator();
			int index = 0;
			while (enumerator.MoveNext())
				if (ed.NodeTypes[index++] != enumerator.Current)
					Assert.Fail();
			Assert.IsTrue(true);
		}
Exemplo n.º 42
0
		internal void RemoveContentType(string name)
		{
			//-- Caller: ContentType.Delete()
			lock (_syncRoot)
			{
				ContentType contentType;
				if (_contentTypes.TryGetValue(name, out contentType))
				{
					SchemaEditor editor = new SchemaEditor();
					editor.Load();
					RemoveContentType(contentType, editor);
					editor.Register();

					// The ContentTypeManager distributes its reset, no custom DistributedAction call needed
					ContentTypeManager.Reset();
				}
			}
		}
Exemplo n.º 43
0
		public void TypeCollection_Contains_ANodeType()
		{
			SchemaEditor ed = new SchemaEditor();
			var nodeTypes = TypeCollectionAccessor<NodeType>.Create(ed);
			ed.Load();
			nodeTypes.Add(ed.NodeTypes[0]);
			nodeTypes.Add(ed.NodeTypes[1]);

			Assert.IsTrue(nodeTypes.Contains(ed.NodeTypes[0]) && !nodeTypes.Contains(ed.NodeTypes[2]));
		}
Exemplo n.º 44
0
		public void TypeCollection_CopyTo_1()
		{
			SchemaEditor ed = new SchemaEditor();
			var nodeTypes = TypeCollectionAccessor<NodeType>.Create(ed);
			ed.Load();
			nodeTypes.Add(ed.NodeTypes[0]);
			nodeTypes.Add(ed.NodeTypes[1]);
			nodeTypes.Add(ed.NodeTypes[2]);
			NodeType[] copy = new NodeType[4];
			nodeTypes.CopyTo(copy, 1);
			Assert.IsTrue(copy[1] == ed.NodeTypes[0] && copy[2] == ed.NodeTypes[1] && copy[3] == ed.NodeTypes[2]);
		}
Exemplo n.º 45
0
		public void SchEd_WriterCalling_Complex_01()
		{
			SchemaEditor ed1 = new SchemaEditor();
			SchemaEditor ed2 = new SchemaEditor();
			SchemaEditorAccessor ed2Acc = new SchemaEditorAccessor(ed2);
			TestSchemaWriter wr = new TestSchemaWriter();

			//-- create original
			PropertyType ptX = CreatePropertyType(ed1, "X", DataType.String, 1);
			PropertyType ptY = CreatePropertyType(ed1, "Y", DataType.String, 2);
			PropertyType ptZ = CreatePropertyType(ed1, "Z", DataType.String, 3);
			NodeType ntA = CreateNodeType(ed1, null, "A", null, 1);
			NodeType ntB = CreateNodeType(ed1, ntA, "B", null, 2);
			NodeType ntC = CreateNodeType(ed1, ntB, "C", null, 3);
			ed1.AddPropertyTypeToPropertySet(ptX, ntB);
			ed1.AddPropertyTypeToPropertySet(ptY, ntC);
			ed1.AddPropertyTypeToPropertySet(ptX, ntA);

			//-- create current
			XmlDocument xd = new XmlDocument();
			xd.LoadXml(ed1.ToXml());
			ed2.Load(xd);
			ptX = ed2.PropertyTypes["X"];
			ptY = ed2.PropertyTypes["Y"];
			ptZ = ed2.PropertyTypes["Z"];
			ntA = ed2.NodeTypes["A"];
			ntB = ed2.NodeTypes["B"];
			ntC = ed2.NodeTypes["C"];

			//-- edit
			ed2.RemovePropertyTypeFromPropertySet(ptX, ntA);

			//-- register
			ed2Acc.RegisterSchema(ed1, wr);

			//-- test
			string log = wr.Log.Replace("\r\n", "");
			Assert.IsTrue(log == "Open();RemovePropertyTypeFromPropertySet(propertyType=<X>, owner=<A>);Close();");

		}