Exemplo n.º 1
0
        public ConfigurationString AddString()
        {
            var n = new ConfigurationString();

            SourceNames.Add(n);
            return(n);
        }
Exemplo n.º 2
0
    public void AddSourceLocation(SourceNames dictName, GameObject sourceToAdd)
    {
        allKnownSources.TryGetValue(dictName, out var specificKnownSources);

        if (specificKnownSources != null)
        {
            specificKnownSources.Add(sourceToAdd);
        }
        else
        {
            HashSet <GameObject> newSet = new HashSet <GameObject>();
            newSet.Add(sourceToAdd);
            allKnownSources.Add(dictName, newSet);
        }
    }
        private void OnServiceChanged()
        {
            try
            {
                isServiceUpdating = true;

                string selectedName = SelectedName;
                SourceNames.Clear();

                bool isSelectedNameContained = false;
                void Add(string name)
                {
                    if (!isSelectedNameContained)
                    {
                        isSelectedNameContained = name == selectedName;
                    }

                    SourceNames.Add(name);
                }

                if (service.All.Count > 1)
                {
                    Add(AllFeedName);
                }

                foreach (IPackageSource source in service.All)
                {
                    Add(source.Name);
                }

                if (isSelectedNameContained)
                {
                    SelectedName = selectedName;
                }
                else if (service.Primary != null)
                {
                    SelectedName = SourceNames.FirstOrDefault(s => string.Equals(s, service.Primary.Name, StringComparison.CurrentCultureIgnoreCase));
                }
                else
                {
                    SelectedName = SourceNames.FirstOrDefault();
                }
            }
            finally
            {
                isServiceUpdating = false;
            }
        }
 protected string GetSource(SourceNames sourceName)
 {
     switch (sourceName)
     {
         case SourceNames.ChildHarold:
             return NLipsum.Core.Lipsums.ChildHarold;
         case SourceNames.TheRaven:
             return NLipsum.Core.Lipsums.TheRaven;
         case SourceNames.Decameron:
             return NLipsum.Core.Lipsums.Decameron;
         case SourceNames.Faust:
             return NLipsum.Core.Lipsums.Faust;
         default:
             return NLipsum.Core.Lipsums.LoremIpsum;
     }
 }
Exemplo n.º 5
0
    public GameObject RequestSourceLocation(SourceNames dictName)
    {
        GameObject sourceToReturn;

        if (allKnownSources.TryGetValue(dictName, out HashSet <GameObject> requestedSources))
        {
            sourceToReturn = requestedSources.FirstOrDefault();

            if (sourceToReturn != null)
            {
                return(sourceToReturn);
            }
        }

        return(null);
    }
Exemplo n.º 6
0
        protected string GetSource(SourceNames sourceName)
        {
            switch (sourceName)
            {
            case SourceNames.ChildHarold:
                return(NLipsum.Core.Lipsums.ChildHarold);

            case SourceNames.TheRaven:
                return(NLipsum.Core.Lipsums.TheRaven);

            case SourceNames.Decameron:
                return(NLipsum.Core.Lipsums.Decameron);

            case SourceNames.Faust:
                return(NLipsum.Core.Lipsums.Faust);

            default:
                return(NLipsum.Core.Lipsums.LoremIpsum);
            }
        }
        private void OnServiceChanged()
        {
            string selectedName = SelectedName;

            SourceNames.Clear();

            bool isSelectedNameContained = false;

            void Add(string name)
            {
                if (!isSelectedNameContained)
                {
                    isSelectedNameContained = name == selectedName;
                }

                SourceNames.Add(name);
            }

            if (service.All.Count > 1)
            {
                Add(AllFeedName);
            }

            foreach (IPackageSource source in service.All)
            {
                Add(source.Name);
            }

            if (isSelectedNameContained)
            {
                SelectedName = selectedName;
            }
            else if (service.Primary != null)
            {
                SelectedName = SourceNames.FirstOrDefault(s => s == service.Primary.Name);
            }
            else
            {
                SelectedName = SourceNames.FirstOrDefault();
            }
        }
 public string GenWords(int wordCount = 1, SourceNames sourceNames = 0)
 {
     var gen = new NLipsum.Core.LipsumGenerator(GetSource(sourceNames), false);
     return string.Join(" ", gen.GenerateWords(wordCount));
 }
 public string GenSentences(int sentenceCount = 1, SourceNames sourceNames = 0)
 {
     var gen = new NLipsum.Core.LipsumGenerator(GetSource(sourceNames), false);
     return string.Join(" ", gen.GenerateSentences(sentenceCount));
 }
