Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to get the workflow details (id and whether it's forced) of a <see cref="ObjectClass"/>
        /// with the given <paramref name="classId"/>.
        /// </summary>
        /// <param name="classOperations">The <see cref="VaultClassOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="classId">The Id of the class to attempt to read.</param>
        /// <param name="workflowId">The default workflow of the class, or zero if there is no default workflow.</param>
        /// <param name="forced">Whether the use of the specified workflow is forced.</param>
        /// <returns>true if the class could be found, false otherwise.</returns>
        public static bool TryGetObjectClassWorkflowDetails
        (
            this VaultClassOperations classOperations,
            int classId,
            out int workflowId,
            out bool forced
        )
        {
            // Sanity.
            if (null == classOperations)
            {
                throw new ArgumentNullException(nameof(classOperations));
            }

            // Default.
            workflowId = 0;
            forced     = false;

            // Attempt to get from the underlying data.
            try
            {
                var oc = classOperations
                         .GetObjectClass(classId);
                workflowId = oc.Workflow;
                forced     = oc.ForceWorkflow;
                return(true);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch
            {
                return(false);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
        /// <summary>
        /// Attempts to get the name of a <see cref="ObjectClass"/>
        /// with the given <paramref name="classId"/>.
        /// </summary>
        /// <param name="classOperations">The <see cref="VaultClassOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="classId">The Id of the class to attempt to read.</param>
        /// <param name="className">The name of the class, or null if not found.</param>
        /// <returns>true if the class could be found, false otherwise.</returns>
        public static bool TryGetObjectClassName
        (
            this VaultClassOperations classOperations,
            int classId,
            out string className
        )
        {
            // Sanity.
            if (null == classOperations)
            {
                throw new ArgumentNullException(nameof(classOperations));
            }

            // Default.
            className = null;

            // Attempt to get from the underlying data.
            try
            {
                className = classOperations
                            .GetObjectClass(classId)
                            .Name;
                return(true);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch
            {
                return(false);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attempts to get the ID of the <see cref="PropertyDef"/> that is defined as
        /// the "Name or Title" property of a <see cref="ObjectClass"/>
        /// with the given <paramref name="classId"/>.
        /// </summary>
        /// <param name="classOperations">The <see cref="VaultClassOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="classId">The Id of the class to attempt to read.</param>
        /// <param name="nameOrTitlePropertyDef">The property of the "Name or Title" property for this class, or <see cref="MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle"/> if not set.</param>
        /// <returns>true if the class could be found, false otherwise.</returns>
        public static bool TryGetObjectClassNamePropertyDef
        (
            this VaultClassOperations classOperations,
            int classId,
            out int nameOrTitlePropertyDef
        )
        {
            // Sanity.
            if (null == classOperations)
            {
                throw new ArgumentNullException(nameof(classOperations));
            }

            // Default.
            nameOrTitlePropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle;

            // Attempt to get from the underlying data.
            try
            {
                nameOrTitlePropertyDef = classOperations
                                         .GetObjectClass(classId)
                                         .NamePropertyDef;
                return(true);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch
            {
                return(false);
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
Ejemplo n.º 4
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.º 5
0
        /// <summary>
        /// Attempts to get the <see cref="ObjectClassAdmin.SemanticAliases"/> of a <see cref="ObjectClassAdmin"/>
        /// with the given <paramref name="classId"/>.
        /// </summary>
        /// <param name="classOperations">The <see cref="VaultClassOperations"/> instance to use to communicate with the vault.</param>
        /// <param name="classId">The Id of the class to attempt to read.</param>
        /// <param name="aliases">The aliases associated with the class.</param>
        /// <returns>true if the class could be found, false otherwise.</returns>
        public static bool TryGetObjectClassAliases
        (
            this VaultClassOperations classOperations,
            int classId,
            out string[] aliases
        )
        {
            // Sanity.
            if (null == classOperations)
            {
                throw new ArgumentNullException(nameof(classOperations));
            }

            // Attempt to get from the underlying data.
            try
            {
                aliases = classOperations
                          .GetObjectClassAdmin(classId)
                          .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
        }