Example #1
0
 public Application(AppiumDriver <AppiumWebElement> driver, AppiumLocalService driverService = null)
 {
     Driver             = driver;
     DriverService      = driverService;
     localizedLogger    = AqualityServices.LocalizedLogger;
     applicationProfile = AqualityServices.ApplicationProfile;
     SetImplicitlyWaitToDriver(AqualityServices.Get <ITimeoutConfiguration>().Implicit);
 }
Example #2
0
 public ClientApplicationAccessAuthorizationHandler(IHttpContextAccessor httpContextAccessor,
                                                    IDataRepositoryFactory dataRepositoryFactory,
                                                    ICacheService cacheService,
                                                    IApplicationProfile applicationProfile)
 {
     _HttpContextAccessor   = httpContextAccessor;
     _DataRepositoryFactory = dataRepositoryFactory;
     _CacheService          = cacheService;
     _ApplicationProfile    = applicationProfile;
 }
Example #3
0
 /// <summary>
 /// Sets dynamic variables for specifed application profile.
 /// </summary>
 /// <param name="application"></param>
 private static void SetDynamicVarriables(IApplicationProfile application)
 {
     if (application != null)
     {
         Environment.SetEnvironmentVariable("ENTRYPUBLISHER", application.PublisherName);
         Environment.SetEnvironmentVariable("ENTRYDEVELOPER", application.DeveloperName);
         Environment.SetEnvironmentVariable("ENTRYTITLE", application.Title);
     }
     else
     {
         throw new NullReferenceException("Application cannot be null.");
     }
 }
Example #4
0
        public void CreateMap(IApplicationProfile profile, Type type)
        {
            SetType(type);

            var(expr, instance, mapFactory) = CreateForwardMap(profile, type);

            if (expr == null)
            {
                return;
            }

            IgnoreProperties(type, expr);

            CreateReverseMap(profile, type, expr, instance);
        }
Example #5
0
 public ScreenFactory(IApplicationProfile applicationProfile)
 {
     this.applicationProfile = applicationProfile;
 }
Example #6
0
        /// <summary>
        /// Creates map.
        /// </summary>
        /// <param name="profile"><see cref="IApplicationProfile"/></param>
        /// <param name="type">Annotated <see cref="Type"/>.</param>
        /// <returns></returns>
        private (object?expr, object?instance, MethodInfo?mapFactoryMethodInfo) CreateForwardMap(IApplicationProfile profile, Type type)
        {
            object?    expr       = null;
            object?    instance   = null;
            MethodInfo?mapFactory = null;

            if (!String.IsNullOrWhiteSpace(MapFactory))
            {
                if (!type.IsInterface)
                {
                    // if there are several methods with the same name then CS0108 compiler warning will be
                    mapFactory = type.GetMethod(MapFactory,
                                                BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.Public);
                }
                else if (MapFactoryType != null)
                {
                    mapFactory = MapFactoryType.GetMethod(MapFactory, BindingFlags.Static | BindingFlags.Public);
                }

                if (mapFactory != null)
                {
                    if (!type.IsInterface)
                    {
                        instance = Activator.CreateInstance(type);
                    }

                    expr = mapFactory.Invoke(instance, new object[] { profile });

                    if (expr != null)
                    {
                        if (IncludeAllDerived)
                        {
                            MethodInfo?mi = expr.GetType().GetMethod("IncludeAllDerived");
                            expr = mi?.Invoke(expr, null);
                        }

                        if (IncludeBase != null)
                        {
                            MethodInfo?mi =
                                expr?.GetType()
                                .GetMethods(BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.Public)
                                .First(m => !m.IsGenericMethod && m.Name.Equals("IncludeBase"));

                            expr = mi?.Invoke(expr, new object[] { IncludeBase, DestinationType });
                        }
                    }
                }
            }

            if (mapFactory == null)
            {
                expr = CreateDefaultMap(profile, type);

                if (IncludeAllDerived)
                {
                    expr = (( IMappingExpression )expr).IncludeAllDerived();
                }

                if (IncludeBase != null)
                {
                    expr = (( IMappingExpression )expr).IncludeBase(IncludeBase, DestinationType);
                }
            }

            return(expr, instance, mapFactory);
        }
Example #7
0
 protected abstract IMappingExpression CreateDefaultReverseMap(IApplicationProfile profile, Type type, IMappingExpression expr);
