public void VirtualType_ctors() { VirtualType vt = new VirtualType("name", "namespace", this.GetType().Assembly, this.GetType()); Assert.AreEqual("name", vt.Name); Assert.AreEqual("namespace", vt.Namespace); Assert.AreEqual(this.GetType().Assembly, vt.Assembly); Assert.AreEqual(this.GetType(), vt.BaseType); vt = new VirtualType(this.GetType()); this.AssertEquivalentTypes(this.GetType(), vt); }
internal List<Attribute> GetContractServiceKnownTypes(DomainOperationEntry operation, HashSet<Type> registeredTypes) { List<Attribute> knownTypeAttributes = new List<Attribute>(); foreach (DomainOperationParameter parameter in operation.Parameters) { Type t = CodeGenUtilities.TranslateType(parameter.ParameterType); // All Nullable<T> types are unwrapped to the underlying non-nullable, because // that is they type we need to represent, not typeof(Nullable<T>) t = TypeUtility.GetNonNullableType(t); if (TypeUtility.IsPredefinedListType(t) || TypeUtility.IsComplexTypeCollection(t)) { Type elementType = TypeUtility.GetElementType(t); if (elementType != null) { t = elementType.MakeArrayType(); } } // Check if the type is a simple type or already registered if (registeredTypes.Contains(t) || !this.TypeRequiresRegistration(t)) { continue; } // Record the type to prevent redundant [ServiceKnownType]'s. // This loop executes within a larger loop over multiple // DomainOperationEntries that may have already processed it. registeredTypes.Add(t); // If we determine we need to generate this enum type on the client, // then we need to register that intent and conjure a virtual type // here in our list of registered types to account for the fact it // could get a different root namespace on the client. if (t.IsEnum && this.ClientCodeGenerator.NeedToGenerateEnumType(t)) { // Request deferred generation of the enum this.ClientCodeGenerator.AddEnumTypeToGenerate(t); // Compose a virtual type that will reflect the correct namespace // on the client when the [ServiceKnownType] is created. t = new VirtualType(t.Name, CodeGenUtilities.TranslateNamespace(t), t.Assembly, t.BaseType); } knownTypeAttributes.Add(new ServiceKnownTypeAttribute(t)); } return knownTypeAttributes; }
public void VirtualType_BaseTypes() { VirtualType vt = new VirtualType(typeof(VT_C)); this.AssertEquivalentTypes(typeof(VT_C), vt); }