Breeze # for Xamarin.Forms (UWP, Droid and iOS)?

In their website , Xamarin appears as one of their clients, but I cannot install the Breeze.Sharp package , which is also tagged Xamarin.

It installs in the PCL project, but for its work I need to install it in all platform projects. When I try to do this, I get the following errors:

IOS / Android:

Failed to install package "Microsoft.AspNet.WebApi.Client 5.2.3". You are trying to install this package in a project whose purpose is "Xamarin.iOS, Version = v1.0", but the package does not contain links to assemblies or content files compatible with this infrastructure. For more information, contact the author of the package.

UWP:

Breeze.Sharp 0.6.0.9 is not compatible with uap10.0 (UAP, Version = v10.0) / win10-x86-aot. The Breeze.Sharp 0.6.0.9 package supports: net (.NETFramework, Version = v0.0) One or more packages are not compatible with UAP, Version = v10.0 (win10-x86-aot).

+4
source share
2 answers

In an email from IdeaBlade, the inventor of Breeze #, he said that although Breeze # is not dead, he pays much less attention to the community than BreezeJS, so they prefer to invest their resources in the JS library.

TrackableEntities @AnthonySneed. , Breeze #, .

+1

.
1.
2. BreezeSharp Portable Class Library (Nuget)
3. (Android, iOS). Android.
4. . ex: Configs.
5. Android → MainActivity.OnCreate

Configs.ModelAssembly = typeof(Customer).Assembly;
  1. Breeze DataService . :

public abstract class BaseDataService<T> where T : BaseEntity
    {
        public static string Metadata { get; protected set; }
        public string EntityName { get; protected set; }
        public string EntityResourceName { get; protected set; }
        public EntityManager EntityManager { get; set; }
        public string DefaultTargetMethod { get; protected set; }
        static BaseDataService()
        {
            Constants = ConstantsFactory.Get;
            try
            {
                var metadata = GetMetadata();
                metadata.Wait();
                Metadata = metadata.Result;

            }
            catch (Exception ex)
            {
                var b = 0;
            }
        }


        public BaseDataService(string resourceName, string targetMethod = null)
        {
            var modelType = typeof(Customer);
            Configuration.Instance.ProbeAssemblies(ConstantsFactory.BusinessAssembly);
            try
            {
                this.EntityName = typeof(T).FullName;
                this.EntityResourceName = resourceName;

                this.DefaultTargetMethod = (string.IsNullOrWhiteSpace(targetMethod) ? "GetAll" : targetMethod);

                var dataService = new DataService($"{ConstantsFactory.Get.BreezeHostUrl}{this.EntityResourceName}", new CustomHttpClient());
                dataService.HasServerMetadata = false;
                var metadataStore = new MetadataStore();
                var namingConvention = NamingConvention.CamelCaseProperties; /*metadataStore.NamingConvention;*/ /*NamingConvention.Default;*/// new NamingConvention()
                namingConvention = namingConvention.WithClientServerNamespaceMapping(
                    new Dictionary<string, string> { { "Business.DomainModels", "DomainModel.Models" } }
                    );

                metadataStore.NamingConvention = namingConvention;

                metadataStore.ImportMetadata(Metadata, true);

                this.EntityManager = new EntityManager(dataService, metadataStore);
                this.EntityManager.MetadataStore.AllowedMetadataMismatchTypes = MetadataMismatchTypes.AllAllowable;
                // Attach an anonymous handler to the MetadataMismatch event
                this.EntityManager.MetadataStore.MetadataMismatch += (s, e) =>
                {
                    // Log the mismatch
                    var message = string.Format("{0} : Type = {1}, Property = {2}, Allow = {3}",
                                                e.MetadataMismatchType, e.StructuralTypeName, e.PropertyName, e.Allow);

                    // Disallow missing navigation properties on the TodoItem entity type
                    if (e.MetadataMismatchType == MetadataMismatchTypes.MissingCLRNavigationProperty &&
                        e.StructuralTypeName.StartsWith("TodoItem"))
                    {
                        e.Allow = false;
                    }
                };
            }
            catch (Exception ex)
            {
                var b = 0;
            }
        }

        public async Task<List<T>> GetAll(string targetMethod = null)
        {
            var internalTargetMethod = (string.IsNullOrWhiteSpace(targetMethod) ? this.DefaultTargetMethod : targetMethod);
            var query = new EntityQuery<T>(internalTargetMethod);
            var qr = await this.EntityManager.ExecuteQuery(query);
            var result = qr.ToList();
            return result;
        }

        public void Delete(T entity)
        {
            entity.EntityAspect.Delete();
        }


        private static async Task<string> GetMetadata()
        {
            var client = new HttpClient();
            var metadata = await client.GetStringAsync(ConstantsFactory.Get.MetadataUrl).ConfigureAwait(false);
            var ret = JsonConvert.DeserializeObject<MetadataModel>(metadata);
            return ret.metadata;
        }


    }
Hide result
  1. CustomerService,

public class CustomerDataService : BaseDataService<Customer>
    {
        public CustomerDataService(IConstants constants) : base("Customers")
        {
            
        }
    }
Hide result
+1

Source: https://habr.com/ru/post/1680375/


All Articles