コード例 #1
0
        private void Initialize()
        {
            foreach (var typeId in typesService.GetRegisteredTypes())
            {
                if (!typesService.IsScalarType(typeId))
                {
                    var type = typesService.GetTypeFromId(typeId);

                    var rule = new TypeMergeRule();

                    Type collectionType = null;
                    Type dictionaryType = null;

                    if (!Utils.IsCollectionType(type, ref collectionType) &&
                        !Utils.IsDictionaryType(type, ref dictionaryType))
                    {
                        var attributes = type.GetCustomAttributes(typeof(ConcurrentAttribute), true);

                        if (attributes.Length == 1)
                        {
                            rule.IsConcurrent        = true;
                            rule.IsStaticConcurrency = ((ConcurrentAttribute)attributes[0]).Behavior == ConcurrentBehavior.Static;
                            if (!rule.IsStaticConcurrency)
                            {
                                rule.DynamicResolverType = ((ConcurrentAttribute)attributes[0]).Resolver;
                            }
                            else
                            {
                                foreach (var edge in typesService.GetTypeEdges(typeId))
                                {
                                    if (edge.Data.Semantic == Graph.EdgeType.Property)
                                    {
                                        var memberId = edge.ToNodeId;
                                        //var memberTypeId = typesService.GetMemberTypeId(memberId);
                                        var memberName = typesService.GetMemberName(typeId, memberId);

                                        PropertyInfo propertyInfo = FindPropertyInfo(type, memberName);

                                        bool isOverride = propertyInfo.GetCustomAttributes(typeof(OverrideAttribute), false).Length == 1;

                                        rule.IsMemberOverride.Add(memberId, isOverride);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        rule.IsConcurrent        = true;
                        rule.IsStaticConcurrency = true;
                    }

                    // Add rule for the type in cache
                    typeMergeRules.Add(typeId, rule);
                }
            }
        }
コード例 #2
0
        private void Initialize()
        {
            foreach (var typeId in typesService.GetRegisteredTypes())
            {
                if (!typesService.IsScalarType(typeId))
                {
                    var type = typesService.GetTypeFromId(typeId);

                    var rule = new TypeMergeRule();

                    Type collectionType = null;
                    Type dictionaryType = null;

                    if (!Utils.IsCollectionType(type, ref collectionType) &&
                        !Utils.IsDictionaryType(type, ref dictionaryType))
                    {
                        var attributes = type.GetCustomAttributes(typeof(ConcurrentAttribute), true);

                        if (attributes.Length == 1)
                        {
                            rule.IsConcurrent = true;
                            rule.IsStaticConcurrency = ((ConcurrentAttribute)attributes[0]).Behavior == ConcurrentBehavior.Static;
                            if (!rule.IsStaticConcurrency)
                            {
                                rule.DynamicResolverType = ((ConcurrentAttribute)attributes[0]).Resolver;
                            }
                            else
                            {
                                foreach (var edge in typesService.GetTypeEdges(typeId))
                                {
                                    if (edge.Data.Semantic == Graph.EdgeType.Property)
                                    {
                                        var memberId = edge.ToNodeId;
                                        //var memberTypeId = typesService.GetMemberTypeId(memberId);
                                        var memberName = typesService.GetMemberName(typeId, memberId);

                                        PropertyInfo propertyInfo = FindPropertyInfo(type, memberName);

                                        bool isOverride = propertyInfo.GetCustomAttributes(typeof(OverrideAttribute), false).Length == 1;

                                        rule.IsMemberOverride.Add(memberId, isOverride);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        rule.IsConcurrent = true;
                        rule.IsStaticConcurrency = true;
                    }

                    // Add rule for the type in cache
                    typeMergeRules.Add(typeId, rule);
                }
            }
        }