Пример #1
0
        public async Task <IActionResult> Post([FromBody] AddProductInputModel input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(GetErrorListFromModelState.GetErrorList(ModelState)));
            }
            if (!TypesManager.checkStatus(input.Type))
            {
                return(BadRequest(new { errors = new { Type = ErrorConst.InvalidType } }));
            }
            var product = new Product
            {
                Name        = input.Name,
                Description = input.Description,
                Type        = input.Type,
                OwnerId     = input.OwnerId
            };

            _context.Products.Add(product);
            try
            {
                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(GetCatchExceptionErrors.getErrors(this, ex));
            }
        }
Пример #2
0
 /// <summary>
 /// Configures the mappers.
 /// </summary>
 /// <param name="document">The document.</param>
 public static void ConfigureMappers(XmlDocument document)
 {
     Mapper.Configuration.DisableConstructorMapping();
     if (document != null)
     {
         foreach (XmlNode node in document.SelectNodes("configuration/mappers/mapper"))
         {
             NodeAttributes attributes     = new NodeAttributes(node);
             Type           sourceType     = TypesManager.ResolveType(attributes.AsString("source"));
             Type           targetType     = TypesManager.ResolveType(attributes.AsString("target"));
             bool           defaultMapping = attributes.AsBool("defaultMapping", true);
             if ((sourceType != null) && (targetType != null))
             {
                 // TODO: Add mappers using Automapper.
                 //IMapper mapper = ObjectProxyFactory.NewMapper(sourceType, targetType);
                 //if (defaultMapping)
                 //{
                 //    mapper.DefaultMap();
                 //}
                 //foreach (XmlNode mapNode in node.SelectNodes("mappings/mapping"))
                 //{
                 //    NodeAttributes mapAttributes = new NodeAttributes(mapNode);
                 //    mapper.Map(mapAttributes.AsString("source"), mapAttributes.AsString("target"));
                 //}
             }
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Finds the entity type given the entity name in the telerik metamodel.
 /// </summary>
 /// <param name="entityName">Name of the entity.</param>
 /// <returns></returns>
 public Type FindEntityTypeInMetamodel(string entityName)
 {
     if (this.typeMetatables.ContainsKey(entityName.ToLower()))
     {
         string fullName = this.typeMetatables[entityName.ToLower()].FullName;
         return(TypesManager.ResolveType(fullName));
     }
     return(null);
 }
Пример #4
0
        public GraphContext(DriverProvider provider, TypesManager typesManager, ChangeTrackerBase changeTracker, EntityManagerBase entityManager)
            : base(typesManager, changeTracker, entityManager)
        {
            Driver = new ManagedDriver(provider.GetDriver(), provider.Manager, this);

            OnModelCreating(new GraphModelBuilder(typesManager));

            Runner = Driver.Session();
        }
Пример #5
0
        /// <summary>
        /// Processes the type if it's a DTO
        /// </summary>
        /// <param name="type">The type.</param>
        private void ProcessDto(Type type)
        {
            DtoAttribute dtoAttribute = AttributeUtil.GetAttributeFrom <DtoAttribute>(type);

            if (dtoAttribute != null)
            {
                Type entityType = null;
                if (dtoAttribute.EntityType != null)
                {
                    entityType = dtoAttribute.EntityType;
                }
                else
                {
                    string entityName = dtoAttribute.EntityName;
                    if (string.IsNullOrEmpty(entityName))
                    {
                        entityName = this.GetEntityName(type.Name);
                    }
                    entityType = TypesManager.ResolveType(entityName);
                    if (entityType == null)
                    {
                        if (this.typeMetatables.ContainsKey(entityName.ToLower()))
                        {
                            entityName = this.typeMetatables[entityName.ToLower()].FullName;
                            entityType = TypesManager.ResolveType(entityName);
                        }
                    }
                }
                if (entityType != null)
                {
                    IMetamodelEntity metaEntity = this.Parent.MetamodelManager.RegisterEntity(entityType, type);
                    if (this.Metatables.ContainsKey(entityType.FullName))
                    {
                        MetaPersistentType metaType = this.Metatables[entityType.FullName];
                        Dictionary <MetaColumn, MetaMember> mapColumns = new Dictionary <MetaColumn, MetaMember>();
                        foreach (MetaMember member in metaType.Members)
                        {
                            MetaPrimitiveMember primitiveMember = member as MetaPrimitiveMember;
                            if (primitiveMember != null)
                            {
                                mapColumns.Add(primitiveMember.Column, member);
                            }
                        }
                        MetaTable metaTable = metaType.Table;
                        foreach (MetaColumn metaColumn in metaTable.Columns)
                        {
                            MetaMember member = mapColumns[metaColumn];
                            metaEntity.AddField(member.Name, metaColumn.IsPrimaryKey, !metaColumn.IsPrimaryKey);
                        }
                    }
                }
            }
        }
Пример #6
0
        private void TypeForm_Load(object sender, EventArgs e)
        {
            //Getting a list of Types from DAL (TypesManager)
            List <Type> Types = TypesManager.GetTypeList();

            //List<Country> Countries = CountryManager.GetCountryList();
            //List<Currency> Currencies = CurrenciesDAL.CurrencyManager.GetCurrencyList();

            ////Put the data into the list box
            TypeListBox.DataSource    = Types;
            TypeListBox.DisplayMember = "Name";
        }
Пример #7
0
        /// <summary>
        /// Processes a type if its a BO
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        private void ProcessBO(Type type, Dictionary <string, Type> dtoMap)
        {
            BOAttribute boAttribute = AttributeUtil.GetAttributeFrom <BOAttribute>(type);

            if (boAttribute == null)
            {
                return;
            }
            if (boAttribute.DtoType != null)
            {
                this.Parent.BOManager.AddBOType(boAttribute.DtoType, type);
                return;
            }
            string name = string.IsNullOrEmpty(boAttribute.Name) ? type.Name : boAttribute.Name;

            if (name.IndexOf('.') > -1)
            {
                Type dtoType = TypesManager.ResolveType(name);
                if (dtoType != null)
                {
                    this.Parent.BOManager.AddBOType(dtoType, type);
                }
                return;
            }
            if (dtoMap.ContainsKey(name))
            {
                this.Parent.BOManager.AddBOType(dtoMap[name], type);
                return;
            }
            string testname = this.DtoPreffix + name + this.DtoSuffix;

            if (dtoMap.ContainsKey(testname))
            {
                this.Parent.BOManager.AddBOType(dtoMap[testname], type);
                return;
            }
            testname = name;
            testname = this.RemovePreffix(testname, this.BOPreffix);
            testname = this.RemoveSuffix(testname, this.BOSuffix);
            if (dtoMap.ContainsKey(testname))
            {
                this.Parent.BOManager.AddBOType(dtoMap[testname], type);
                return;
            }
            testname = this.DtoPreffix + testname + this.DtoSuffix;
            if (dtoMap.ContainsKey(testname))
            {
                this.Parent.BOManager.AddBOType(dtoMap[testname], type);
                return;
            }
        }
Пример #8
0
        public void LoadLevel()
        {
            try
            {
                if (this.Data == "-1" || this.Data == "")
                {
                    return;
                }
                string[] data = this.Data.Split(',');

                StringEffects       = data[0];
                StringCriticEffects = data[1];

                this.APCost = 6;
                if (TypesManager.IsNumeric(data[2]))
                {
                    this.APCost = int.Parse(data[2]);
                }

                this.MinPO  = int.Parse(data[3]);
                this.MaxPO  = int.Parse(data[4]);
                this.TauxCC = int.Parse(data[5]);
                this.TauxEC = int.Parse(data[6]);

                this.InLine         = bool.Parse(data[7].Trim());
                this.NeedVisibility = bool.Parse(data[8].Trim());
                this.NeedEmptyCell  = bool.Parse(data[9].Trim());
                this.AllowPOBoost   = bool.Parse(data[10].Trim());

                this.MaxPerTurn   = int.Parse(data[12]);
                this.MaxPerPlayer = int.Parse(data[13]);
                this.TurnNumber   = int.Parse(data[14]);
                this.Range        = data[15].Trim();
                try
                {
                    this.IsECEndTurn = bool.Parse(data[19].Trim());
                }
                catch (Exception e)
                {
                }
            }
            catch (Exception e)
            {
                Logger.Error("Cant load level '" + this.Level + "' for spell '" + this.SpellCache.Name + "'" + e.ToString());
            }
        }
Пример #9
0
        public static void Initialize()
        {
            var types = TypesManager.GetTypes(typeof(AdminCommand));

            foreach (var command in types)
            {
                try
                {
                    AdminCommand instance = (AdminCommand)Activator.CreateInstance(command);
                    if (instance.NeedLoaded)
                    {
                        m_commands.Add(instance.Prefix, instance);
                    }
                }
                catch { }
            }
            Logger.Info("@AdminCommands@ initialized");
        }
Пример #10
0
        private void SaveTypeButton_Click(object sender, EventArgs e)
        {
            if (TypeIDTextBox.Text == string.Empty)
            {
                Type t = new Type();
                t.Name = NameTextBox.Text;

                Type savedType = TypesManager.AddType(t);

                MessageBox.Show("A new Type has been added.");

                //refresh the value in the list
                List <Type> typeList = TypesManager.GetTypeList();
                TypeListBox.DataSource = typeList;

                //re-select the chosen type
                SelectTypeFromListBox(savedType.Id);
            }
            else
            {
                //Update existing type entry
                int    typeId   = int.Parse(TypeIDTextBox.Text);
                string typeName = NameTextBox.Text;


                if (TypesManager.UpdateType(typeId, typeName) == 1)
                {
                    //update is successful
                    MessageBox.Show("Type has been updated.");

                    //Get the list of types, and refresh the list box
                    //Re-select the value in the list box
                    List <Type> typeList = TypesManager.GetTypeList();
                    TypeListBox.DataSource = typeList;
                }
                else
                {
                    MessageBox.Show("Type has NOT been updated.");
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Configures the security manager.
        /// </summary>
        /// <param name="document">The document.</param>
        private static void ConfigureSecurityManager(XmlDocument document)
        {
            ISecurityManager securityManager = null;
            XmlNode          securityNode    = document.SelectSingleNode("configuration/security");

            if (securityNode != null)
            {
                NodeAttributes securityAttributes = new NodeAttributes(securityNode);
                if (!string.IsNullOrEmpty(securityAttributes.AsString("sessionManager")))
                {
                    Type sessionManagerType = TypesManager.ResolveType(securityAttributes.AsString("sessionManager"));
                    if (sessionManagerType != null)
                    {
                        ISessionManager sessionManager = (ISessionManager)Activator.CreateInstance(sessionManagerType);
                        IoC.Register <ISessionManager>(sessionManager);
                    }
                }
                if (!string.IsNullOrEmpty(securityAttributes.AsString("auditManager")))
                {
                    Type auditManagerType = TypesManager.ResolveType(securityAttributes.AsString("auditManager"));
                    if (auditManagerType != null)
                    {
                        IAuditManager auditManager = (IAuditManager)Activator.CreateInstance(auditManagerType);
                        IoC.Register <IAuditManager>(auditManager);
                    }
                }
                if (!string.IsNullOrEmpty(securityAttributes.AsString("securityManager")))
                {
                    Type securityManagerType = TypesManager.ResolveType(securityAttributes.AsString("securityManager"));
                    if (securityManagerType != null)
                    {
                        securityManager = (ISecurityManager)Activator.CreateInstance(securityManagerType);
                        IoC.Register <ISecurityManager>(securityManager);
                        string mappersName = securityAttributes.AsString("mapper");
                        securityManager.Configure(mappersName);
                    }
                }
            }
        }
Пример #12
0
        internal GraphContextBase(TypesManager typesManager, ChangeTrackerBase changeTracker, EntityManagerBase entityManager)
        {
            TypesManager  = typesManager ?? throw new ArgumentNullException(nameof(typesManager));
            ChangeTracker = changeTracker ?? throw new ArgumentNullException(nameof(changeTracker));
            EntityManager = entityManager ?? throw new ArgumentNullException(nameof(entityManager));

            Interceptors = new List <IInterceptor>();
            Interceptors.Add(new OgmCoreProxyPrimitiveInterceptor(this));
            Interceptors.Add(new OgmCoreProxyEntityInterceptor(this));
            Interceptors.Add(new OgmCoreProxyEntityCollectionSetterInterceptor(this));
            Interceptors.Add(new OgmCoreProxyEntityCollectionGetterInterceptor(this));

            ProxyGenerationOptions options = new ProxyGenerationOptions()
            {
                Selector = new OgmCoreProxyInterceptorSelector(this)
            };

            options.AddMixinInstance(new Dictionary <string, object>());
            ProxyGenerator = new ProxyGenerator();

            ObjectWalker = new ObjectGraphWalker(ProxyGenerator, options, typesManager, changeTracker, Interceptors);
        }
Пример #13
0
        private void DeleteTypeButton_Click(object sender, EventArgs e)
        {
            int typeId       = int.Parse(TypeIDTextBox.Text);   //parse from int to string
            int rowsAffected = TypesManager.DeleteType(typeId); //check for # rows affected

            if (rowsAffected == 1)
            {
                MessageBox.Show(
                    "Type deleted.",
                    "Deleted",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(
                    "Unable to delete type.",
                    "Unable to delete.",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            //refresh the list with the updated information
            TypeListBox.DataSource = TypesManager.GetTypeList();
        }
Пример #14
0
        public async Task <IActionResult> Put([FromBody] EditProductInputModel input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(GetErrorListFromModelState.GetErrorList(ModelState)));
            }
            if (!TypesManager.checkStatus(input.Type))
            {
                return(BadRequest(new { errors = new { Type = ErrorConst.InvalidType } }));
            }

            var product = _context.Products.Where(i => i.Id == input.Id).FirstOrDefault();

            if (product != null)
            {
                try
                {
                    product.Name        = input.Name;
                    product.Description = input.Description;
                    product.Type        = input.Type;
                    product.OwnerId     = input.OwnerId;
                    _context.Products.Update(product);
                    await _context.SaveChangesAsync();

                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(GetCatchExceptionErrors.getErrors(this, ex));
                }
            }
            else
            {
                return(BadRequest(new { errors = new { Id = ErrorConst.NO_ITEM } }));
            }
        }
Пример #15
0
 public GraphContextBase(IStatementRunner runner, TypesManager typesManager, ChangeTrackerBase changeTracker, EntityManagerBase entityManager)
     : this(typesManager, changeTracker, entityManager)
 {
     Runner = runner ?? throw new ArgumentNullException(nameof(runner));
 }
Пример #16
0
        public ObjectGraphWalker(ProxyGenerator proxyGenerator, ProxyGenerationOptions proxyGenerationOptions, TypesManager typesManager, ChangeTrackerBase changeTracker, IEnumerable <IInterceptor> interceptors)
        {
            ProxyGenerator         = proxyGenerator ?? throw new ArgumentNullException(nameof(proxyGenerator));
            ProxyGenerationOptions = proxyGenerationOptions ?? throw new ArgumentNullException(nameof(proxyGenerationOptions));
            TypesManager           = typesManager ?? throw new ArgumentNullException(nameof(typesManager));
            ChangeTracker          = changeTracker ?? throw new ArgumentNullException(nameof(changeTracker));

            Interceptors = interceptors?.ToList() ?? throw new ArgumentNullException(nameof(interceptors));
        }
Пример #17
0
        static void Main(string[] args)
        {
            #region "GET ALL"

            #region "GET ALL Currencies TEST"

            List <Currency> currenciesList = CurrencyManager.GetCurrencyList();
            Console.WriteLine("List of currencies: " + "\n");

            foreach (Currency currency in currenciesList)
            {
                Console.WriteLine(currency.Name);
            }

            #endregion
            #region "GET ALL Colours TEST"

            List <Colour> coloursList = ColoursManager.GetColourList();
            Console.WriteLine("\nList of colours: ");

            foreach (Colour colour in coloursList)
            {
                Console.WriteLine(colour.Name);
            }

            #endregion
            #region "GET ALL Country TEST"
            List <Country> countriesList = CountryManager.GetCountryList();
            Console.WriteLine("\nList of countries: ");

            foreach (Country country in countriesList)
            {
                Console.WriteLine(country.Name);
            }
            #endregion
            #region "GET ALL Types TEST"
            List <Type> typesList = TypesManager.GetTypeList();
            Console.WriteLine("\nList of types: ");

            foreach (Type type in typesList)
            {
                Console.WriteLine(type.Name);
            }

            #endregion
            #endregion
            #region "GET ONE"
            #region "GET ONE Currency by ID TEST"
            Console.Write("\nEnter a currency ID: ");
            string getCurrencyId = Console.ReadLine();

            Currency getCurrencyById = CurrencyManager.GetCurrency(int.Parse(getCurrencyId));

            if (getCurrencyById != null)
            {
                Console.WriteLine(getCurrencyById.Name);
            }
            else
            {
                Console.WriteLine("Sorry, currency ID cannot be found.");
            }
            #endregion
            #region "GET ONE Colours by ID TEST"

            Console.Write("\nEnter a Colour ID: ");
            string getColourId = Console.ReadLine();

            Colour getColourById = ColoursManager.GetColour(int.Parse((getColourId)));

            if (getColourById != null)
            {
                Console.WriteLine(getColourById.Name);
            }
            else
            {
                Console.WriteLine("Sorry, the colour ID cannot be found.");
            }
            #endregion
            #region "GET ONE Country by ID TEST"

            Console.Write("\nEnter a country Code: ");
            string getCountryCode = Console.ReadLine();

            Country getCountryByCode = CountryManager.GetCountry(getCountryCode);

            if (getCountryByCode != null)
            {
                Console.WriteLine(getCountryByCode.Name);
            }
            else
            {
                Console.WriteLine("Sorry, the country code cannot be found.");
            }
            #endregion
            #region "GET ONE Type by ID TEST"

            Console.Write("\nEnter a type ID: ");
            string getTypeId = Console.ReadLine();

            Type getTypeById = TypesManager.GetTypes(int.Parse((getTypeId)));

            if (getTypeById != null)
            {
                Console.WriteLine(getTypeById.Name);
            }
            else
            {
                Console.WriteLine("Sorry, the type ID cannot be found.");
            }

            #endregion
            #endregion

            #region "ADD"

            /*
             #region "ADD Currency TEST"
             * Currency addCurrency = new Currency();
             * addCurrency.Name = "Japanese Yen";
             *
             * Currency addCurrencyTwo = CurrencyManager.AddCurrency(addCurrency);
             * Console.WriteLine(string.Format("The new Currency ID is {0}", addCurrency.Id));
             */
            #region "ADD Colour TEST"
            Colour addColour = new Colour();
            addColour.Id   = 20;
            addColour.Name = "Blue";

            Colour addColourTwo = ColoursManager.AddColour(addColour);
            Console.WriteLine(string.Format("The new Colour Id is {0}", addColourTwo.Id));
            #endregion

            #region "ADD Country TEST"
            #endregion

            #region "ADD Type TEST"
            #endregion

            #endregion

            #region "UPDATE"

            /*
             #region "UPDATE Currency TEST"
             * Currency updateCurrency = new Currency();
             * updateCurrency.Id = 3;
             * updateCurrency.Name = "Japanese Yen";
             * updateCurrency.ColourId = 4;
             * updateCurrency.CountryCode = "JPN";
             *
             * int rowsAffected = CurrencyManager.UpdateCurrency(updateCurrency);
             * Console.WriteLine("Update successful! {0} rows affected", rowsAffected);
             *
             #endregion
             */

            #region "UPDATE Colours TEST"
            Colour updateColours = new Colour();
            updateColours.Id   = 2;
            updateColours.Name = "Blue";

            //int colourRowsAffected = ColoursManager.UpdateColour(updateColours);
            //Console.WriteLine("Update successful! {0} rows affected", colourRowsAffected);

            #endregion

            #region "UPDATE Countries TEST"
            Country updateCountries = new Country();
            updateCountries.CountryCode = "GRE";
            updateCountries.Name        = "Greece Updated";

            //string countryRowsAffected = CountryManager.UpdateCountry(updateCountries);
            //Console.WriteLine("Update successful! {0} rows affected", countryRowsAffected);
            #endregion

            #region "UPDATE Types TEST"
            Type updateTypes = new Type();
            updateTypes.Id   = 2;
            updateTypes.Name = "Crypto";

            //int typeRowsAffected = TypesManager.UpdateType(updateTypes);
            //Console.WriteLine("Update successful! {0} rows affected", typeRowsAffected);

            #endregion
            #endregion

            #region "DELETE"

            #region "DELETE Currency TEST"
            Console.Write("\nPlease enter the Currency Id you wish to delete: ");
            string deleteCurrencyId = Console.ReadLine();
            CurrencyManager.DeleteCurrency(Int32.Parse(deleteCurrencyId));

            if (deleteCurrencyId != null)
            {
                Console.WriteLine(string.Format("\nCurrency Id {0} has been deleted.", deleteCurrencyId));
            }
            else
            {
                Console.WriteLine("Sorry, the currency ID cannot be deleted.");
            }
            #endregion

            #region "DELETE Colours TEST"
            Console.Write("\nPlease enter the Colour Id you wish to delete: ");
            string deleteColourId = Console.ReadLine();
            ColoursManager.DeleteColour(Int32.Parse(deleteColourId));

            if (deleteColourId != null)
            {
                Console.WriteLine(string.Format("\nColour Id {0} has been deleted.", deleteColourId));
            }
            else
            {
                Console.WriteLine("Sorry, the colour ID cannot be deleted.");
            }

            #endregion

            #region "DELETE Countries TEST"
            Console.Write("\nPlease enter the Country Code you wish to delete: ");
            string deleteCountryCode = Console.ReadLine();
            CountryManager.DeleteCountry(deleteCountryCode);

            if (deleteCountryCode != null)
            {
                Console.WriteLine("\nCountry Code {0} has been deleted.", deleteCountryCode);
            }
            else
            {
                Console.WriteLine("Sorry, the country code cannot be deleted.");
            }
            #endregion

            #region "DELETE Types TEST"
            Console.Write("\nPlease enter the Type Id you wish to delete: ");
            string deleteTypeId = Console.ReadLine();
            TypesManager.DeleteType(Int32.Parse(deleteTypeId));

            if (deleteTypeId != null)
            {
                Console.WriteLine(string.Format("\n Type Id {0} has been deleted.", deleteTypeId));
            }
            else
            {
                Console.WriteLine("Sorry, the type ID cannot be deleted.");
            }
            Console.WriteLine("");
            Console.WriteLine("Press any key to close...");
            Console.Read(); //keep console window open
            #endregion

            #endregion
        }
Пример #18
0
        public IOgmEntity Visit(IOgmEntity entity)
        {
            while ((entity as IDictionary <string, object>) != null && (entity as IDictionary <string, object>)["000_ChangeTracker"] != ChangeTracker)
            {
                entity = (entity as IProxyTargetAccessor)?.DynProxyGetTarget() as IOgmEntity;
            }

            if (entity == null)
            {
                return(entity);
            }
            if (entity is IProxyTargetAccessor)
            {
                return(entity);
            }
            else
            {
                using (ManagerAccess.Manager.ScopeOMnG())
                {
                    IOgmEntity result = (IOgmEntity)ProxyGenerator.CreateClassProxyWithTarget(entity.GetType(), entity, ProxyGenerationOptions, Interceptors.ToArray());

                    (result as IDictionary <string, object>).Add("000_ChangeTracker", ChangeTracker);

                    if (entity.EntityId == null)
                    {
                        ChangeTracker.Track(new EntityChangeNodeCreation(entity));
                    }

                    foreach (PropertyInfo pinfo in entity.GetType().GetProperties()
                             .Where(p => !ObjectExtensions.IsPrimitive(p.PropertyType) && TypesManager.IsGraphProperty(p))
                             .Where(p => !TypesManager.KnownTypes.ContainsKey(p.ReflectedType) || !TypesManager.KnownTypes[p.ReflectedType].IgnoredProperties.Contains(p)))
                    {
                        object obj = ObjectExtensions.Configuration.Get(pinfo, entity);

                        IEnumerable collection = obj as IEnumerable;
                        if (collection != null)
                        {
                            if (!ManagedCollections.ContainsKey(obj.GetType().GetGenericArguments()[0]))
                            {
                                ManagedCollections.Add(
                                    obj.GetType().GetGenericArguments()[0],
                                    GetType().GetMethod(nameof(ManageCollection), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod).MakeGenericMethod(obj.GetType().GetGenericArguments()[0]));
                            }

                            ManagedCollections[obj.GetType().GetGenericArguments()[0]].Invoke(this, new[] { obj });
                        }
                        else
                        {
                            ObjectExtensions.Configuration.Set(pinfo, entity, Visit(obj as IOgmEntity));
                        }
                    }

                    return(result);
                }
            }
        }
Пример #19
0
 public TransactionGraphContext(ITransaction runner, TypesManager typesManager, ChangeTrackerBase changeTracker, EntityManagerBase entityManager)
     : base(runner, typesManager, changeTracker, entityManager)
 {
 }
Пример #20
0
        /// <summary>
        /// Try to get the DTO type from the parameters. If the DTO is not found, but an entity type is found, then clone the entity type to create a new DTO type..
        /// </summary>
        /// <param name="dtoTypeName">Name of the dto type.</param>
        /// <param name="dtoName">Name of the dto.</param>
        /// <param name="path">The path.</param>
        /// <param name="entityName">Name of the entity.</param>
        /// <param name="entityTypeName">Name of the entity type.</param>
        /// <returns></returns>
        private static Type GetDtoType(string dtoTypeName, string dtoName, string path, string entityName, string entityTypeName)
        {
            Type result     = null;
            Type entityType = null;

            // Search by type name
            if (!string.IsNullOrEmpty(dtoTypeName))
            {
                result = TypesManager.ResolveType(dtoTypeName);
                if (result != null)
                {
                    return(result);
                }
            }
            ISecurityManager securityManager = IoC.Get <ISecurityManager>();

            // Search by dto name
            if (!string.IsNullOrEmpty(dtoTypeName))
            {
                IMetamodelEntity metamodelEntity = securityManager.MetamodelManager.GetEntityByDtoName(dtoName);
                if (metamodelEntity != null)
                {
                    foreach (Type type in metamodelEntity.DtoTypes)
                    {
                        if (dtoName.ToLower().Equals(type.Name.ToLower()))
                        {
                            return(type);
                        }
                    }
                }
            }
            // search by entity name
            if (!string.IsNullOrEmpty(entityName))
            {
                IMetamodelEntity metamodelEntity = securityManager.MetamodelManager.GetEntityByName(entityName);
                if (metamodelEntity != null)
                {
                    if (metamodelEntity.DtoTypes.Count > 0)
                    {
                        return(metamodelEntity.DtoTypes[0]);
                    }
                    else
                    {
                        entityType = metamodelEntity.EntityType;
                    }
                }
            }
            // search by entity type
            if ((!string.IsNullOrEmpty(entityTypeName)) && (entityType == null))
            {
                entityType = TypesManager.ResolveType(entityTypeName);
                if (entityType != null)
                {
                    IMetamodelEntity metamodelEntity = securityManager.MetamodelManager.GetEntity(entityType);
                    if ((metamodelEntity != null) && (metamodelEntity.DtoTypes.Count > 0))
                    {
                        return(metamodelEntity.DtoTypes[0]);
                    }
                }
            }
            // If not found in own metamodel, because is not loaded into the system... but we can get the entity type by name from the telerik metamodel?
            if ((entityType == null) && (!string.IsNullOrEmpty(entityName)))
            {
                entityType = securityManager.Scanner.FindEntityTypeInMetamodel(entityName);
            }
            if ((entityType == null) && (!string.IsNullOrEmpty(path)))
            {
                entityType = securityManager.Scanner.FindEntityTypeInMetamodel(path);
            }
            if (entityType == null)
            {
                return(null);
            }
            result = TypeBuilderHelper.CloneCommonType(entityType, AppDomain.CurrentDomain, "Supido.Business.Dto", "SupidoDynamicModule", entityType.Name + "Dto");
            securityManager.Scanner.ProcessDynamicDto(result, entityType);
            return(result);
        }
Пример #21
0
 public GlobalTestContext(DriverProvider <GlobalTestContext> provider, TypesManager typesManager, ChangeTrackerBase changeTracker, EntityManagerBase entityManager)
     : base(provider, typesManager, changeTracker, entityManager)
 {
 }
Пример #22
0
 public MockContext(DriverProvider provider, TypesManager typesManager, ChangeTrackerBase changeTracker, EntityManagerBase entityManager)
     : base(provider, typesManager, changeTracker, entityManager)
 {
 }