Default class folder in Xamarin.Forms - xamarin

What is the default class folder in Xamarin.Forms?
In web development solution there is App_Code folder, where should I use in Xamarin.Forms ?

You can organize your code however you like. You can place everything in the root folder, or create separate (even nested) folders. Xamarin Forms does not require any special folder structure.
I tend to use a structure like this, but this is solely my preference:
Root
- Model
- View
- ViewModel
- Service
- Data

Related

How to prevent a new controller from creating a new folder for its views in the Views folder?

I'm writing an ASP.NET MVC 5 application, where folders are organized by feature (ViewModels, Controllers, and Views are grouped together). I was able to override all default folder paths and manage all routing successfully. However, every time I create a new controller, Visual Studio creates a new Views folder and a child folder with controller name, which is a little bit annoying but that's fine.
Now, when I create another controller, I'm getting this error, because Visual Studio created the Views folder again, which is hidden now (excluded from the project). To fix this, I have to include the Views folder in the project and delete it after I create the controller.
Does anybody know any way to prevent this?
Error
There was an error running the selected code generator: 'A file or
folder with the name 'Views' already exists on disk at this location.
Please choose another name.
If this file or folder does not appear in the Solution Explorer, then
it is not currently part of your project. To view files which exist on
disk, but are not in the project, select Show All Files from the
Project menu.
Instead of using visual studio's Add -> Controller which generates the undesired view folder, create your controller using Add -> Class. Name the class conventionally with a Controller suffix and subclass Controller like this MyController : Controller.

How to change default view creation logic in visual studio?

I've looked here and here to try to answer this question as well as a billion Google searches, but have yet to come up with a solution.
My directory structure is a multi-tenant MVC site with an overridden view engine that uses Areas to serve content for different hosts that share a lot of common logic served globally from the base controllers and views folders. We have taken this a step further and broken out different global site sections into a new folder called SiteSections. Inside of this folder we have more Areas.
The issue I am having, is whenever I try to use the visual studio context menu from inside a controller that is inside the SiteSections folder, it always adds it to the global Views folder.
What I am assuming is happening is that since these are Areas held within a different directory, Visual Studio is searching the Areas folder for an Area with the name of which I am working in. Since this is kept in a different directory, it is just defaulting to the global one. I've looked into all the different T4 templates and do not see anything specifying the directory where the view will be created.
I have just one question, that I'm hoping is possible.
How can I override Visual Studio to look in a second directory for the Area in question?
Thanks in advance!
I experienced something like that, not with Areas, but with Folders.
Have you tried to add custom view engine on ViewEngines?
The steps that i followed:
1 - I put this line at Global.asax.cs on method Application_Start:
ViewsEngines.Engines.Add(new MyCustomViewEngine());
2 - I created the file named as MyCustomViewEngine inheriting from RazorViewEngine, for example:
public class MyCustomViewEngine : RazorViewEngine
{
public MyCustomViewEngine()
{
base.ViewLocationFormats = MyViewLocationFormats;
}
private static string[] MyViewLocationFormats = new[]
{
"~/Views/Folder/{0}.cshtml",
"~/Views/Folder_1/Folder_2/{0}.cshtml"
}
}
I think that you can use in this way: "~/Areas/Views/Folder/{0}.cshtml",
Hope this helps!

My MVC3 app is adding "/Controllers/" folder to all my links

I've inherited an MVC3 .NET web app, which had all the controllers for the site in a separate project to the main web app. Not sure why this was the case. As it's a small app, I decided (for "neatness") to move the controller code back into the main web project, under the usual "Controllers" folder.
"Controllers" project folders:
Admin
Members
Config
Moved above code into main Web project under "Controllers" folder, ie:
Controllers
Admin
Members
Config
The problem now is, all the links generated by the code include "/Controllers/" in the path, assumedly because the controller code is now in a "Controllers" project folder. Is this a simple MVC issue to fix? Or would it likely be a flaw in code itself, in that it relies on where the code files run from to generate links?

Building CMS on top of CodeIgniter

Is it possible to build a CMS on top of CodeIgniter where the CMS files is separate from customization files? What I mean is, like CodeIgniter by default comes with 2 main folder, application and system folder. So, all your own files is placed in application folder so that next time you can easily update CodeIgniter by overriding the system folder and everything will still working fine.
So, can I store my files at custom folder?
E.g.:
system folder - codeigniter
my_system folder - CMS
application folder - All customization on each individual projects
You may use CodeIgniter's native application "Package", you can find the doc here : http://ellislab.com/codeigniter/user-guide/libraries/loader.html
You can store your file where you want expect system folder as you written. best approach is make folder on root named public or you want and put your file.
system folder contains everything codeigniter needs. application folder contains your specific code - it defaults to showing the welcome page.
consider naming your system folder with the codeigniter version number and date
makes it easier when you are upgrading
and you can easily switch to different versions directly from the index.php page by editing the file path to the folders

Mobile and desktop web app with codeigniter

I want to build two versions of my project for mobile and desktop.
Am working codeigniter 2.0.2, am looking for a way for the mobile and desktop versions of the project to share the same model, controllers, libraries, and helpers.
Also i have set up a sub-domain,m.xyz.com to point to folder called "m" on public_html folder,
i want the the mobile to be in the "m" folder and share resources with the desktop app residing in root so i dont create duplicate models, controllers etc.
CodeIgniter allows you to specify the folder that you are loading your views from. Since you want to reuse all of your application code, simply set up CodeIgniter so that it is loading mobile optimized views rather than the default (desktop) views.
Copy the root index.php file into the /m/ folder that you created.
Update the $system_path and $application_folder variables in /m/index.php with the correct paths.
Update the $view_folder variable in /m/index.php with the path to your view folder containing your mobile optimized views.
You mobile site will now mirror your desktop site - it will just be pulling in different views.
Note that the structure of your mobile views folder will need to mirror the structure of your default views folder.
EDIT: The $view_folder option will not be available until version 2.1. Here is the code if you wish to make the change yourself:
https://github.com/EllisLab/CodeIgniter/commit/8eef9c77512d4fad5357d3cbda83b89f844d7d16

Resources