Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 3
0
        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);
     }
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 7
0
        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);
     }
 }
Ejemplo n.º 9
0
        public async Task <Unit> Invoke(IStreamStore streamStore, CancellationToken ct)
        {
            await streamStore.SetStreamMetadata(
                StreamId,
                ExpectedVersion,
                MaxAge,
                MaxCount,
                MetadataJson?.ToString(Formatting.Indented),
                ct);

            return(Unit.Instance);
        }
Ejemplo n.º 10
0
        public static MetadataJson GetMetadataJson(
            InstanceJson instance = null,
            ProjectJson project   = null)
        {
            MetadataJson metadataJson = new MetadataJson
            {
                Instance = instance ?? GetInstanceMetadataJson(),
                Project  = project ?? GetProjectMetadataJson()
            };

            return(metadataJson);
        }
Ejemplo n.º 11
0
 public List <IPAddress> GetMetadata(MetadataJson metadata)
 {
     try
     {
         string[] forwardedIps = metadata.Instance.NetworkInterfaces[0].ForwardedIps;
         return(ParseForwardIpsResult(forwardedIps));
     }
     catch (NullReferenceException)
     {
         return(null);
     }
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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));
        }
Ejemplo n.º 22
0
 public ProjectDirectoryListingProvider([NotNull] MetadataJson metadata, [NotNull] IReadOnlyFileSystem readOnlyFileSystem)
 {
     this.metadata           = metadata;
     this.readOnlyFileSystem = readOnlyFileSystem;
 }
Ejemplo n.º 23
0
 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);
 }