Beispiel #1
0
        public Repository(params Assembly[] searchAssemblies)
        {
            mInstancePool = new JsonReferenceResolver();

            mSchema     = PersistedNode.GetSchema(searchAssemblies ?? new Assembly[0]);
            mConverters = PersistedNode.GetConverters(searchAssemblies ?? new Assembly[0]);
        }
Beispiel #2
0
        internal IconResolver([NotNull] ObjectDependencyGraph <PersistedNode> schema)
        {
            if (schema == null)
            {
                throw new ArgumentNullException(nameof(schema));
            }

            mSchema = schema;
            mStores = new List <IBlobStore>();
            mCache  = new Dictionary <StringKeySequence, ImageSource>();
        }
Beispiel #3
0
        public static ObjectDependencyGraph <PersistedNode> GetSchema(params Assembly[] searchAssemblies)
        {
            var schema = new ObjectDependencyGraph <PersistedNode>();

            var types =
                from assembly in searchAssemblies
                from type in assembly.GetTypes()

                where type.IsSubclassOf(typeof(Persistable))
                where !type.IsAbstract && !type.IsInterface

                select type;

            var composedTypeArray    = types.ToArray();
            var typeToInfoDictionary = new Dictionary <Type, PersistedNode>();

            foreach (var type in composedTypeArray)
            {
                var currentHierarchyLevel = type;
                var keyType = type;

                while (currentHierarchyLevel != null && currentHierarchyLevel != typeof(Persistable) && currentHierarchyLevel != typeof(object))
                {
                    if (currentHierarchyLevel.GetCustomAttribute <KeyClassAttribute>(false) != null)
                    {
                        keyType = currentHierarchyLevel;
                        break;
                    }

                    currentHierarchyLevel = currentHierarchyLevel.BaseType;
                }

                var info = typeToInfoDictionary.GetValueByKeyOrDefault(keyType);
                if (info == null)
                {
                    typeToInfoDictionary.Add(keyType, info = new PersistedNode(keyType));
                }

                var transientDependencies =
                    from property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic)
                    from dependency in GetTransientDependencies(property.PropertyType)
                    select dependency;

                info.ConcreteTypes.Add(type);

                foreach (var dependency in transientDependencies)
                {
                    info.Dependencies.Add(dependency);
                }

                schema.Register(info);
                typeToInfoDictionary.AddOrUpdate(keyType, info);
            }

            foreach (var type in typeToInfoDictionary.Keys)
            {
                var info           = typeToInfoDictionary[type];
                var dependencyNode = schema.Element(info);

                foreach (var dependency in info.Dependencies)
                {
                    var dependencyInfo = typeToInfoDictionary.GetValueByKeyOrDefault(dependency);
                    if (dependencyInfo == null || dependencyInfo.Key == dependency)
                    {
                        continue;
                    }

                    dependencyNode.DependsOn(dependencyInfo);
                }
            }

            return(schema);
        }
Beispiel #4
0
 public ProductionChain()
 {
     mGraph = new ObjectDependencyGraph <Good>();
 }
Beispiel #5
0
 public OperationSequence()
 {
     mRunningOperations = new List <IOperation>();
     mProgressInfos     = new Dictionary <IOperation, ProgressInfo>();
     mGraph             = new ObjectDependencyGraph <IOperation>();
 }
 internal ObjectDependencyGraphNode([NotNull] ObjectDependencyGraph <TBaseType> graph, [NotNull] TBaseType sourceNode) : base(graph, sourceNode)
 {
 }