private static void UpgradeFromRev142ToRev299(IVault vault) { (vault.GetStructureVersionToken() == "v1.rev142").AssertTrue(); (vault.Id != Guid.Empty).AssertTrue(); (vault.Revision is UInt64).AssertTrue(); }
public static IVault Virtualize(this IVault @this, Func <IVault, IValue, IValue> virtualizer, Func <IVault, IValue, IValue> materializer) { return(@this.Virtualize( new VaultVisitorComposite(virtualizer), new VaultVisitorComposite(materializer))); }
public SecretsHelper(ISettingsHelper settingsHelper, AuthenticationHelper authHelper, IVault vault, ISecretsProvider secretsProvider) { SettingsHelper = settingsHelper; AuthenticationHelper = authHelper; this.vault = vault; this.secretsProvider = secretsProvider; }
private static IValue GetStructureVersionHolder(this IVault vault) { // Load all possible version holders var versionHolder1 = vault.GetValue("$version"); var versionHolder2 = vault.GetValue("$format"); var versionHolder3 = vault.GetValue("$structureversion"); // Get version token from the latest holder var genuineHolder = versionHolder3 ?? versionHolder2 ?? versionHolder1; genuineHolder = genuineHolder ?? vault.CreateValue("$structureversion"); var genuineVersion = genuineHolder.ContentString; // Ensure that all kinds of version holders are present in the vault (backward compat!) versionHolder1 = versionHolder1 ?? vault.GetOrCreateValue("$version"); versionHolder2 = versionHolder2 ?? vault.GetOrCreateValue("$format"); versionHolder3 = versionHolder3 ?? vault.GetOrCreateValue("$structureversion"); var allHolders = new [] { versionHolder1, versionHolder2, versionHolder3 }; // Now synchronize all version signatures across all holders foreach (var anyVersionHolder in allHolders) { if (anyVersionHolder != null) { anyVersionHolder.SetContent(genuineVersion); } } // Return only the latest holder return(genuineHolder); }
public void EndDialog(IVault vault) { SelectedVault = vault; DialogResult = vault == null ? DialogResult.Cancel : DialogResult.OK; closingFromEndDialog = true; Close(); }
private IValue VisitInternal(IVault copyCat, IValue internalValue) { var copy = copyCat.CreateValue(internalValue.VPath); copy.SetContent(internalValue.ContentStream).SetEntireMetadata(internalValue.Metadata); return(copy); }
public static byte[] GetFileThumbnail(IVault vault, string fileName, int width, int height, bool retDefault = true, DateTime? cacheDate = null) { if (!cacheDate.HasValue) { cacheDate = DateTime.MinValue; } var objVer = GetObjectByFile(vault, fileName); if (objVer == null) return null; var objFile = GetFileByObject(vault, objVer); if (objFile == null) return null; if (objFile.ChangeTimeUtc <= cacheDate.Value) { return null; } return (byte[])vault.ObjectOperations.GetThumbnailAsBytes( objVer, objFile.FileVer, width, height, retDefault ); }
protected virtual IValue Visit(IVault copyCat, IValue value) { var copy = copyCat.CreateValue(value.VPath); copy.SetContent(value.ContentStream).SetEntireMetadata(value.Metadata); return(copy); }
public static SharedFolderPermission ResolveSharedFolderAccessPath(this IVault vault, string username, string sharedFolderUid, bool forManageUsers = false, bool forManageRecords = false) { if (string.IsNullOrEmpty(sharedFolderUid)) { return(null); } if (!vault.TryGetSharedFolder(sharedFolderUid, out var sf)) { return(null); } var permissions = sf.UsersPermissions .Where(x => x.UserType == UserType.User && x.UserId == username || x.UserType == UserType.Team && vault.TryGetTeam(x.UserId, out _)) .Where(x => (!forManageUsers || x.ManageUsers) && (!forManageRecords || x.ManageRecords)) .ToArray(); if (permissions.Length <= 0) { return(null); } return(permissions.FirstOrDefault(x => x.UserType == UserType.User) ?? permissions[0]); }
static SentinelWorkspaceLogHub() { string configurationFile = ConfigurationManager.AppSettings["SentinelApiConfig"]; GlobalLog.WriteToStringBuilderLog($"Loading config [{configurationFile}].", 14001); string textOfJsonConfig = File.ReadAllText(Path.Combine(SentinelWorkspacePoc.GetExecutionPath(), $"{configurationFile}")); SentinelApiConfig = JsonConvert.DeserializeObject <SentinelApiConfig>(textOfJsonConfig); // Turn on the KeyVault for use KeyVault = new KeyVault(SentinelApiConfig); // Create the processor syslogToSentinelProcessor = new SyslogToSentinelProcessor(SentinelApiConfig); // Create the storage container connection syslogToAzureBlob = new SyslogToAzureBlob(SentinelApiConfig, GetKeyVaultSecret(SentinelApiConfig.SyslogToAzureBlobStorageSecret)); eventLogProcessor = new EventLogProcessor("Security", NewEventRecord, readEventLogFileFromBeginning); using (var certificateManagement = new CertificateManagement()) { AuthX509Certificate2 = certificateManagement.FindCertificateByThumbprint("MY", SentinelApiConfig.CertificateThumbprint, StoreLocation.LocalMachine); } // Get the certificate from KeyVault string sentinalAuthCertEncoded = GetKeyVaultSecret($"{SentinelApiConfig.WorkspaceId.ToLower()}-wsid"); byte[] certFromKeyVault = Encoding.Unicode.GetBytes(sentinalAuthCertEncoded); // AuthX509Certificate2 = new X509Certificate2(certFromKeyVault, "SecurePassword", X509KeyStorageFlags.Exportable); // Get the current WorkspaceKey from KeyVault sentinalAuthWorkspaceKey = GetKeyVaultSecret($"{SentinelApiConfig.WorkspaceId.ToLower()}-wskey"); }
private static void UpgradeFromRev299ToRev492(IVault vault) { (vault.GetStructureVersionToken() == "v1.rev299").AssertTrue(); #if DOWNGRADE_STRUCTURE_VERSION_TO_REV299 AssertionHelper.Fail(); #else // branches: remove all empty default values from branches foreach (var branch in vault.GetBranchesRecursive().Concat(vault.Root.MkArray())) { var @default = branch.GetValue("default"); if (@default != null && @default.ContentString.IsNullOrEmpty()) { @default.Delete(); } } // branches: upgrade metadata -> id is no more stored in general-purpose section foreach (var branch in vault.GetBranchesRecursive().Concat(vault.Root.MkArray())) { try { var oldSchoolId = branch.GetId() ?? Guid.NewGuid(); branch.SetMetadata(null); branch.Metadata["$id"] = oldSchoolId.ToString(); (branch.Id == oldSchoolId).AssertTrue(); } catch (Exception) { // do nothing in case of invalid format } } // values: // 1) upgrade metadata -> id is no more stored in general-purpose section // 2) upgrade metadata -> type token is no more stored in general-purpose section foreach (var value in vault.GetValuesRecursive()) { try { var oldSchoolId = value.GetId() ?? Guid.NewGuid(); var oldSchoolTypeToken = value.GetTypeToken(); value.SetMetadata(null); value.Metadata["$id"] = oldSchoolId.ToString(); value.Metadata["type-token"] = oldSchoolTypeToken; (value.Id == oldSchoolId).AssertTrue(); (value.GetTypeToken2() == oldSchoolTypeToken).AssertTrue(); } catch (Exception) { // do nothing in case of invalid format } } #endif }
public static IVault Virtualize(this IVault @this, Func <IVault, IBranch, IBranch> branchVirtualizer, Func <IVault, IValue, IValue> valueVirtualizer, Func <IVault, IBranch, IBranch> branchMaterializer, Func <IVault, IValue, IValue> valueMaterializer) { return(@this.Virtualize( new VaultVisitorComposite(branchVirtualizer, valueVirtualizer), new VaultVisitorComposite(branchMaterializer, valueMaterializer))); }
public static XmlVaultDto FromRootBranch(IVault vault) { var root = XmlBranchDto.FromBranch(vault.Root ?? new Branch((VaultBase)vault, null, null)); return(new XmlVaultDto { Root = root }); }
public override string Expand(ObjectClassAdmin @class, IVault vault) { var @type = vault.ObjectTypeOperations.GetObjectType(@class.ObjectType); return(Template ?.Replace("{Class}", NameConverter.ToString(@class.Name)) ?.Replace("{ObjectType}", NameConverter.ToString(@type.NameSingular))); }
public VirtualVault(IVault vault, VaultVisitor virtualizer, VaultVisitor materializer) { _vault = vault.AssertNotNull(); _virtualizer = virtualizer.AssertNotNull(); _materializer = materializer.AssertNotNull(); _vaultExposition = _vault.ExposeReadOnly(); _virtualizer.Visit(this, _vault); }
public VirtualVault(IVault vault, VaultVisitor virtualizer, VaultVisitor materializer) { _vault = vault.AssertNotNull(); _virtualizer = virtualizer.AssertNotNull(); _materializer = materializer.AssertNotNull(); _vaultExposition = _vault.ExposeReadOnly(); _virtualizer.Visit(this, _vault); }
protected virtual IBranch Visit(IVault copyCat, IBranch branch) { var copy = copyCat.GetOrCreateBranch(branch.VPath); copy.SetEntireMetadata(branch.Metadata); branch.GetBranches().ForEach(b => Visit(copyCat, b)); ((Branch)branch).GetValues(ValueKind.Regular).ForEach(v => Visit(copyCat, (IValue)v)); ((Branch)branch).GetValues(ValueKind.Internal).ForEach(v => VisitInternal(copyCat, v)); return copy; }
public void BeforeMutate(IVault vault) { vault.AssertNotNull(); (_lastVaultId == null || _lastVaultId == vault.Id).AssertTrue(); _lastVaultId = vault.Id; _revisions.Add(vault.Revision); _dirs.Add(1); }
public static void Init(IAuthBroker broker, IVault vault, ISettingsHelper settingsHelper, string secretsJson, Func<IHttpClient> clientFactory, bool isCommercial) { AuthBroker = broker; Vault = vault; SettingsHelper = settingsHelper; SecretsJson = secretsJson; HttpClientFactory = clientFactory; IsCommercial = isCommercial; }
public void BeforeMutate(IVault vault) { vault.AssertNotNull(); (_lastVaultId == null || _lastVaultId == vault.Id).AssertTrue(); _lastVaultId = vault.Id; _revisions.Add(vault.Revision); _dirs.Add(1); }
///GENMHASH:98060D1B7FD52C7724F36876E3AA8CC9:C3E882EB9B8E9BD6C5F7A74CD50D69D0 internal KeyImpl(string name, KeyBundle innerObject, IVault vault) : base(name, innerObject) { this.vault = vault; updateKeyRequest = new UpdateKeyRequest { VaultBaseUrl = vault.VaultUri, KeyName = Name }; }
///GENMHASH:D4F352220A93EA5AA29C8B5E4597D85A:C23C77328A8E0D7CC1FB12BB56B5BE22 internal SecretImpl(string name, SecretBundle innerObject, IVault vault) : base(name, innerObject) { this.vault = vault; this.updateSecretRequest = new UpdateSecretRequest { VaultBaseUrl = vault.VaultUri, SecretName = name }; }
public static IEnumerable<ObjectVersion> GetObjectsByCondition(IVault vault, SearchConditions cond) { var searchResults = vault.ObjectSearchOperations.SearchForObjectsByConditionsEx( SearchConditions: cond, SearchFlags: MFSearchFlags.MFSearchFlagReturnLatestVisibleVersion, SortResults: false, MaxResultCount: 0 ); return searchResults.Cast<ObjectVersion>().ToList(); }
protected virtual IBranch Visit(IVault copyCat, IBranch branch) { var copy = copyCat.GetOrCreateBranch(branch.VPath); copy.SetEntireMetadata(branch.Metadata); branch.GetBranches().ForEach(b => Visit(copyCat, b)); ((Branch)branch).GetValues(ValueKind.Regular).ForEach(v => Visit(copyCat, (IValue)v)); ((Branch)branch).GetValues(ValueKind.Internal).ForEach(v => VisitInternal(copyCat, v)); return(copy); }
public static IVault ImportFrom(this IVault target, IVault source, CollisionHandling collisionHandling) { var cloneOfRoot = source.Root.Clone(); target.Root.SetEntireMetadata(cloneOfRoot.Metadata); cloneOfRoot.GetBranches().ForEach(b => target.ImportBranch(b, collisionHandling)); ((Branch)cloneOfRoot).GetValues(ValueKind.Regular).ForEach(v => target.ImportValue(v, collisionHandling != CollisionHandling.Error)); ((Branch)cloneOfRoot).GetValues(ValueKind.Internal).ForEach(v => target.ImportValue(v, true)); return(target); }
public static void CopyTo(IVault vlt, VaultAssetType vat, string van, string target, FileMode mode) { var asset = vlt.GetAsset(vat, van); using (Stream s = vlt.LoadAsset(asset), fs = new FileStream(target, mode)) { s.CopyTo(fs); } }
public static ObjVer GetObjectByFile(IVault vault, string fileName) { var cond = new SearchCondition(); cond.ConditionType = MFConditionType.MFConditionTypeEqual; cond.Expression.SetFileValueExpression(MFFileValueType.MFFileValueTypeFileName); cond.TypedValue.SetValue(MFDataType.MFDatatypeText, fileName); var result = vault.ObjectSearchOperations.SearchForObjectsByCondition(cond, false); return result.Count < 1 ? null : result[1].ObjVer; }
public virtual IVault Visit(IVault copyCat, IVault vault) { using (((VaultBase)copyCat).InternalExpose()) { using (vault.ExposeReadOnly()) { Visit(copyCat, vault.Root); return(copyCat); } } }
public virtual IVault Visit(IVault copyCat, IVault vault) { using (((VaultBase)copyCat).InternalExpose()) { using (vault.ExposeReadOnly()) { Visit(copyCat, vault.Root); return copyCat; } } }
public EvalSession(IVault vault, IVault repository) { Vault = vault.AssertNotNull(); _expositions.Add(vault.ExposeReadOnly()); Repository = repository; if (repository != null) { _expositions.Add(repository.ExposeReadOnly()); } }
public IEnumerable <KeyValuePair <string, object> > DescribeTraits(IVault vault) { var lv = vault as LocalVault; if (lv == null) { throw new ArgumentException(nameof(vault), "missing or invalid type"); } return(ExtUtil.NO_TRAITS); }
public IValue ToValue(IVault vault) { // fixup xmlwriter's error Name = Name == null ? null : Name.Replace("\n", Environment.NewLine); Metadata = Metadata == null ? null : Metadata.Replace("\n", Environment.NewLine); Content = Content == null ? null : Content.Replace("\n", Environment.NewLine); var value = new Value((VaultBase)vault, Name, Content.AsLazyStream()); value.RawSetMetadata(Metadata); return value; }
public CompiledScenarioCache(IVault vault, Type t) { Vault = vault; Revision = vault.Revision; ScenarioType = t; lock (PoolSyncRoot) { _pool.Add(SpawnNewInstance()); _pool.Add(SpawnNewInstance()); } }
public IBranch ToBranch(IVault vault) { // fixup xmlwriter's error Name = Name == null ? null : Name.Replace("\n", Environment.NewLine); Metadata = Metadata == null ? null : Metadata.Replace("\n", Environment.NewLine); var values = Values.Select(v => v.ToValue(vault)).Cast<Element>(); var branches = Branches.Select(b => b.ToBranch(vault)).Cast<Element>(); var branch = new Branch((VaultBase)vault, Name, values.Concat(branches)); return branch.RawSetMetadata(Metadata); }
public static TypedValue GetPropertyById(IVault vault, ObjVer obj, int id) { try { var res = vault.ObjectPropertyOperations.GetProperty(obj, id); return res.Value; } catch (COMException) { return null; } }
public IValue ToValue(IVault vault) { // fixup xmlwriter's error Name = Name == null ? null : Name.Replace("\n", Environment.NewLine); Metadata = Metadata == null ? null : Metadata.Replace("\n", Environment.NewLine); Content = Content == null ? null : Content.Replace("\n", Environment.NewLine); var value = new Value((VaultBase)vault, Name, Content.AsLazyStream()); value.RawSetMetadata(Metadata); return(value); }
public AccessService( IAccessControlListClient accessControlListService, IServiceAccountClient serviceAccountClient, IApiKeyClient apiKeyClient, IVault vault ) { _accessControlListService = accessControlListService; _serviceAccountClient = serviceAccountClient; _apiKeyClient = apiKeyClient; _vault = vault; }
private static Expression Expand(Expression ex, IVault vault, IVault repository, List<Expression> stack, Dictionary<String, IBranch> nodes) { if (ex is VariableExpression) { return Expand((VariableExpression)ex, vault, repository, stack, nodes); } else { ex.Flatten(n => n.Children.Cast<Expression>()).OfType<VariableExpression>() .ForEach(v => v.ReplaceMeWith(() => Expand(v, vault, repository, stack, nodes))); return ex; } }
public override string Expand(StateAdmin state, IVault vault) { var result = Template?.Replace("{State}", NameConverter.ToString(state.Name)); if (result?.Contains("{Workflow}") != true) { return(result); } var workflow = GetWorkflow(vault, state.ID); return(result.Replace("{Workflow}", NameConverter.ToString(workflow?.Name))); }
private static void UpgradeFromRev122ToRev142(IVault vault) { (vault.GetStructureVersionToken() == "v1.rev122").AssertTrue(); foreach (var value in vault.GetValuesRecursive()) { // all values get a GUID generated and associated if they don't have one yet if (value.GetId() == null) { value.SetId(Guid.NewGuid()); } } }
public IBranch ToBranch(IVault vault) { // fixup xmlwriter's error Name = Name == null ? null : Name.Replace("\n", Environment.NewLine); Metadata = Metadata == null ? null : Metadata.Replace("\n", Environment.NewLine); var values = Values.Select(v => v.ToValue(vault)).Cast <Element>(); var branches = Branches.Select(b => b.ToBranch(vault)).Cast <Element>(); var branch = new Branch((VaultBase)vault, Name, values.Concat(branches)); return(branch.RawSetMetadata(Metadata)); }
public void Verify(IVault vault) { var auxValuesAdded = false; if (_lastVaultId != null) { _revisions.Add(vault.Revision); _dirs.Add(int.MaxValue); auxValuesAdded = true; } try { for (var i = 0; i < _revisions.Count - 1; ++i) { if (_dirs[i] == 0) { if (_revisions[i + 1] >= _revisions[i]) { continue; } } else if (_dirs[i] == 1) { if (_revisions[i + 1] > _revisions[i]) { continue; } } Func <UInt64, int, String> fmt = (rev, dir) => String.Format("{0}{1}", rev, dir == 1 ? "+" : dir == 0 ? "=" : "?"); throw new AssertionException(String.Format( "Revision history '{0}' is invalid at '{1}, {2}'.", _revisions.Zip(_dirs, fmt).StringJoin(), fmt(_revisions[i], _dirs[i]), _revisions[i + 1])); } } finally { if (auxValuesAdded) { _revisions.RemoveAt(_revisions.Count - 1); _dirs.RemoveAt(_dirs.Count - 1); } } }
protected Workflow GetWorkflow(IVault vault, int state) { var workflows = vault.WorkflowOperations.GetWorkflowsForClient()?.Cast <Workflow>(); foreach (var workflow in workflows) { var states = vault.WorkflowOperations.GetWorkflowStates(workflow.ID)?.Cast <State>()?.Select(s => s.ID); if (states.Contains(state)) { return(workflow); } ; } return(null); }
private void ValidateScenario(IVault implScenario) { if (Version.Id != implScenario.Id) { throw new ArgumentException(String.Format( "The compiled scenario has id '{0}' which is incompatible " + "with the id '{1}' of a scenario being assigned.", Version.Id, implScenario.Id)); } if (Version.Revision > implScenario.Revision) { throw new ArgumentException(String.Format( "The compiled scenario has revision '{0}' which is earlier than " + "the revision '{1}' of a scenario being assigned.", Version.Revision, implScenario.Revision)); } }
public DataSourceSyncRunner( IJobInfoFinder jobInfoFinder, IHttpClientFactory httpClientFactory, JobRunnerProgram jobRunnerProgram, TraffkGlobalDbContext gdb, Bal.Data.Rdb.TraffkTenantShards.TraffkTenantShardsDbContext tdb, IVault vault, IOptions <BlobStorageServices.Config> blobConfig, Serilog.ILogger logger) : base(gdb, jobInfoFinder, logger) { HttpClientFactory = httpClientFactory; BlobConfig = blobConfig; Vault = vault; TenantName = tdb.TenantFindByTenantId(jobInfoFinder.JobInfo.TenantId.Value).Result.First().TenantName; }
private static Expression ExpandRhs(IBranch b, IVault repository, List<Expression> stack, Dictionary<String, IBranch> nodes) { var elf = b.GetValue("elfCode").ContentString.ToCanonicalElf(); var script = (Script)new ElfAstBuilder(elf).BuildAst(); var assign = (AssignmentExpression)((ExpressionStatement) script.Classes.Single().Funcs.Single().Body.Statements.Single()).Expression; var rhs = assign.Expression; if (stack.Contains(rhs)) { throw new EvalStackOverflowException(); } else { stack.Add(rhs); return Expand(rhs, b.Vault, repository, stack, nodes); } }
protected EvalSession(IVault vault, IVault repository) { AppDomain.CurrentDomain.Load("Esath.Data"); _expositions.Add(vault.AssertNotNull().ExposeReadOnly()); if (repository != null) { _expositions.Add(repository.AssertNotNull().ExposeReadOnly()); } VM = new VirtualMachine(); VM.Context.Add("vault", vault); VM.Context.Add("repository", repository); VM.Context.Add("designTime", repository == null); VM.Context.Add("evalCache", new Dictionary<VPath, Object>()); VM.Context.Add("evalSession", this); VM.Context.Add("nodesInProgress", new HashSet<VPath>()); VM.Context.Add("nodeInProgress", null); }
public void Verify(IVault vault) { var auxValuesAdded = false; if (_lastVaultId != null) { _revisions.Add(vault.Revision); _dirs.Add(int.MaxValue); auxValuesAdded = true; } try { for (var i = 0; i < _revisions.Count - 1; ++i) { if (_dirs[i] == 0) { if (_revisions[i + 1] >= _revisions[i]) continue; } else if (_dirs[i] == 1) { if (_revisions[i + 1] > _revisions[i]) continue; } Func<UInt64, int, String> fmt = (rev, dir) => String.Format("{0}{1}", rev, dir == 1 ? "+" : dir == 0 ? "=" : "?"); throw new AssertionException(String.Format( "Revision history '{0}' is invalid at '{1}, {2}'.", _revisions.Zip(_dirs, fmt).StringJoin(), fmt(_revisions[i], _dirs[i]), _revisions[i + 1])); } } finally { if (auxValuesAdded) { _revisions.RemoveAt(_revisions.Count - 1); _dirs.RemoveAt(_dirs.Count - 1); } } }
public static object Eval(this IBranch b, IVault repository) { try { AppDomain.CurrentDomain.Load("Esath.Data"); var ei = new ElfInteractive(); var stack = new List<Expression>(); var nodes = new Dictionary<String, IBranch>(); var expandedCode = ExpandRhs(b, repository, stack, nodes).RenderElfCode(null); nodes.ForEach(kvp => ei.Ctx.Add(kvp.Key, kvp.Value)); return ei.Eval(expandedCode).Retval; } catch(BaseEvalException) { throw; } catch(ErroneousScriptRuntimeException esex) { if (esex.Type == ElfExceptionType.OperandsDontSuitMethod) { throw new ArgsDontSuitTheFunctionException(esex.Thread.RuntimeContext.PendingClrCall, esex); } else { throw new UnexpectedErrorException(esex); } } catch(Exception ex) { if (ex.InnerException is FormatException) { throw new BadFormatOfSerializedStringException(ex); } else { throw new UnexpectedErrorException(ex); } } }
private void RouteVaultEvents(IVault vault, List<ElementChangingEventArgs> changing, List<ElementChangedEventArgs> changed) { vault.Changing(e => { changing.Add(e); if (e.OldValue is Stream) { var s = ((Stream)e.OldValue).AsString(); var setter = typeof(ElementEventArgs).GetProperty("OldValue").GetSetMethod(true); setter.Invoke(e, s.MkArray()); } if (e.NewValue is Stream) { var s = ((Stream)e.NewValue).AsString(); var setter = typeof(ElementEventArgs).GetProperty("NewValue").GetSetMethod(true); setter.Invoke(e, s.MkArray()); } }); vault.Changed(e => { changed.Add(e); if (e.OldValue is Stream) { var s = ((Stream)e.OldValue).AsString(); var setter = typeof(ElementEventArgs).GetProperty("OldValue").GetSetMethod(true); setter.Invoke(e, s.MkArray()); } if (e.NewValue is Stream) { var s = ((Stream)e.NewValue).AsString(); var setter = typeof(ElementEventArgs).GetProperty("NewValue").GetSetMethod(true); setter.Invoke(e, s.MkArray()); } }); }
public EvalSession(IVaultCompiler compiler, IVault repository) { _expositions.Add(compiler.AssertNotNull().Vault.ExposeReadOnly()); if (repository != null) { _expositions.Add(repository.AssertNotNull().ExposeReadOnly()); } var cache = compiler.GetCompiledAsync(); if (cache != null) { Scenario = cache.RequestInstance(repository); _evalExposition = Scenario.Expose(); } else { // if cache returned is null, this means that the compiler is busy generating an assembly // however, we don't want to make user wait so let's just fall back to 5-10x times slower Eval2 Eval2 = new Ver2.EvalSession(compiler.Vault, repository); _evalExposition = Eval2; } }
public void EndDialog(IVault vault) { SelectedVault = vault; DialogResult = vault == null ? DialogResult.Cancel : DialogResult.OK; closingFromEndDialog = true; Close(); }
public VaultDialogForm(VaultAction action) { // Initialize internal state Action = action; SelectedVault = null; // Initialize controls and events InitializeComponent(); _tcTabs.Selected += (o, e) => { var virtualTab = e.TabPage.Tag.AssertCast<IVaultDialogTab>(); this.Text = virtualTab.FullTitle; if (TabActivated != null) TabActivated(o, new VaultDialogTabEventArgs(virtualTab)); }; _tcTabs.Deselected += (o, e) => { var virtualTab = e.TabPage.Tag.AssertCast<IVaultDialogTab>(); if (TabDeactivated != null) TabDeactivated(o, new VaultDialogTabEventArgs(virtualTab)); }; // Load plugins var lastSelectedTabType = (Type)AppDomain.CurrentDomain.GetData(this.GetType().FullName); lastSelectedTabType = lastSelectedTabType ?? VaultFormats.Default.GetType(); TabPage tabToSelectNow = null; var map = new Dictionary<TabPage, IVaultFormat>(); foreach (var format in VaultFormats.All) { format.InjectIntoVaultDialog(this); var tab = _tcTabs.TabPages.Cast<TabPage>().Last(); map.Add(tab, format); if (format.GetType() == lastSelectedTabType) { tabToSelectNow = tab; } } // Select previously selected page (or a default format) tabToSelectNow.AssertNotNull(); if (tabToSelectNow != null) { if (tabToSelectNow == _tcTabs.TabPages.Cast<TabPage>().First()) { // the target tab is already selected, but we need to raise our events if (TabActivated != null) TabActivated(this, new VaultDialogTabEventArgs(Tabs.First())); } else { _tcTabs.SelectedTab = tabToSelectNow; } } // Remember tab selections this.TabActivated += (o, e) => { var tabType = map[e.Tab.TabPage].GetType(); AppDomain.CurrentDomain.SetData(this.GetType().FullName, tabType); }; }
public EvalSession(IVault vault, IVault repository, IEnumerable<Guid> checkedNodes) : this(vault, repository) { _checkedNodes = new HashSet<Guid>(checkedNodes ?? new Guid[0]); }
public static void CopyTo(IVault vlt, VaultAssetType vat, string van, string target, FileMode mode) { var asset = vlt.GetAsset(vat, van); using (Stream s = vlt.LoadAsset(asset), fs = new FileStream(target, mode)) { s.CopyTo(fs); } }
public EvalSession(IVault vault) : this(vault, null) { }
// runtime mode protected CompiledScenario(IVault scenario, IVault repository) { ValidateScenario(scenario); Scenario = new CachedVault(scenario.AssertNotNull()); Repository = repository == null ? null : new CachedVault(repository); }
public VaultCompiler(IVault vault) { Vault = vault.AssertNotNull(); Vault.Changed(SignificantChangeFilter, SignificantChangeProcessor); InitializeCompiler(); }
private static Expression Expand(VariableExpression vex, IVault vault, IVault repository, List<Expression> stack, Dictionary<String, IBranch> nodes) { var @ref = vault.GetBranch(vex.Name.FromElfIdentifier()); if (@ref == null) { throw new ReferencedBranchDoesNotExistException(vex.Name); } if (@ref.IsFov()) { if (@ref.GetOrCreateValue("declarationType", "source").ContentString == "source") { String val; if (repository == null) { val = @ref.GetValue("valueForTesting").ContentString; } else { var external = @ref.GetValue("repositoryValue").ContentString; val = repository.GetValue(external).ContentString; } return new LiteralExpression(String.Format("[[{0}]]{1}", @ref.GetValue("type").ContentString, val)); } else { return ExpandRhs(@ref, repository, stack, nodes); } } else { var varName = @ref.VPath.ToElfIdentifier(); nodes[varName] = @ref; return new VariableExpression(varName); } }
// design mode protected CompiledScenario(IVault scenario) : this(scenario, null) { }