Example #8
0
 protected abstract IMappingExpression CreateDefaultMap(IApplicationProfile profile, Type type);
Example #9
0
        private void CreateReverseMap(IApplicationProfile profile, Type type, object expression, object?instance)
        {
            object?    expr = expression;
            MethodInfo?reverseMapFactory = null;

            if (!String.IsNullOrWhiteSpace(ReverseMapFactory))
            {
                if (!type.IsInterface)
                {
                    // if there are several methods with the same name then CS0108 compiler warning will be
                    reverseMapFactory = GetReverseMapFactoryMethodInfo(type, expr !.GetType());
                }
                else if (MapFactoryType != null)
                {
                    reverseMapFactory = GetReverseMapFactoryMethodInfo(MapFactoryType, expr !.GetType());
                }


                if (instance == null)
                {
                    if (!type.IsInterface)
                    {
                        instance = Activator.CreateInstance(type);
                    }

                    if (instance != null && reverseMapFactory != null)
                    {
                        expr = reverseMapFactory.Invoke(instance, new object[] { profile }) !;
                    }
                    else if (reverseMapFactory == null)
                    {
                        expr = CreateDefaultReverseMap(profile, type, ( IMappingExpression )expr);
                    }
                    else
                    {
                        ParameterInfo[] @params = reverseMapFactory.GetParameters();
                        expr =
                            @params[0].ParameterType == typeof(IApplicationProfile)
                                ? reverseMapFactory.Invoke(instance, @params.Length == 2 ? new object[] { profile, expr } : new object[] { profile })
                                : reverseMapFactory.Invoke(instance, @params.Length == 2 ? new object[] { expr, profile } : new object[] { expr });
                    }
                }
                else if (reverseMapFactory != null)
                {
                    ParameterInfo[] @params = reverseMapFactory.GetParameters();
                    expr =
                        @params[0].ParameterType == typeof(IApplicationProfile)
                            ? reverseMapFactory.Invoke(instance, @params.Length == 2 ? new object[] { profile, expr } : new object[] { profile })
                            : reverseMapFactory.Invoke(instance, @params.Length == 2 ? new object[] { expr, profile } : new object[] { expr });
                }
                else
                {
                    MethodInfo?mi = expr !.GetType().GetMethod("ReverseMap");
                    expr = mi?.Invoke(expr, new object?[] { profile, type, expr });
                }

                if (IncludeAllDerivedForReverse)
                {
                    MethodInfo?mi = expr !.GetType().GetMethod("IncludeAllDerived");
                    mi?.Invoke(expr, null);
                }
            }
            else if (ReverseMap)
            {
                if (expr is IMappingExpression e)
                {
                    e = CreateDefaultReverseMap(profile, type, e);

                    if (IncludeAllDerivedForReverse)
                    {
                        e.IncludeAllDerived();
                    }
                }
                else
                {
                    MethodInfo?mi = expr !.GetType().GetMethod("ReverseMap");
                    mi?.Invoke(expr, null);

                    if (IncludeAllDerivedForReverse)
                    {
                        mi = expr !.GetType().GetMethod("IncludeAllDerived");
                        mi?.Invoke(expr, null /*new object?[] { profile, type, expr }*/);
                    }
                }
            }
        }
Example #10
0
 /// <summary>
 /// Sets dynamic variables for specifed application profile.
 /// </summary>
 /// <param name="application"></param>
 private static void SetDynamicVarriables(IApplicationProfile application)
 {
     if (application != null)
     {
         Environment.SetEnvironmentVariable("ENTRYPUBLISHER", application.PublisherName);
         Environment.SetEnvironmentVariable("ENTRYDEVELOPER", application.DeveloperName);
         Environment.SetEnvironmentVariable("ENTRYTITLE", application.Title);
     }
     else
     {
         throw new NullReferenceException("Application cannot be null.");
     }
 }
Example #11
0
 /// <summary>
 /// Unsets the dynmaic environment variables.
 /// </summary>
 /// <param name="self">Application profile.</param>
 public static void UnsetVariables(this IApplicationProfile self)
 {
     SharedFunctions.UnsetDynamicVariables();
 }
Example #12
0
 /// <summary>
 /// Sets the dynamic environment variables to match this application profile.
 /// </summary>
 /// <param name="self">Application profile.</param>
 public static void SetVariables(this IApplicationProfile self)
 {
     SharedFunctions.SetDynamicVarriables(self);
 }