Breeze.PocoMetadata.EntityDescriptor.Replace C# (CSharp) Method

Replace() public method

Replace the given type wherever it appears in the metadata. Can be used to replace an interface with a class.
public Replace ( Type type, IEnumerable types ) : Type
type System.Type Type to replace
types IEnumerable List of available types provided to the PocoMetadataBuilder
return System.Type
        public virtual Type Replace(Type type, IEnumerable<Type> types)
        {
            return type;
        }

Usage Example

        /// <summary>
        /// Build the Breeze metadata as a nested Dictionary.
        /// The result can be converted to JSON and sent to the Breeze client.
        /// </summary>
        /// <param name="types">Entity metadata types to include in the metadata</param>
        /// <returns></returns>
        public Metadata BuildMetadata(IEnumerable <Type> types)
        {
            InitMap();
            _allTypes    = types.ToList();
            _types       = types.Select(t => _describer.Replace(t, types)).Distinct().Where(t => _describer.Include(t)).ToList();
            _entityTypes = _types.Where(t => !_describer.IsComplexType(t)).ToList();
            var navigations = new List <Dictionary <string, object> >();

            foreach (var t in _types)
            {
                // Add type with data properties
                AddType(t);
            }
            foreach (var t in _types)
            {
                // Add navigation properties
                var cmap     = _typeMap[t];
                var dataList = (List <Dictionary <string, object> >)cmap["dataProperties"];
                var navList  = new List <Dictionary <string, object> >();
                AddNavigationProperties(t, dataList, navList);
                if (navList.Any())
                {
                    cmap.Add("navigationProperties", navList);
                    navigations.AddRange(navList);
                }
            }

            // resolve associations into association names
            ResolveAssociations(navigations);

            if (_enumList.Any())
            {
                _map.Add("enumTypes", _enumList);
            }
            return(_map);
        }