Пример #1
0
 /// <summary>
 /// Determines whether the specified property may be accessed.
 /// </summary>
 /// <param name="property">Property to access.</param>
 /* private */ void ValidatePropertyAccess(UserConfigurationProperties property)
 {
     if ((property & this.propertiesAvailableForAccess) != property)
     {
         throw new PropertyException(Strings.MustLoadOrAssignPropertyBeforeAccess, property.ToString());
     }
 }
Пример #2
0
    /// <summary>
    /// Determines whether the specified property was updated.
    /// </summary>
    /// <param name="property">property to evaluate.</param>
    /// <returns>Boolean indicating whether to send the property Xml.</returns>
    /* private */ bool IsPropertyUpdated(UserConfigurationProperties property)
    {
        bool isPropertyDirty = false;
        bool isPropertyEmpty = false;

        switch (property)
        {
        case UserConfigurationProperties.Dictionary:
            isPropertyDirty = this.Dictionary.IsDirty;
            isPropertyEmpty = this.Dictionary.Count == 0;
            break;

        case UserConfigurationProperties.XmlData:
            isPropertyDirty = (property & this.updatedProperties) == property;
            isPropertyEmpty = (this.xmlData == null) || (this.xmlData.Length == 0);
            break;

        case UserConfigurationProperties.BinaryData:
            isPropertyDirty = (property & this.updatedProperties) == property;
            isPropertyEmpty = (this.binaryData == null) || (this.binaryData.Length == 0);
            break;

        default:
            EwsUtilities.Assert(
                false,
                "UserConfiguration.IsPropertyUpdated",
                "property not supported: " + property.ToString());
            break;
        }

        // Consider the property updated, if it's been modified, and either
        //    . there's a value or
        //    . there's no value but the operation is update.
        return(isPropertyDirty && ((!isPropertyEmpty) || (!this.isNew)));
    }
Пример #3
0
    /// <summary>
    /// Initializes properties.
    /// </summary>
    /// <param name="requestedProperties">The properties requested for this UserConfiguration.</param>
    /// <remarks>
    /// InitializeProperties is called in 3 cases:
    /// .  Create new object:  From the UserConfiguration constructor.
    /// .  Bind to existing object:  Again from the constructor.  The constructor is called eventually by the GetUserConfiguration request.
    /// .  Refresh properties:  From the Load method.
    /// </remarks>
    /* private */ void InitializeProperties(UserConfigurationProperties requestedProperties)
    {
        this.itemId     = null;
        this.dictionary = new UserConfigurationDictionary();
        this.xmlData    = null;
        this.binaryData = null;
        this.propertiesAvailableForAccess = requestedProperties;

        this.ResetIsDirty();
    }
Пример #4
0
 /// <summary>
 /// Binds to an existing user configuration and loads the specified properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to which the user configuration is bound.</param>
 /// <param name="name">The name of the user configuration.</param>
 /// <param name="parentFolderName">The name of the folder containing the user configuration.</param>
 /// <param name="properties">The properties to load.</param>
 /// <returns>A user configuration instance.</returns>
 static UserConfiguration Bind(
     ExchangeService service,
     String name,
     WellKnownFolderName parentFolderName,
     UserConfigurationProperties properties)
 {
     return(UserConfiguration.Bind(
                service,
                name,
                new FolderId(parentFolderName),
                properties));
 }
        /// <summary>
        /// Binds to an existing user configuration and loads the specified properties.
        /// Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="service">The service to which the user configuration is bound.</param>
        /// <param name="name">The name of the user configuration.</param>
        /// <param name="parentFolderId">The Id of the folder containing the user configuration.</param>
        /// <param name="properties">The properties to load.</param>
        /// <returns>A user configuration instance.</returns>
        public static async Task <UserConfiguration> Bind(
            ExchangeService service,
            string name,
            FolderId parentFolderId,
            UserConfigurationProperties properties)
        {
            UserConfiguration result = await service.GetUserConfiguration(
                name,
                parentFolderId,
                properties);

            result.isNew = false;

            return(result);
        }
