annotate api/Objects/WarFoundryStagedLoadingObject.cs @ 256:958ecd7b2844

Re #270: Add multiple categories to API * Add Categories property * Add method to add Category * Tie up Categories with MainCategory for default behaviour
author IBBoard <dev@ibboard.co.uk>
date Mon, 17 May 2010 20:03:05 +0000
parents 2f3cafb69799
children 6cb0fb78b9a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 35
diff changeset
1 // This file (WarFoundryStagedLoadingObject.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 35
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.IO;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Factories;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class WarFoundryStagedLoadingObject : WarFoundryObject, IWarFoundryStagedLoadObject
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 private bool isFullyLoaded;
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
14 private bool isLoading;
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 private IWarFoundryFactory creatingFactory;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 private FileInfo sourceFile;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 protected WarFoundryStagedLoadingObject(IWarFoundryFactory creatingFactory) : this (null, creatingFactory)
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 protected WarFoundryStagedLoadingObject(string objName, IWarFoundryFactory creatingFactory) : this(null, objName, creatingFactory)
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 protected WarFoundryStagedLoadingObject(string objId, string objName, IWarFoundryFactory creatingFactory) : base(objId, objName)
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 this.creatingFactory = creatingFactory;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 isFullyLoaded = false;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 public FileInfo SourceFile
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 get { return sourceFile; }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 set { sourceFile = value; }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 public void EnsureFullyLoaded ()
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 {
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
40 if (!IsFullyLoaded && !IsLoading)
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 if (Factory == null)
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 throw new InvalidOperationException("No factory set for partially loaded object with ID "+ID);
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 Factory.CompleteLoading(this);
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 public IWarFoundryFactory Factory
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 get { return creatingFactory; }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 public bool IsFullyLoaded
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 {
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 get { return isFullyLoaded; }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
61 public bool IsLoading
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
62 {
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
63 get { return isLoading; }
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
64 }
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
65
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 public void SetAsFullyLoaded()
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 {
35
9cac51553fd1 * Remove "isLoading" flag on setting fully loaded
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
68 isLoading = false;
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 isFullyLoaded = true;
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 }
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
71
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
72 public void SetAsLoading()
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
73 {
35
9cac51553fd1 * Remove "isLoading" flag on setting fully loaded
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
74 if (!isFullyLoaded)
9cac51553fd1 * Remove "isLoading" flag on setting fully loaded
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
75 {
9cac51553fd1 * Remove "isLoading" flag on setting fully loaded
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
76 isLoading = true;
9cac51553fd1 * Remove "isLoading" flag on setting fully loaded
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
77 }
34
b28be912adab Re #32 - Migrate to schema
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
78 }
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 }
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 }