Exemplo n.º 1
0
        /// <summary>
        /// Create inheritance chain for given definition.
        /// </summary>
        /// <param name="definition">Definition which chain is registered.</param>
        private void createChain(RuntimeTypeDefinition definition)
        {
            var subChains = definition.GetSubChains();
            var chain     = new InheritanceChain(definition.TypeInfo, subChains);

            registerChain(chain);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Register inheritance chain and all its subchains.
        /// </summary>
        /// <param name="chain">Registered chain.</param>
        private void registerChain(InheritanceChain chain)
        {
            _inheritanceChains[chain.Path.Signature] = chain;

            foreach (var subchain in chain.SubChains)
            {
                registerChain(subchain);
            }
        }
Exemplo n.º 3
0
    /// <summary>
    /// Updates the given Type inheritance tree info.
    /// </summary>
    /// <param name="type"></param>
    public void Update(Type type)
    {
        var element = new InheritanceChain(type).First;

        while (element.Next != null)
        {
            _inheritanceDictionary.AddOrUpdate(element.Value, (_) => AddValueFactory(element.Next.Value), (_, sdt) => UpdateValueFactory(element.Next.Value, sdt));
            element = element.Next;
        }
    }
Exemplo n.º 4
0
        public override InheritanceChain GetInheritanceChain(PathInfo typePath)
        {
            //informace o dědičnosti poskytujeme pouze
            //pro náš definovaný typ
            if (typePath.Signature == _declaringType.TypeName)
            {
                //definovaný typ je potomkem typu object
                InheritanceChain baseType = TypeServices.GetChain(TypeDescriptor.ObjectInfo);
                return(TypeServices.CreateChain(_declaringType, new[] { baseType }));
            }

            //dotaz se týkal typu, který nedefinujeme
            return(null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initialize important type systems definitions.
        /// </summary>
        private void initializeTypeSystemBase()
        {
            //null support
            var nullDefinition = new DirectTypeDefinition <Null>();

            nullDefinition.ForcedInfo = Null.TypeInfo;
            AddDirectDefinition(nullDefinition);

            //support for System.Object
            var chain = new InheritanceChain(TypeDescriptor.Create <object>(), new InheritanceChain[0]);

            _inheritanceChains.Add(chain.Path.Signature, chain);

            //support for Array
            var arrayDefinition = new DirectTypeDefinition(typeof(Array <>));

            arrayDefinition.ForcedInfo = TypeDescriptor.ArrayInfo;
            AddDirectDefinition(arrayDefinition);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the chain.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>InheritanceChain.</returns>
        internal InheritanceChain GetChain(Type type)
        {
            if (type == null)
            {
                return(null);
            }

            var path = new PathInfo(type);

            InheritanceChain existingChain;

            if (_inheritanceChains.TryGetValue(path.Signature, out existingChain))
            {
                return(existingChain);
            }

            //we have to create new chain
            var subChains = new List <InheritanceChain>();

            var baseChain = GetChain(type.BaseType);

            if (baseChain != null)
            {
                subChains.Add(baseChain);
            }

            foreach (var iface in type.GetInterfaces())
            {
                var subChain = GetChain(iface);
                if (subChain != null)
                {
                    subChains.Add(subChain);
                }
            }

            var info         = TypeDescriptor.Create(type);
            var createdChain = new InheritanceChain(info, subChains);

            _inheritanceChains.Add(createdChain.Path.Signature, createdChain);
            return(createdChain);
        }