コード例 #1
0
        protected TensorDimensionsBase(IImmutableList<int> immutableDimensions)
        {
            m_dims = immutableDimensions;

            // Precompute this since we are immutable.
            ElementCount = IsEmpty ? 0 : Math.Abs(m_dims.Aggregate(1, (acc, item) => acc * item));  // Tolerate -1s.
        }
コード例 #2
0
        public Exercise(ILoggerService loggerService, ISpeechService speechService, string name, int setCount, int repetitionCount, IEnumerable<MatcherWithAction> matchersWithActions)
        {
            loggerService.AssertNotNull(nameof(loggerService));
            speechService.AssertNotNull(nameof(speechService));
            name.AssertNotNull(nameof(name));
            matchersWithActions.AssertNotNull(nameof(matchersWithActions));

            if (setCount < 0)
            {
                throw new ArgumentException("setCount cannot be less than zero.", "setCount");
            }

            if (repetitionCount < 0)
            {
                throw new ArgumentException("repetitionCount cannot be less than zero.", "repetitionCount");
            }

            this.logger = loggerService.GetLogger(this.GetType());
            this.speechService = speechService;
            this.name = name;
            this.setCount = setCount;
            this.repetitionCount = repetitionCount;
            this.matchersWithActions = matchersWithActions.ToImmutableList();

            using (var dummyExecutionContext = new ExecutionContext())
            {
                this.duration = this
                    .GetEventsWithActions(dummyExecutionContext)
                    .SelectMany(x => x.Actions)
                    .Select(x => x.Duration)
                    .DefaultIfEmpty()
                    .Aggregate((running, next) => running + next);
            }
        }
コード例 #3
0
        public static IIrcListener BuildListener(IConnection connection, IImmutableList<EventHandler<Command.CommandReceivedEventArgs>> commandHandlers)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (commandHandlers == null) throw new ArgumentNullException("commandHandlers");

            return new IrcListener(connection, commandHandlers, new Command.MessageFactory(), new Command.CommandFactory());
        }
コード例 #4
0
ファイル: WalletEntry.cs プロジェクト: cole2295/BitSharp
 public WalletEntry(IImmutableList<MonitoredWalletAddress> addresses, EnumWalletEntryType type, ChainPosition chainPosition, UInt64 value)
 {
     Addresses = addresses;
     Type = type;
     ChainPosition = chainPosition;
     Value = value;
 }
コード例 #5
0
ファイル: Instruction.cs プロジェクト: TheJP/stebs
 public Instruction(byte opCode, int mpmAddress, string mnemonic, IImmutableList<OperandType> operandTypes)
 {
     if(mnemonic == null || operandTypes == null) { throw new ArgumentNullException(); }
     this.OpCode = opCode;
     this.MpmAddress = mpmAddress;
     this.Mnemonic = mnemonic;
     this.OperandTypes = operandTypes;
 }
コード例 #6
0
ファイル: Configuration.cs プロジェクト: modulexcite/PCLMock
 public Configuration(
     IEnumerable<Transformation> namespaceTransformations,
     IEnumerable<Transformation> nameTransformations,
     IEnumerable<Filter> interfaceFilters)
 {
     this.namespaceTransformations = namespaceTransformations.ToImmutableList();
     this.nameTransformations = nameTransformations.ToImmutableList();
     this.interfaceFilters = interfaceFilters.ToImmutableList();
 }
コード例 #7
0
 private static IImmutableList<Symbol> AddSymbols(Type type, IImmutableList<Symbol> derivedTypeSymbols)
 {
    if (type == null)
       return derivedTypeSymbols;
    var symbolFields = type.GetFields(BindingFlags.Public | BindingFlags.Static)
       .Where(field => SymbolType.IsAssignableFrom(field.FieldType));
    var symbols = symbolFields.Select(field => (Symbol)field.GetValue(null));
    return AddSymbols(type.BaseType, derivedTypeSymbols.AddRange(symbols));
 }
コード例 #8
0
        public MetronomeAction(IAudioService audioService, IDelayService delayService, ILoggerService loggerService, IEnumerable<MetronomeTick> ticks)
        {
            audioService.AssertNotNull(nameof(audioService));
            delayService.AssertNotNull(nameof(delayService));
            loggerService.AssertNotNull(nameof(loggerService));
            ticks.AssertNotNull(nameof(ticks));

            this.ticks = ticks.ToImmutableList();
            this.innerAction = new SequenceAction(GetInnerActions(audioService, delayService, loggerService, this.ticks));
        }
コード例 #9
0
    private IActionResult HandleErrors(IImmutableList<Error> errors)
    {
      var notFound = errors.FirstOrDefault(e => e.Kind == ErrorKind.NotFound);
      if (notFound != null)
      {
        return this.HttpNotFound(notFound.Message);
      }

      return new HttpStatusCodeResult(500);
    }
コード例 #10
0
 private static IEnumerable<Tuple<Coords, Coords>> LineToSegments(IImmutableList<Coords> line)
 {
     var seed = new List<Tuple<Coords, Coords>> { Tuple.Create(new Coords(999, 999), line.First()) };
     var tuples = line.Skip(1).Aggregate(seed, (acc, current) =>
     {
         var previous = acc.Last().Item2;
         acc.Add(Tuple.Create(previous, current));
         return acc;
     });
     return tuples.Skip(1);
 }
