Ejemplo n.º 1
0
        public void CloneFrom(Vault pIVaultSource)
        {
            TestVault internalTestVault = ( TestVault )pIVaultSource;

            ovaps          = internalTestVault.ovaps;
            ValueListItems = internalTestVault.ValueListItems;
            objTypes       = internalTestVault.objTypes;
            propertyDefs   = internalTestVault.propertyDefs;
            Workflows      = internalTestVault.Workflows;
            classAdmins    = internalTestVault.classAdmins;
            namedValues    = internalTestVault.namedValues;

            TestObjectOperations        = internalTestVault.TestObjectOperations;
            classOperations             = internalTestVault.ClassOperations;
            objectPropertyOperations    = internalTestVault.ObjectPropertyOperations;
            valueListItemOperations     = internalTestVault.ValueListItemOperations;
            objectSearchOperations      = internalTestVault.ObjectSearchOperations;
            objectTypeOperations        = internalTestVault.ObjectTypeOperations;
            propertyDefOperations       = internalTestVault.PropertyDefOperations;
            workflowOperations          = internalTestVault.WorkflowOperations;
            namedValueStorageOperations = internalTestVault.NamedValueStorageOperations;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the list of value list items for the specified property def id. (for multiselect lookups)
        /// </summary>
        /// <param name="objVerEx">The child/owned object.</param>
        /// <param name="propDefId">The property definition id.</param>
        /// <returns>List of value list item objects if available</returns>
        /// <remarks>If one or more value list items cannot be loaded (e.g. permissions or ID does not exist) then they will be skipped in the returned collection.</remarks>
        /// <exception cref="ArgumentException">Thrown if <paramref name="propDefId"/> does not point to a suitable property definition.</exception>
        public static List <ValueListItem> GetPropertyAsValueListItems(
            this ObjVerEx objVerEx,
            int propDefId
            )
        {
            // Sanity.
            if (null == objVerEx)
            {
                throw new ArgumentNullException(nameof(objVerEx));
            }

            // Validity of the property def id
            if (0 > propDefId)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(propDefId),
                          "Property Ids must be greater than -1; ensure that your property alias was resolved."
                          );
            }

            // Get the value list id of the property def
            PropertyDef propDef = objVerEx
                                  .Vault
                                  .PropertyDefOperations
                                  .GetPropertyDef(propDefId);

            // Exception if property was not found
            if (null == propDef)
            {
                throw new ArgumentException(
                          $"The property could not be found.",
                          nameof(propDefId)
                          );
            }

            // Does this have an owning type?
            if (false == propDef.BasedOnValueList || 0 > propDef.ValueList)
            {
                throw new ArgumentException(
                          $"The property \"{propDef.Name}\" is not based on a value list.",
                          nameof(propDefId)
                          );
            }

            // Does this have an owning type?
            if ((int)MFDataType.MFDatatypeMultiSelectLookup != (int)propDef.DataType)
            {
                throw new ArgumentException(
                          $"The property \"{propDef.Name}\" is no multi select lookup property.",
                          nameof(propDefId)
                          );
            }

            // Get the lookup elements and initialize result list
            IEnumerable <Lookup>         lookups     = objVerEx.GetLookupsFromProperty(propDefId);
            List <ValueListItem>         listResults = new List <ValueListItem>();
            VaultValueListItemOperations vliOps      = objVerEx.Vault.ValueListItemOperations;

            // Loop through the lookup elements
            foreach (Lookup lookup in lookups)
            {
                try
                {
                    listResults.Add(
                        vliOps.GetValueListItemByID(propDef.ValueList, lookup.Item)
                        );
                }
                catch
                {
                    // If we cannot load the value list item then we can skip this item.
                    // This would only happen if the lookup points to an item that no longer
                    // exists.
                }
            }

            // return the list with the value list items for the multiselect lookup entries
            return(listResults);
        }