Exemplo n.º 1
0
        /// <summary>
        /// Recupera o valor.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Colosoft.Business.IEntity GetValue(Colosoft.Business.IEntityLoader loader, Colosoft.Business.IEntity entity)
        {
            var childAccessor = loader.GetChildrenAccessors().FirstOrDefault(f => f.Name == ChildName);

            if (childAccessor == null)
            {
                throw new NotSupportedException(
                          string.Format("Filho '{0}' da entidade '{1}' não foi encontrado", ChildName, loader.DataModelType.Name));
            }


            return(childAccessor.Get(entity));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Recupera a configuração.
        /// </summary>
        /// <param name="loader"></param>
        /// <returns></returns>
        public static ControleAlteracaoEntityLoaderConfiguration ObtemConfiguracao(Colosoft.Business.IEntityLoader loader)
        {
            ControleAlteracaoEntityLoaderConfiguration config = null;

            if (!PossuiConfiguracao(loader))
            {
                config = new ControleAlteracaoEntityLoaderConfiguration();
                loader.CustomParameters[Key] = config;
            }
            else
            {
                config = (ControleAlteracaoEntityLoaderConfiguration)loader.CustomParameters[Key];
            }

            return(config);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Recupera o valor da propriedade.
        /// </summary>
        /// <param name="controllerContext"></param>
        /// <param name="bindingContext"></param>
        /// <param name="descriptor"></param>
        /// <param name="loader"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        private object GetPropertyValue(ControllerContext controllerContext, ModelBindingContext bindingContext, System.ComponentModel.ICustomTypeDescriptor descriptor, Colosoft.Business.IEntityLoader loader, string propertyName)
        {
            if (propertyName == "Uid" && !string.IsNullOrEmpty(loader.UidPropertyName))
            {
                propertyName = loader.UidPropertyName;
            }
            var propertyMetadata       = bindingContext.PropertyMetadata[propertyName];
            var property               = descriptor.GetProperties()[propertyName];
            var propertyBinder         = this.Binders.GetBinder(property.PropertyType);
            var propertyBindingContext = new System.Web.Mvc.ModelBindingContext(bindingContext)
            {
                ModelMetadata = propertyMetadata,
                ModelName     = CreatePropertyModelName(bindingContext.ModelName, propertyMetadata.PropertyName)
            };
            var value = propertyBinder.BindModel(controllerContext, propertyBindingContext);

            if (value == null && propertyName == "Uid")
            {
                value = GetPropertyValue(controllerContext, bindingContext, descriptor, loader, loader.UidPropertyName);
            }
            return(value);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Verifica se existem a configuração no loader.
 /// </summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public static bool PossuiConfiguracao(Colosoft.Business.IEntityLoader loader)
 {
     return(loader.CustomParameters.ContainsKey(Key));
 }