rickstrahl / westwindtoolkit Goto Github PK
View Code? Open in Web Editor NEWA utility toolkit for .NET development from Core to Web
A utility toolkit for .NET development from Core to Web
At the Westwind.Web.Mvc.ViewRender
class has this method:
public static T CreateController<T>(RouteData routeData = null)
where T : Controller, new()
The CreateController
to create an MVC Controller instance.
But when the MVC Controller Methods have parameters and it is not parameter less then that have problem!
Thanks a lot for interested library.
There is any way to use ViewRenderer class in console application with out HTTP context ?
I am running an app that is .NetCore with a Web API, nothing else. I used the suggested installation method. That and the results follow:
PM> Install-Package Westwind.Utilities
Restoring packages for C:\Users\Main\Documents\Visual Studio 2017\Projects\mycoreupload\mycoreupload\mycoreupload.csproj...
Install-Package : Package Westwind.Utilities 2.71.0 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package
Westwind.Utilities 2.71.0 supports:
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : One or more packages are incompatible with .NETCoreApp,Version=v1.1.
At line:1 char:1
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package restore failed. Rolling back package changes for 'mycoreupload'.
At line:1 char:1
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
The problem often occurs during serialization of the object
For the fix:
_InstancePropertyInfo = Instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(a => a.GetIndexParameters().Length == 0).ToArray();
Current Code: Line 547 in ReflectionUtils or thereabouts:
if (Member.MemberType == MemberTypes.Property)
((PropertyInfo)Member). pi.SetValue(Parent, Value, null);
else
((FieldInfo)Member).SetValue(Parent, Value);
perhaps a test: ((PropertyInfo)Member).CanWrite ?? before the SetValue
It's done that way in the StringSerializer
This issue also occurs in the "ConfigurationFileConfigurationProvider" when missingFields are set.
Regards
Rob v N
Brisbane, AUS
Number.formatNumber
does not work correctly when specifying a fixed-precision format (for example "n1") in locales not using a period as decimal separator.
See line 2052 in ww.jquery.js v1.26: Number.toFixed
formats according to the neutral locale meaning that it uses a period for the decimal separator. Thus, if we want to split the integer and fractional parts in the resulting string we need to split with '.' rather than the current locale-dependent number format's separator.
I'm running into an error which seems to stem from the decision made on this line of code:
IsCompatibleWith(typeof(short?), typeof(short))
returns false. The intent of the method seems to be to see if a short is compatible with an int, etc., but doesn't account for whether short? is compatible with short.
Hi Rick,
In web.config files it is possible to set an optional attribute configSource on a section. This enables the user to store the settings within that section in a separate file. We use this feature to separate customer-specific settings from the common root web config.
When configuring the the db resource provider of the Westwind.Globalization project, we try to follow this strategy as well. For example:
<DbResourceConfiguration configSource="Customer\dbResourceProvider.config" />
This goes well when reading. The settings are properly read from the file specified in the configSource attribute, probably via the built-in .net functionality.
However, the provider attempts to write them back to file when any are missing. But instead of writing them to the configSource file (where they came from), they are written as child nodes in the root config file. This breaks the configuration, because child nodes are not allowed for sections where a configSource is specified.
The problem seems to be the Write function at
https://github.com/RickStrahl/WestwindToolkit/blob/master/Westwind.Utilities/Configuration/Providers/ConfigurationFileConfigurationProvider.cs#L327 , which calls WriteConfigurationValue on the DOM of the root web config.
The workaround is to ensure all expected config settings are there so it doesn't have to write at all :-) but i guess being more compliant to the specs would make an improvement to the toolkit .
Hello!
When using WestwindJsonSerializer to serialize something that contains a Guid (a data reader for example), the Guids are serialized as an object with length parameter instead of the guid's string.
For example:
"Guid": {Length: 36}
instead of: "Guid": "8631CF71-2948-466C-A103-5B3726341D63"
Fix suggestion:
In WestwindJsonSerializer.cs, around line 339:
else if (val is Guid)
WriteObject(sb, val.ToString());
else
replace WriteObject with WriteString
Thanks!
I believe I've found a bug in the Westwind.Web.Mvc.ViewRenderer
implementation.
In RenderViewToStringInternal
(line 137), it checks to see if the viewEngineResult
is null. At least with MVC4 in my testing, the viewEngineResult is always not null. If the view path was truly not found, the result is not null but the viewEngineResult.View
property is null.
This ends up causing an ArgumentNullException on the ViewContext
constructor call on line 148.
I'd suggest changing the conditional to:
if (viewEngineResult == null|| viewEngineResult.View == null)
throw new FileNotFoundException...
Of course I might be wrong too ;)
Hi,
I'm trying out SqlDataAccess with SQL server 2012.
When I use InsertEntity (with returnIdentityKey = true), the method returns a System.DbNull value, although the insert statement is successful.
If I manually execute the LastSql from the SqlDataAccess instance, it works. I.e when I execute this:
INSERT INTO SomeTable(columnA, columnB) VALUES(valueA, valueB); select SCOPE_IDENTITY()
If I execute the same statement above with SqlDataAccess.ExecuteScalar() it also works.
However, I understand from the source code that InsertEntity() first executes the insert command using ExecuteNonQuery and then performs an ExecuteScalar("select SCOPE_IDENTITY()"). Isn't this a problem? From what I can see, ExecuteNonQuery always closes the connection (in a finally clause) so "select SCOPE_IDENTITY()" would run in a new connection.
Regards,
Hans
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.