public SharedWorldState(WorldStore store, IWorldName w, XDocument d = null) : base(store, w, false, d) { var r = XDocument.Root; _cidKeyVault = r.EnsureElement(XmlNames.xCICDKeyVault); }
internal BaseWorldState(WorldStore store, IWorldName w, bool isLocal, XDocument d = null) { if (store == null) { throw new ArgumentNullException(nameof(store)); } if (w == null) { throw new ArgumentNullException(nameof(w)); } _store = store; World = w; string safeName = SafeElementName(w, isLocal); if (d == null) { d = new XDocument(new XElement(safeName, new XAttribute(XmlNames.xWorkStatus, GlobalWorkStatus.Idle.ToString()))); } else if (d.Root.Name != safeName) { throw new ArgumentException($"Invalid state document root. Must be {safeName}, found {d.Root.Name}.", nameof(d)); } d.Changed += (o, e) => IsStateDirty = true; XDocument = d; }
/// <summary> /// Initializes a new WorldSelector that exposes a <see cref="CurrentWorld"/>. /// </summary> /// <param name="store">The world store.</param> /// <param name="commandRegister">The command register.</param> /// <param name="factory">The factory for XTypedObjects.</param> /// <param name="userKeyStore">The user key store.</param> /// <param name="appLife">Simple application lifetime controller.</param> public WorldSelector(WorldStore store, CommandRegister commandRegister, XTypedFactory factory, SecretKeyStore userKeyStore, IBasicApplicationLifetime appLife) { Store = store ?? throw new ArgumentNullException(nameof(store)); _command = commandRegister ?? throw new ArgumentNullException(nameof(commandRegister)); _userKeyStore = userKeyStore ?? throw new ArgumentNullException(nameof(userKeyStore)); _appLife = appLife ?? throw new ArgumentNullException(nameof(appLife)); _factory = factory ?? throw new ArgumentNullException(nameof(factory)); commandRegister.Register(this); _existingCommands = new HashSet <ICommandHandler>(commandRegister.GetAllCommands(false)); }
public LocalWorldState(WorldStore store, IWorldName w, XDocument d = null) : base(store, w, true, d) { var r = XDocument.Root; _generalState = r.EnsureElement(XmlNames.xGeneralState); _lastBuild = r.EnsureElement(XmlNames.xLastBuild); _builds = r.EnsureElement(XmlNames.xBuilds); _releaseBuildResult = _builds.EnsureElement(XmlNames.xRelease); _ciBuildResult = _builds.EnsureElement(XmlNames.xCI); _localBuildResult = _builds.EnsureElement(XmlNames.xLocal); _publishedBuildHistory = r.EnsureElement(XmlNames.xPublishedBuildHistory); LastBuildType = _lastBuild.AttributeEnum(XmlNames.xType, BuildResultType.None); _buildResults = new BuildResult[3]; }
/// <summary> /// Helper to impact local state an save it. /// </summary> /// <param name="this">This store.</param> /// <param name="m">The monitor to use.</param> /// <param name="state">The state to save.</param> /// <param name="a">The state modifier.</param> /// <returns>True on succes, false on error.</returns> public static bool SetLocalState(this WorldStore @this, IActivityMonitor m, LocalWorldState state, Action <LocalWorldState> a) { a(state); return(@this.SaveState(m, state)); }