Exemplo n.º 10
0
 public ChromSource SourceFromName(string name)
 {
     return((ChromSource)SourceNames.IndexOf(e => e == name));
 }
Exemplo n.º 11
0
        public string GenSentences(int sentenceCount = 1, SourceNames sourceNames = 0)
        {
            var gen = new NLipsum.Core.LipsumGenerator(GetSource(sourceNames), false);

            return(string.Join(" ", gen.GenerateSentences(sentenceCount)));
        }
Exemplo n.º 12
0
        public string GenWords(int wordCount = 1, SourceNames sourceNames = 0)
        {
            var gen = new NLipsum.Core.LipsumGenerator(GetSource(sourceNames), false);

            return(string.Join(" ", gen.GenerateWords(wordCount)));
        }
Exemplo n.º 13
0
 protected override void Update()
 {
     if (!IsPowerSource)
     {
         base.Update();
         if (_oldResults != null)
         {
             VerifyCurrent(_updateResults);
         }
         _oldResults = _updateResults;
         if (_pseudoParents.Count == 0)
         {
             if (_updateResults.Where(x => x.transform.GetComponent <BaseCircuit>().Current > 0).Any())
             {
                 foreach (BaseCircuit circuitInstance in _updateResults.Select(x => x.transform.GetComponent <BaseCircuit>()).Where(x => x.Current > 0))
                 {
                     _pseudoParents.Add(circuitInstance);
                 }
             }
         }
         else if (_updateResults.Where(x => x.transform.GetComponent <BaseCircuit>().SourceNames.Except(SourceNames).Any() && !_pseudoParents.Contains(x.transform.GetComponent <BaseCircuit>()) && !_pseudoChildren.Contains(x.transform.GetComponent <BaseCircuit>())).Any())
         {
             foreach (BaseCircuit circ in _updateResults.Where(x => x.transform.GetComponent <BaseCircuit>().SourceNames.Except(SourceNames).Any() && !_pseudoParents.Contains(x.transform.GetComponent <BaseCircuit>())).Select(x => x.transform.GetComponent <BaseCircuit>()))
             {
                 if (!circ.GetType().IsAssignableFrom(typeof(Transistor)))
                 {
                     _pseudoParents.Add(circ);
                 }
                 else if (circ.transform.position.y == transform.position.y && transform.position.x > circ.transform.position.x)
                 {
                     _pseudoParents.Add(circ);
                 }
             }
         }
         if (_pseudoParents.Contains(this))
         {
             _pseudoParents.Remove(this);
         }
         if (PseudoParents.Count > 0)
         {
             foreach (List <string> source in _pseudoParents.Select(x => x.SourceNames))
             {
                 if (!SourceNames.Any() || source.Except(SourceNames).Any())
                 {
                     foreach (string sourceName in source.Except(SourceNames))
                     {
                         if (sourceName != gameObject.name)
                         {
                             SourceNames.Add(sourceName);
                         }
                     }
                 }
             }
         }
         List <BaseCircuit> currentConns = _updateResults.Select(x => x.transform.GetComponent <BaseCircuit>()).ToList();
         if (currentConns.Where(x => x.Current > 0).Any())
         {
             if (_pseudoParents.Count > 0)
             {
                 List <BaseCircuit> parents = currentConns.Where(x => _pseudoParents.Contains(x)).ToList();
                 List <string>      results = new List <string>();
                 foreach (BaseCircuit parent in parents)
                 {
                     foreach (string name in SourceNames)
                     {
                         if (!parent.SourceNames.Contains(name) && !results.Contains(name))
                         {
                             results.Add(name);
                         }
                         else
                         {
                             results.Remove(name);
                         }
                     }
                 }
                 if (results.Any())
                 {
                     SourceNames.RemoveAll(x => results.Contains(x));
                 }
             }
             _pseudoParents.RemoveAll(x => x == null);
         }
         else
         {
             _pseudoParents = new List <BaseCircuit>();
             _sourceNames   = new List <string>();
             _current       = 0;
         }
         _pseudoChildren.RemoveAll(x => x == null);
         float power = 0;
         if (_pseudoParents.Count == 0)
         {
             Connected = false;
         }
         foreach (BaseCircuit parentCircuit in _pseudoParents)
         {
             power += parentCircuit.Current;
         }
         Current = power;
     }
 }
Exemplo n.º 14
0
 public void RemoveString(ConfigurationString configurationString)
 {
     SourceNames.Remove(configurationString);
 }