static public bool CanAccess(this ScopeAccess item, Referenceable referenceable) { if (referenceable != null) { return(item.CanAccess(referenceable.GetScopeAccessLevel())); } return(false); }
public void TestAbstractNonIdentifiableReferenceableDictionarySerialization() { var obj = new NonIdentifiableCollectionContainer(); var item = new Referenceable { Id = GuidGenerator.Get(1), Value = "Test" }; obj.AbstractRefDictionary.Add("Item1", item); obj.AbstractRefDictionary.Add("Item2", item); var objectReferences = new YamlAssetMetadata <Guid>(); var path = new YamlAssetPath(); path.PushMember(nameof(CollectionContainer.AbstractRefDictionary)); path.PushIndex("Item1"); objectReferences.Set(path, GuidGenerator.Get(1)); var yaml = SerializeAsString(obj, objectReferences); Assert.AreEqual(AbstractNonIdentifiableReferenceableDictionaryYaml, yaml); }
public void TestConcreteNonIdentifiableReferenceableListSerialization() { var obj = new NonIdentifiableCollectionContainer(); var item = new Referenceable { Id = GuidGenerator.Get(1), Value = "Test" }; obj.ConcreteRefList.Add(item); obj.ConcreteRefList.Add(item); var objectReferences = new YamlAssetMetadata <Guid>(); var path = new YamlAssetPath(); path.PushMember(nameof(CollectionContainer.ConcreteRefList)); path.PushIndex(0); objectReferences.Set(path, GuidGenerator.Get(1)); var yaml = SerializeAsString(obj, objectReferences); Assert.AreEqual(ConcreteNonIdentifiableReferenceableListYaml, yaml); }
public void TestConcreteReferenceableDictionarySerialization() { var obj = new CollectionContainer(); var item = new Referenceable { Id = GuidGenerator.Get(1), Value = "Test" }; obj.ConcreteRefDictionary.Add("Item1", item); obj.ConcreteRefDictionary.Add("Item2", item); var objectReferences = new YamlAssetMetadata <Guid>(); var ids = CollectionItemIdHelper.GetCollectionItemIds(obj.ConcreteRefDictionary); ids["Item1"] = IdentifierGenerator.Get(1); ids["Item2"] = IdentifierGenerator.Get(2); var path = new YamlAssetPath(); path.PushMember(nameof(CollectionContainer.ConcreteRefDictionary)); path.PushItemId(IdentifierGenerator.Get(1)); objectReferences.Set(path, GuidGenerator.Get(1)); var yaml = SerializeAsString(obj, objectReferences); Assert.AreEqual(ConcreteReferenceableDictionaryYaml, yaml); }
public void TestAbstractReferenceableListSerialization() { var obj = new CollectionContainer(); var item = new Referenceable { Id = GuidGenerator.Get(1), Value = "Test" }; obj.AbstractRefList.Add(item); obj.AbstractRefList.Add(item); var objectReferences = new YamlAssetMetadata <Guid>(); var ids = CollectionItemIdHelper.GetCollectionItemIds(obj.AbstractRefList); ids[0] = IdentifierGenerator.Get(1); ids[1] = IdentifierGenerator.Get(2); var path = new YamlAssetPath(); path.PushMember(nameof(CollectionContainer.AbstractRefList)); path.PushItemId(IdentifierGenerator.Get(1)); objectReferences.Set(path, GuidGenerator.Get(1)); var yaml = SerializeAsString(obj, objectReferences); Assert.AreEqual(AbstractReferenceableListYaml, yaml); }