/// <summary> /// Creates a new object instance according to the lifetime manager's properties. /// If the target type is decorated with the <see cref="InterceptedAttribute"/>, /// it is automatically intercepted. /// </summary> /// <returns></returns> protected virtual object CreateObjectInstance() { var instance = ConfigurationHelper.CreateInstance( ServiceObjectType, ConstructionParameters, Properties); if (ServiceObjectType.GetCustomAttributes(typeof(InterceptedAttribute), true).Length > 0 && ServiceObjectType.GetCustomAttributes(typeof(DisableInterceptionAttribute), false).Length == 0) { // --- This is an intercepted object instance = Interceptor.GetInterceptedObject(ServiceType, instance, null); } return(instance); }
/// <summary> /// Gets the name of the shape. /// </summary> /// <param name="serviceObjectType">Type of the service object.</param> /// <returns>Shape name.</returns> private static string GetShapeName(ServiceObjectType serviceObjectType) { switch (serviceObjectType) { case ServiceObjectType.Item: return(XmlElementNames.ItemShape); case ServiceObjectType.Folder: return(XmlElementNames.FolderShape); case ServiceObjectType.Conversation: return(XmlElementNames.ConversationShape); default: EwsUtilities.Assert( false, "PropertySet.GetShapeName", string.Format("An unexpected object type {0} for property shape. This code path should never be reached.", serviceObjectType)); return(string.Empty); } }
/// <summary> /// Writes the get shape to json. /// </summary> /// <param name="jsonRequest">The json request.</param> /// <param name="service">The service.</param> /// <param name="serviceObjectType">Type of the service object.</param> internal void WriteGetShapeToJson(JsonObject jsonRequest, ExchangeService service, ServiceObjectType serviceObjectType) { string shapeName = GetShapeName(serviceObjectType); JsonObject jsonShape = new JsonObject(); jsonShape.Add(XmlElementNames.BaseShape, defaultPropertySetMap.Member[this.BasePropertySet]); if (serviceObjectType == ServiceObjectType.Item) { if (this.RequestedBodyType.HasValue) { jsonShape.Add(XmlElementNames.BodyType, this.RequestedBodyType.Value); } if (this.FilterHtmlContent.HasValue) { jsonShape.Add(XmlElementNames.FilterHtmlContent, this.FilterHtmlContent.Value); } if (this.ConvertHtmlCodePageToUTF8.HasValue && service.RequestedServerVersion >= ExchangeVersion.Exchange2010_SP1) { jsonShape.Add(XmlElementNames.ConvertHtmlCodePageToUTF8, this.ConvertHtmlCodePageToUTF8.Value); } if (!string.IsNullOrEmpty(this.InlineImageUrlTemplate) && service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { jsonShape.Add(XmlElementNames.InlineImageUrlTemplate, this.InlineImageUrlTemplate); } if (this.BlockExternalImages.HasValue && service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { jsonShape.Add(XmlElementNames.BlockExternalImages, this.BlockExternalImages.Value); } if (this.AddBlankTargetToLinks.HasValue && service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { jsonShape.Add(XmlElementNames.AddBlankTargetToLinks, this.AddBlankTargetToLinks.Value); } if (this.MaximumBodySize.HasValue && service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { jsonShape.Add(XmlElementNames.MaximumBodySize, this.MaximumBodySize.Value); } } if (this.additionalProperties.Count > 0) { WriteAdditionalPropertiesToJson(jsonShape, service, this.additionalProperties); } jsonRequest.Add(shapeName, jsonShape); }
/// <summary> /// Writes the property set to XML. /// </summary> /// <param name="writer">The writer to write to.</param> /// <param name="serviceObjectType">The type of service object the property set is emitted for.</param> internal void WriteToXml(EwsServiceXmlWriter writer, ServiceObjectType serviceObjectType) { string shapeElementName = GetShapeName(serviceObjectType); writer.WriteStartElement(XmlNamespace.Messages, shapeElementName); writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.BaseShape, defaultPropertySetMap.Member[this.BasePropertySet]); if (serviceObjectType == ServiceObjectType.Item) { if (this.RequestedBodyType.HasValue) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.BodyType, this.RequestedBodyType.Value); } if (this.RequestedUniqueBodyType.HasValue) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.UniqueBodyType, this.RequestedUniqueBodyType.Value); } if (this.RequestedNormalizedBodyType.HasValue) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.NormalizedBodyType, this.RequestedNormalizedBodyType.Value); } if (this.FilterHtmlContent.HasValue) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.FilterHtmlContent, this.FilterHtmlContent.Value); } if (this.ConvertHtmlCodePageToUTF8.HasValue && writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2010_SP1) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.ConvertHtmlCodePageToUTF8, this.ConvertHtmlCodePageToUTF8.Value); } if (!string.IsNullOrEmpty(this.InlineImageUrlTemplate) && writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.InlineImageUrlTemplate, this.InlineImageUrlTemplate); } if (this.BlockExternalImages.HasValue && writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.BlockExternalImages, this.BlockExternalImages.Value); } if (this.AddBlankTargetToLinks.HasValue && writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.AddBlankTargetToLinks, this.AddBlankTargetToLinks.Value); } if (this.MaximumBodySize.HasValue && writer.Service.RequestedServerVersion >= ExchangeVersion.Exchange2013) { writer.WriteElementValue( XmlNamespace.Types, XmlElementNames.MaximumBodySize, this.MaximumBodySize.Value); } } if (this.additionalProperties.Count > 0) { WriteAdditionalPropertiesToXml(writer, this.additionalProperties); } writer.WriteEndElement(); // Item/FolderShape }
/// <summary> /// Sets the type of service object this view applies to. /// </summary> /// <param name="objType">Service object type</param> internal void SetServiceObjectType(ServiceObjectType objType) { this.serviceObjType = objType; }
/// <summary> /// Initializes a new instance of the <see cref="SeekToConditionItemView"/> class. /// </summary> /// <param name="condition">Condition to be used when seeking.</param> /// <param name="pageSize">The maximum number of elements the search operation should return.</param> public SeekToConditionItemView(SearchFilter condition, int pageSize) { this.Condition = condition; this.PageSize = pageSize; this.serviceObjType = ServiceObjectType.Item; }
/// <summary> /// Sets the type of service object this view applies to. /// </summary> /// <param name="objType">Service object type</param> internal void SetServiceObjectType(ServiceObjectType objType) { this.serviceObjType = objType; }
/// <summary> /// Initializes a new instance of the <see cref="SeekToConditionItemView"/> class. /// </summary> /// <param name="condition">Condition to be used when seeking.</param> /// <param name="pageSize">The maximum number of elements the search operation should return.</param> public SeekToConditionItemView(SearchFilter condition, int pageSize) { this.Condition = condition; this.PageSize = pageSize; this.serviceObjType = ServiceObjectType.Item; }