コード例 #11
0
        public ParallelAction(IEnumerable<IAction> children)
        {
            Ensure.ArgumentNotNull(children, nameof(children), assertContentsNotNull: true);

            this.children = children.ToImmutableList();
            this.duration = this
                .children
                .Select(x => x.Duration)
                .DefaultIfEmpty()
                .Max();
        }
コード例 #12
0
 private static IImmutableList<Field> AddFields(IImmutableList<Field> derivedTypeFields, Type type)
 {
    if (type == null)
       return derivedTypeFields;
    var fields = type.GetNestedTypes()
       .Aggregate(derivedTypeFields, AddFields);
    var fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static)
       .Where(field => FieldType.IsAssignableFrom(field.FieldType));
    var fieldsForThisType = fieldInfos.Select(field => (Field)field.GetValue(null));
    return AddFields(fields.AddRange(fieldsForThisType), type.BaseType);
 }
コード例 #13
0
        public SequenceAction(IEnumerable<IAction> children)
        {
            children.AssertNotNull(nameof(children), assertContentsNotNull: true);

            this.children = children.ToImmutableList();
            this.duration = this
                .children
                .Select(x => x.Duration)
                .DefaultIfEmpty()
                .Aggregate((running, next) => running + next);
        }
コード例 #14
0
ファイル: Graph.cs プロジェクト: MrTortoise/graphviz
        public Graph(GraphKinds graphKind, Id name, IImmutableList<Statement> statements)
        {
            if (statements == null)
            {
                throw new ArgumentNullException("statements");
            }

            this.graphKind = graphKind;
            this.name = name;
            this.statements = statements;
        }
コード例 #15
0
        internal TypeScriptApiMethod(string name, string url, string verb, IImmutableList<TypeScriptApiMethodArgument> arguments, string returnType)
        {
            Name = name;
            Url = url;
            Verb = verb.ToUpper();
            Arguments = arguments;
            ReturnType = returnType;

            FormattedArguments = GetFormattedArguments();
            FormattedEndpoint = GetFormattedEndpoint();
            FormattedData = GetFormattedData();
        }
コード例 #16
0
ファイル: Part.cs プロジェクト: nehresmann/Nyaxix.Irc
        public Part(string server, Prefix prefix, IImmutableList<string> destinations)
        {
            if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("Null or whitespace string", "server");
            if (prefix == null) throw new ArgumentNullException("prefix");
            if (destinations == null) throw new ArgumentNullException("destinations");
            if (destinations.Count == 0 || destinations.Any(c => String.IsNullOrWhiteSpace(c))) throw new ArgumentException("Empty destination list or list contains an empty element.", "destinations");

            this.server = server;
            this.prefix = prefix;
            this.destinations = destinations;
            this.ircMessage = Common.CreateIrcMessageFormat(this.Prefix, Part.CanonicalCommand, "{0}", this.Destinations);
        }
コード例 #17
0
ファイル: List.cs プロジェクト: nehresmann/Nyaxix.Irc
        public List(string server, Prefix prefix, IImmutableList<string> channels)
        {
            if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("Null or whitespace string", "server");
            if (prefix == null) throw new ArgumentNullException("prefix");
            if (channels == null) throw new ArgumentNullException("channels");
            if (channels.Count == 0 || channels.Any(c => String.IsNullOrWhiteSpace(c))) throw new ArgumentException("Empty channel list or list contains an empty element.", "channels");

            this.server = server;
            this.prefix = prefix;
            this.channels = channels;
            this.ircMessage = Common.CreateIrcMessageFormat(prefix, List.CanonicalCommand, "{0}", String.Join(",", this.Channels));
        }
コード例 #18
0
ファイル: Message.cs プロジェクト: nehresmann/Nyaxix.Irc
        public Message(string server, Prefix prefix, string command, IImmutableList<string> parameters)
        {
            if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("String null or empty", "server");
            if (prefix == null) throw new ArgumentNullException("prefix");
            if (String.IsNullOrWhiteSpace(command)) throw new ArgumentException("String null or empty", "command");
            if (parameters == null) throw new ArgumentNullException("parameters");
            if (parameters.Any(s => String.IsNullOrWhiteSpace(s))) throw new ArgumentException("Empty or null parameter", "parameters");

            this.server = server;
            this.prefix = prefix;
            this.command = command;
            this.parameters = parameters;
        }
コード例 #19
0
        public void RemoveDigitsOtherThan(IImmutableList<InternalRow> internalRows)
        {
            var placedDigitsToRemove = _placedDigits.Where(pd =>
            {
                return internalRows.FirstOrDefault(ir => ir.Item1.Equals(pd.Key.Item1) && ir.Item2 == pd.Key.Item2) == null;
            }).ToList();

            foreach (var placedDigitToRemove in placedDigitsToRemove)
            {
                BoardCanvas.Children.Remove(placedDigitToRemove.Value);
                _placedDigits.Remove(placedDigitToRemove);
            }
        }
コード例 #20
0
ファイル: ProjectEntry.cs プロジェクト: Runt-Editor/Runt
 protected ProjectEntry(string rel, bool isOpen, DirectoryInfo dir, ImmutableList<DirectoryEntry> directories,
     ImmutableList<Entry> files, ReferencesEntry references, ImmutableList<DiagnosticMessage> diagnostics, int id,
     ImmutableList<string> sources, ImmutableDictionary<string, string> generatedSources,
     IImmutableList<ConfigurationData> configurations)
     : base(rel, isOpen, dir, directories, files)
 {
     _id = id;
     _references = references;
     _children = new Lazy<IReadOnlyList<Entry>>(() => ImmutableList.Create<Entry>(_references).AddRange(base.Children));
     _diagnostics = diagnostics;
     _sources = sources;
     _generatedSources = generatedSources;
     _configurations = configurations;
 }
