public ActionDefaultsFacetViaMethod(MethodInfo method, IFacetHolder holder)
     : base(holder) {
     this.method = method;
     var actionInvocationFacet = holder.GetFacet<IActionInvocationFacet>();
     if (actionInvocationFacet is ActionInvocationFacetViaMethod) {
         var facetViaMethod = (ActionInvocationFacetViaMethod) actionInvocationFacet;
         actionMethod = facetViaMethod.GetMethod();
     }
 }
 private void DecoratedFacet(Type facetType, IFacetHolder holder) {
     if (facetDecorators.ContainsKey(facetType)) {
         foreach (IFacetDecorator decorator in facetDecorators[facetType]) {
             IFacet previousFacet = holder.GetFacet(facetType);
             IFacet decoratedFacet = decorator.Decorate(previousFacet, holder);
             if (decoratedFacet != null && decoratedFacet != previousFacet) {
                 holder.AddFacet(decoratedFacet);
             }
         }
     }
 }
 private bool ProcessCollection(IFacetHolder holder) {
     var typeOfFacet = holder.GetFacet<ITypeOfFacet>();
     Type collectionElementType;
     if (typeOfFacet != null) {
         collectionElementType = typeOfFacet.Value;
     }
     else {
         collectionElementType = typeof (object);
         holder.AddFacet(new TypeOfFacetDefaultToObject(holder, Reflector));
     }
     holder.AddFacet(new DotNetCollectionFacet(holder, collectionElementType));
     return true;
 }
        private bool ProcessGenericEnumerable(Type type, IFacetHolder holder) {
            var typeOfFacet = holder.GetFacet<ITypeOfFacet>();
            bool isCollection = CollectionUtils.IsGenericCollection(type); // as opposed to IEnumerable 
            bool isQueryable = CollectionUtils.IsGenericQueryable(type);
            bool isSet = CollectionUtils.IsSet(type);
            Type collectionElementType;
            if (typeOfFacet != null) {
                collectionElementType = typeOfFacet.Value;
            }
            else {
                collectionElementType = CollectionUtils.ElementType(type);
                holder.AddFacet(new TypeOfFacetInferredFromGenerics(collectionElementType, holder, Reflector));
            }

            Type facetType = isQueryable ? typeof (DotNetGenericIQueryableFacet<>) : (isCollection ? typeof (DotNetGenericCollectionFacet<>) : typeof (DotNetGenericIEnumerableFacet<>));

            Type genericFacet = facetType.GetGenericTypeDefinition();
            Type genericCollectionFacetType = genericFacet.MakeGenericType(CollectionUtils.ElementType(type));
            var facet = (IFacet) Activator.CreateInstance(genericCollectionFacetType, holder, collectionElementType, isSet);
            holder.AddFacet(facet);

            return true;
        }
 private static bool IsAlwaysHidden(IFacetHolder holder) {
     var hiddenfacet = holder.GetFacet<IHiddenFacet>();
     return hiddenfacet != null && hiddenfacet.Value == When.Always;
 }
Beispiel #6
0
 protected static void AddOrAddToExecutedWhereFacet(MethodInfo method, IFacetHolder holder) {
     var attribute = AttributeUtils.GetCustomAttribute<ExecutedAttribute>(method);
     if (attribute != null && !attribute.IsAjax) {
         var executedFacet = holder.GetFacet<IExecutedControlMethodFacet>();
         if (executedFacet == null) {
             FacetUtils.AddFacet(new ExecutedFacetAnnotationForControlMethods(method, attribute.Value.ToWhere(), holder));
         }
         else {
             executedFacet.AddMethodExecutedWhere(method, attribute.Value.ToWhere());
         }
     }
 }
Beispiel #7
0
 private static void DefaultTypicalLength(ICollection<IFacet> facets, IFacetHolder specification, IFacetHolder holder) {
     var typicalLengthFacet = specification.GetFacet<ITypicalLengthFacet>();
     if (typicalLengthFacet == null) {
         typicalLengthFacet = new TypicalLengthFacetZero(holder);
     }
     else {
         typicalLengthFacet = new TypicalLengthFacetInferred(typicalLengthFacet.Value, holder);
     }
     facets.Add(typicalLengthFacet);
 }
Beispiel #8
0
 private static string GetDisplayTitle(IFacetHolder holder, INakedObject nakedObject) {
     var mask = holder.GetFacet<IMaskFacet>();
     string title = mask != null ? nakedObject.Specification.GetFacet<ITitleFacet>().GetTitleWithMask(mask.Value, nakedObject) : nakedObject.TitleString();
     return string.IsNullOrWhiteSpace(title) && !nakedObject.Specification.IsParseable ? nakedObject.Specification.UntitledName : title;
 }
Beispiel #9
0
 internal static bool RenderEagerly(IFacetHolder holder) {
     IEagerlyFacet eagerlyFacet = holder == null ? null : holder.GetFacet<IEagerlyFacet>();
     return eagerlyFacet != null && eagerlyFacet.What == Do.Rendering;
 }
Beispiel #10
0
        internal static void GetTableColumnInfo(IFacetHolder holder, out Func<INakedObjectAssociation, bool> filterFunc, out Func<INakedObjectAssociation, int> orderFunc, out bool withTitle) {
            ITableViewFacet tableViewFacet = holder == null ? null : holder.GetFacet<ITableViewFacet>();

            if (tableViewFacet == null) {
                filterFunc = x => true;
                orderFunc = null;
                withTitle = true;
            }
            else {
                string[] columns = tableViewFacet.Columns;
                filterFunc = x => columns.Contains(x.Id);
                orderFunc = x => Array.IndexOf(columns, x.Id);
                withTitle = tableViewFacet.Title;
            }
        }
Beispiel #11
0
 private static RouteValueDictionary CreateAutoCompleteAttributes(IFacetHolder holder, string completionAjaxUrl) {
     int minLength = holder.GetFacet<IAutoCompleteFacet>().MinLength;
     var attrs = new RouteValueDictionary {{"data-completions", completionAjaxUrl}, {"data-completions-minlength", minLength}};
     return attrs;
 }