public void ReadAndWriteProperties() { // Arrange: Create instance var resource = new SimpleResource { Id = 1, Foo = 1337 }; // Act: Build Proxy var proxy = (ISimpleResource)_typeController.GetProxy(resource); var duplicate = (IDuplicateFoo)proxy; // Assert Assert.AreEqual(resource.Foo, proxy.Foo); Assert.AreEqual(resource.Foo, duplicate.Foo); proxy.Foo = 187; // duplicate.Foo = 10; ReadOnly but still uses the same property Assert.AreEqual(187, resource.Foo); Assert.AreEqual(187, duplicate.Foo); }
public static TResource Proxify <TResource>(this TResource source, IResourceTypeController typeController) where TResource : class, IPublicResource { return((TResource)typeController.GetProxy(source as Resource)); }
/// <summary> /// Convert a referenced instance to a proxy /// </summary> protected internal TResource Convert <TResource>(IResource instance) where TResource : IResource { return((TResource)_typeController.GetProxy((Resource)instance)); }