Пример #1
0
		public ReferenceTypeSerializer(ResourceType referringResourceType, ResourceProperty resourceProperty) : base(resourceProperty.ResourceType)
		{
			if (resourceProperty.ResourceType.ResourceTypeKind == ResourceTypeKind.EntityType)
			{
				object[] name = new object[1];
				name[0] = resourceProperty.Name;
				referringResourceType.ThrowIfNull("referringResourceType", new ParameterExtensions.MessageLoader(SerializerBase.GetReferringResourceTypeCannotNullMessage), name);
				DataContext currentContext = DataServiceController.Current.GetCurrentContext();
				if (currentContext != null)
				{
					PSEntityMetadata entityMetadata = currentContext.UserSchema.GetEntityMetadata(referringResourceType) as PSEntityMetadata;
					PSEntityMetadata.ReferenceSetCmdlets referenceSetCmdlet = null;
					if (!entityMetadata.CmdletsForReferenceSets.TryGetValue(resourceProperty.Name, out referenceSetCmdlet))
					{
						this.referencePropertyType = PSEntityMetadata.ReferenceSetCmdlets.ReferencePropertyType.Instance;
					}
					else
					{
						this.referencePropertyType = referenceSetCmdlet.PropertyType;
						return;
					}
				}
				return;
			}
			else
			{
				throw new ArgumentException("resourceType");
			}
		}
Пример #2
0
		public static void AddDerivedType(this ResourceType resourceType, ResourceType derivedType)
		{
			object[] name = new object[1];
			name[0] = resourceType.Name;
			derivedType.ThrowIfNull("derivedType", Resources.NullPassedAsDerivedType, name);
			object[] fullName = new object[2];
			fullName[0] = resourceType.FullName;
			fullName[1] = derivedType.FullName;
			ExceptionHelpers.ThrowArgumentExceptionIf("derivedType", derivedType.BaseType != resourceType, Resources.NotBaseResourceType, fullName);
			(resourceType.CustomState as ResourceCustomState).DerivedTypes.Add(derivedType);
		}
Пример #3
0
		public ReferenceSetSerializer(ResourceType referringResourceType, ResourceProperty resourceProperty) : base(resourceProperty.ResourceType)
		{
			if (resourceProperty.ResourceType.ResourceTypeKind == ResourceTypeKind.EntityType)
			{
				object[] name = new object[1];
				name[0] = resourceProperty.Name;
				referringResourceType.ThrowIfNull("referringResourceType", new ParameterExtensions.MessageLoader(SerializerBase.GetReferringResourceTypeCannotNullMessage), name);
				this.resourceProperty = resourceProperty;
				this.referringResourceType = referringResourceType;
				return;
			}
			else
			{
				throw new ArgumentException("resourceType");
			}
		}
Пример #4
0
		internal ResourceSet AddResourceSet(string name, ResourceType entityType)
		{
			name.ThrowIfNullOrEmpty("name", Resources.NullIsPassedAsResourceSetName, new object[0]);
			object[] objArray = new object[1];
			objArray[0] = name;
			entityType.ThrowIfNull("entityType", Resources.ParameterSetNull, objArray);
			if (entityType.ResourceTypeKind == ResourceTypeKind.EntityType)
			{
				ResourceSet resourceSet = new ResourceSet(name, entityType);
				if (!this.ResourceSets.Keys.Contains<string>(name))
				{
					this.ResourceSets.Add(name, resourceSet);
					return resourceSet;
				}
				else
				{
					object[] item = new object[3];
					item[0] = name;
					item[1] = entityType.Name;
					item[2] = this.ResourceSets[name];
					throw new ArgumentException(ExceptionHelpers.GetExceptionMessage(Resources.ResourceSetNameDuplicated, item));
				}
			}
			else
			{
				throw new InvalidResourceTypeException(entityType.Name, entityType.ResourceTypeKind.ToString(), ResourceTypeKind.EntityType.ToString());
			}
		}