Пример #1
0
        private IPropertyBag DoParse(Type t, TypeTreeParsingContext context)
        {
            if (_propertyBagCache.ContainsKey(t))
            {
                return(_propertyBagCache[t]);
            }

            Dictionary <string, IStructProperty <StructProxy> > properties = new Dictionary <string, IStructProperty <StructProxy> >()
            {
                { ComponentIdProperty.Name, ComponentIdProperty }
            };

            foreach (var member in new TypeFieldIterator(t).Get(
                         TypeFieldIterator.Specifier.Public | TypeFieldIterator.Specifier.ValueType))
            {
                IStructProperty <StructProxy> property = VisitType(member, new TypeTreeParsingContext()
                {
                    Offset = context.Offset + member.GetOffset()
                });
                if (!properties.ContainsKey(property.Name))
                {
                    properties[property.Name] = property;
                }
            }

            foreach (var member in new TypePropertyIterator(t).Get(
                         TypePropertyIterator.Specifier.Public | TypePropertyIterator.Specifier.ValueType))
            {
                try
                {
                    IStructProperty <StructProxy> property = VisitType(member, new TypeTreeParsingContext()
                    {
                        Offset = context.Offset
                    });

                    // TODO Unknown types: GameObjects, etc
                    if (property != null)
                    {
                        if (!properties.ContainsKey(property.Name))
                        {
                            properties[property.Name] = property;
                        }
                    }
                }
                catch (Exception)
                { }
            }

            _propertyBagCache[t] = new StructPropertyBag <StructProxy>(properties.Values.ToList());

            return(_propertyBagCache[t]);
        }
Пример #2
0
        private void AddPropertiesFromIterator(
            IEnumerable <ITypedMemberDescriptor> members,
            TypeTreeParsingContext context,
            Dictionary <string, IStructProperty <StructProxy> > properties)
        {
            foreach (var member in members)
            {
                try
                {
                    IStructProperty <StructProxy> property =
                        VisitType(member, new TypeTreeParsingContext()
                    {
                        Offset = context.Offset + member.GetOffset()
                    });

                    if (property != null && !properties.ContainsKey(property.Name))
                    {
                        properties[property.Name] = property;
                    }
                }
                catch (Exception)
                { }
            }
        }