Пример #6
0
    /// <summary>
    /// Binds to an existing user configuration and loads the specified properties.
    /// Calling this method results in a call to EWS.
    /// </summary>
    /// <param name="service">The service to which the user configuration is bound.</param>
    /// <param name="name">The name of the user configuration.</param>
    /// <param name="parentFolderId">The Id of the folder containing the user configuration.</param>
    /// <param name="properties">The properties to load.</param>
    /// <returns>A user configuration instance.</returns>
    static UserConfiguration Bind(
        ExchangeService service,
        String name,
        FolderId parentFolderId,
        UserConfigurationProperties properties)
    {
        UserConfiguration result = service.GetUserConfiguration(
            name,
            parentFolderId,
            properties);

        result.isNew = false;

        return(result);
    }
Пример #7
0
    /// <summary>
    /// Initializes a new instance of <see cref="UserConfiguration"/> class.
    /// </summary>
    /// <param name="service">The service to which the user configuration is bound.</param>
    /// <param name="requestedProperties">The properties requested for this user configuration.</param>
    UserConfiguration(ExchangeService service, UserConfigurationProperties requestedProperties)
    {
        EwsUtilities.ValidateParam(service, "service");

        if (service.RequestedServerVersion < UserConfiguration.ObjectVersion)
        {
            throw new ServiceVersionException(
                      string.Format(
                          Strings.ObjectTypeIncompatibleWithRequestVersion,
                          this.GetType().Name,
                          UserConfiguration.ObjectVersion));
        }

        this.service = service;
        this.isNew   = true;

        this.InitializeProperties(requestedProperties);
    }
        /// <summary>
        /// Initializes properties.
        /// </summary>
        /// <param name="requestedProperties">The properties requested for this UserConfiguration.</param>
        /// <remarks>
        /// InitializeProperties is called in 3 cases:
        /// .  Create new object:  From the UserConfiguration constructor.
        /// .  Bind to existing object:  Again from the constructor.  The constructor is called eventually by the GetUserConfiguration request.
        /// .  Refresh properties:  From the Load method.
        /// </remarks>
        private void InitializeProperties(UserConfigurationProperties requestedProperties)
        {
            this.itemId = null;
            this.dictionary = new UserConfigurationDictionary();
            this.xmlData = null;
            this.binaryData = null;
            this.propertiesAvailableForAccess = requestedProperties;

            this.ResetIsDirty();
        }
Пример #9
0
    /// <summary>
    /// Loads the specified properties on the user configuration. Calling this method results in a call to EWS.
    /// </summary>
    /// <param name="properties">The properties to load.</param>
    void Load(UserConfigurationProperties properties)
    {
        this.InitializeProperties(properties);

        this.service.LoadPropertiesForUserConfiguration(this, properties);
    }
        /// <summary>
        /// Loads the specified properties on the user configuration. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="properties">The properties to load.</param>
        public System.Threading.Tasks.Task Load(UserConfigurationProperties properties, CancellationToken token = default(CancellationToken))
        {
            this.InitializeProperties(properties);

            return(this.service.LoadPropertiesForUserConfiguration(this, properties, token));
        }
