Exemplo n.º 1
0
        //Load only assemblies by name
        private void LoadAssembly(string name, string assemblyPath)
        {
            try
            {
                AssemblyName assemblyName = new AssemblyName();
                assemblyName.CodeBase = assemblyPath;

                Assembly assembly = Assembly.Load(assemblyName);
                foreach (Type myType in assembly.GetTypes())
                {
                    if (myType.GetInterface(typeof(ITag).Name) != null)
                    {
                        ITag tag = (ITag)System.Activator.CreateInstance(myType);
                        if (GetTagName(myType) == name)
                        {
                            RegisterITag(name, tag);
                        }
                    }

                    if (myType.GetInterface(typeof(ISimpleFilter).Name) != null)
                    {
                        ISimpleFilter filter = (ISimpleFilter)System.Activator.CreateInstance(myType);
                        if (GetTagName(myType) == name)
                        {
                            RegisterISimpleFilter(GetTagName(myType), filter);
                        }
                    }
                }
            }
            catch (ReflectionTypeLoadException ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(ex.Message);
                for (int i = 0; i < ex.Types.Length; i++)
                {
                    if (ex.Types[i] != null)
                    {
                        sb.AppendFormat("\t{0} loaded\r\n", ex.Types[i].Name);
                    }
                }

                for (int i = 0; i < ex.LoaderExceptions.Length; i++)
                {
                    if (ex.LoaderExceptions[i] != null)
                    {
                        sb.AppendFormat("\texception {0}\r\n", ex.LoaderExceptions[i].Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Create instance by full assembly name
        private void CreateInstanceByAssemblyName(string AssemblyName)
        {
            try
            {
                Type type = Type.GetType(AssemblyName);
                if (type.GetInterface(typeof(ITag).Name) != null)
                {
                    ITag tag = (ITag)Activator.CreateInstance(type);
                    RegisterITag(GetTagName(type), tag);
                }
                else if (type.GetInterface(typeof(ISimpleFilter).Name) != null)
                {
                    ISimpleFilter filter = (ISimpleFilter)Activator.CreateInstance(type);
                    RegisterISimpleFilter(GetTagName(type), filter);
                }
            }
            catch (ReflectionTypeLoadException ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(ex.Message);
                for (int i = 0; i < ex.Types.Length; i++)
                {
                    if (ex.Types[i] != null)
                    {
                        sb.AppendFormat("\t{0} loaded\r\n", ex.Types[i].Name);
                    }
                }

                for (int i = 0; i < ex.LoaderExceptions.Length; i++)
                {
                    if (ex.LoaderExceptions[i] != null)
                    {
                        sb.AppendFormat("\texception {0}\r\n", ex.LoaderExceptions[i].Message);
                    }
                }
            }
        }
Exemplo n.º 3
0
 //Register Filter by Name
 private void RegisterISimpleFilter(string name, ISimpleFilter filter)
 {
     provider = provider.WithFilter(name, filter);
 }
Exemplo n.º 4
0
        protected virtual void ApplySimpleFilter <TSource>(WhereBuilder whereBuilder, ISimpleFilter filter)
        {
            var resolvedConditionOperator = ResolveConditionOperatorFrom(filter.Type);

            if (filter.CaseInsensitive == true)
            {
                filter.Path += ".ToLower()";
                filter.Value = $"{filter.Value}"?.ToLower();
            }

            whereBuilder.Compare(filter.Path, resolvedConditionOperator, filter.Value, and: filter.And == true, negate: filter.Not == true);
        }
Exemplo n.º 5
0
 //Register Filter by Name
 private void RegisterISimpleFilter(string name, ISimpleFilter filter)
 {
     provider = provider.WithFilter(name, filter);
 }
        protected virtual void ApplySimpleFilter <TSource>(WhereBuilder whereBuilder, ISimpleFilter filter)
        {
            var resolvedConditionOperator = ResolveConditionOperatorFrom(filter.Type);

            whereBuilder.Compare(filter.Path, resolvedConditionOperator, filter.Value, and: filter.And == true, negate: filter.Not == true);
        }