Exemple #1
0
        public bool SolveOptionalType <T>(ref Optional <T> type, DB.Document doc, DB.ElementTypeGroup group, Func <DB.Document, string, T> recoveryAction, string paramName) where T : DB.ElementType
        {
            bool wasMissing = type.IsMissing;

            if (wasMissing)
            {
                type = (T)doc.GetElement(doc.GetDefaultElementTypeId(group)) ??
                       throw new ArgumentException($"No suitable {group} has been found.", paramName);
            }

            else if (type.Value == null)
            {
                type = (T)recoveryAction.Invoke(doc, paramName);
            }

            return(wasMissing);
        }
Exemple #2
0
 public bool SolveOptionalType <T>(ref Optional <T> type, DB.Document doc, DB.ElementTypeGroup group, string paramName) where T : DB.ElementType
 {
     return(SolveOptionalType(ref type, doc, group, (document, name) => throw new ArgumentNullException(paramName), paramName));
 }