Invoke method CsSCript Notepad++ - visual-studio

I have this simple method CallMethod made in Notepad++ with CsScript.
How to invoke in from VS ?
namespace TestCall
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ClassCall
{
public void CallMethod()
{
Console.Write("MethodCalling");
}
}
}
I made this invoker
namespace TestCall
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Class1
{
public ClassCall a = new ClassCall();
public void Invoker()
{
Console.Write("MethodCall");
a.CallMethod();
Console.Write("MethodCalled");
}
}
}
But how to call it to be opened with Notepad++ with CSScript, so i can debug it?
Thanks

CS-Script offers a debugging option which can be used when you create an script.
Here's the github documentation.
Put the cursor on the line you want a breakpoint and press F9.

Related

Dataannotations error in xamarin

I've developed a xamarin.forms app. Everything was working fine and I updated my Visual Studio installation. But now i am getting below errors. Here is the code:
using SQLite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace SampleApp
{
[SQLite.Table("CSV_File")]
public class FileCSV : INotifyPropertyChanged
{
private int _id;
[ForeignKey("Id")]
[PrimaryKey, AutoIncrement, NotNull]
public int Id
{
get
{
return _id;
}
set
{
this._id = value;
OnPropertyChanged(nameof(Id));
}
}
And fere are the errors:
Error CS0246 The type or namespace name 'ForeignKey' could not be
found (are you missing a using directive or an assembly
reference?)
Error CS0234 The type or namespace name 'DataAnnotations' does not
exist in the namespace 'System.ComponentModel' (are you missing an
assembly
reference?)
Change the target profile of your Shared Project to Profile259.

Namespace name RecyclerView could not be found

I have been following along with Xamarin's guide, but am not able to reference RecyclerView to create an instance of it.
JDK 8 is installed. I have installed the Xamarin.Android.Support.v7.RecyclerView package and all of its dependencies. I'm targeting API level 24. But still no dice.
I can't find anything online that references this issue. Any ideas?
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V7.RecyclerView;
using Android.Views;
using Android.Widget;
namespace ArbanQC
{
[Activity(Label = "LoadsActivity")]
public class LoadsActivity : Activity
{
ProgressDialog progress;
bool ScheduleShowing;
RecyclerView grid; //Namespace is not recognized here.
List<Load> loads = new List<Load>();
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
RequestWindowFeature(WindowFeatures.NoTitle);
SetContentView(Resource.Layout.Loads);
grid = FindViewById<RecyclerView>(Resource.Id.loadsGrid); //Also not recognized here
ScheduleShowing = true;
}
}
}
Your using directive:
using Android.Support.V7.RecyclerView;
is incorrect - it should be:
using Android.Support.V7.Widget;

How to use the vibration service in a shared project Xamarin.Forms (Portable) in Visual Studio?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace App1
{
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
}
void OnButton_Clicked(object sender, EventArgs args)
{
/* code to vibrate */
}
}
}
I have not tested this myself but the simplest solution is to use the component developed already called CrossVibrate.
In general, you just have to create an abstraction (Interface) and implement it for each OS. This component handles this for you.

In which namespace is the extension method EntityTypeConfiguration.MapSingleType

I am trying to implement the following code to map a database to a POCO that has slightly different Property names then the corresponding columns, and a slightly different class name than the table name.
Here's the article
The problem is there is no method called MapSingleType. I have the following two methods available:
public EntityTypeConfiguration<TEntityType> Map<TDerived>(Action<EntityMappingConfiguration<TDerived>> derivedTypeMapConfigurationAction) where TDerived : class, TEntityType;
public EntityTypeConfiguration<TEntityType> Map(Action<EntityMappingConfiguration<TEntityType>> entityMappingConfigurationAction);
However, I can't find any examples of how to use them and I'm hoping to find the MapSingleType method since that works perfect for the very large number of columns I have to map.
I have downloaded CTP4 from here
And I am using EF 4.0.3
Here is the code I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using PlayingWithEF.DAL.CLS.Classes;
using System.Data.Entity.ModelConfiguration;
namespace PlayingWithEF.DAL.CLS.Context
{
public class CLSContext : DbContext
{
public DbSet<Listing> Listings { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Listing>().Map(...?)
}
}
}
You're going to have to map each property individually:
modelBuilder.Entity<Listing>()
.Property(l => l.YourProperty)
.HasColumnName("PropertyName");
modelBuilder.Entity<Listing>()
.ToTable("TableName");
You can't use CTP4 and EF 4.0.3 together, they're different versions of the same library.
I believe this functionality was removed from the betas at some point, and is no longer in the shipping version.

Common DataAnnotations in ASP.Net MVC2

Howdy, I have what should be a simple question. I have a set of validations that use System.CompontentModel.DataAnnotations . I have some validations that are specific to certain view models, so I'm comfortable with having the validation code in the same file as my models (as in the default AccountModels.cs file that ships with MVC2). But I have some common validations that apply to several models as well (valid email address format for example). When I cut/paste that validation to the second model that needs it, of course I get a duplicate definition error because they're in the same namespace (projectName.Models). So I thought of removing the common validations to a separate class within the namespace, expecting that all of my view models would be able to access the validations from there. Unexpectedly, the validations are no longer accessible. I've verified that they are still in the same namespace, and they are all public. I wouldn't expect that I would have to have any specific reference to them (tried adding using statement for the same namespace, but that didn't resolve it, and via the add references dialog, a project can't reference itself (makes sense).
So any idea why public validations that have simply been moved to another file in the same namespace aren't visible to my models?
CommonValidations.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
namespace ProjectName.Models
{
public class CommonValidations
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public sealed class EmailFormatValidAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value != null)
{
var expression = #"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]#[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$";
return Regex.IsMatch(value.ToString(), expression);
}
else
{
return false;
}
}
}
}
}
And here's the code that I want to use the validation from:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Growums.Models;
namespace ProjectName.Models
{
public class PrivacyModel
{
[Required(ErrorMessage="Required")]
[EmailFormatValid(ErrorMessage="Invalid Email")]
public string Email { get; set; }
}
}
You have declared EmailFormatValidAttribute as a subclass to CommonValidations. As such you need to reference it like CommonValidations.EmailFormatValidAttribute. Or alternatively move the EmailFormatValidAttribute class out of the CommonValidations class.
This should work:
[CommonValidations.EmailFormatValid(ErrorMessage="Invalid Email")]
public string Email { get; set; }
By the way, you can simplify your class as follows:
public class EmailFormatValidAttribute : RegularExpressionAttribute
{
public EmailFormatValidAttribute() :
base(#"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]#[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")
{}
}
Also, take a look at this: Data Annotations Extensions. It's a great DataAnnotations library which has already the most common validations included in it.

Resources