本文整理汇总了C#中ResourceType.GetNamedStreamsDeclaredOnThisType方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceType.GetNamedStreamsDeclaredOnThisType方法的具体用法?C# ResourceType.GetNamedStreamsDeclaredOnThisType怎么用?C# ResourceType.GetNamedStreamsDeclaredOnThisType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceType
的用法示例。
在下文中一共展示了ResourceType.GetNamedStreamsDeclaredOnThisType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNamedStreamTest
public void AddNamedStreamTest()
{
ResourceType type1 = new ResourceType(typeof(object), ResourceTypeKind.EntityType, null, "namespace", "type1", true);
type1.CanReflectOnInstanceType = false;
ResourceProperty id = new ResourceProperty("ID", ResourcePropertyKind.Key | ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int)));
type1.AddProperty(id);
id.CanReflectOnInstanceTypeProperty = false;
ResourceType type2 = new ResourceType(typeof(object), ResourceTypeKind.EntityType, type1, "namespace", "type2", false);
type2.AddProperty(new ResourceProperty("Stream1", ResourcePropertyKind.Stream, ResourceType.GetPrimitiveResourceType(typeof(System.IO.Stream))));
type2.AddProperty(new ResourceProperty("Stream2", ResourcePropertyKind.Stream, ResourceType.GetPrimitiveResourceType(typeof(System.IO.Stream))));
ResourceType type3 = new ResourceType(typeof(object), ResourceTypeKind.EntityType, type2, "namespace", "type3", false);
type3.AddProperty(new ResourceProperty("Stream3", ResourcePropertyKind.Stream, ResourceType.GetPrimitiveResourceType(typeof(System.IO.Stream))));
Assert.AreEqual(0, type1.GetNamedStreams().Count(), "Wrong count");
Assert.AreEqual(0, type1.GetNamedStreamsDeclaredOnThisType().Count(), "Wrong count");
Assert.AreEqual(2, type2.GetNamedStreams().Count(), "Wrong count");
Assert.IsNotNull(type2.GetNamedStreams().Single(s => s.Name == "Stream1"), "Unexpected null");
Assert.IsNotNull(type2.GetNamedStreams().Single(s => s.Name == "Stream2"), "Unexpected null");
Assert.AreEqual(2, type2.GetNamedStreamsDeclaredOnThisType().Count(), "Wrong count");
Assert.IsNotNull(type2.GetNamedStreamsDeclaredOnThisType().Single(s => s.Name == "Stream1"), "Unexpected null");
Assert.IsNotNull(type2.GetNamedStreamsDeclaredOnThisType().Single(s => s.Name == "Stream2"), "Unexpected null");
Assert.AreEqual(3, type3.GetNamedStreams().Count(), "Wrong count");
Assert.IsNotNull(type3.GetNamedStreams().Single(s => s.Name == "Stream1"), "Unexpected null");
Assert.IsNotNull(type3.GetNamedStreams().Single(s => s.Name == "Stream2"), "Unexpected null");
Assert.IsNotNull(type3.GetNamedStreams().Single(s => s.Name == "Stream3"), "Unexpected null");
Assert.AreEqual(1, type3.GetNamedStreamsDeclaredOnThisType().Count(), "Wrong count");
Assert.IsNotNull(type3.GetNamedStreamsDeclaredOnThisType().Single(s => s.Name == "Stream3"), "Unexpected null");
type3.SetReadOnly();
Assert.AreEqual(0, type1.GetNamedStreams().Count(), "Wrong count");
Assert.AreEqual(0, type1.GetNamedStreamsDeclaredOnThisType().Count(), "Wrong count");
Assert.AreEqual(2, type2.GetNamedStreams().Count(), "Wrong count");
Assert.IsNotNull(type2.GetNamedStreams().Single(s => s.Name == "Stream1"), "Unexpected null");
Assert.IsNotNull(type2.GetNamedStreams().Single(s => s.Name == "Stream2"), "Unexpected null");
Assert.AreEqual(2, type2.GetNamedStreamsDeclaredOnThisType().Count(), "Wrong count");
Assert.IsNotNull(type2.GetNamedStreamsDeclaredOnThisType().Single(s => s.Name == "Stream1"), "Unexpected null");
Assert.IsNotNull(type2.GetNamedStreamsDeclaredOnThisType().Single(s => s.Name == "Stream2"), "Unexpected null");
Assert.AreEqual(3, type3.GetNamedStreams().Count(), "Wrong count");
Assert.IsNotNull(type3.GetNamedStreams().Single(s => s.Name == "Stream1"), "Unexpected null");
Assert.IsNotNull(type3.GetNamedStreams().Single(s => s.Name == "Stream2"), "Unexpected null");
Assert.IsNotNull(type3.GetNamedStreams().Single(s => s.Name == "Stream3"), "Unexpected null");
Assert.AreEqual(1, type3.GetNamedStreamsDeclaredOnThisType().Count(), "Wrong count");
Assert.IsNotNull(type3.GetNamedStreamsDeclaredOnThisType().Single(s => s.Name == "Stream3"), "Unexpected null");
}