Beispiel #1
0
        public EditorFile(
            IStorageGraph storage,
            FactorySet <IContainer> containerfactoryset,
            bool isnewfile = false
            )
        {
            this.storage             = storage;
            this.containerfactoryset = containerfactoryset;

            var obj = storage[storage.Root];

            containers =
                new BoundList <IContainer>(
                    storage.Root,
                    this,
                    containerfactoryset,
                    new ViewerSet <IContainer>()
                    );

            containers.Bind();

            if (isnewfile)
            {
                containers.CreateAllObjects();
            }
        }
Beispiel #2
0
 public static IOListener CreateListen_Node(
     this IStorageGraph graph,
     StorageObjectID subject,
     IOEvent verb,
     Action responder
     ) =>
 CreateListen_Node(
     graph,
     subject,
     verb,
     (key, @object) =>
     responder()
     );
Beispiel #3
0
 public static IOListener CreateListen_Node(
     this IStorageGraph graph,
     StorageObjectID subject,
     IOEvent verb,
     Action <string, StorageObjectID> childresponder
     ) =>
 new IOListener(
     new IOMessage(
         subject,
         verb
         ),
     message =>
     childresponder(message.Relation, message.Object)
     );
Beispiel #4
0
        public static void Transfer(
            this IStorageGraph source,
            IStorageGraph destination
            )
        {
            var translationIDmap =
                new Dictionary <StorageObjectID, StorageObjectID>();

            foreach (var oldobjID in source.ObjectIDs)
            {
                IStorageObject obj_source, obj_destination;

                if (oldobjID != source.Root)
                {
                    obj_source = source[oldobjID];

                    translationIDmap.Add(oldobjID, (obj_destination = destination.CreateObject()).ID);
                }
                else
                {
                    obj_source      = source[source.Root];
                    obj_destination = destination[destination.Root];

                    translationIDmap.Add(oldobjID, destination.Root);
                }

                using (var stream_src = obj_source.OpenRead()) {
                    using (var stream_dst = obj_destination.OpenWrite()) {
                        stream_src.CopyTo(stream_dst);
                    }
                }
            }

            foreach (var oldobjID in source.ObjectIDs)
            {
                var newobjID = translationIDmap[oldobjID];
                var newobj   = destination[newobjID];

                foreach (var outgoing in source.Outgoing(oldobjID))
                {
                    newobj.Add(outgoing.Key, translationIDmap[outgoing.Value]);
                }
            }
        }
Beispiel #5
0
 public static IOListener CreateListen(
     this IStorageGraph graph,
     Action <IOMessage> responder,
     StorageObjectID subject,
     IOEvent verb,
     StorageObjectID @object = default(StorageObjectID),
     string key    = default(string),
     string newkey = default(string)
     ) =>
 new IOListener(
     new IOMessage(
         subject,
         verb,
         key,
         newkey,
         @object
         ),
     responder
     );
Beispiel #6
0
        public void TestCreateGraph()
        {
            graph = new MemoryStorageGraph();
            var factoryset = new FactorySet <IContainer>();

            factoryset
            .Factories
            .Add(
                PolylineContainer.CreateFactory(
                    new FactorySet <PolylineData>(
                        PolylineData.FactoryInstance
                        ),
                    new ViewerSet <PolylineData>()
                    )
                );

            file = new EditorFile(graph, factoryset);

            obj1 = graph.CreateObject();
            obj2 = graph.CreateObject();
        }
Beispiel #7
0
 public static IStorageObject CreateObject(this IStorageGraph graph) =>
 graph[graph.Create()];
Beispiel #8
0
 public void CreateGraph_memory()
 {
     graph = new MemoryStorageGraph();
 }