GetChanges() публичный Метод

Returns a list of changes made to this object since the transaction began or the last call to AcceptChanges.
public GetChanges ( ) : IList
Результат IList
Пример #1
0
            public void clearing_single_valued_reference_generates_Delete_operation___otherwise_fim_web_service_throws()
            {
                RmPerson person = new RmPerson
                {
                    Manager = new RmReference("2CFAAD59-A6ED-4A96-91A2-52992361929A")
                };

                var resourceChanges = new RmResourceChanges(person);
                resourceChanges.BeginChanges();

                person.Manager = null;

                var changes = resourceChanges.GetChanges();

                Assert.Equal(1, changes.Count);

                var change = changes.Single();

                Assert.Equal(RmAttributeChangeOperation.Delete, change.Operation);
                Assert.Equal(RmPerson.AttributeNames.Manager.Name, change.Name.Name);
                Assert.Equal(person.Manager, change.Value);
            }
Пример #2
0
            public void clearing_single_valued_date_generates_Delete_operation___otherwise_fim_web_service_throws()
            {
                RmPerson person = new RmPerson
                {
                    EmployeeEndDate = new DateTime(2011, 1, 1)
                };

                var resourceChanges = new RmResourceChanges(person);
                resourceChanges.BeginChanges();

                person.EmployeeEndDate = null;

                var changes = resourceChanges.GetChanges();

                Assert.Equal(1, changes.Count);

                var change = changes.Single();

                Assert.Equal(RmAttributeChangeOperation.Delete, change.Operation);
                Assert.Equal(RmPerson.AttributeNames.EmployeeEndDate.Name, change.Name.Name);
                Assert.Equal(person.EmployeeEndDate, change.Value);
            }
Пример #3
0
            public void modifying_single_value_generates_Replace_operation()
            {
                RmPerson person = new RmPerson
                    {
                        DisplayName = "original-name"
                    };

                var resourceChanges = new RmResourceChanges(person);
                resourceChanges.BeginChanges();

                person.DisplayName = "new-name";
                person.LastName = "last name";

                var changes = resourceChanges.GetChanges();

                Assert.Equal(2, changes.Count);
                Assert.NotEmpty(changes.Where(x =>
                                              x.Name.Name == RmPerson.AttributeNames.LastName.Name
                                              && x.Value.ToString() == "last name")
                    );
                Assert.NotEmpty(changes.Where(x =>
                                              x.Name.Name == RmResource.AttributeNames.DisplayName.Name
                                              && x.Value.ToString() == "new-name")
                    );
                foreach (var change in changes)
                {
                    Assert.Equal(RmAttributeChangeOperation.Replace, change.Operation);
                }
            }
Пример #4
0
            public void setting_single_valued_reference_generates_Replace_operation()
            {
                RmPerson person = new RmPerson();

                var resourceChanges = new RmResourceChanges(person);
                resourceChanges.BeginChanges();

                person.Manager = new RmReference("2CFAAD59-A6ED-4A96-91A2-52992361929A");

                var changes = resourceChanges.GetChanges();

                Assert.Equal(1, changes.Count);

                var change = changes.Single();

                Assert.Equal(RmAttributeChangeOperation.Replace, change.Operation);
                Assert.Equal(RmPerson.AttributeNames.Manager.Name, change.Name.Name);
                Assert.Equal(person.Manager, change.Value);
            }
Пример #5
0
        /// <summary>
        /// Constructs a put request based on the changes tracked in the transaction.
        /// </summary>
        /// <param name="transaction">The transaction object which tracked the changes made to an object.</param>
        /// <returns></returns>
        public virtual PutRequest CreatePutRequest(RmResourceChanges transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }

            RmResource rmObject = transaction.RmObject;
            if (rmObject == null)
            {
                throw new InvalidOperationException("transaction does not have rmObject");
            }
            if (rmObject.ObjectID == null) {
                throw new InvalidOperationException("The rmObject does not have an ObjectID.");
            }
            lock (rmObject)
            {

                PutRequest putRequest = new PutRequest();

                putRequest.ResourceReferenceProperty = new ResourceReferenceProperty(rmObject.ObjectID.ToString());
                if (string.IsNullOrEmpty(rmObject.Locale) == false)
                {
                    putRequest.ResourceLocaleProperty = new ResourceLocaleProperty(new System.Globalization.CultureInfo(rmObject.Locale));
                }

                putRequest.ModifyRequest = new ModifyRequest();

                IList<RmAttributeChange> changes = transaction.GetChanges();

                foreach (RmAttributeChange attributeChange in changes)
                {
                    if (this.ProhibitedAttributes.ContainsKey(attributeChange.Name.Name))
                        continue;

                    DirectoryAccessChange putReqChange = BuildDirectoryAccessChange(attributeChange);

                    if (base.IsMultiValued(attributeChange.Name))
                    {
                        putReqChange.Operation = attributeChange.Operation.ToString();
                    }
                    else
                    {
                        if (attributeChange.Operation == RmAttributeChangeOperation.Add)
                        {
                            putReqChange.Operation = RmAttributeChangeOperation.Replace.ToString();
                        }
                        else if (attributeChange.Operation == RmAttributeChangeOperation.Delete)
                        {
                            putReqChange.Operation = RmAttributeChangeOperation.Replace.ToString();
                            putReqChange.AttributeValue = null;
                        } else {
                            putReqChange.Operation = attributeChange.Operation.ToString();
                        }
                    }
                    putRequest.ModifyRequest.Changes.Add(putReqChange);
                }
                return putRequest;
            }
        }