Пример #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((ViewSpecs.GetHashCode() * 397) ^ ViewLayouts.GetHashCode());
     }
 }
Пример #2
0
        public ViewSpecList Filter(Func <ViewSpec, bool> viewPredicate)
        {
            var viewSpecs     = ImmutableList.ValueOf(ViewSpecs.Where(viewPredicate));
            var viewSpecNames = new HashSet <string>(viewSpecs.Select(viewSpec => viewSpec.Name));

            return(new ViewSpecList(viewSpecs, ViewLayouts.Where(layout => viewSpecNames.Contains(layout.ViewName))));
        }
Пример #3
0
        public ViewSpecList SaveViewLayouts(ViewLayoutList viewLayoutList)
        {
            IEnumerable <ViewLayoutList> newLayouts = ViewLayouts.Where(layout => layout.ViewName != viewLayoutList.ViewName);

            if (!viewLayoutList.IsEmpty)
            {
                newLayouts = new[] { viewLayoutList }.Concat(newLayouts);
            }
            return(new ViewSpecList(ViewSpecs, newLayouts));
        }
Пример #4
0
        public ViewSpecList ReplaceView(string oldName, ViewSpec newView)
        {
            List <ViewSpec> items = new List <ViewSpec>();
            bool            found = false;

            foreach (var item in ViewSpecs)
            {
                if (item.Name != oldName)
                {
                    items.Add(item);
                    continue;
                }
                found = true;
                if (newView != null)
                {
                    items.Add(newView);
                }
            }
            if (!found && null != newView)
            {
                items.Add(newView);
            }
            IEnumerable <ViewLayoutList> newLayouts;

            if (oldName != null)
            {
                if (newView == null)
                {
                    newLayouts = ViewLayouts.Where(layout => layout.ViewName != oldName);
                }
                else if (newView.Name == oldName)
                {
                    newLayouts = ViewLayouts;
                }
                else
                {
                    newLayouts = ViewLayouts.Where(layout => layout.ViewName != newView.Name)
                                 .Select(layout => layout.ViewName == oldName ? layout.ChangeViewName(newView.Name) : layout);
                }
            }
            else
            {
                newLayouts = ViewLayouts;
            }
            return(new ViewSpecList(items, newLayouts));
        }
Пример #5
0
 public IEnumerable <ViewLayout> AllViewLayouts()
 {
     return(ViewLayouts.All());
 }
Пример #6
0
 public ViewLayoutList GetViewLayouts(string name)
 {
     return(ViewLayouts.FirstOrDefault(layout => layout.ViewName == name) ??
            ViewLayoutList.EMPTY.ChangeViewName(name));
 }
Пример #7
0
 public override object ConvertFrom(string attributeValue, SerializationContext context)
 {
     return(ViewLayouts.ById(attributeValue));
 }