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


C# MemberPath.Resolve方法代码示例

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


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

示例1: CanBeModified

        /// <summary>
        /// Indicate if the referred member can be modified or not due to sealing.
        /// </summary>
        /// <param name="asset">The asset to modify</param>
        /// <param name="path">The path to the member to modify</param>
        /// <returns><value>true</value> if it can be modified</returns>
        public bool CanBeModified(Asset asset, MemberPath path)
        {
            if (path.GetNodeOverrides(asset).Any(x => x.IsNew()))
                return true;

            var assetBase = asset.Base;
            while (assetBase != null && assetBase.Asset != null)
            {
                var parent = assetBase.Asset;
                var parentPath = path.Resolve(asset, parent).FirstOrDefault(); // if several paths exist in parent, they should be all equal (same object instance)
                if (parentPath == null)
                    break;

                var parentOverrides = parentPath.GetNodeOverrides(parent).ToList();
                if (parentOverrides.LastOrDefault().IsSealed())
                    return false;

                if (parentOverrides.Any(x => x.IsNew()))
                    break;

                assetBase = parent.Base;
            }

            return true;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:31,代码来源:AssetUpdater.cs

示例2: TestResolveComplex

        public void TestResolveComplex()
        {
            var memberPath = new MemberPath();
            memberPath.Push(MemberSubs);
            memberPath.Push(ListClassDesc, 1);
            memberPath.Push(MemberSub);
            memberPath.Push(MemberValue);

            var id = Guid.NewGuid();
            var referenceElt = new MyClass { Sub = new MyClass { Value = 1 } };
            var dualElt1 = new MyClass { Sub = new MyClass { Value = 2 } };
            var dualElt2 = new MyClass { Sub = new MyClass { Value = 3 } };
            var brokenDual = new MyClass();
            IdentifiableHelper.SetId(referenceElt, id);
            IdentifiableHelper.SetId(dualElt1, id);
            IdentifiableHelper.SetId(dualElt2, id);
            IdentifiableHelper.SetId(brokenDual, id);

            var reference = new MyClass { Subs = { new MyClass(), referenceElt } };
            var dual = new MyClass { Subs = { new MyClass(), new MyClass(), dualElt1, brokenDual, new MyClass(), dualElt2 } };

            var resolvedPaths = memberPath.Resolve(reference, dual).ToList();
            Assert.AreEqual(2, resolvedPaths.Count);

            object value;
            Assert.IsTrue(resolvedPaths[0].TryGetValue(dual, out value));
            Assert.AreEqual(dual.Subs[2].Sub.Value, value);

            Assert.IsTrue(resolvedPaths[1].TryGetValue(dual, out value));
            Assert.AreEqual(dual.Subs[5].Sub.Value, value);
        }
开发者ID:psowinski,项目名称:xenko,代码行数:31,代码来源:TestMemberPath.cs

示例3: TestResolveCollectionBroken

        public void TestResolveCollectionBroken()
        {
            var memberPath = new MemberPath();
            memberPath.Push(MemberSubs);
            memberPath.Push(ListClassDesc, 0);

            var referenceElt = new MyClass();
            IdentifiableHelper.SetId(referenceElt, Guid.NewGuid());

            var reference = new MyClass { Subs = { referenceElt } };
            var dual = new MyClass();
            dual.Subs.Add(new MyClass());
            dual.Subs.Add(new MyClass());

            var resolvedPaths = memberPath.Resolve(reference, dual).ToList();
            Assert.AreEqual(0, resolvedPaths.Count);

            memberPath = new MemberPath();
            memberPath.Push(MemberSubs);
            memberPath.Push(ListClassDesc, 1);
            
            resolvedPaths = memberPath.Resolve(reference, dual).ToList();
            Assert.AreEqual(0, resolvedPaths.Count);
        }
开发者ID:psowinski,项目名称:xenko,代码行数:24,代码来源:TestMemberPath.cs

示例4: TestResolveBroken

        public void TestResolveBroken()
        {
            var memberPath = new MemberPath();
            memberPath.Push(MemberSub);
            memberPath.Push(MemberStruct);
            memberPath.Push(MemberClass);
            memberPath.Push(MemberValue);

            var reference = new MyClass { Sub = new MyClass { Struct = new MyStruct { Class = new MyClass { Value = 1 } } } };
            var dual = new MyClass { Sub = new MyClass { Struct = new MyStruct { Class = null } } };

            var resolvedPaths = memberPath.Resolve(reference, dual).ToList();
            Assert.AreEqual(0, resolvedPaths.Count);
        }
开发者ID:psowinski,项目名称:xenko,代码行数:14,代码来源:TestMemberPath.cs

示例5: TestResolveSimple

        public void TestResolveSimple()
        {
            var memberPath = new MemberPath();
            memberPath.Push(MemberSub);
            memberPath.Push(MemberStruct);
            memberPath.Push(MemberClass);
            memberPath.Push(MemberMaps);
            memberPath.Push(MapClassDesc, "toto");
            memberPath.Push(MemberValue);

            var reference = new MyClass { Sub = new MyClass { Struct = new MyStruct { Class = new MyClass { Maps = { {"toto", new MyClass { Value = 1 } } } } } } };
            var dual = new MyClass { Sub = new MyClass { Struct = new MyStruct { Class = new MyClass { Maps = { { "toto", new MyClass { Value = 2 } } } } } } };

            var resolvedPaths = memberPath.Resolve(reference, dual).ToList();
            Assert.AreEqual(1, resolvedPaths.Count);

            object value;
            Assert.IsTrue(resolvedPaths[0].TryGetValue(dual, out value));
            Assert.AreEqual(dual.Sub.Struct.Class.Maps["toto"].Value, value);
        }
开发者ID:psowinski,项目名称:xenko,代码行数:20,代码来源:TestMemberPath.cs


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