I need to use Microsoft.AspNet.WebApi.Versioning in VB.NET but I cannot translate the following code:
config.AddApiVersioning(o =>
{
o.AssumeDefaultVersionWhenUnspecified = true;
o.DefaultApiVersion = new Microsoft.Web.Http.ApiVersion(1, 0);
});
var constraintResolver = new DefaultInlineConstraintResolver()
{
ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) }
};
config.MapHttpAttributeRoutes(constraintResolver);
In particular I have an error when I define DefaultInlineConstraintResolver:
Dim constraintResolver = New DefaultInlineConstraintResolver() With
{
.ConstraintMap = { ["apiVersion"] = GetType(ApiVersionRouteConstraint) }
}
How resolve?
Tks.
I have found the solution. The correct code is:
Dim constraintResolver = New DefaultInlineConstraintResolver()
constraintResolver.ConstraintMap.Add("apiVersion", GetType(ApiVersionRouteConstraint))
Related
Currently, i've getting the string data from the maps.kml to display in laravel blade for simple testing. Based on the official documentation, mapbox can parse the kml string to maps. But it wont displayed.
Controller
...
$excelFile = public_path().'/assets/excel.xlsx';
$kmlfile = public_path(). '/assets/maps.kml';
$kmlContent = file_get_contents($kmlfile);
$kmlLoad = simplexml_load_string($kmlContent);
$kmlJsonFile = $kmlLoad->Document->Folder->Placemark;
// $kmlJson = json_decode($kmlLoad);
$parse = SimpleXLSX::parse($excelFile);
if ($parse) {
$petaSheet = $parse->rows(0, 0); //worksheet index, row limit
foreach($kmlJsonFile as $item)
{
foreach($petaSheet as $peta)
{
if($peta[0] == $item->name)
{
$item->Style->LineStyle->color = $peta[0];
}
}
}
// $monitorSheet = $parse->rows(1, 0);
} else {
$excelRaw = SimpleXLSX::parseError();
}
// $kmlJsonFile = json_encode($kmlJsonFile);
return view('home', [
'peta' => $petaSheet,
'kml' => $kmlContent
]);
Here the js file inside laravel blade
var kmlString = "";
kmlString += `{!! $kml !!}`;
var runLayer = omnivore.kml.parse(kmlString)
.on('ready', function() {
map.fitBounds(runLayer.getBounds());
})
.addTo(map);
I have a datatable dt, and want to make a PDF file from it. Everything is dynamic and it works but I can't format the layout such as alternate row background etc. Here is my code :
private void MakeGridExportToPDF(string strTitle, DataTable dt)
{
using (RadGrid grid = new RadGrid { AutoGenerateColumns = false, ShowHeader = true, })
{
grid.NeedDataSource += (object sender, GridNeedDataSourceEventArgs e) =>
{
grid.DataSource = dt;
};
// Add columns
dt.Columns.OfType<DataColumn>().ToList().ForEach(col =>
{
grid.MasterTableView.Columns.Add(new GridBoundColumn { DataField = col.ColumnName, HeaderText = col.Caption.ToCamel() });
});
GridExportSettings export = grid.ExportSettings;
export.OpenInNewWindow = true;
export.FileName = strTitle;
export.IgnorePaging = true;
GridPdfSettings pdf = export.Pdf;
pdf.PageHeight = Unit.Parse("210mm"); //
pdf.PageWidth = Unit.Parse(GetPageWidth(grid.MasterTableView.Columns.Count)); //
pdf.DefaultFontFamily = "Arial Unicode MS";
pdf.PageTopMargin = Unit.Parse("45mm");
grid.ItemCreated += (object sender, GridItemEventArgs e) =>
{
GridItem item = e.Item;
if (item is GridDataItem)
{
item.Style["vertical-align"] = "middle";
item.Style["text-align"] = "center";
}
switch (item.ItemType) //Mimic RadGrid appearance for the exported PDF file
{
case GridItemType.Item:
item.Style["background-color"] = "#DFDFDF";
item.Font.Italic = true;
break;
case GridItemType.AlternatingItem:
item.Style["background-color"] = "#FFFFFF";
break;
case GridItemType.Header:
item.Style["background-color"] = "#FFFFFF";
item.Style["Color"] = "#767676";
item.Font.Bold = true;
break;
case GridItemType.Footer:
item.Style["background-color"] = "#FFFFFF";
break;
}
};
this.smCSVFile.Controls.Add(grid);
grid.MasterTableView.ExportToPdf();
bDone = true;
}
}
What am I doing wrong. the ItemCreated is triggered when grid is created first but not when is exported and don't see any changes. Any help would be greatly appreciated.
My problem has been resolved by removing use(RadGrid grid .... and just make the Radgrid = new RadGrid { AutoGenerateColumns = false, ShowHeader = true, }
I have a code with which i can fetch image through internet ... I have completed it. I have to add to button , one to increase and one to reduce the interval ... in action script 2.0
import mx.transitions.*;
import mx.transitions.easing.*;
my_pb.mode = "manual";
this.createEmptyMovieClip("img_mc", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();
var mclListenerbject = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
my_pb.label = "loading: "+target_mc._name;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) {
var pctLoaded:Number = Math.ceil(100*(numBytesLoaded/numBytesTotal));
my_pb.setProgress(numBytesLoaded, numBytesTotal);
};
var number:Number = 2000;
var myInterval = setInterval(testInterval, number); //
function testInterval() {
my_mcl.addListener(mclListener);
my_mcl.loadClip("http://google.com/l5", img_mc);
}
i can create 2 button but there are some error...
If you want change the interval of the setInterval function, you have to clear it and then use the function with the new interval value, like this :
var delay:Number = 2000;
var interval = setInterval(on_repeat, delay);
function on_repeat() {
// instructions
}
fast.onPress = function(){
clearInterval(interval);
interval = setInterval(on_repeat, delay - 1000);
}
slow.onPress = function(){
clearInterval(interval);
interval = setInterval(on_repeat, delay + 1000);
}
But, as #Raptor has said, I recommend you to use ActionScript 3 instead of the old ActionScript 2.
For example, the code above can simply be replaced by a Timer object like this :
var delay:int = 2000;
var timer:Timer = new Timer(delay);
timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void {
// instructions
})
timer.start();
fast.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
timer.delay = delay - 1000;
})
slow.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void {
timer.delay = delay + 1000;
})
Hope that can help.
var current_loader:Number = 1;
var current_img:Number = 0;
this.createEmptyMovieClip('img_01', 999);
this.createEmptyMovieClip('img_02', 998);
img_01._x = img_01._y=img_02._x=img_02._y=20;
var loader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadStart = function(target_mc:MovieClip) {
};
listener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) {
};
listener.onLoadComplete = function(target_mc:MovieClip) {
if (target_mc._name == 'img_01') {
img_02._visible = false;
} else {
img_01._visible = false;
}
};
var delay:Number = 2000;
var interval = setInterval(load_image, delay);
function load_image() {
loader.addListener(listener);
loader.loadClip("http://google.com/latimage.php?", _root['img_0'+current_loader]);
current_loader = current_loader == 1 ? 2 : 1;
current_img = current_img == images.length-1 ? 0 : current_img+1;
}
slow.onRelease = function() {
interval = setInterval(load_image, delay+1000);
trace(interval);
};
fast.onRelease = function() {
clearInterval(interval);
interval = setInterval(load_image, delay-1000);
trace(interval);
};
image_load();
Let's say I have the following code
var $variable = $('<li/>', {
tabindex: 0,
click: function() {
//more code in here
}
}
is it possible to define the click: with a variable? Baring in mind it is already inside a variable and will also include an if statement, like so:
if(condition) {
var functiontype = 'click';
}
else {
var functiontype = 'hover';
}
var $variable = $('<li/>', {
tabindex: 0,
functiontype: function() {
//more code in here
}
}
I tried doing this but it didn't work. Can someone please point me in the right direction?
if(condition) {
var functiontype = 'click';
}
else {
var functiontype = 'hover';
}
var options = {};
options["tabindex"] = 0;
options[functiontype] = function(){
// your code
}
var $variable = $('<li/>', options);
You may do the reverse :
var $variable = $('<li/>', {
tabindex: 0
};
$variable[condition?'click':'hover'] = function(){
// the code here
}
I am trying to fill remote data into picker, but it crashes.
here is the code:
var countryDataArray = [];
var picker_country = Ti.UI.createPicker
({
bottom:'-251dp'
});
win.add(picker_country);
getCountryList(); //to call web service
//Gets country list from the server
function getCountryList()
{
getCountry.onload = function()
{
var jsonString = JSON.parse(this.responseText);
var msg = jsonString.Message;
var success = jsonString.IsSuccess;
countryDataArray = jsonString.dsetData.CountryList;
Ti.API.log('countryList value:'+countryDataArray);
activity.hide();
if(countryDataArray.length > 0)
{
for (var i=0; i < countryDataArray.length ; i++)
{
data[i] = Ti.UI.createPickerRow(
{
title:countryDataArray[i].Name,
country_id:countryDataArray[i].ID,
fontSize:18
});
};
}
picker_country.add(data);
}
what's wrong with this code ? code works fine with static data !!!
static data :-
var data = [
{title:'Bananas',custom_item:'b',fontSize:18},
{title:'Strawberries',custom_item:'s',fontSize:20},
{title:'Mangos',custom_item:'m',fontSize:22,selected:true},
{title:'Grapes',custom_item:'g',fontSize:24}
];
Solved !!! I Don't why but I just assign the data to picker before adding the picker into the view and it get solved !
picker_country.add(data);
win.add(picker_country);