public List<MetadataScript> GetScripts(MetadataJson metadata) { AttributesJson attributesJson; List<MetadataScript> scripts = new List<MetadataScript>(); try { attributesJson = metadata.Instance.Attributes; } catch (NullReferenceException) { attributesJson = null; } scripts = GetAttributeScripts(attributesJson); if (scripts.Count > 0) { return scripts; } try { attributesJson = metadata.Project.Attributes; } catch (NullReferenceException) { attributesJson = null; } return scripts; }
public List <MetadataScript> GetScripts(MetadataJson metadata) { AttributesJson attributesJson; List <MetadataScript> scripts = new List <MetadataScript>(); try { attributesJson = metadata.Instance.Attributes; } catch (NullReferenceException) { attributesJson = null; } scripts = GetAttributeScripts(attributesJson); if (scripts.Count > 0) { return(scripts); } try { attributesJson = metadata.Project.Attributes; } catch (NullReferenceException) { attributesJson = null; } return(scripts); }
private void RunScripts() { string version = "unknown"; try { version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); } catch (Exception e) { Logger.Warning("Exception caught reading version number. {0}", e); } Logger.Info("Starting {0} scripts (version {1}).", this.scriptType, version); try { MetadataJson metadata = MetadataWatcher.GetMetadata(); this.metadata = reader.GetScripts(metadata); this.writer.SetScripts(this.metadata); } catch (Exception e) { Logger.Error("Caught top level exception. {0}\r\n{1}", e.Message, e.StackTrace); } Logger.Info("Finished running {0} scripts.", this.scriptType); }
private static void ActivateMetadataUpdate(MetadataJson metadata) { MetadataUpdateEventArgs eventArgs = new MetadataUpdateEventArgs(metadata); if (MetadataUpdateEvent != null) { MetadataUpdateEvent(null, eventArgs); } }
private static void GetMetadataNetworkInterfacesTest(NetworkInterfacesJson[] input, Dictionary <PhysicalAddress, List <IPAddress> > expected) { InstanceJson instance = MetadataJsonHelpers.GetInstanceMetadataJson(networkInterfaces: input); MetadataJson metadata = MetadataJsonHelpers.GetMetadataJson(instance: instance); Assert.Equal <Dictionary <PhysicalAddress, List <IPAddress> > >(expected, Reader.GetMetadata(metadata)); }
public void ComponentIsEnabledTest() { MetadataJson metadata = CreateTestMetadata(windowsKeys: null, disableAccountManager: false); Assert.True(Reader.IsEnabled(metadata)); metadata = CreateTestMetadata(windowsKeys: null, disableAccountManager: true); Assert.False(Reader.IsEnabled(metadata)); }
public void ComponentIsEnabledTest() { MetadataJson metadata = CreateTestMetadata(forwardAddresses: null, disableAddressManager: false); Assert.True(Reader.IsEnabled(metadata)); metadata = CreateTestMetadata(forwardAddresses: null, disableAddressManager: true); Assert.False(Reader.IsEnabled(metadata)); }
public bool IsEnabled(MetadataJson metadata) { try { return(!metadata.Instance.Attributes.DisableAddressManager); } catch (NullReferenceException) { return(true); } }
public async Task <Unit> Invoke(IStreamStore streamStore, CancellationToken ct) { await streamStore.SetStreamMetadata( StreamId, ExpectedVersion, MaxAge, MaxCount, MetadataJson?.ToString(Formatting.Indented), ct); return(Unit.Instance); }
public static MetadataJson GetMetadataJson( InstanceJson instance = null, ProjectJson project = null) { MetadataJson metadataJson = new MetadataJson { Instance = instance ?? GetInstanceMetadataJson(), Project = project ?? GetProjectMetadataJson() }; return(metadataJson); }
public List <IPAddress> GetMetadata(MetadataJson metadata) { try { string[] forwardedIps = metadata.Instance.NetworkInterfaces[0].ForwardedIps; return(ParseForwardIpsResult(forwardedIps)); } catch (NullReferenceException) { return(null); } }
public void GetMetadataEmptyTest() { MetadataJson metadata = MetadataJsonHelpers.GetMetadataJson(); Assert.Equal(new Dictionary <PhysicalAddress, List <IPAddress> >(), Reader.GetMetadata(metadata)); metadata.Instance = null; Assert.Equal(new Dictionary <PhysicalAddress, List <IPAddress> >(), Reader.GetMetadata(metadata)); metadata = null; Assert.Equal(new Dictionary <PhysicalAddress, List <IPAddress> >(), Reader.GetMetadata(metadata)); }
public void GetMetadataEmptyTest() { MetadataJson metadata = MetadataJsonHelpers.GetMetadataJson(); Assert.Equal(new List <WindowsKey>(), Reader.GetMetadata(metadata)); metadata.Instance = null; Assert.Null(Reader.GetMetadata(metadata)); metadata = null; Assert.Null(Reader.GetMetadata(metadata)); }
public List <WindowsKey> GetMetadata(MetadataJson metadata) { try { string windowsKeys = metadata.Instance.Attributes.WindowsKeys; return(ParseWindowsKeys(windowsKeys)); } catch (NullReferenceException) { return(null); } }
public Dictionary <string, bool> GetMetadata(MetadataJson metadata) { if (metadata == null || metadata.Instance == null || metadata.Instance.Attributes == null) { return(null); } Dictionary <string, bool> updatesConfigs = new Dictionary <string, bool> { { AttributeKeys.DisableAgentUpdates, metadata.Instance.Attributes.DisableAgentUpdate }, }; return(updatesConfigs); }
internal MangaContext(MetadataJson metadata, ProjectDirectoryListingProvider listing) { this.listing = listing; this.metadata = metadata; using var file = listing.FileOpen(listing.GetCharactersPath()); using var jsonReader = new JsonTextReader(file); var serializer = new JsonSerializer(); this.charactersJson = serializer.Deserialize <CharactersJson>(jsonReader); IdNameMapping = new DualDictionary <long, string>(charactersJson.Characters .ToDictionary(c => c.Id, c => c.Name)); this.characterTypeConverter = new CharacterTypeConverter(IdNameMapping); }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } hash ^= devices_.GetHashCode(); hash ^= tags_.GetHashCode(); if (Description.Length != 0) { hash ^= Description.GetHashCode(); } hash ^= processingModules_.GetHashCode(); if (IsDedicatedProcessingNode != false) { hash ^= IsDedicatedProcessingNode.GetHashCode(); } if (HostIp.Length != 0) { hash ^= HostIp.GetHashCode(); } if (MetadataJson.Length != 0) { hash ^= MetadataJson.GetHashCode(); } if (State != 0) { hash ^= State.GetHashCode(); } if (Latency != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Latency); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public Dictionary <PhysicalAddress, List <IPAddress> > GetMetadata(MetadataJson metadata) { Dictionary <PhysicalAddress, List <IPAddress> > data = new Dictionary <PhysicalAddress, List <IPAddress> >(); if (metadata == null || metadata.Instance == null || metadata.Instance.NetworkInterfaces == null) { return(data); } foreach (NetworkInterfacesJson entry in metadata.Instance.NetworkInterfaces) { string mac = entry.MAC.ToUpper().Replace(":", "-"); try { data.Add(PhysicalAddress.Parse(mac), ParseForwardIpsResult(entry.ForwardedIps)); } catch (FormatException) { Logger.Info("Caught exception in PhysicalAddress.Parse. Could not parse MAC: {0}", mac); } } return(data); }
public List <MetadataScript> GetScripts(MetadataJson metadata) { AttributesJson instanceAttributesJson; AttributesJson projectAttributesJson; try { instanceAttributesJson = metadata.Instance.Attributes; } catch (NullReferenceException) { instanceAttributesJson = null; } try { projectAttributesJson = metadata.Project.Attributes; } catch (NullReferenceException) { projectAttributesJson = null; } List <MetadataScript> scripts = new List <MetadataScript>(); foreach (string suffix in MetadataScript.Suffixes) { string scriptKey = MetadataScript.GetMetadataKeyTitle(this.scriptType, suffix); string script = GetPropertyValue(instanceAttributesJson, scriptKey) ?? GetPropertyValue(projectAttributesJson, scriptKey); if (!string.IsNullOrEmpty(script)) { Logger.Info("Found {0} in metadata.", MetadataScript.GetMetadataKeyHyphen(this.scriptType, suffix)); scripts.Add(FetchScript(suffix, script)); } } return(scripts); }
public List<MetadataScript> GetScripts(MetadataJson metadata) { AttributesJson instanceAttributesJson; AttributesJson projectAttributesJson; try { instanceAttributesJson = metadata.Instance.Attributes; } catch (NullReferenceException) { instanceAttributesJson = null; } try { projectAttributesJson = metadata.Project.Attributes; } catch (NullReferenceException) { projectAttributesJson = null; } List<MetadataScript> scripts = new List<MetadataScript>(); foreach (string suffix in MetadataScript.Suffixes) { string scriptKey = MetadataScript.GetMetadataKeyTitle(this.scriptType, suffix); string script = GetPropertyValue(instanceAttributesJson, scriptKey) ?? GetPropertyValue(projectAttributesJson, scriptKey); if (!string.IsNullOrEmpty(script)) { Logger.Info("Found {0} in metadata.", MetadataScript.GetMetadataKeyHyphen(this.scriptType, suffix)); scripts.Add(FetchScript(suffix, script)); } } return scripts; }
/// <summary> /// Compares the response of GetMetadata with the expected response. /// </summary> /// <param name="input">The metadata value of windows-keys.</param> /// <param name="expected">The expected response of GetMetadata</param> private static void GetMetadataTest(string input, List <WindowsKey> expected) { MetadataJson metadata = CreateTestMetadata(input); Assert.Equal <List <WindowsKey> >(expected, Reader.GetMetadata(metadata)); }
public ProjectDirectoryListingProvider([NotNull] MetadataJson metadata, [NotNull] IReadOnlyFileSystem readOnlyFileSystem) { this.metadata = metadata; this.readOnlyFileSystem = readOnlyFileSystem; }
private void Init([NotNull] MetadataJson json, [NotNull] IReadOnlyFileSystem rootFs) { Root = new MangaContext(json, new ProjectDirectoryListingProvider(json, rootFs)); }
public MetadataUpdateEventArgs(MetadataJson metadata) { this.Metadata = metadata; }
public bool IsEnabled(MetadataJson metadata) { // Disabling the updates component from the metadata server is not // supported. This should always return true. return(true); }