Ejemplo n.º 1
0
        public bool MatchArgs(IJsTypeInfo[] arguments, MatchAntiCycle antiCycle = null)
        {
            antiCycle = antiCycle ?? new MatchAntiCycle();
            if (ArgumentTypes.Length < arguments.Length && MoreArgsType == null)
            {
                return(false);
            }
            int i = 0;

            for (; i < arguments.Length; i++)
            {
                if (!(ArgumentTypes.Length >= i ? MoreArgsType : ArgumentTypes[i]).MatchType(arguments[i], antiCycle))
                {
                    return(false);
                }
            }
            for (; i < this.ArgumentTypes.Length; i++)
            {
                if (!this.ArgumentTypes[i].CanBeNull)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public bool MatchSig(JsMethodSignature signature, MatchAntiCycle antiCycle = null)
        {
            if (signature == this)
            {
                return(true);
            }

            antiCycle = antiCycle ?? new MatchAntiCycle();

            if (this.MoreArgsType == null && (signature.MoreArgsType != null || signature.ArgumentTypes.Length > this.ArgumentTypes.Length))
            {
                return(false);
            }

            if (!ArgumentTypes.Zip(signature.ArgumentTypes, (a, b) => a.MatchType(b, antiCycle)).All(_ => _))
            {
                return(false);
            }

            if (!signature.ArgumentTypes.Skip(this.ArgumentTypes.Length).All(a => this.MoreArgsType.MatchType(a, antiCycle)))
            {
                return(false);
            }

            if (!this.ArgumentTypes.Skip(signature.ArgumentTypes.Length).All(a => a.MatchType(signature.MoreArgsType, antiCycle)))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        //private static Dictionary<Type, Func<IJsTypeInfo, IJsTypeInfo, bool>> interfaceMatchers = new Dictionary<Type, Func<IJsTypeInfo, IJsTypeInfo, bool>>
        //{
        //    [typeof(IJsMemberAccessType)] = (a, b) =>
        //    {
        //    }
        //};
        public static bool MatchType(this IJsTypeInfo a, IJsTypeInfo b, MatchAntiCycle antiCycle = null)
        {
            if (a == null | b == null)
            {
                return(false);
            }
            if (a == b)
            {
                return(true);
            }

            if (a.Typeof != b.Typeof || a.Typeof == "object" && b.Typeof == "function")
            {
                return(false);
            }

            antiCycle = antiCycle ?? new MatchAntiCycle();
            antiCycle.Add((a, b));
            if (!a.CanBeNull && b.CanBeNull)
            {
                return(false);
            }

            if (a is IJsMemberAccessType aMember &&
                (!(b is IJsMemberAccessType bMember) ||
                 !aMember.ListProperties().All(
                     p => bMember.GetProperty(p.Name) is var p2 && p2.Exists && p.Type.MatchType(p2.Type, antiCycle))))
            {
                return(false);
            }

            if (a is IJsInvocableType aInvokable &&
                (!(b is IJsInvocableType bInvokable) ||
                 !(bInvokable.GetSignatures().ToArray() is var bSignatures &&
                   aInvokable.GetSignatures().All(sig =>
                                                  bSignatures.Any(sigB => sigB.MatchSig(sig, antiCycle))))))
            {
                return(false);
            }

            return(true);

            //foreach (var im in interfaceMatchers)
            //{
            //    var (ai, bi) = (im.Key.IsInstanceOfType(a), im.Key.IsInstanceOfType(b));
            //    if (ai && !bi) return false;
            //}
        }
Ejemplo n.º 4
0
    public static IList <string> GenerateArguments(
        Option <VideoInputFile> maybeVideoInputFile,
        Option <AudioInputFile> maybeAudioInputFile,
        Option <WatermarkInputFile> maybeWatermarkInputFile,
        Option <ConcatInputFile> maybeConcatInputFile,
        IList <IPipelineStep> pipelineSteps)
    {
        var arguments = new List <string>();

        foreach (IPipelineStep step in pipelineSteps)
        {
            arguments.AddRange(step.GlobalOptions);
        }

        var includedPaths = new System.Collections.Generic.HashSet <string>();

        foreach (VideoInputFile videoInputFile in maybeVideoInputFile)
        {
            includedPaths.Add(videoInputFile.Path);

            foreach (IInputOption step in videoInputFile.InputOptions)
            {
                arguments.AddRange(step.InputOptions(videoInputFile));
            }

            arguments.AddRange(new[] { "-i", videoInputFile.Path });
        }

        foreach (AudioInputFile audioInputFile in maybeAudioInputFile)
        {
            if (!includedPaths.Contains(audioInputFile.Path))
            {
                includedPaths.Add(audioInputFile.Path);

                foreach (IInputOption step in audioInputFile.InputOptions)
                {
                    arguments.AddRange(step.InputOptions(audioInputFile));
                }

                arguments.AddRange(new[] { "-i", audioInputFile.Path });
            }
        }

        foreach (WatermarkInputFile watermarkInputFile in maybeWatermarkInputFile)
        {
            if (!includedPaths.Contains(watermarkInputFile.Path))
            {
                includedPaths.Add(watermarkInputFile.Path);

                foreach (IInputOption step in watermarkInputFile.InputOptions)
                {
                    arguments.AddRange(step.InputOptions(watermarkInputFile));
                }

                arguments.AddRange(new[] { "-i", watermarkInputFile.Path });
            }
        }

        foreach (ConcatInputFile concatInputFile in maybeConcatInputFile)
        {
            foreach (IInputOption step in concatInputFile.InputOptions)
            {
                arguments.AddRange(step.InputOptions(concatInputFile));
            }

            arguments.AddRange(new[] { "-i", concatInputFile.Path });
        }

        foreach (IPipelineStep step in pipelineSteps)
        {
            arguments.AddRange(step.FilterOptions);
        }

        foreach (IPipelineStep step in pipelineSteps.Filter(s => s is not StreamSeekFilterOption))
        {
            arguments.AddRange(step.OutputOptions);
        }

        return(arguments);
    }
Ejemplo n.º 5
0
    protected async Task <Either <BaseError, TraktList> > MatchListItems(TvContext dbContext, TraktList list)
    {
        try
        {
            var ids = new System.Collections.Generic.HashSet <int>();

            foreach (TraktListItem item in list.Items
                     .OrderBy(i => i.Title).ThenBy(i => i.Year).ThenBy(i => i.Season).ThenBy(i => i.Episode))
            {
                switch (item.Kind)
                {
                case TraktListItemKind.Movie:
                    Option <int> maybeMovieId = await IdentifyMovie(dbContext, item);

                    foreach (int movieId in maybeMovieId)
                    {
                        ids.Add(movieId);
                        item.MediaItemId = movieId;
                    }

                    break;

                case TraktListItemKind.Show:
                    Option <int> maybeShowId = await IdentifyShow(dbContext, item);

                    foreach (int showId in maybeShowId)
                    {
                        ids.Add(showId);
                        item.MediaItemId = showId;
                    }

                    break;

                case TraktListItemKind.Season:
                    Option <int> maybeSeasonId = await IdentifySeason(dbContext, item);

                    foreach (int seasonId in maybeSeasonId)
                    {
                        ids.Add(seasonId);
                        item.MediaItemId = seasonId;
                    }

                    break;

                default:
                    Option <int> maybeEpisodeId = await IdentifyEpisode(dbContext, item);

                    foreach (int episodeId in maybeEpisodeId)
                    {
                        ids.Add(episodeId);
                        item.MediaItemId = episodeId;
                    }

                    break;
                }
            }

            await dbContext.SaveChangesAsync();

            foreach (int mediaItemId in ids)
            {
                Option <MediaItem> maybeItem = await _searchRepository.GetItemToIndex(mediaItemId);

                foreach (MediaItem item in maybeItem)
                {
                    await _searchIndex.UpdateItems(_searchRepository, new[] { item }.ToList());
                }
            }

            _searchIndex.Commit();

            return(list);
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Error matching trakt list items");
            return(BaseError.New(ex.Message));
        }
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReadOnlySet{T}"/> class
 /// that uses the specified equality comparer for the set type, contains elements
 /// copied from the specified collection, and has sufficient capacity to accommodate
 /// the number of elements copied.
 /// </summary>
 /// <param name="collection">The collection whose elements are copied to the new set.</param>
 /// <param name="comparer">The <see cref="IEqualityComparer{T}"/> implementation to use when
 /// comparing values in the set, or null to use the default <see cref="EqualityComparer{T}"/>
 /// implementation for the set type.</param>
 public ReadOnlySet(IEnumerable <T> collection, IEqualityComparer <T> comparer)
 {
     _set = new HashSet <T>(collection, comparer);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReadOnlySet{T}"/> class
 /// that is empty and uses the specified equality comparer for the set type.
 /// </summary>
 /// <param name="comparer">The <see cref="IEqualityComparer{T}"/> implementation to use when
 /// comparing values in the set, or null to use the default <see cref="EqualityComparer{T}"/>
 /// implementation for the set type.</param>
 public ReadOnlySet(IEqualityComparer <T> comparer)
 {
     _set = new HashSet <T>(comparer);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReadOnlySet{T}"/> class
 /// that uses the default equality comparer for the set type, contains elements copied
 /// from the specified collection, and has sufficient capacity to accommodate the
 /// number of elements copied.
 /// </summary>
 /// <param name="collection">The collection whose elements are copied to the new set.</param>
 public ReadOnlySet(IEnumerable <T> collection)
 {
     _set = new HashSet <T>(collection);
 }
Ejemplo n.º 9
0
    /// <summary>
    /// Asset Bundle-like export, except using DataNode's deep serialization.
    /// </summary>

    static public void ExportAssets(DataNode.SaveType type, string path)
    {
        EditorUtility.DisplayCancelableProgressBar("Working", "Collecting references...", 0f);

        ComponentSerialization.ClearReferences();

        var objects    = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        var components = new System.Collections.Generic.HashSet <string>();

        foreach (var obj in objects)
        {
            if (obj is MonoScript)
            {
                var s = obj.name;
                if (!components.Contains(s))
                {
                    components.Add(s);
                }
                continue;
            }

            var go = obj as GameObject;

            if (go)
            {
                go.CollectReferencedPrefabs(true);
                var comps = go.GetComponentsInChildren <MonoBehaviour>(true);

                foreach (var comp in comps)
                {
                    var t = comp.GetType().ToString();
                    if (!components.Contains(t))
                    {
                        components.Add(t);
                    }
                }
            }
            else
            {
                ComponentSerialization.AddReference(obj);
            }
        }

        EditorUtility.DisplayCancelableProgressBar("Working", "Copying scripts...", 0f);

        var dir = Tools.GetDirectoryFromPath(path);

        // Copy the scripts
        foreach (var c in components)
        {
            var fn = c + ".cs";
            var p  = Tools.FindFile(Application.dataPath, fn);
            if (!string.IsNullOrEmpty(p))
            {
                System.IO.File.Copy(p, System.IO.Path.Combine(dir, fn), true);
            }
        }

        EditorUtility.DisplayCancelableProgressBar("Working", "Creating a DataNode...", 0f);

        foreach (var pair in ComponentSerialization.referencedPrefabs)
        {
            pair.Value.CollectReferencedResources();
        }

        var data = ComponentSerialization.SerializeBundle();

        if (data != null && data.children.size > 0)
        {
            Save(data, path, type);
        }
        else
        {
            Debug.LogWarning("No assets found to serialize");
        }

        ComponentSerialization.ClearReferences();
        EditorUtility.ClearProgressBar();
    }
Ejemplo n.º 10
0
 // Use this for initialization
 void Awake()
 {
     current_maps_hash = LevelMap.LoadCurrentMapsHash();
     print("Current maps: " + current_maps_hash.Count);
 }
Ejemplo n.º 11
0
 private static int Count4dNeighbours(Space4 space, (int x, int y, int z, int w) coord)