Ejemplo n.º 1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "LaunchGroup" /> class.
        /// </summary>
        /// <param name = "parent">The parent of this group.</param>
        /// <param name = "groups">The child groups of this group.</param>
        /// <param name = "launchers">The child launchers of this group.</param>
        public LaunchGroup(LaunchGroup parent = null,
                           IEnumerable <LaunchGroup> groups = null,
                           IEnumerable <Launcher> launchers = null)
        {
            Groups               = new ObservableCollection <LaunchGroup>();
            Launchers            = new ObservableCollection <Launcher>();
            EnvironmentVariables = new EnvironmentVariableCollection();
            Parent               = parent;

            HasChanges = false;

            if (groups != null)
            {
                foreach (var group in groups)
                {
                    Groups.Add(group);
                }
            }

            if (launchers != null)
            {
                foreach (var launcher in launchers)
                {
                    Launchers.Add(launcher);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "Launcher" /> class.
 /// </summary>
 /// <param name = "parent">The <see cref = "LaunchGroup" /> that contains this Launcher.</param>
 public Launcher(LaunchGroup parent = null)
 {
     Parent = parent;
     EnvironmentVariables = new EnvironmentVariableCollection();
     Arguments            = string.Empty;
     File             = string.Empty;
     Name             = string.Empty;
     WorkingDirectory = string.Empty;
     HasChanges       = false;
 }
        /// <summary>
        ///   Determines whether the specified <see cref = "EnvironmentVariableCollection" /> is equal to this instance.
        /// </summary>
        /// <param name = "other">The <see cref = "EnvironmentVariableCollection" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref = "EnvironmentVariableCollection" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(EnvironmentVariableCollection other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (Count != other.Count)
            {
                return(false);
            }

            return(Items.All(other.Contains));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Reads the JSON representation of the object.
        /// </summary>
        /// <param name = "reader">The <see cref = "T:Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <param name = "objectType">Type of the object.</param>
        /// <param name = "existingValue">The existing value of object being read.</param>
        /// <param name = "serializer">The calling serializer.</param>
        /// <returns>
        ///   The object value.
        /// </returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var collection = new EnvironmentVariableCollection();

            string key = null;

            while (reader.Read() && reader.TokenType != JsonToken.EndObject)
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    key = (string)reader.Value;
                }
                else if (reader.TokenType == JsonToken.String)
                {
                    var value = (string)reader.Value;
                    collection.Add(key, value);
                    key = null;
                }
            }

            return(collection);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Gets all the environment variables to be used when launching this application, starting
        ///   with the topmost parent and overriding values down to the launcher's settings.
        /// </summary>
        public EnvironmentVariableCollection AggregateEnvironmentVariables()
        {
            var envVars = new Stack <EnvironmentVariableCollection>();

            envVars.Push(EnvironmentVariables);

            LaunchGroup parent = mParent;

            while (parent != null)
            {
                envVars.Push(parent.EnvironmentVariables);
                parent = parent.Parent;
            }

            var aggregatedEnvVars = new EnvironmentVariableCollection(envVars.Pop());

            while (envVars.Count > 0)
            {
                aggregatedEnvVars.UpdateWith(envVars.Pop());
            }

            return(aggregatedEnvVars);
        }