Posts

[Code Snippet] Example of using Delegate, Func and Action side by side in C#

Quick and dirty example of using Delegate, Func and Action side by side in C# to show how to use function pointer  or callback in C# Example #1  Delegate and Func side by side      static int DoubleTheValue (int x)         {             return x * 2;         }         // delegate type should match the function signature  -  DoubleTheValue         public delegate int functionDelegateType (int x);               static void Method1 ( functionDelegateType func)         {             int doubleValue = func(5);         }         static void Method2 (Func<int, int> func) // easier syntax         {             int doubleValue = func(5);     ...

[Code snippet] INotifyPropertyChanged in the model and subscribed the PropertyChanged event of the model in ViewModel

internal class Model:INotifyPropertyChanged { public Model() { } string _FirstName = " Shahir" ; public string FirstName { get { return _FirstName; } set { _FirstName = value ; OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged([CallerMemberName] string propertyName = " " ) { if (PropertyChanged!= null ) { PropertyChanged( this , new PropertyChangedEventArgs(propertyName)); } } } internal class MyViewModel:INotifyPropertyChanged { private Model myModel; public MyViewModel(Model model) { this .myModel = model; myModel.PropertyChanged += myModel_PropertyChanged; } public event Property...

Code snippet: ArcGIS Runtime 100.x Geodatabase Delta Sync

ESRI namespaces using Esri.ArcGISRuntime.Tasks.Offline; using Esri.ArcGISRuntime.Data; using Esri.ArcGISRuntime.Tasks; using Esri.ArcGISRuntime.Http; Code snippet string localGeodatabaseName = @"C:\Data\test.geodatabase"; string deltaGeodatabaseName = @"C:\Deltas\_ags_data{52DwertD40459D02EC197E5EC12C}.geodatabase"; Task<IReadOnlyList<SyncLayerResult>> syncTaskResult = GeodatabaseSyncTask.ImportGeodatabaseDeltaAsync (localGeodatabaseName , deltaGeodatabaseName );

Code snippet: HTTP call to ArcGIS server from ArcGIS Runtime Enviroment 100.x

Required namespaces -  using System.Net.Http; using Esri.ArcGISRuntime.Http; using Newtonsoft.Json; //To parse the response Code snippet -  Uri requestUri = new Uri(serviceUrl +"?f=pjson"); //Default HttpClient handler which also handles the ArcGIS server Identity ArcGISHttpClientHandler handler = new ArcGISHttpClientHandler()                                                                    { UseDefaultCredentials = true }; HttpClient client = new HttpClient(handler); string serverResponseJsonString = await client.GetStringAsync(requestUri); Console.WriteLine(serverResponseJsonString );                  //Convert respones string to JSON Object, optional ArcGisServerResponse  serverResponseJson = JsonConvert.D...

Flavours of .NET implementation

  OS Open Source Purpose .NET Framework Windows No Used for building Windows desktop applications and ASP.NET Web apps running on IIS. .NET Core Windows, Linux, macOS Yes Used for building cross-platform console apps and ASP.NET Core Web apps and cloud services. Xamarin iOS, Android, macOS Yes Used for building mobile applications for iOS and Android, as well as desktop apps for macOS. .NET Standard N/A Yes Used for building libraries that can be referenced from all .NET implementations, such as .NET Framework, .NET Core and Xamarin. Ref -  https://msdn.microsoft.com/en-us/magazine/mt842506.aspx

Code Snippet: ESRI JS API 4.11 get Latittude Longitude on mouse hover

ESRI JS API 4.11 get Latittude Longitude on mouse hover //print point on mouse hover on map mapView . on ( "pointer-move" , function ( event ){ let mapPoint = mapView . toMap ({ x: event . x , y: event . y }); console . log ( mapPoint ); }); //print point on mouse click on map mapView . on ( "click" , function ( event ){ let mapPoint = event . mapPoint ; console . log ( mapPoint ) }); Both console statement will return the identical object as below which has latitude and longitude { __accessor__ : b } cache :  (...) extent :  (...) hasM :  (...) hasZ :  (...) latitude :  (...) longitude :  (...) m :  (...) spatialReference :  (...) type :  (...) x :  (...) y :  (...) z :  (...) constructed :  (...) destroyed :  (...) initialized :  (...) __accessor__ :  b  { host :  {…} ,  _origin :  6 ,  cursors :  {…} ,...

Code Snippet : Windows NTLM POST using Node JS

let ntlm = require('request-ntlm-lite'); let postData = 'user=test';   //anything let headers = {'Content-Type': 'application/x-www-form-urlencoded'}; let ntlmOptions = {                  url: 'postUrl', username: 'username', password: 'password', workstation:'', rejectUnauthorized: false, //disable ssl certificate error ntlm_domain: 'domain_name', json: true, headers:headers }; ntlm.post(ntlmOptions, postData, function(error, response, body){ console.log(error); console.log(response);                      });