Example #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");
			}
		}
Example #2
0
			public ReferenceSetCmdlets(PSEntityMetadata.ReferenceSetCmdlets.ReferencePropertyType propertyType, PSReferenceSetCmdletInfo addRefCmdlet, PSReferenceSetCmdletInfo removeRefCmdlet, PSReferenceSetCmdletInfo getRefCmdlet = null, bool getRefHidden = false)
			{
				this.Cmdlets = new Dictionary<CommandType, PSReferenceSetCmdletInfo>();
				this.PropertyType = propertyType;
				if (addRefCmdlet != null)
				{
					this.Cmdlets.Add(CommandType.AddReference, addRefCmdlet);
				}
				if (removeRefCmdlet != null)
				{
					this.Cmdlets.Add(CommandType.RemoveReference, removeRefCmdlet);
				}
				if (getRefCmdlet != null)
				{
					this.Cmdlets.Add(CommandType.GetReference, getRefCmdlet);
					this.GetRefHidden = getRefHidden;
				}
			}