Esempio n. 1
0
 public ViewResultBase Details()
 {
     if (!string.IsNullOrEmpty(Request["isTooltip"]))
     {
         Guid id;
         if (Guid.TryParse(Request["id"], out id))
         {
             var data = ElementInfo.Create(base.EntityType.GetData(id));
             return(new PartialViewResult {
                 ViewName = "Partials/Details", ViewData = new ViewDataDictionary(data)
             });
         }
         else
         {
             throw new ValidationException("非法的Guid标识" + Request["id"]);
         }
     }
     else if (!string.IsNullOrEmpty(Request["isInner"]))
     {
         return(new PartialViewResult {
             ViewName = "Partials/Details"
         });
     }
     else
     {
         return(this.View());
     }
 }
Esempio n. 2
0
 public ActionResult GetInfo(Guid?id)
 {
     if (!id.HasValue)
     {
         throw new ValidationException("未传入标识");
     }
     return(this.JsonResult(ElementInfo.Create(base.EntityType.GetData(id.Value))));
 }
Esempio n. 3
0
        /// <summary>
        /// Invoked when the associated map is validated.
        /// </summary>
        internal protected virtual void OnValidate()
        {
            var flags     = TypeEx.FlattenInstancePublicAndHidden;
            var type      = _Map.EntityType;
            var sensitive = _Map.Repository.Link.Engine.CaseSensitiveNames;

            _ElementInfo = ElementInfo.Create(_Map.EntityType, _Name, raise: false, flags: flags);

            if (_ElementInfo == null && !sensitive)
            {
                flags       |= BindingFlags.IgnoreCase;
                _ElementInfo = ElementInfo.Create(_Map.EntityType, _Name, raise: false, flags: flags);
            }

            if (_ElementInfo == null)
            {
                throw new NotFoundException(
                          "Member '{0}' not found in type '{1}'."
                          .FormatWith(_Name, _Map.EntityType.EasyName()));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a list with the child dependencies that have been removed since the last
        /// time those were captured.
        /// </summary>
        internal static List <object> GetRemovedChilds(this MetaEntity meta, bool forgetRemoved)
        {
            var list   = new List <object>();
            var entity = meta.Entity; if (entity != null)

            {
                var type = entity.GetType();
                foreach (var kvp in meta.ChildDependencies)
                {
                    // Obtaining the current state...
                    var info = ElementInfo.Create(type, kvp.Key, flags: TypeEx.FlattenInstancePublicAndHidden);
                    if (!info.CanRead)
                    {
                        continue;
                    }
                    var curr = ((IEnumerable)info.GetValue(entity)).Cast <object>().ToList();

                    // Adding the entities that has been removed...
                    foreach (var item in kvp.Value)
                    {
                        if (!curr.Contains(item))
                        {
                            list.Add(item);
                        }
                    }
                    curr.Clear(); curr = null;

                    if (forgetRemoved)                     // Foget removed childs if such is requested
                    {
                        foreach (var item in list)
                        {
                            kvp.Value.Remove(item);
                        }
                    }
                }
            }
            return(list);
        }