コード例 #21
0
ファイル: Join.cs プロジェクト: nehresmann/Nyaxix.Irc
        public Join(string server, Prefix prefix, IImmutableList<string> channels, Maybe<IImmutableList<string>> keys)
        {
            if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("Null or whitespace string", "server");
            if (prefix == null) throw new ArgumentNullException("prefix");
            if (channels == null) throw new ArgumentNullException("channels");
            if (channels.Count == 0 || channels.Any(c => String.IsNullOrWhiteSpace(c))) throw new ArgumentException("Empty channel list or list contains an empty element.", "channels");
            if (keys.HasValue && keys.Value.Count != 0 && (keys.Value.Count != channels.Count || keys.Value.Any(k => String.IsNullOrWhiteSpace(k)))) throw new ArgumentException("Non-empty key list contains an empty element or doesn't have the same number of elements as the channel list.", "keys");

            this.server = server;
            this.prefix = prefix;
            this.channels = channels;
            this.keys = keys.DefaultIfEmpty(ImmutableList<string>.Empty).Single();
            this.ircMessage = Common.CreateIrcMessageFormat(prefix, Join.CanonicalCommand, "{0} {1}", String.Join(",", this.Channels), String.Join(",", this.Keys));
        }
コード例 #22
0
        public ExerciseProgram(ILoggerService loggerService, string name, IEnumerable<Exercise> exercises)
        {
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(name, nameof(name));
            Ensure.ArgumentNotNull(exercises, nameof(exercises), assertContentsNotNull: true);

            this.logger = loggerService.GetLogger(this.GetType());
            this.name = name;
            this.exercises = exercises.ToImmutableList();
            this.duration = this
                .exercises
                .Select(x => x.Duration)
                .DefaultIfEmpty()
                .Aggregate((running, next) => running + next);
        }
コード例 #23
0
ファイル: Grid.cs プロジェクト: taylorjg/RippleEffectDlx
        public Grid(IImmutableList<string> rowStrings)
        {
            if (rowStrings == null) throw new ArgumentNullException(nameof(rowStrings));

            var rows = new List<IImmutableList<int>>();

            foreach (var rowString in rowStrings)
            {
                var row = new List<int>();

                foreach (var ch in rowString)
                {
                    if (!ValidChars.Contains(ch)) throw new ArgumentException(nameof(rowStrings));
                    row.Add(ch == SpaceCharacter ? 0 : ch - ZeroCharacter);
                }

                rows.Add(row.ToImmutableList());
            }

            _rows = rows.ToImmutableList();
        }
コード例 #24
0
    static IEnumerable<Segment> GetGraphKeyImpl(ISymbol symbol, IImmutableList<Segment> acc)
    {
      if (symbol == null)
        return acc.Reverse();

      if (symbol is ITypeSymbol)
        return GetGraphKeyImpl(symbol.ContainingSymbol, acc.Add(Segment.From(symbol, "+")));

      if (symbol is INamespaceSymbol)
      {
        if (((INamespaceSymbol)symbol).IsGlobalNamespace)
          return GetGraphKeyImpl(symbol.ContainingSymbol, acc);

        return GetGraphKeyImpl(symbol.ContainingSymbol, acc.Add(Segment.From(symbol, ".")));
      }

      if (symbol is IModuleSymbol)
        return GetGraphKeyImpl(symbol.ContainingSymbol, acc);

      if (symbol is IAssemblySymbol)
        return GetGraphKeyImpl(symbol.ContainingSymbol, acc);

      return GetGraphKeyImpl(symbol.ContainingSymbol, acc.Add(Segment.From(symbol, "!")));
    }
 public void UpdateShortcuts(IImmutableList <ReportsCalendarBaseQuickSelectShortcut> newShortcuts)
 {
     shortcuts = newShortcuts;
     collectionView.ReloadData();
 }
コード例 #26
0
 public WorldMapLocations(IImmutableList <WorldMapLocation> locations)
 {
     Locations = locations;
 }
コード例 #27
0
 public ImmutableListWithValueSemantics(IImmutableList <T> list) => _list = list;
コード例 #28
0
 public override Expression Build(IImmutableList <Expression> arguments, Expression body)
 => new ForeachDirective(arguments[0], arguments[2], body);
コード例 #29
0
 public static bool IsNullOrEmpty <TItem>(this IImmutableList <TItem> list)
 {
     return(list == null || list.Count < 1);
 }
コード例 #30
0
ファイル: GenotypeInfo.cs プロジェクト: scalavision/witty.er
 public static IGenotypeInfo Create(string originalGtString, bool isPhased,
                                    IImmutableList <string> genotypeIndices)
 => new GenotypeInfo(originalGtString, isPhased, genotypeIndices);
コード例 #31
0
ファイル: Aggregate.cs プロジェクト: ViktorHofer/arcade
        public async Task <IImmutableList <Models.AggregatedWorkItemCounts> > JobSummaryAsync(
            IImmutableList <string> groupBy,
            int maxResultSets,
            string build   = default,
            string creator = default,
            string name    = default,
            string source  = default,
            string type    = default,
            CancellationToken cancellationToken = default
            )
        {
            if (groupBy == default(IImmutableList <string>))
            {
                throw new ArgumentNullException(nameof(groupBy));
            }

            const string apiVersion = "2019-06-17";

            var _baseUri = Client.Options.BaseUri;
            var _url     = new RequestUriBuilder();

            _url.Reset(_baseUri);
            _url.AppendPath(
                "/api/aggregate/jobs",
                false);

            if (!string.IsNullOrEmpty(creator))
            {
                _url.AppendQuery("Creator", Client.Serialize(creator));
            }
            if (!string.IsNullOrEmpty(source))
            {
                _url.AppendQuery("Source", Client.Serialize(source));
            }
            if (!string.IsNullOrEmpty(type))
            {
                _url.AppendQuery("Type", Client.Serialize(type));
            }
            if (!string.IsNullOrEmpty(build))
            {
                _url.AppendQuery("Build", Client.Serialize(build));
            }
            if (!string.IsNullOrEmpty(name))
            {
                _url.AppendQuery("Name", Client.Serialize(name));
            }
            if (groupBy != default(IImmutableList <string>))
            {
                foreach (var _item in groupBy)
                {
                    _url.AppendQuery("groupBy", Client.Serialize(_item));
                }
            }
            if (maxResultSets != default(int))
            {
                _url.AppendQuery("maxResultSets", Client.Serialize(maxResultSets));
            }
            _url.AppendQuery("api-version", Client.Serialize(apiVersion));


            using (var _req = Client.Pipeline.CreateRequest())
            {
                _req.Uri    = _url;
                _req.Method = RequestMethod.Get;

                using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false))
                {
                    if (_res.Status < 200 || _res.Status >= 300)
                    {
                        await OnJobSummaryFailed(_req, _res).ConfigureAwait(false);
                    }

                    if (_res.ContentStream == null)
                    {
                        await OnJobSummaryFailed(_req, _res).ConfigureAwait(false);
                    }

                    using (var _reader = new StreamReader(_res.ContentStream))
                    {
                        var _content = await _reader.ReadToEndAsync().ConfigureAwait(false);

                        var _body = Client.Deserialize <IImmutableList <Models.AggregatedWorkItemCounts> >(_content);
                        return(_body);
                    }
                }
            }
        }
コード例 #32
0
 public static IImmutableList <T> RemoveRange <T>(this IImmutableList <T> list, IEnumerable <T> items)
 {
     Requires.NotNull(list, "list");
     return(list.RemoveRange(items, EqualityComparer <T> .Default));
 }
コード例 #33
0
 public static int IndexOf <T>(this IImmutableList <T> list, T item, IEqualityComparer <T> equalityComparer)
 {
     Requires.NotNull(list, "list");
     return(list.IndexOf(item, 0, list.Count, equalityComparer));
 }
コード例 #34
0
ファイル: Person.cs プロジェクト: mattwarren/DemoCode
 public Person WithPhones(IImmutableList<PhoneNumber> phones)
 {
     return new Person(Name, Address, phones);
 }
コード例 #35
0
 public static int LastIndexOf <T>(this IImmutableList <T> list, T item, int startIndex, int count)
 {
     Requires.NotNull(list, "list");
     return(list.LastIndexOf(item, startIndex, count, EqualityComparer <T> .Default));
 }
コード例 #36
0
ファイル: Person.cs プロジェクト: ivandrofly/DemoCode
 private Person(Builder builder)
 {
     Name = builder.Name;
     Address = builder.Address;
     Phones = builder.Phones.ToImmutableList();
 }
コード例 #37
0
        public async Task SetMergePoliciesAsync(
            string branch,
            string repository,
            IImmutableList <Models.MergePolicy> body = default,
            CancellationToken cancellationToken      = default
            )
        {
            if (string.IsNullOrEmpty(branch))
            {
                throw new ArgumentNullException(nameof(branch));
            }

            if (string.IsNullOrEmpty(repository))
            {
                throw new ArgumentNullException(nameof(repository));
            }

            const string apiVersion = "2019-01-16";

            var _baseUri = Client.Options.BaseUri;
            var _url     = new RequestUriBuilder();

            _url.Reset(_baseUri);
            _url.AppendPath(
                "/api/repo-config/merge-policy",
                false);

            if (!string.IsNullOrEmpty(repository))
            {
                _url.AppendQuery("repository", Client.Serialize(repository));
            }
            if (!string.IsNullOrEmpty(branch))
            {
                _url.AppendQuery("branch", Client.Serialize(branch));
            }
            _url.AppendQuery("api-version", Client.Serialize(apiVersion));


            using (var _req = Client.Pipeline.CreateRequest())
            {
                _req.Uri    = _url;
                _req.Method = RequestMethod.Post;

                if (body != default(IImmutableList <Models.MergePolicy>))
                {
                    _req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
                    _req.Headers.Add("Content-Type", "application/json; charset=utf-8");
                }

                using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false))
                {
                    if (_res.Status < 200 || _res.Status >= 300)
                    {
                        await OnSetMergePoliciesFailed(_req, _res).ConfigureAwait(false);
                    }


                    return;
                }
            }
        }
コード例 #38
0
    static public (ProcessOutput processOutput, IReadOnlyCollection <(IImmutableList <string> path, IReadOnlyList <byte> content)> resultingFiles) ExecuteFileWithArguments(
        IReadOnlyDictionary <IImmutableList <string>, IReadOnlyList <byte> > environmentFilesNotExecutable,
        byte[] executableFile,
        string arguments,
        IDictionary <string, string>?environmentStrings,
        IImmutableList <string>?workingDirectory = null,
        IReadOnlyDictionary <IImmutableList <string>, IReadOnlyList <byte> >?environmentFilesExecutable = null,
        IReadOnlyDictionary <string, IReadOnlyList <byte> >?environmentPathExecutableFiles = null)
    {
        var environmentStringsDict =
            environmentStrings?.ToImmutableDictionary() ?? ImmutableDictionary <string, string> .Empty;

        var environmentPathContainerDirectoryName = "environment-path-cont";

        var containerDirectory = Filesystem.CreateRandomDirectoryInTempDirectory();

        string writeEnvironmentFile(KeyValuePair <IImmutableList <string>, IReadOnlyList <byte> > environmentFile)
        {
            var environmentFilePath      = Path.Combine(containerDirectory, Filesystem.MakePlatformSpecificPath(environmentFile.Key));
            var environmentFileDirectory = Path.GetDirectoryName(environmentFilePath) !;

            Directory.CreateDirectory(environmentFileDirectory);

            File.WriteAllBytes(environmentFilePath, (environmentFile.Value as byte[]) ?? environmentFile.Value.ToArray());

            return(environmentFilePath);
        }

        foreach (var environmentFile in environmentFilesNotExecutable)
        {
            writeEnvironmentFile(environmentFile);
        }

        var mainExecutableFileName         = "name-used-to-execute-file.exe";
        var mainExecutableFilePathRelative = ImmutableList.Create(mainExecutableFileName);

        var executableFileNameAppendix =
            RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "";

        var allExecutableFiles =
            (environmentFilesExecutable ?? ImmutableDictionary <IImmutableList <string>, IReadOnlyList <byte> > .Empty)
            .ToImmutableDictionary()
            .SetItems(
                (environmentPathExecutableFiles ?? ImmutableDictionary <string, IReadOnlyList <byte> > .Empty)
                .Select(execFile => new KeyValuePair <IImmutableList <string>, IReadOnlyList <byte> >(
                            ImmutableList.Create(environmentPathContainerDirectoryName, execFile.Key + executableFileNameAppendix), execFile.Value)))
            .SetItem(mainExecutableFilePathRelative, executableFile);

        foreach (var environmentFile in allExecutableFiles)
        {
            var fileAbsolutePath = writeEnvironmentFile(environmentFile);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                var unixFileInfo = new UnixFileInfo(fileAbsolutePath);

                unixFileInfo.FileAccessPermissions |=
                    FileAccessPermissions.GroupExecute | FileAccessPermissions.UserExecute | FileAccessPermissions.OtherExecute |
                    FileAccessPermissions.GroupRead | FileAccessPermissions.UserRead | FileAccessPermissions.OtherRead;
            }
        }

        var workingDirectoryAbsolute =
            Path.Combine(
                containerDirectory,
                Filesystem.MakePlatformSpecificPath(workingDirectory ?? ImmutableList <string> .Empty));

        var mainExecutableFilePathAbsolute = Path.Combine(containerDirectory, mainExecutableFileName);

        var environmentPathExecutableFilesPathAbsolute = Path.Combine(containerDirectory, environmentPathContainerDirectoryName);

        var pathEnvironmentVarSeparator =
            RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ";" : ":";

        var environmentPathEntryBefore =
            environmentStringsDict.FirstOrDefault(c => c.Key.Equals("PATH", StringComparison.InvariantCultureIgnoreCase));

        var environmentPath = environmentPathExecutableFilesPathAbsolute + pathEnvironmentVarSeparator + environmentPathEntryBefore.Value;

        var environmentStringsWithExecutableFiles =
            environmentStringsDict
            .SetItem(environmentPathEntryBefore.Key ?? "PATH", environmentPath);

        var process = new Process
        {
            StartInfo = new ProcessStartInfo
            {
                WorkingDirectory       = workingDirectoryAbsolute,
                FileName               = mainExecutableFilePathAbsolute,
                Arguments              = arguments,
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
            },
        };

        foreach (var envString in environmentStringsWithExecutableFiles.EmptyIfNull())
        {
            process.StartInfo.Environment[envString.Key] = envString.Value;
        }

        process.Start();
        var standardOutput = process.StandardOutput.ReadToEnd();
        var standardError  = process.StandardError.ReadToEnd();

        process.WaitForExit();
        var exitCode = process.ExitCode;

        process.Close();

        var createdFiles =
            Filesystem.GetFilesFromDirectory(
                directoryPath: containerDirectory,
                filterByRelativeName: path => !path.SequenceEqual(mainExecutableFilePathRelative));

        try
        {
            Directory.Delete(path: containerDirectory, recursive: true);
        }
        // Avoid crash in scenario like https://forum.botlab.org/t/farm-manager-tribal-wars-2-farmbot/3038/170
        catch (UnauthorizedAccessException)
        {
        }

        return(new ProcessOutput
        {
            ExitCode = exitCode,
            StandardError = standardError,
            StandardOutput = standardOutput,
        }, createdFiles);
    }
コード例 #39
0
ファイル: Aggregate.cs プロジェクト: ViktorHofer/arcade
        public async Task <IImmutableList <Models.AggregateAnalysisDetail> > AnalysisDetailAsync(
            string analysisName,
            string analysisType,
            string build,
            IImmutableList <string> groupBy,
            string source,
            string type,
            string workitem,
            CancellationToken cancellationToken = default
            )
        {
            if (string.IsNullOrEmpty(analysisName))
            {
                throw new ArgumentNullException(nameof(analysisName));
            }

            if (string.IsNullOrEmpty(analysisType))
            {
                throw new ArgumentNullException(nameof(analysisType));
            }

            if (string.IsNullOrEmpty(build))
            {
                throw new ArgumentNullException(nameof(build));
            }

            if (groupBy == default(IImmutableList <string>))
            {
                throw new ArgumentNullException(nameof(groupBy));
            }

            if (string.IsNullOrEmpty(source))
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (string.IsNullOrEmpty(type))
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (string.IsNullOrEmpty(workitem))
            {
                throw new ArgumentNullException(nameof(workitem));
            }

            const string apiVersion = "2019-06-17";

            var _baseUri = Client.Options.BaseUri;
            var _url     = new RequestUriBuilder();

            _url.Reset(_baseUri);
            _url.AppendPath(
                "/api/aggregate/analysisdetail",
                false);

            if (!string.IsNullOrEmpty(source))
            {
                _url.AppendQuery("source", Client.Serialize(source));
            }
            if (!string.IsNullOrEmpty(type))
            {
                _url.AppendQuery("type", Client.Serialize(type));
            }
            if (!string.IsNullOrEmpty(build))
            {
                _url.AppendQuery("build", Client.Serialize(build));
            }
            if (!string.IsNullOrEmpty(workitem))
            {
                _url.AppendQuery("workitem", Client.Serialize(workitem));
            }
            if (!string.IsNullOrEmpty(analysisType))
            {
                _url.AppendQuery("analysisType", Client.Serialize(analysisType));
            }
            if (!string.IsNullOrEmpty(analysisName))
            {
                _url.AppendQuery("analysisName", Client.Serialize(analysisName));
            }
            if (groupBy != default(IImmutableList <string>))
            {
                foreach (var _item in groupBy)
                {
                    _url.AppendQuery("groupBy", Client.Serialize(_item));
                }
            }
            _url.AppendQuery("api-version", Client.Serialize(apiVersion));


            using (var _req = Client.Pipeline.CreateRequest())
            {
                _req.Uri    = _url;
                _req.Method = RequestMethod.Get;

                using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false))
                {
                    if (_res.Status < 200 || _res.Status >= 300)
                    {
                        await OnAnalysisDetailFailed(_req, _res).ConfigureAwait(false);
                    }

                    if (_res.ContentStream == null)
                    {
                        await OnAnalysisDetailFailed(_req, _res).ConfigureAwait(false);
                    }

                    using (var _reader = new StreamReader(_res.ContentStream))
                    {
                        var _content = await _reader.ReadToEndAsync().ConfigureAwait(false);

                        var _body = Client.Deserialize <IImmutableList <Models.AggregateAnalysisDetail> >(_content);
                        return(_body);
                    }
                }
            }
        }
コード例 #40
0
        public ScenarioTests_AzDoFlow()
        {
            source1Assets        = GetAssetData("Foo", "1.1.0", "Bar", "2.1.0");
            source2Assets        = GetAssetData("Pizza", "3.1.0", "Hamburger", "4.1.0");
            source1AssetsUpdated = GetAssetData("Foo", "1.17.0", "Bar", "2.17.0");

            expectedAzDoDependenciesSource1 = new List <DependencyDetail>();
            string           sourceRepoUri = GetAzDoRepoUrl(TestRepository.TestRepo1Name);
            DependencyDetail foo           = new DependencyDetail
            {
                Name    = "Foo",
                Version = "1.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedAzDoDependenciesSource1.Add(foo);

            DependencyDetail bar = new DependencyDetail
            {
                Name    = "Bar",
                Version = "2.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedAzDoDependenciesSource1.Add(bar);

            expectedAzDoDependenciesSource2 = new List <DependencyDetail>();
            string           source2RepoUri = GetAzDoRepoUrl(TestRepository.TestRepo3Name);
            DependencyDetail pizza          = new DependencyDetail
            {
                Name    = "Pizza",
                Version = "3.1.0",
                RepoUri = source2RepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedAzDoDependenciesSource2.Add(pizza);

            DependencyDetail hamburger = new DependencyDetail
            {
                Name    = "Hamburger",
                Version = "4.1.0",
                RepoUri = source2RepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedAzDoDependenciesSource2.Add(hamburger);

            expectedAzDoDependenciesSource1Updated = new List <DependencyDetail>();
            DependencyDetail fooUpdated = new DependencyDetail
            {
                Name    = "Foo",
                Version = "1.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedAzDoDependenciesSource1Updated.Add(fooUpdated);

            DependencyDetail barUpdated = new DependencyDetail
            {
                Name    = "Bar",
                Version = "2.1.0",
                RepoUri = sourceRepoUri,
                Commit  = TestRepository.CoherencyTestRepo1Commit,
                Type    = DependencyType.Product,
                Pinned  = false
            };

            expectedAzDoDependenciesSource1Updated.Add(barUpdated);
        }
コード例 #41
0
ファイル: Aggregate.cs プロジェクト: ViktorHofer/arcade
        public async Task <Models.BuildAggregation> BuildAsync(
            string buildNumber,
            IImmutableList <string> sources,
            IImmutableList <string> types,
            CancellationToken cancellationToken = default
            )
        {
            if (string.IsNullOrEmpty(buildNumber))
            {
                throw new ArgumentNullException(nameof(buildNumber));
            }

            if (sources == default(IImmutableList <string>))
            {
                throw new ArgumentNullException(nameof(sources));
            }

            if (types == default(IImmutableList <string>))
            {
                throw new ArgumentNullException(nameof(types));
            }

            const string apiVersion = "2019-06-17";

            var _baseUri = Client.Options.BaseUri;
            var _url     = new RequestUriBuilder();

            _url.Reset(_baseUri);
            _url.AppendPath(
                "/api/aggregate/build",
                false);

            if (sources != default(IImmutableList <string>))
            {
                foreach (var _item in sources)
                {
                    _url.AppendQuery("sources", Client.Serialize(_item));
                }
            }
            if (types != default(IImmutableList <string>))
            {
                foreach (var _item in types)
                {
                    _url.AppendQuery("types", Client.Serialize(_item));
                }
            }
            if (!string.IsNullOrEmpty(buildNumber))
            {
                _url.AppendQuery("buildNumber", Client.Serialize(buildNumber));
            }
            _url.AppendQuery("api-version", Client.Serialize(apiVersion));


            using (var _req = Client.Pipeline.CreateRequest())
            {
                _req.Uri    = _url;
                _req.Method = RequestMethod.Get;

                using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false))
                {
                    if (_res.Status < 200 || _res.Status >= 300)
                    {
                        await OnBuildFailed(_req, _res).ConfigureAwait(false);
                    }

                    if (_res.ContentStream == null)
                    {
                        await OnBuildFailed(_req, _res).ConfigureAwait(false);
                    }

                    using (var _reader = new StreamReader(_res.ContentStream))
                    {
                        var _content = await _reader.ReadToEndAsync().ConfigureAwait(false);

                        var _body = Client.Deserialize <Models.BuildAggregation>(_content);
                        return(_body);
                    }
                }
            }
        }
コード例 #42
0
        public bool TryGetBlockUnmintedTxes(UInt256 blockHash, out IImmutableList <UnmintedTx> unmintedTxes)
        {
            CheckTransaction();

            return(CursorTryGet(blockHash, out unmintedTxes, this.unmintedTxes, MakeUnmintedTxesKey, x => DataDecoder.DecodeUnmintedTxList(x)));
        }
コード例 #43
0
ファイル: GenotypeInfo.cs プロジェクト: scalavision/witty.er
 private GenotypeInfo(string originalGtString, bool isPhased, IImmutableList <string> genotypeIndices)
 {
     OriginalGtString = originalGtString;
     IsPhased         = isPhased;
     GenotypeIndices  = genotypeIndices;
 }
コード例 #44
0
        public bool TryAddBlockUnmintedTxes(UInt256 blockHash, IImmutableList <UnmintedTx> unmintedTxes)
        {
            CheckWriteTransaction();

            return(this.unmintedTxes.TryAdd(blockHash, unmintedTxes));
        }
コード例 #45
0
        public IEnumerable <TSol> SelectParents(IImmutableList <TSol> sortedPopulation)
        {
            var truncatedPopulation = sortedPopulation.Take((int)(selectionIntensity * sortedPopulation.Count));

            return(baseSelectionAlgorithm.SelectParents(truncatedPopulation.ToImmutableArray()));
        }
コード例 #46
0
 public BakingDish <T>?FindBakingDish <T>(IImmutableList <T> cups)
 {
     return(new BakingDish <T>(cups));
 }
コード例 #47
0
 public static IImmutableList <T> Remove <T>(this IImmutableList <T> list, T value)
 {
     Requires.NotNull(list, "list");
     return(list.Remove(value, EqualityComparer <T> .Default));
 }
コード例 #48
0
 public static IImmutableList <T> Replace <T>(this IImmutableList <T> list, T oldValue, T newValue)
 {
     Requires.NotNull(list, "list");
     return(list.Replace(oldValue, newValue, EqualityComparer <T> .Default));
 }
コード例 #49
0
 public static ImmutableListWithValueSemantics <T> WithValueSemantics <T>(this IImmutableList <T> list) => new(list);
コード例 #50
0
ファイル: InputSequence.cs プロジェクト: Dnantz/tpp-core
 public InputSequence(IEnumerable <InputSet> inputSets)
 {
     InputSets = inputSets.ToImmutableList();
 }
コード例 #51
0
 public DetectedFlagArgument(string flagName, IImmutableList <string> leftSideArguments, IImmutableList <string> rightSideArguments)
 {
     FlagName           = flagName;
     LeftSideArguments  = leftSideArguments;
     RightSideArguments = rightSideArguments;
 }
コード例 #52
0
 public OrdersAssigned(double fee, IImmutableList <HashValue> orders)
 {
     Fee    = fee;
     Orders = orders ?? throw new NullReferenceException("orders");
 }
コード例 #53
0
ファイル: TetraStick.cs プロジェクト: taylorjg/TetraSticks
 public TetraStick(string tag, IImmutableList<Coords> interiorJunctionPoints, params IImmutableList<Coords>[] lines)
 {
     Tag = tag;
     InteriorJunctionPoints = interiorJunctionPoints;
     Lines = ImmutableList.CreateRange(lines);
 }
コード例 #54
0
 public ActionDragManager(string request, IImmutableList <ImmutableAction> action, IMessageQueue queue) : base(request)
 {
     _actions = action;
     _queue   = queue;
 }
コード例 #55
0
ファイル: Person.cs プロジェクト: mattwarren/DemoCode
 public Person(string name, Address address, IImmutableList<PhoneNumber> phones)
 {
     Name = name;
     Address = address;
     Phones = phones;
 }
コード例 #56
0
 public StuffDragManager(string request, IImmutableList <StuffId> stuff, IMessageQueue queue) : base(request)
 {
     Stuff  = stuff;
     _queue = queue;
 }
コード例 #57
0
ファイル: LocalClient.cs プロジェクト: knocte/BitSharp
        //TODO move into p2p node
        private static ImmutableArray<UInt256> CalculateBlockLocatorHashes(IImmutableList<ChainedBlock> blockHashes)
        {
            var blockLocatorHashes = new List<UInt256>();

            if (blockHashes.Count > 0)
            {
                var step = 1;
                var start = 0;
                for (var i = blockHashes.Count - 1; i > 0; i -= step, start++)
                {
                    if (start >= 10)
                        step *= 2;

                    blockLocatorHashes.Add(blockHashes[i].BlockHash);
                }
                blockLocatorHashes.Add(blockHashes[0].BlockHash);
            }

            return blockLocatorHashes.ToImmutableArray();
        }
コード例 #58
0
 public ReloadCollectionViewSource(IImmutableList <TModel> items, CellConfiguration configureCell)
 {
     this.items         = items;
     this.configureCell = configureCell;
 }
コード例 #59
0
        private static IEnumerable<InternalRow> BuildInternalRowsForRoom(IReadOnlyList<Room> rooms, IImmutableList<InitialValue> initialValues, Room room)
        {
            var cellsWithInitialValues = initialValues.Select(initialValue => initialValue.Item1);
            var initialValuesInThisRoom = initialValues.Where(initialValue => room.Cells.Contains(initialValue.Item1)).Select(initialValue => initialValue.Item2);

            var cellsRemaining = room.Cells.Except(cellsWithInitialValues).ToImmutableList();
            var valuesRemaining = Enumerable.Range(1, room.Cells.Count).Except(initialValuesInThisRoom).ToImmutableList();

            return
                from cell in cellsRemaining
                from value in valuesRemaining
                select BuildInternalRow(rooms, cell, value, false);
        }
コード例 #60
0
        public async Task Darc_AzDoFlow_FeedFlow()
        {
            TestContext.WriteLine("AzDo Dependency Feed Flow, non-batched");

            // Feed flow test strings
            string proxyFeed      = "https://some-proxy.azurewebsites.net/container/some-container/sig/somesig/se/2020-02-02/darc-int-maestro-test1-bababababab-1/index.json";
            string azdoFeed1      = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-efabaababababe-1/nuget/v3/index.json";
            string azdoFeed2      = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-efabaababababd-1/nuget/v3/index.json";
            string azdoFeed3      = "https://some_org.pkgs.visualstudio.com/_packaging/darc-int-maestro-test1-efabaababababf-1/nuget/v3/index.json";
            string regularFeed    = "https://dotnetfeed.blob.core.windows.net/maestro-test1/index.json";
            string buildContainer = "https://dev.azure.com/dnceng/internal/_apis/build/builds/9999999/artifacts";

            string[] expectedFeeds    = { proxyFeed, azdoFeed1, azdoFeed3 };
            string[] notExpectedFeeds = { regularFeed, azdoFeed2, buildContainer };

            IImmutableList <AssetData> feedFlowSourceAssets = ImmutableList.Create(
                GetAssetDataWithLocations(
                    "Foo",
                    "1.1.0",
                    proxyFeed,
                    LocationType.NugetFeed
                    ),
                GetAssetDataWithLocations(
                    "Bar",
                    "2.1.0",
                    azdoFeed1,
                    LocationType.NugetFeed),
                GetAssetDataWithLocations(
                    "Pizza",
                    "3.1.0",
                    azdoFeed2,
                    LocationType.NugetFeed,
                    regularFeed,
                    LocationType.NugetFeed
                    ),
                GetAssetDataWithLocations(
                    "Hamburger",
                    "4.1.0",
                    azdoFeed3,
                    LocationType.NugetFeed,
                    buildContainer,
                    LocationType.Container)
                );

            TestContext.WriteLine("Azure DevOps Internal feed flow");
            TestParameters parameters = await TestParameters.GetAsync();

            SetTestParameters(parameters);

            EndToEndFlowLogic testLogic = new EndToEndFlowLogic(parameters);

            List <DependencyDetail> expectedAzDoFeedFlowDependencies = new List <DependencyDetail>();

            DependencyDetail feedFoo = new DependencyDetail
            {
                Name      = "Foo",
                Version   = "1.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    proxyFeed
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedFoo);

            DependencyDetail feedBar = new DependencyDetail
            {
                Name      = "Bar",
                Version   = "2.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    azdoFeed1
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedBar);

            DependencyDetail feedPizza = new DependencyDetail
            {
                Name      = "Pizza",
                Version   = "3.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    azdoFeed2, regularFeed
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedPizza);

            DependencyDetail feedHamburger = new DependencyDetail
            {
                Name      = "Hamburger",
                Version   = "4.1.0",
                RepoUri   = GetAzDoRepoUrl(TestRepository.TestRepo1Name),
                Commit    = TestRepository.CoherencyTestRepo1Commit,
                Type      = DependencyType.Product,
                Pinned    = false,
                Locations = new List <string> {
                    azdoFeed3, buildContainer
                }
            };

            expectedAzDoFeedFlowDependencies.Add(feedHamburger);
            await testLogic.NonBatchedAzDoFlowTestBase(
                $"AzDo_FeedFlowBranch_{Environment.MachineName}",
                $"AzDo_FeedFlowChannel_{Environment.MachineName}",
                feedFlowSourceAssets,
                expectedAzDoFeedFlowDependencies,
                isFeedTest : true,
                expectedFeeds : expectedFeeds,
                notExpectedFeeds : notExpectedFeeds).ConfigureAwait(false);
        }