Example #1
0
        /// <summary>
        /// Serializes this instance.
        /// </summary>
        public void Serialize(BinaryWriter writer)
        {
            writer.Write(RawArgs.Count);

            foreach (string arg in RawArgs)
            {
                writer.Write(arg);
            }

            writer.Write(ClientPath);
            writer.Write(ClientStartTime.ToFileTime());

            writer.Write(EnvironmentVariables.Count);

            foreach (KeyValuePair <string, string> variable in EnvironmentVariables)
            {
                writer.Write(variable.Key);
                writer.Write(variable.Value);
            }

            writer.Write(CurrentDirectory);
            ServerModeStatusAndPerf.Write(writer);

            writer.Flush();
        }
Example #2
0
        /// <summary>
        /// Deserilizes data and creates an instance of <see cref="BuildXLAppServerData"/>.
        /// </summary>
        public static BuildXLAppServerData Deserialize(BinaryReader reader)
        {
            int numberOfArgs = reader.ReadInt32();

            Contract.Assert(numberOfArgs >= 0);

            var rawArgs = new string[numberOfArgs];

            for (int i = 0; i < rawArgs.Length; i++)
            {
                rawArgs[i] = reader.ReadString();
            }

            var clientPath      = reader.ReadString();
            var clientStartTime = DateTime.FromFileTime(reader.ReadInt64()).ToUniversalTime();

            int environmentVariableCount = reader.ReadInt32();
            var environmentVariables     = new KeyValuePair <string, string> [environmentVariableCount];

            for (int i = 0; i < environmentVariableCount; i++)
            {
                environmentVariables[i] = new KeyValuePair <string, string>(reader.ReadString(), reader.ReadString());
            }

            var currentDirectory        = reader.ReadString();
            var serverModeStatusAndPerf = ServerModeStatusAndPerf.Read(reader);

            return(new BuildXLAppServerData(
                       rawArgs,
                       environmentVariables,
                       serverModeStatusAndPerf,
                       currentDirectory,
                       clientPath,
                       clientStartTime));
        }
Example #3
0
        /// <summary>
        /// Creates an instance of <see cref="BuildXLAppServerData"/>.
        /// </summary>
        public static BuildXLAppServerData Create(
            IReadOnlyList <string> rawArgs,
            IReadOnlyList <KeyValuePair <string, string> > environmentVariables,
            ServerModeStatusAndPerf serverModeStatusAndPerf)
        {
            Contract.Requires(rawArgs != null);
            Contract.Requires(environmentVariables != null);

            return(new BuildXLAppServerData(
                       rawArgs,
                       environmentVariables,
                       serverModeStatusAndPerf,
                       Directory.GetCurrentDirectory(),
                       AssemblyHelper.GetThisProgramExeLocation(),
                       Process.GetCurrentProcess().StartTime));
        }
Example #4
0
        /// <summary>
        /// Creates an instance of <see cref="BuildXLAppServerData"/>.
        /// </summary>
        public static BuildXLAppServerData Create(
            IReadOnlyList <string> rawArgs,
            IReadOnlyList <KeyValuePair <string, string> > environmentVariables,
            ServerModeStatusAndPerf serverModeStatusAndPerf)
        {
            Contract.Requires(rawArgs != null);
            Contract.Requires(environmentVariables != null);

            return(new BuildXLAppServerData(
                       rawArgs,
                       environmentVariables,
                       serverModeStatusAndPerf,
                       Directory.GetCurrentDirectory(),
                       Environment.GetCommandLineArgs()[0],
                       Process.GetCurrentProcess().StartTime));
        }
Example #5
0
        /// <summary>
        /// Creates an instance of <see cref="BuildXLAppServerData"/>.
        /// </summary>
        private BuildXLAppServerData(
            IReadOnlyList <string> rawArgs,
            IReadOnlyList <KeyValuePair <string, string> > environmentVariables,
            ServerModeStatusAndPerf serverModeStatusAndPerf,
            string currentDirectory,
            string clientPath,
            DateTime clientStartTime)
        {
            Contract.Requires(rawArgs != null);
            Contract.Requires(environmentVariables != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(currentDirectory));
            Contract.Requires(!string.IsNullOrWhiteSpace(clientPath));

            RawArgs = rawArgs;
            EnvironmentVariables    = environmentVariables;
            ServerModeStatusAndPerf = serverModeStatusAndPerf;
            CurrentDirectory        = currentDirectory;
            ClientPath      = clientPath;
            ClientStartTime = clientStartTime;
        }