portable-class-library

System.ComponentModel.DescriptionAttribute in portable class library

蓝咒 提交于 2019-11-29 05:36:16
问题 I am using the Description attribute in my enums to provide a user friendly name to an enum field. e.g. public enum InstallationType { [Description("Forward of Bulk Head")] FORWARD = 0, [Description("Rear of Bulk Head")] REAR = 1, [Description("Roof Mounted")] ROOF = 2, } And accessing this is easy with a nice helper method: public static string GetDescriptionFromEnumValue(Enum value) { DescriptionAttribute attribute = value.GetType() .GetField(value.ToString()) .GetCustomAttributes(typeof

Modify request headers per request C# HttpClient PCL

笑着哭i 提交于 2019-11-29 02:14:34
问题 I'm currently using the System.Net.Http.HttpClient for cross platform support. I read that it is not a good practice to instantiate a HttpClient object for each request and that you should reuse it whenever possible. Now I have a problem while writing a client library for a service. Some API calls need to have a specific header, some MUST not include this specific header. It seems that I can only manipulate the "DefaultRequestHeaders" which will be send with each request. Is there an option

MonoDevelop: is it possible to switch PCL's compiler?

孤人 提交于 2019-11-29 02:01:30
We are starting a cross-platform project to be deployed to Android and iOS. Obviously, a lot of code is to be shared between the two, and some of the code relies heavily on the .NET framework items, like sqlite-net library does. The best way (afaik) to share the code between 2 projects is to use a PCL – this way it is possible to reference the project with shared code from both iOS and Android projects in a solution and have everything re-compiled and linked in a nice manner. However, a PCL created in MonoDevelop is compiled with gmcs compiler and some of external dependencies fail to be built

Is there an alternative to AppDomain.GetAssemblies on portable library?

笑着哭i 提交于 2019-11-29 02:00:45
I'm looking for a way to get the current app's assemblies inside a portable library project. In classic library project, the code line below do the job: var assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); But seems that System.AppDomain is not available to portable library. Does anyone know a way to get the current domain assemblies on portable library? You can use platform hooks: In your portable library: using System.Collections.Generic; namespace PCL { public interface IAppDomain { IList<IAssembly> GetAssemblies(); } public interface IAssembly { string GetName(); } public class

Portable class library for MonoDroid and MonoTouch

跟風遠走 提交于 2019-11-29 01:24:26
问题 I want to create PCL for MonoDroid and MonoTouch, to share code AES encryption (RijndaelManaged), but Visual Studio wouldn't let me to do so, instead it forces me to add all other frameworks, message is following: The following frameworks will be selected automatically because they support all of the available functionality that is portable between the other frameworks you have selected: .NET for Windows Store apps, .NET Framework 4.5, Windows Phone 8. and those frameworks doesn't support

Update UI thread from portable class library

守給你的承諾、 提交于 2019-11-28 23:53:44
I have an MVVM Cross application running on Windows Phone 8 which I recently ported across to using Portable Class Libraries. The view models are within the portable class library and one of them exposes a property which enables and disables a PerformanceProgressBar from the Silverlight for WP toolkit through data binding. When the user presses a button a RelayCommand kicks off a background process which sets the property to true which should enable the progress bar and does the background processing. Before I ported it to a PCL I was able to invoke the change from the UI thread to ensure the

Windows Phone development and Unit Testing

試著忘記壹切 提交于 2019-11-28 21:41:46
问题 I'm looking to start a project targeting Windows Phone, but I'm slightly put off by the lack of unit testing support[1]. I'm used to using NUnit/ XUnit for most of my testing needs, with something like NSubstitute for mocking. Near as I can tell, you can't use these frameworks for Windows Phone projects... Given some investigation, I was wondering if the following scenario would work: Use Visual Studio 2012 Create a Portable Class Library project(s) for the View Models and other logic Create

using SQLite inside portable class library

淺唱寂寞╮ 提交于 2019-11-28 17:48:10
问题 recently we started to work on a new project which includes clients for Windows 8 Metro, Windows Phone and Desktop application. it was decided to use MVVM pattern as main Architecture because sharing ViewModels between projects is much more acceptable solution for us. we decided to use portable class library for this purpose, but the problem is that after downloading and installing SQLite for windows runtime from Visualstudio 2012 extension gallery when we try to add reference to appropriate

Portable Class Library in MVC 4 / Razor with Visual Studio 2012 RC?

帅比萌擦擦* 提交于 2019-11-28 15:59:03
问题 since working with Visual Studio 2012 RC we get an HttpCompileException when using a class out of an portable class library (.net 4.5 & metro profile) within a razor view. Exception: (german to english translated on google, sorry) System.Web.HttpCompileException (0x80004005): c:\Users\user\AppData\Local\Temp\Temporary ASP.NET Files\root\1995167a\126b7c4d\App_Web_index.cshtml.1fbcdbb1.zaniprm5.0.cs(29): error CS0012: The type 'System.Object' is not in a referenced assembly is defined. Add a

Why doesn't String class implement IEnumerable<char> in portable library?

只谈情不闲聊 提交于 2019-11-28 11:02:07
I've created a PCL project that targets .NET Framework 4 and Silverlight 5 (I use an extension for Visual Studio 2010, not portable project template from Visual Studio 2012, if that matters). I am trying to reverse a string using System.Linq.Enumerable.Reverse<TSource>() extension method, but it doesn't work because compiler thinks that System.String doesn't implement IEnumerable<char> . Hans Passant The Portable Class Libraries must restrict itself to the classes and methods that are available on all the target platforms it promises to support. The biggest trouble-maker here is WinRT, the CLR