Beispiel #1
0
        /// <summary>
        /// Attempts to get the <see cref="PropertyDef.DataType"/> of a <see cref="PropertyDef"/>
        /// with the given <paramref name="propertyDefId"/>.
        /// </summary>
        /// <param name="propertyDefOperations">The <see cref="VaultPropertyDefOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="propertyDefId">The Id of the property definition to attempt to read.</param>
        /// <param name="dataType">The data type of the property definition, or <see cref="MFDataType.MFDatatypeUninitialized"/> if not found.</param>
        /// <returns>true if the property definition could be found, false otherwise.</returns>
        public static bool TryGetPropertyDefDataType
        (
            this VaultPropertyDefOperations propertyDefOperations,
            int propertyDefId,
            out MFDataType dataType
        )
        {
            // Sanity.
            if (null == propertyDefOperations)
            {
                throw new ArgumentNullException(nameof(propertyDefOperations));
            }

            // Default.
            dataType = MFDataType.MFDatatypeUninitialized;

            // Attempt to get from the underlying data.
            try
            {
                dataType = propertyDefOperations
                           .GetPropertyDef(propertyDefId)
                           .DataType;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// Attempts to get the name of a <see cref="PropertyDef"/>
        /// with the given <paramref name="propertyDefId"/>.
        /// </summary>
        /// <param name="propertyDefOperations">The <see cref="VaultPropertyDefOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="propertyDefId">The Id of the property definition to attempt to read.</param>
        /// <param name="propertyDefName">The name of the property definition, or null if not found.</param>
        /// <returns>true if the property definition could be found, false otherwise.</returns>
        public static bool TryGetPropertyDefName
        (
            this VaultPropertyDefOperations propertyDefOperations,
            int propertyDefId,
            out string propertyDefName
        )
        {
            // Sanity.
            if (null == propertyDefOperations)
            {
                throw new ArgumentNullException(nameof(propertyDefOperations));
            }

            // Default.
            propertyDefName = null;

            // Attempt to get from the underlying data.
            try
            {
                propertyDefName = propertyDefOperations
                                  .GetPropertyDef(propertyDefId)
                                  .Name;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        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;
        }
        /// <summary>
        /// Attempts to get the <see cref="PropertyDefAdmin.SemanticAliases"/> of a <see cref="PropertyDefAdmin"/>
        /// with the given <paramref name="propertyDefId"/>.
        /// </summary>
        /// <param name="propertyDefOperations">The <see cref="VaultPropertyDefOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="propertyDefId">The Id of the property definition to attempt to read.</param>
        /// <param name="aliases">The aliases associated with the property definition.</param>
        /// <returns>true if the property definition could be found, false otherwise.</returns>
        public static bool TryGetPropertyDefAliases
        (
            this VaultPropertyDefOperations propertyDefOperations,
            int propertyDefId,
            out string[] aliases
        )
        {
            // Sanity.
            if (null == propertyDefOperations)
            {
                throw new ArgumentNullException(nameof(propertyDefOperations));
            }

            // Attempt to get from the underlying data.
            try
            {
                aliases = propertyDefOperations
                          .GetPropertyDefAdmin(propertyDefId)
                          .SemanticAliases
                          .Value
                          .Split(";".ToCharArray())
                          .Select(a => a.Trim())
                          .ToArray();
                return(true);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch
            {
                // Default.
#pragma warning disable CA1825 // Avoid zero-length array allocations.
                aliases = new string[0];
#pragma warning restore CA1825 // Avoid zero-length array allocations.
                return(false);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }