webAPI OData v4 Function Registration - function

Having setup my WebAPI OData endpoint by doing this ...
http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint
I then tried adding a function as per the "Example:Adding a function" section at the bottom of this ...
http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/odata-actions-and-functions
I hit a bit of a problem as the method call "builder.EntityType()" does not exist but everything else is up and running fine.
Is there some special dependency I don't know about?
I'm using version 5.6.0 (latest stable) of the OData v4 package from nuget and compiling against .Net 4.6.
EDIT:
I tried updating the reference to the 5.7.0-rc build of the OData package, but that did solve it either, here's the bit we care about from my packages.config ...
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
<package id="Microsoft.AspNet.OData" version="5.7.0-rc" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net46" />
<package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net46" />
<package id="Microsoft.OData.Core" version="6.13.0" targetFramework="net46" />
<package id="Microsoft.OData.Edm" version="6.13.0" targetFramework="net46" />
<package id="Microsoft.Spatial" version="6.13.0" targetFramework="net46" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net46" />
</packages>
I'm using a few other things like ninject to do some DI stuff but I have not included those here to keep the question short.

Ok it turns out for some reason there was version 5.5.1.0 of the package in my bin folder which it was choosing to pick up despite an assembly binding to tell it to use the later 5.7.0.0 version.
Also to really mess with my head Microsoft have moved a bunch of stuff around and some using statements had to be changed in my class (possibly why my code was using an older version) ...
Old usings:
using Microsoft.Data.Edm;
using System.Web.Http.OData.Builder;
New usings:
using Microsoft.OData.Edm;
using System.Web.OData.Builder;
using System.Web.OData.Extensions;
It's probably worth noting that as the walkthrough makes no mention of usings or version numbers, it just says "we used OData v4" ... helpful as ever!
I had to dig through the source on codeplex to find the answer but essentially that walkthrough is based on 5.7.0.0 or later of the package.

Related

Propagate=False in BIML

I'm using BIML to create my package.
There is a sequence container where I want to set the system variable Propagate to False.
I cannot find the method in BIML to set the system variable for Propagate.
Propagate is a System scoped variable that only exists within Event Handlers.
The following Biml creates an SSIS Package with an OnError event handler that has an empty Sequence Container
The Event itself redefines the System::Propagate variable to have a value of false instead of the default value of true
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name="so_38121956">
<Events>
<Event EventType="OnError" Name="OnError">
<Variables>
<Variable DataType="Boolean" Name="Propagate" Namespace="System">false</Variable>
</Variables>
<Tasks>
<Container Name="SEQC Propagate no more">
</Container>
</Tasks>
</Event>
</Events>
</Package>
</Packages>
</Biml>
Try using BIML Online.
http://bimlonline.com/
Here you can upload an existing SSIS package with propagate set and the browser based application will reverse engineer it for you to give you the BIML.
Its handy if you know how to do something in SSIS, but not sure of the BIML equivalent.
Officially its still in Beta, but works well.

Increase RAM allowance for Windows Phone 8.1

To which file am I supposed to write information that my WP8.1 application requires 300+ MB RAM? I would like to use this setup at least for the time of developing app, later I will consider other approach, targeting all devices.
As far as I can see I have only one manifest file in my project, Package.appxmanifest, shown here. I wrote the line "m3:MinDeviceMemory"1GB"/m3:MinDeviceMemory" but it doesn't seem to be enough. I have no idea where to write ID_REQ_MEMORY_300 as recommended in msdn here.
https://msdn.microsoft.com/en-us/library/windows/apps/jj681682(v=vs.105).aspx
I see no "App" object in any of my files so I can't write any "Requirements" or "FunctionalCapability" object too. Where can I find it?
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest"xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="1cd9812c-28c9-4bc9-b45b-933beb09ad48" Publisher="CN=Štěpán" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="1cd9812c-28c9-4bc9-b45b-933beb09ad48" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Chess Openings</DisplayName>
<PublisherDisplayName>Štěpán</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
<m3:MinDeviceMemory>1GB</m3:MinDeviceMemory>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Chess_Openings.App">
<m3:VisualElements DisplayName="Chess Openings" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="Chess Openings" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
<m3:InitialRotationPreference>
<m3:Rotation Preference="portrait" />
</m3:InitialRotationPreference>
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
</Capabilities>
</Package>
All this my question is wrong. There is no ID_FUNCCAP_EXTEND_MEM any more in Windows Phone 8.1 compared to Windows Phone 8. This is what I was looking for all the time.
There is no default and extended memory limit in WP8.1 but just one default memory limit and it is the high one. After checking
Windows.System.MemoryManager.AppMemoryUsageLimit
I quickly recognized that my program wasn't failing because of insufficient memory, as I thought.
I guess
<m3:MinDeviceMemory>1GB</m3:MinDeviceMemory>
(as shown in code) can limit lower memory devices from store, but this isn't what I was looking for.

