public static bool IsAliasOf(this IDomainModel instance, string alias)
        {
            var attrType = instance.GetType();
            var attr     = (DocumentTypeAliasAttribute)attrType.GetCustomAttributes(typeof(DocumentTypeAliasAttribute), false).FirstOrDefault();

            bool isAlias = attr != null?attr.Name.Equals(alias, StringComparison.CurrentCultureIgnoreCase) : false;

            return(isAlias);
        }
        public static string GetAliasName(this IDomainModel instance)
        {
            var attrType = instance.GetType();
            var attr     = (DocumentTypeAliasAttribute)attrType.GetCustomAttributes(typeof(DocumentTypeAliasAttribute), false).FirstOrDefault();

            string alias = attr?.Name;

            return(alias);
        }
예제 #3
0
        private void ValidateModel(PublishEventArgs <IContent> e, IDomainModel model)
        {
            dynamic castModel = Convert.ChangeType(model, model.GetType());
            var     result    = validateBus.Validate(castModel);

            if (!result.IsValid)
            {
                e.Cancel = true;

                foreach (var error in result.Errors)
                {
                    var errors = new EventMessage(error.PropertyName, error.ErrorMessage, EventMessageType.Error);
                    e.CancelOperation(errors);
                }
            }
        }