Example #1
0
        public static string BuildPropertyName(
            this Type type,
            HierarchyKind hierarchyKind,
            string prefix)
        {
            var result = Invariant($"{hierarchyKind.BuildNameToken()}{prefix}{type.BuildNameToken()}Property");

            return(result);
        }
Example #2
0
        public static string BuildScriptedModelName(
            this DeclaredKeyMethod declaredKeyMethod,
            SetterKind setterKind,
            HierarchyKind hierarchyKind,
            TypeWrapperKind typeWrapperKind,
            string childIdentifier)
        {
            var result = Invariant($"{Settings.ModelBaseName}{declaredKeyMethod.BuildNameToken()}{setterKind.BuildNameToken()}{typeWrapperKind.BuildNameToken()}{hierarchyKind.BuildNameToken()}{childIdentifier}");

            return(result);
        }
        /// <summary>
        /// Gets a code template.
        /// </summary>
        /// <param name="generationType">The type of the class containing the generation logic.</param>
        /// <param name="hierarchyKind">The hierarchy kind.</param>
        /// <param name="codeTemplateKind">The code template kind.</param>
        /// <param name="keyMethodKinds">The key method kinds.</param>
        /// <param name="codeSnippetKind">Optional code snippet kind.  Default is None (not treated as a code snippet).</param>
        /// <param name="throwIfDoesNotExist">Throw if the code template does not exist.</param>
        /// <returns>
        /// The code template corresponding to the specified parameters.
        /// </returns>
        public static string GetCodeTemplate(
            this Type generationType,
            HierarchyKind hierarchyKind,
            CodeTemplateKind codeTemplateKind,
            KeyMethodKinds keyMethodKinds,
            CodeSnippetKind codeSnippetKind = CodeSnippetKind.None,
            bool throwIfDoesNotExist        = true)
        {
            var result = generationType.GetCodeTemplate(hierarchyKind.ToString(), codeTemplateKind, keyMethodKinds, codeSnippetKind, throwIfDoesNotExist);

            return(result);
        }
Example #4
0
        public static string BuildNameToken(
            this HierarchyKind hierarchyKind)
        {
            new { hierarchyKind }.AsArg().Must().NotBeEqualTo(HierarchyKind.NotApplicable);

            switch (hierarchyKind)
            {
            case HierarchyKind.Standalone:
                return(string.Empty);

            case HierarchyKind.AbstractBaseRoot:
                return("Parent");

            case HierarchyKind.ConcreteInherited:
                return("Child");

            default:
                throw new NotSupportedException("This hierarchy kind is not supported: " + hierarchyKind);
            }
        }