how to add configuration for log4net (or any other 3rd party library) in ASP.NET 5.0

I was reading Scott Gu's blog on ASP.NET 5.0 features and one of the new feature mentioned in the blog is to use json file as configuration and elimination of Web.config file.
I have few questions around that feature.
Assume I have following log4net configuration which was previously added to Web.Config in previous version of ASP.NET
Config file
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\TestProj\\TestLog.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
How would one add sections in config.json ?
How would one convert above xml and add it to config.json?
Does 3rd Party library ( In my example log4net ) or users of the library have to add some type of custom conversion api to support json based configuration, in order to take advantage of new configuration feature provided in ASP.NET 5.0?
Recently I had the same problem with log4net. I managed to do it working as following:
Create log4net.xml file containing the configuration section for log4net
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
...
</log4net>
You can put the file in the project root folder.
And in the Startup.Startup() method you can configure the log4net providing the xml as a configuration:
public Startup(IApplicationEnvironment appEnv)
{
// ...
XmlConfigurator.Configure(new FileInfo(Path.Combine(appEnv.ApplicationBasePath, "log4net.xml")));
}
I hope this helps.
Current versions of log4net don't support Json projects, so the config needs to be in a separate xml file.

How to use both struts2 ssl plugin and json plugin

I've encountered a problem when using struts2.
I want to use both struts2 json plugin and ssl plugin.
But in the struts.xml they need to extend default packages.
<package name="myPackage1" extends="json-default">
<package name="myPackage1" extends="ssl-default">
How can I use both of the plugins?
Thanks!!
When declaring a package you must declare both extensions together, instead of declaring a package two times.
Try using
<package name="myPackage1" extends="json-default,ssl-default">

Castle Windsor IOC and Order of Appearance in Config File

I'm new to Castle Windsor and am confused about the order in the config file. This is taken from the GettingStarted1 sample. The HttpServiceWatcher class takes an IFailureNotifier implementor in it's constructor. However, no matter how I order the two components that implement this interface -- AlarmFailureNotifier and EmailFailureNotifier -- I always get EmailFailureNotifier. I know you can override which is chosen using parameters and a "service lookup" reference, but I thought that the order of declaration is used when other mechanisms are not.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="castle"
type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
</configSections>
<castle>
<components>
<component
id="httpservicewatcher"
type="GettingStartedPart1.HttpServiceWatcher, GettingStartedPart1">
</component>
<component
id="alarm.notifier"
service="GettingStartedPart1.IFailureNotifier, GettingStartedPart1"
type="GettingStartedPart1.AlarmFailureNotifier, GettingStartedPart1" />
<component
id="email.notifier"
service="GettingStartedPart1.IFailureNotifier, GettingStartedPart1"
type="GettingStartedPart1.EmailFailureNotifier, GettingStartedPart1" />
<component
id="form.component"
type="GettingStartedPart1.Form1,GettingStartedPart1" />
</components>
</castle>
</configuration>
This was resolved with Castle 2.0 (that went RTM early last year).
The latest version of Castle is 2.1.1:
http://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download
Castle's releases are always a bit tricky to find (they need to update their site). I always refer to the Project list:
http://www.castleproject.org/castle/projects.html
You want: MicroKernal/Windsor
I don't know which version you're using, but I believe this was a bug some time ago and it has been corrected in the build server version. Try that one and see what happens.
Also, you could use default components like this: Castle Windsor and default components