public void TestSimpleConstruction()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset1 { MyString = "String" };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
 }
 public void TestSimpleCollectionUpdate()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     var node = ((IGraphNode)graph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
     //var ids = CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out itemIds);
 }
 public void TestNestedCollectionConstruction()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset7 { MyAsset2 = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } } };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
     CollectionItemIdentifiers ids;
     Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyAsset2.MyStrings, out ids));
     Assert.AreEqual(3, ids.KeyCount);
     Assert.AreEqual(0, ids.DeletedCount);
     Assert.True(ids.ContainsKey(0));
     Assert.True(ids.ContainsKey(1));
     Assert.True(ids.ContainsKey(2));
 }
 public static AssetPropertyGraph ConstructPropertyGraph(AssetPropertyGraphContainer container, AssetItem assetItem, ILogger logger)
 {
     var assetType = assetItem.Asset.GetType();
     while (assetType != null)
     {
         Type propertyGraphType;
         var typeToTest = assetType.IsGenericType ? assetType.GetGenericTypeDefinition() : assetType;
         if (NodeGraphTypes.TryGetValue(typeToTest, out propertyGraphType))
         {
             return (AssetPropertyGraph)Activator.CreateInstance(propertyGraphType, container, assetItem, logger);
         }
         assetType = assetType.BaseType;
     }
     throw new InvalidOperationException("No AssetPropertyGraph type matching the given asset type has been found");
 }
        public AssetPropertyGraph(AssetPropertyGraphContainer container, AssetItem assetItem, ILogger logger)
        {
            if (container == null) throw new ArgumentNullException(nameof(container));
            if (assetItem == null) throw new ArgumentNullException(nameof(assetItem));
            Container = container;
            AssetCollectionItemIdHelper.GenerateMissingItemIds(assetItem.Asset);
            CollectionItemIdsAnalysis.FixupItemIds(assetItem, logger);
            Asset = assetItem.Asset;
            RootNode = (AssetNode)Container.NodeContainer.GetOrCreateNode(assetItem.Asset);
            ApplyOverrides(RootNode, assetItem.Overrides);
            nodeListener = new GraphNodeChangeListener(RootNode, ShouldListenToTargetNode);
            nodeListener.Changing += AssetContentChanging;
            nodeListener.Changed += AssetContentChanged;

            baseLinker = new AssetToBaseNodeLinker(this) { LinkAction = LinkBaseNode };
        }
 public void TestCollectionItemIdentifierWithDuplicates()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } };
     var ids = CollectionItemIdHelper.GetCollectionItemIds(asset.MyStrings);
     ids.Add(0, IdentifierGenerator.Get(100));
     ids.Add(1, IdentifierGenerator.Get(200));
     ids.Add(2, IdentifierGenerator.Get(100));
     var assetItem = new AssetItem("MyAsset", asset);
     Assert.AreEqual(IdentifierGenerator.Get(100), ids[0]);
     Assert.AreEqual(IdentifierGenerator.Get(200), ids[1]);
     Assert.AreEqual(IdentifierGenerator.Get(100), ids[2]);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
     Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out ids));
     Assert.AreEqual(3, ids.KeyCount);
     Assert.AreEqual(0, ids.DeletedCount);
     Assert.AreEqual(IdentifierGenerator.Get(100), ids[0]);
     Assert.AreEqual(IdentifierGenerator.Get(200), ids[1]);
     Assert.AreNotEqual(IdentifierGenerator.Get(100), ids[2]);
     Assert.AreNotEqual(IdentifierGenerator.Get(200), ids[2]);
 }
Example #7
0
 public MyAssetBasePropertyGraph(AssetPropertyGraphContainer container, AssetItem assetItem, ILogger logger)
     : base(container, assetItem, logger)
 {
 }
 public AssetCompositePropertyGraph(AssetPropertyGraphContainer container, AssetItem assetItem, ILogger logger) : base(container, assetItem, logger)
 {
 }