Пример #11
0
        /// <summary>
        /// Loads the specified properties on the user configuration. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="properties">The properties to load.</param>
        public System.Threading.Tasks.Task Load(UserConfigurationProperties properties)
        {
            this.InitializeProperties(properties);

            return(this.service.LoadPropertiesForUserConfiguration(this, properties));
        }
 /// <summary>
 /// Adds the passed property to updatedProperties.
 /// </summary>
 /// <param name="property">Property to update.</param>
 private void MarkPropertyForUpdate(UserConfigurationProperties property)
 {
     this.updatedProperties |= property;
     this.propertiesAvailableForAccess |= property;
 }
        /// <summary>
        /// Initializes a new instance of <see cref="UserConfiguration"/> class.
        /// </summary>
        /// <param name="service">The service to which the user configuration is bound.</param>
        /// <param name="requestedProperties">The properties requested for this user configuration.</param>
        internal UserConfiguration(ExchangeService service, UserConfigurationProperties requestedProperties)
        {
            EwsUtilities.ValidateParam(service, "service");

            if (service.RequestedServerVersion < UserConfiguration.ObjectVersion)
            {
                throw new ServiceVersionException(
                    string.Format(
                        Strings.ObjectTypeIncompatibleWithRequestVersion,
                        this.GetType().Name,
                        UserConfiguration.ObjectVersion));
            }

            this.service = service;
            this.isNew = true;

            this.InitializeProperties(requestedProperties);
        }
        /// <summary>
        /// Binds to an existing user configuration and loads the specified properties.
        /// Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="service">The service to which the user configuration is bound.</param>
        /// <param name="name">The name of the user configuration.</param>
        /// <param name="parentFolderId">The Id of the folder containing the user configuration.</param>
        /// <param name="properties">The properties to load.</param>
        /// <returns>A user configuration instance.</returns>
        public static UserConfiguration Bind(
            ExchangeService service,
            string name,
            FolderId parentFolderId,
            UserConfigurationProperties properties)
        {
            UserConfiguration result = service.GetUserConfiguration(
                name,
                parentFolderId,
                properties);

            result.isNew = false;

            return result;
        }
        /// <summary>
        /// Determines whether the specified property was updated.
        /// </summary>
        /// <param name="property">property to evaluate.</param>
        /// <returns>Boolean indicating whether to send the property Xml.</returns>
        private bool IsPropertyUpdated(UserConfigurationProperties property)
        {
            bool isPropertyDirty = false;
            bool isPropertyEmpty = false;

            switch (property)
            {
                case UserConfigurationProperties.Dictionary:
                    isPropertyDirty = this.Dictionary.IsDirty;
                    isPropertyEmpty = this.Dictionary.Count == 0;
                    break;
                case UserConfigurationProperties.XmlData:
                    isPropertyDirty = (property & this.updatedProperties) == property;
                    isPropertyEmpty = (this.xmlData == null) || (this.xmlData.Length == 0);
                    break;
                case UserConfigurationProperties.BinaryData:
                    isPropertyDirty = (property & this.updatedProperties) == property;
                    isPropertyEmpty = (this.binaryData == null) || (this.binaryData.Length == 0);
                    break;
                default:
                    EwsUtilities.Assert(
                        false,
                        "UserConfiguration.IsPropertyUpdated",
                        "property not supported: " + property.ToString());
                    break;
            }

            // Consider the property updated, if it's been modified, and either 
            //    . there's a value or 
            //    . there's no value but the operation is update.
            return isPropertyDirty && ((!isPropertyEmpty) || (!this.isNew));
        }
        /// <summary>
        /// Loads the specified properties on the user configuration. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="properties">The properties to load.</param>
        public void Load(UserConfigurationProperties properties)
        {
            this.InitializeProperties(properties);

            this.service.LoadPropertiesForUserConfiguration(this, properties);
        }
 /// <summary>
 /// Binds to an existing user configuration and loads the specified properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to which the user configuration is bound.</param>
 /// <param name="name">The name of the user configuration.</param>
 /// <param name="parentFolderName">The name of the folder containing the user configuration.</param>
 /// <param name="properties">The properties to load.</param>
 /// <returns>A user configuration instance.</returns>
 public static UserConfiguration Bind(
     ExchangeService service,
     string name,
     WellKnownFolderName parentFolderName,
     UserConfigurationProperties properties)
 {
     return UserConfiguration.Bind(
         service,
         name,
         new FolderId(parentFolderName),
         properties);
 }
Пример #18
0
 /// <summary>
 /// Resets flags to indicate that properties haven't been modified.
 /// </summary>
 /* private */ void ResetIsDirty()
 {
     this.updatedProperties  = NoProperties;
     this.dictionary.IsDirty = false;
 }
 /// <summary>
 /// Resets flags to indicate that properties haven't been modified.
 /// </summary>
 private void ResetIsDirty()
 {
     this.updatedProperties = NoProperties;
     this.dictionary.IsDirty = false;
 }
Пример #20
0
 /// <summary>
 /// Adds the passed property to updatedProperties.
 /// </summary>
 /// <param name="property">Property to update.</param>
 /* private */ void MarkPropertyForUpdate(UserConfigurationProperties property)
 {
     this.updatedProperties            |= property;
     this.propertiesAvailableForAccess |= property;
 }
 /// <summary>
 /// Determines whether the specified property may be accessed.
 /// </summary>
 /// <param name="property">Property to access.</param>
 private void ValidatePropertyAccess(UserConfigurationProperties property)
 {
     if ((property & this.propertiesAvailableForAccess) != property)
     {
         throw new PropertyException(Strings.MustLoadOrAssignPropertyBeforeAccess, property.ToString());
     }
 }