예제 #1
0
        public void EnvironmentBindingsCanBeCustomizedThroughCompilerParametersEnvironment()
        {
            EntityFormatter actualFormatter   = null;
            var             expectedFormatter = new EntityFormatter();

            var compiler = new Boo.Lang.Compiler.BooCompiler();

            compiler.Parameters.Pipeline = new CompilerPipeline {
                new ActionStep(() => actualFormatter = My <EntityFormatter> .Instance)
            };
            compiler.Parameters.Environment = new ClosedEnvironment(expectedFormatter);
            compiler.Run();

            Assert.AreSame(expectedFormatter, actualFormatter);
        }
        /// <summary>
        /// replaces placeholders with property values in format string.
        /// [propertyName], [propertyName:nullValue], [propertyName:nullValue:pad], [propertyName::pad]
        /// pad option can include prefix U | L | C . for Uppercase, lowercase, capitalize
        /// </summary>
        public string ToString(string format, IFormatProvider formatProvider)
        {
            ICustomFormatter formatter;

            formatter = new EntityFormatter(this.GetType());

            if (formatter != null)
            {
                return(formatter.Format(format, this, formatProvider));
            }
            else
            {
                return(base.ToString());
            }
        }
예제 #3
0
        public override void Execute()
        {
            #line 6 "..\..\Signum\Views\SearchResults.cshtml"

            QueryDescription queryDescription          = (QueryDescription)ViewData[ViewDataKeys.QueryDescription];
            var             entityColumn               = queryDescription.Columns.SingleEx(a => a.IsEntity);
            Implementations implementations            = entityColumn.Implementations.Value;
            bool            navigable                  = (bool)ViewData[ViewDataKeys.Navigate] && (implementations.IsByAll ? true : implementations.Types.Any(t => Navigator.IsNavigable(t, null, isSearch: true)));
            bool            allowSelection             = (bool)ViewData[ViewDataKeys.AllowSelection];
            RowAttributes   rowAttributes              = (RowAttributes)ViewData[ViewDataKeys.RowAttributes];
            QueryRequest    queryRequest               = (QueryRequest)ViewData[ViewDataKeys.QueryRequest];
            ResultTable     queryResult                = (ResultTable)ViewData[ViewDataKeys.Results];
            Dictionary <int, CellFormatter> formatters = (Dictionary <int, CellFormatter>)ViewData[ViewDataKeys.Formatters];
            EntityFormatter entityFormatter            = (EntityFormatter)ViewData[ViewDataKeys.EntityFormatter];

            int columnsCount = queryResult.Columns.Count() + (navigable ? 1 : 0) + (allowSelection ? 1 : 0);


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n");


            #line 21 "..\..\Signum\Views\SearchResults.cshtml"
            if (ViewData.ContainsKey(ViewDataKeys.MultipliedMessage))
            {
            #line default
            #line hidden
                WriteLiteral("    <tr");

                WriteLiteral(" class=\"extract\"");

                WriteLiteral(">\r\n        <td>\r\n            <div");

                WriteLiteral(" class=\"sf-td-multiply alert alert-warning\"");

                WriteLiteral(">\r\n                <span");

                WriteLiteral(" class=\"glyphicon glyphicon-exclamation-sign\"");

                WriteLiteral("></span>\r\n");

                WriteLiteral("                ");


            #line 27 "..\..\Signum\Views\SearchResults.cshtml"
                Write(ViewData[ViewDataKeys.MultipliedMessage]);


            #line default
            #line hidden
                WriteLiteral("\r\n            </div>\r\n        </td>\r\n    </tr>\r\n");


            #line 31 "..\..\Signum\Views\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 33 "..\..\Signum\Views\SearchResults.cshtml"
            foreach (var row in queryResult.Rows)
            {
                Lite <IEntity> entityField = row.Entity;


            #line default
            #line hidden
                WriteLiteral("    <tr");

                WriteLiteral(" data-entity=\"");


            #line 36 "..\..\Signum\Views\SearchResults.cshtml"
                Write(entityField.Key());


            #line default
            #line hidden
                WriteLiteral("\"");

                WriteLiteral(" ");


            #line 36 "..\..\Signum\Views\SearchResults.cshtml"
                Write(rowAttributes == null ? null : rowAttributes(Html, row));


            #line default
            #line hidden
                WriteLiteral(">\r\n");


            #line 37 "..\..\Signum\Views\SearchResults.cshtml"


            #line default
            #line hidden

            #line 37 "..\..\Signum\Views\SearchResults.cshtml"
                if (allowSelection)
                {
            #line default
            #line hidden
                    WriteLiteral("            <td");

                    WriteLiteral(" style=\"text-align:center\"");

                    WriteLiteral(">");


            #line 39 "..\..\Signum\Views\SearchResults.cshtml"
                    Write(Html.CheckBox(
                              Model.Compose("rowSelection", row.Index.ToString()),
                              new
                    {
                        @class = "sf-td-selection",
                        value  = entityField.Id.ToString() + "__" + Navigator.ResolveWebTypeName(entityField.EntityType) + "__" + entityField.ToString()
                    }));


            #line default
            #line hidden
                    WriteLiteral("</td>\r\n");


            #line 46 "..\..\Signum\Views\SearchResults.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("        ");


            #line 47 "..\..\Signum\Views\SearchResults.cshtml"
                if (navigable)
                {
            #line default
            #line hidden
                    WriteLiteral("            <td>");


            #line 49 "..\..\Signum\Views\SearchResults.cshtml"
                    Write((entityFormatter ?? QuerySettings.EntityFormatRules.Last(fr => fr.IsApplyable(row)).Formatter)(Html, row));


            #line default
            #line hidden
                    WriteLiteral("</td>\r\n");


            #line 50 "..\..\Signum\Views\SearchResults.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("        ");


            #line 51 "..\..\Signum\Views\SearchResults.cshtml"
                foreach (var col in queryResult.Columns.Where(a => a.Column.IsVisible))
                {
                    var value = row[col];
                    var ft    = formatters[col.Index];



            #line default
            #line hidden
                    WriteLiteral("            <td ");


            #line 56 "..\..\Signum\Views\SearchResults.cshtml"
                    Write(ft.WriteDataAttribute(value));


            #line default
            #line hidden
                    WriteLiteral(" style=\"");


            #line 56 "..\..\Signum\Views\SearchResults.cshtml"
                    Write(ft.TextAlign == null ? null : "text-align:" + ft.TextAlign);


            #line default
            #line hidden
                    WriteLiteral("\">");


            #line 56 "..\..\Signum\Views\SearchResults.cshtml"
                    Write(ft.Formatter(Html, value));


            #line default
            #line hidden
                    WriteLiteral("</td>\r\n");


            #line 57 "..\..\Signum\Views\SearchResults.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("    </tr>\r\n");


            #line 59 "..\..\Signum\Views\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 61 "..\..\Signum\Views\SearchResults.cshtml"
            if (queryResult.Rows.IsNullOrEmpty())
            {
            #line default
            #line hidden
                WriteLiteral("    <tr>\r\n        <td");

                WriteAttribute("colspan", Tuple.Create(" colspan=\"", 2820), Tuple.Create("\"", 2843)

            #line 64 "..\..\Signum\Views\SearchResults.cshtml"
                               , Tuple.Create(Tuple.Create("", 2830), Tuple.Create <System.Object, System.Int32>(columnsCount

            #line default
            #line hidden
                                                                                                                 , 2830), false)
                               );

                WriteLiteral(">");


            #line 64 "..\..\Signum\Views\SearchResults.cshtml"
                Write(SearchMessage.NoResultsFound.NiceToString());


            #line default
            #line hidden
                WriteLiteral("</td>\r\n    </tr>\r\n");


            #line 66 "..\..\Signum\Views\SearchResults.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 68 "..\..\Signum\Views\SearchResults.cshtml"

            ViewData[ViewDataKeys.Pagination] = queryResult.Pagination;



            #line default
            #line hidden
            WriteLiteral("    <tr");

            WriteLiteral(" class=\"extract\"");

            WriteLiteral(">\r\n        <td>\r\n");

            WriteLiteral("            ");


            #line 73 "..\..\Signum\Views\SearchResults.cshtml"
            Write(Html.Partial(Finder.Manager.PaginationSelectorView, Model));


            #line default
            #line hidden
            WriteLiteral("\r\n        </td>\r\n    </tr>\r\n");


            #line 76 "..\..\Signum\Views\SearchResults.cshtml"


            #line default
            #line hidden
            WriteLiteral("\r\n");
        }
예제 #4
0
 public EntityFormatterRule(Func <ResultRow, bool> isApplyable, EntityFormatter formatter)
 {
     Formatter   = formatter;
     IsApplyable = isApplyable;
 }