IFormattable implementation of RmResource
Inheritance: IFormattable
示例#1
0
        /// <summary>
        /// Constructs a create request based on the provided object.
        /// </summary>
        /// <param name="newResource">The RmResource object for which to construct a create request.</param>
        /// <returns></returns>
        public virtual CreateRequest CreateCreateRequest(RmResource newResource)
        {
            if (newResource == null)
            {
                throw new ArgumentNullException("newResource");
            }
            lock (newResource)
            {
                CreateRequest createRequest = new CreateRequest();

                createRequest.AddRequest = new AddRequest();
                createRequest.AddRequest.AttributeTypeAndValues = new List<DirectoryAccessChange>();
                foreach (KeyValuePair<RmAttributeName, RmAttributeValue> attribute in newResource.Attributes)
                {
                    if (this.ProhibitedAttributes.ContainsKey(attribute.Key.Name))
                        continue;

                    foreach (IComparable value in attribute.Value.Values)
                    {
                        DirectoryAccessChange createReqChange = BuildDirectoryAccessChange(attribute.Key, value);
                        // cannot specify the operation on create
                        createReqChange.Operation = null;
                        createRequest.AddRequest.AttributeTypeAndValues.Add(createReqChange);
                    }
                }
                return createRequest;
            }
        }
示例#2
0
 /// <summary>
 /// Begins a transaction on the provided RmResource object.
 /// </summary>
 /// <param name="rmObject">The object to watch during the transaction.</param>
 public RmResourceChanges(RmResource rmObject)
 {
     if (rmObject == null) {
         throw new ArgumentNullException("rmObject");
     }
     this.rmObject = rmObject;
 }
示例#3
0
 /// <summary>
 /// Returns a list of changes to make to source in order for it to look like destination.
 /// </summary>
 /// <param name="source">The starting object state.</param>
 /// <param name="destination">The ending object state.</param>
 /// <returns>A list of RmAttributeChanges to apply to source for it to look like destination</returns>
 public static IList<RmAttributeChange> GetDifference(RmResource source, RmResource destination)
 {
     if (source == null) {
         throw new ArgumentNullException("source");
     }
     if (destination == null) {
         throw new ArgumentNullException("destination");
     }
     return GetDifference(source.attributes, destination.attributes);
 }
示例#4
0
        public ObjectDetailsModel(RmResource resource, IFimClient fimClient, WindowsManager windowsManager)
        {
            _fimClient = fimClient;
            _windowsManager = windowsManager;

            Resource = resource;

            Attributes = resource.Attributes
                .Select(x => new FlattenedAttribute(x))
                .ToList();
        }
示例#5
0
        public void ObjectDetailsDialog(RmResource target)
        {
            if (target == null)
            {
                _log.Debug("Cannot show details of null object");
                return;
            }

            var model = new ObjectDetailsModel(target, FimClientFactory.CreateClient(), this);

            var detailsWindow = new ObjectDetailsWindow();

            detailsWindow.Initialize(model);

            _log.Debug("Showing details of [{0}:{1}]", target.ObjectType, target.ObjectID);

            detailsWindow.Show();
        }
示例#6
0
        private RmResource ConvertToResource(ExportObject exportObject)
        {
            var sourceObject = exportObject.ResourceManagementObject;

            var resource = new RmResource();
            resource.ObjectType = sourceObject.ObjectType;

            foreach (var attribute in sourceObject.ResourceManagementAttributes)
            {
                var rmAttributeName = new RmAttributeName(attribute.AttributeName);
                var rmAttributeValue = attribute.IsMultiValue
                    ? (RmAttributeValue)new RmAttributeValueMulti(attribute.Values)
                    : (RmAttributeValue)new RmAttributeValueSingle(attribute.Value)
                ;

                if (rmAttributeValue.Value is string)
                {
                    string s = (string)rmAttributeValue.Value;
                    if (s.StartsWith("urn:uuid:"))
                    {
                        rmAttributeValue.Value = new RmReference(s);
                    }
                }

                if (resource.ContainsKey(rmAttributeName))
                {
                    resource[rmAttributeName] = rmAttributeValue;
                }
                else
                {
                    resource.Add(rmAttributeName, rmAttributeValue);
                }
            }

            return resource;
        }
示例#7
0
 /// <summary>
 /// Creates the given resource and returns its ObjectId.
 /// This method does not set the ObjectId of newResource.
 /// </summary>
 /// <param name="newResource">The resource to create.</param>
 /// <returns>The ObjectId of the resource.</returns>
 public RmReference Create(RmResource newResource)
 {
     if (newResource == null)
         throw new ArgumentNullException("newResource");
     CreateRequest request = this.requestFactory.CreateCreateRequest(newResource);
     CreateResponse response = this.wsTransferFactoryClient.Create(request);
     try {
         RmReference reference = new RmReference(response.ResourceCreated.EndpointReference.ReferenceProperties.ResourceReferenceProperty.Value);
         newResource.ObjectID = reference;
         return reference;
     } catch (NullReferenceException) {
         return new RmReference();
     } catch (FormatException) {
         return new RmReference();
     }
 }
示例#8
0
 private static RmReference CreateResource(RmResource resource)
 {
     CreateRequest createRequest = requestFactory.CreateCreateRequest(resource);
     CreateResponse createResponse = transferFactoryClient.Create(createRequest);
     RmReference reference = new RmReference(createResponse.ResourceCreated.EndpointReference.ReferenceProperties.ResourceReferenceProperty.Value);
     return reference;
 }
示例#9
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     EnsureNotDisposed();
     lock (rmObject.attributes) {
         this.originalAttributes = null;
         GC.SuppressFinalize(this);
         this.rmObject = null;
     }
 }