예제 #1
0
        private void LoadExtensions()
        {
            var projectRegistry = new ProjectExtensionRegistry();

            RegistryUtil.ForEachPackage(this, "Projects", (packageId, key) =>
            {
                foreach (string projectId in key.GetSubKeyNames())
                {
                    using (var subKey = key.OpenSubKey(projectId + "\\Extensions"))
                    {
                        if (subKey != null)
                        {
                            projectRegistry.Add(LoadExtensionRegistry(new Guid(projectId), subKey));
                        }
                    }
                }
            });

            ProjectRegistries = new ReadOnlyKeyedCollection <Guid, IKeyedCollection <string, ExtensionRegistration> >(projectRegistry);

            RegistryUtil.ForEachPackage(this, "Extensions", (packageId, key) =>
            {
                DefaultRegistry = new ReadOnlyKeyedCollection <string, ExtensionRegistration>(LoadExtensionRegistry(null, key));
            });
        }
예제 #2
0
 public EditVarietyViewModel(IKeyedCollection<string, Variety> varieties, Variety variety)
 {
     _title = "Rename Variety";
     _varieties = varieties;
     _variety = variety;
     _name = variety.Name;
 }
예제 #3
0
 public EditVarietyViewModel(IKeyedCollection <string, Variety> varieties, Variety variety)
 {
     _title     = "Rename Variety";
     _varieties = varieties;
     _variety   = variety;
     _name      = variety.Name;
 }
예제 #4
0
        async Task <ChannelStored2[]> ChannelsToDiscover(LoggedConnection db, IKeyedCollection <string, ChannelStored2> channelPev, ILogger log)
        {
            var pendingSansVideo = await db.Query <(string channel_id, string channel_title)>("channels pending classification",
                                                                                              @"select distinct channel_id, channel_title
from channel_latest c
where review_status in ('Pending')
  and not exists(select * from video_extra_stage e where e.v:ChannelId::string=c.channel_id)
limit :DiscoverChannels
        ", param : new { RCfg.DiscoverChannels });

            log.Debug("Collect - found {Channels} channels pending discovery", pendingSansVideo.Count);

            var remaining   = RCfg.DiscoverChannels - pendingSansVideo.Count;
            var newDiscover = remaining > 0
        ? await db.Query <(string channel_id, string channel_title)>("channels to classify",
                                                                     @"with tc as (
    select to_channel_id, any_value(to_channel_title) as channel_title, count(*) as recs
    from rec
    where to_channel_id is not null
    group by to_channel_id
  )
  select to_channel_id as channel_id, channel_title from tc
  where not exists(select * from channel_stage c where c.v:ChannelId::string = to_channel_id)
  order by recs desc
  limit :remaining", param : new { remaining })
        : new (string channel_id, string channel_title)[]
            public bool MoveNext()
            {
                // We just started, so we're not in a collection yet
                if (currentCollection == null)
                {
                    // Try to find the first collection
                    if (collectionsEnumerator.MoveNext())
                    {
                        // There is at least a collection, start with this one
                        currentCollection = collectionsEnumerator.Current.Value;

                        if (currentCollection == null)
                        {
                            throw new InvalidOperationException("Merged sub collection is null.");
                        }
                    }
                    else
                    {
                        // There is no collection at all, stop
                        currentItem = default(TItem);
                        exceeded    = true;
                        return(false);
                    }
                }

                // Check if we're within the current collection
                if (indexInCurrentCollection < currentCollection.Count)
                {
                    // We are, return this element and move to the next
                    currentItem = currentCollection[indexInCurrentCollection];
                    indexInCurrentCollection++;
                    return(true);
                }

                // We're beyond the current collection, but there may be more,
                // and because there may be many empty collections, we need to check
                // them all until we find an element, not just the next one
                while (collectionsEnumerator.MoveNext())
                {
                    currentCollection        = collectionsEnumerator.Current.Value;
                    indexInCurrentCollection = 0;

                    if (currentCollection == null)
                    {
                        throw new InvalidOperationException("Merged sub collection is null.");
                    }

                    if (indexInCurrentCollection < currentCollection.Count)
                    {
                        currentItem = currentCollection[indexInCurrentCollection];
                        indexInCurrentCollection++;
                        return(true);
                    }
                }

                // We're beyond all collections, stop
                currentItem = default(TItem);
                exceeded    = true;
                return(false);
            }
KeyedCollection/*PERMUDA*/Proxy(
    IKeyedCollection/*PERMUDA*//*PERMUDA FROMSUFFIX*/ from
)
{
    NonNull.CheckParameter( from, "from" );
    this.From = from;
}
예제 #7
0
 public EditMeaningViewModel(IKeyedCollection<string, Meaning> meanings, Meaning meaning)
 {
     _title = "Edit Meaning";
     _meanings = meanings;
     _meaning = meaning;
     _gloss = meaning.Gloss;
     _category = meaning.Category;
 }
예제 #8
0
 public EditMeaningViewModel(IKeyedCollection <string, Meaning> meanings, Meaning meaning)
 {
     _title    = "Edit Meaning";
     _meanings = meanings;
     _meaning  = meaning;
     _gloss    = meaning.Gloss;
     _category = meaning.Category;
 }
        public virtual void Include <TSubItem>(IKeyedCollection <TKey, TSubItem> collection) where TSubItem : TItem
        {
            var type = typeof(TSubItem);
            var variantCollection = new VariantKeyedCollection <TItem, TSubItem, TKey>(collection);

            collections.Add(type, variantCollection);
            collectionsLookup.Add(type, variantCollection);
        }
예제 #10
0
 /// <summary>
 /// Initializes the collection from a dictionary.
 /// Clones of items are created and their key properties set according to the dictionary
 /// </summary>
 public static void FromDictionaryForSerialization <K, V>(this IKeyedCollection <K, V> collection, IDictionary <K, V> dic)
 {
     foreach (var kv in dic)
     {
         var val = kv.Value.JsonClone();
         collection.SetKey(val, kv.Key);
         collection.Add(val);
     }
 }
예제 #11
0
        /// <summary>
        /// Constructs a dictionary where items key is used for the dictionary and null in each item
        /// </summary>
        public static IDictionary <K, V> ToDictionaryForSerialization <K, V>(this IKeyedCollection <K, V> list)
        {
            var dic = list.ToList().JsonClone().ToDictionary(list.GetKey);

            foreach (var kv in dic.Values)
            {
                list.SetKey(kv, default(K));
            }
            return(dic);
        }
예제 #12
0
        public LoadOrderResolver(IKeyedCollection<Guid, PackageRegistration> packages)
        {
            if (packages == null)
                throw new ArgumentNullException("packages");

            _packages = packages;

            _packagesById = _packages.ToDictionary(p => p.PackageId, p => p, StringComparer.OrdinalIgnoreCase);
            _seen = _packages.ToDictionary(p => p, p => false);
        }
예제 #13
0
        public NiLocalRegistry(IServiceProvider serviceProvider)
            : base(serviceProvider)
        {
            Registrations = ReadOnlyKeyedCollection.Create(_registrations);

            LoadProjectFactories();
            LoadToolWindows();
            LoadClasses();
            LoadOptionPages();
        }
        public override void Include <TSubItem>(IKeyedCollection <TKey, TSubItem> collection)
        {
            base.Include(collection);

            if (collection is INotifyCollectionChanged collectionNotifier)
            {
                collectionNotifier.itemChanged       += OnItemChanged;
                collectionNotifier.collectionChanged += OnCollectionChanged;
            }
        }
예제 #15
0
        public LoadOrderResolver(IKeyedCollection <Guid, PackageRegistration> packages)
        {
            if (packages == null)
            {
                throw new ArgumentNullException("packages");
            }

            _packages = packages;

            _packagesById = _packages.ToDictionary(p => p.PackageId, p => p, StringComparer.OrdinalIgnoreCase);
            _seen         = _packages.ToDictionary(p => p, p => false);
        }
        public override void Include <TSubItem>(IKeyedCollection <Guid, TSubItem> collection)
        {
            base.Include(collection);

            var graphElementCollection = collection as IGraphElementCollection <TSubItem>;

            if (graphElementCollection != null)
            {
                graphElementCollection.ItemAdded         += (element) => ItemAdded?.Invoke(element);
                graphElementCollection.ItemRemoved       += (element) => ItemRemoved?.Invoke(element);
                graphElementCollection.CollectionChanged += () => CollectionChanged?.Invoke();
            }
        }
예제 #17
0
    public DependencyGraph(IEnumerable <T> nodes, Func <T, IEnumerable <string> > getDependencies, Expression <Func <T, string> > getKey)
    {
        _getKey = getKey;
        _nodes  = new KeyedCollection <string, T>(getKey);
        _nodes.AddRange(nodes);

        foreach (var node in _nodes)
        {
            foreach (var d in getDependencies(node))
            {
                AddDependency(GetKey(node), d);
            }
        }
    }
예제 #18
0
        ChannelStored2 ChannelStored(ChannelSheet sheet, IKeyedCollection <string, ChannelStored2> channelPev)
        {
            var stored = channelPev[sheet.Id] ?? new ChannelStored2 {
                ChannelId     = sheet.Id,
                ChannelTitle  = sheet.Title,
                HardTags      = sheet.HardTags,
                SoftTags      = sheet.SoftTags,
                Relevance     = sheet.Relevance,
                LR            = sheet.LR,
                MainChannelId = sheet.MainChannelId,
                UserChannels  = sheet.UserChannels,
                ReviewStatus  = ManualAccepted
            };

            return(stored);
        }
예제 #19
0
 public EditMeaningViewModel(IKeyedCollection<string, Meaning> meanings)
 {
     _title = "New Meaning";
     _meanings = meanings;
 }
        // TODO: Report, there seems to be a Unity bug that fails to find IROD in .NET 2.0 standard but only on the first compile

        /*
         * public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
         * {
         *      dictionary.TryGetValue(key, out var value);
         *      return value;
         * }*/

        public static TValue GetValueOrDefault <TKey, TValue>(this IKeyedCollection <TKey, TValue> dictionary, TKey key)
        {
            dictionary.TryGetValue(key, out var value);
            return(value);
        }
예제 #21
0
 public static ReadOnlyKeyedCollection <TKey, TItem> ToReadOnlyKeyedCollection <TKey, TItem>(this IKeyedCollection <TKey, TItem> collection)
 {
     return(new ReadOnlyKeyedCollection <TKey, TItem>(collection));
 }
예제 #22
0
 public static ReadOnlyKeyedCollection <TKey, TItem> Create <TKey, TItem>(IKeyedCollection <TKey, TItem> source)
 {
     return(new ReadOnlyKeyedCollection <TKey, TItem>(source));
 }
예제 #23
0
        internal EntitySchema(string name, JObject schema)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (schema == null)
            {
                throw new ArgumentNullException(nameof(schema));
            }

            Name = name;

            var members = new MemberCollection();

            members.Add(new EntityIdField());

            foreach (var field in (JObject)schema["fields"])
            {
                int?decimals = field.Value["decimals"] != null ? (int?)(long)field.Value["decimals"] : null;

                switch ((string)field.Value["type"])
                {
                case "field":
                    members.Add(new EntityField(
                                    field.Key,
                                    (string)field.Value["comments"],
                                    ParseDataType((string)field.Value["data_type"]),
                                    decimals,
                                    (bool)field.Value["mandatory"]
                                    ));
                    break;

                case "foreign":
                    members.Add(new EntityForeign(
                                    field.Key,
                                    (string)field.Value["comments"],
                                    (string)field.Value["link_table"],
                                    ParseDataType((string)field.Value["data_type"]),
                                    decimals,
                                    (bool)field.Value["mandatory"]
                                    ));
                    break;

                case "foreign_child":
                    members.Add(new EntityForeignChild(
                                    field.Key,
                                    (string)field.Value["comments"],
                                    (string)field.Value["link_table"],
                                    (string)field.Value["link_field"]
                                    ));
                    break;

                case "calculated":
                    members.Add(new EntityCalculatedField(
                                    field.Key,
                                    (string)field.Value["comments"],
                                    ParseDataType((string)field.Value["data_type"]),
                                    decimals
                                    ));
                    break;
                }
            }

            Members = new ReadOnlyKeyedCollection <string, EntityMember>(members);

            var idFields = new List <EntityPhysicalField>();

            var ids = schema["id"];

            if (ids is JArray)
            {
                idFields.AddRange(ids.Select(p => (EntityPhysicalField)members[(string)p]));
            }
            else
            {
                idFields.Add((EntityPhysicalField)members[(string)ids]);
            }

            IdField = new ReadOnlyCollection <EntityPhysicalField>(idFields);

            string keyField = (string)schema["key"];

            if (keyField != null)
            {
                KeyField = (EntityField)members[keyField];
            }
            string labelField = (string)schema["label"];

            if (labelField != null)
            {
                LabelField = (EntityField)members[labelField];
            }

            Comments = (string)schema["comments"];

            foreach (string allow in schema["actions"])
            {
                switch (allow)
                {
                case "read": CanRead = true; break;

                case "create": CanCreate = true; break;

                case "update": CanUpdate = true; break;

                case "delete": CanDelete = true; break;
                }
            }
        }
 public VariantKeyedCollection(IKeyedCollection <TKey, TImplementation> implementation) : base(implementation)
 {
     this.implementation = implementation;
 }
예제 #25
0
 public NiPackageManager(IServiceProvider serviceProvider)
     : base(serviceProvider)
 {
     Packages = ReadOnlyKeyedCollection.Create(_packages);
 }
예제 #26
0
 public static ReadOnlyKeyedCollection <TKey, TItem> ToReadOnly <TKey, TItem>(this IKeyedCollection <TKey, TItem> self)
 {
     return(Create(self));
 }
예제 #27
0
 public EditVarietyViewModel(IKeyedCollection <string, Variety> varieties)
 {
     _title     = "New Variety";
     _varieties = varieties;
 }
예제 #28
0
        public void ParseAllTags_ReturnsCorrectLangTagInfos()
        {
            IKeyedCollection <string, SldrLanguageTagInfo> tags = Sldr.ParseAllTags(@"*agq = agq-Latn | *agq-CM = agq-Latn-CM
amo-Latn = amo
*ar = ar-Arab
*ar = ar-CM = ar-Arab-CM
*ar = ar-CY = ar-Arab-CY
*ar-EG = ar-Arab-EG > *ar
*oro-Latn
*sr | *sr-Cyrl | *sr-Cyrl-RS = sr-RS
*sr-Latn = sr-Latn-RO");

            Assert.That(tags.Count, Is.EqualTo(10));

            SldrLanguageTagInfo langTagInfo;

            Assert.That(tags.TryGet("agq", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Latn"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("agq"));

            Assert.That(tags.TryGet("agq-CM", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Latn"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("agq-CM"));

            Assert.That(tags.TryGet("amo", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.False);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Latn"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("amo-Latn"));

            Assert.That(tags.TryGet("ar", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Arab"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("ar"));

            Assert.That(tags.TryGet("ar-EG", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Arab"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("ar-EG"));

            Assert.That(tags.TryGet("oro", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Latn"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("oro-Latn"));

            Assert.That(tags.TryGet("sr", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.Null);
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("sr"));

            Assert.That(tags.TryGet("sr-Cyrl", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.Null);
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("sr-Cyrl"));

            Assert.That(tags.TryGet("sr-RS", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.EqualTo("Cyrl"));
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("sr-Cyrl-RS"));

            Assert.That(tags.TryGet("sr-Latn", out langTagInfo), Is.True);
            Assert.That(langTagInfo.IsAvailable, Is.True);
            Assert.That(langTagInfo.ImplicitScriptCode, Is.Null);
            Assert.That(langTagInfo.SldrLanguageTag, Is.EqualTo("sr-Latn"));
        }
예제 #29
0
 public EditMeaningViewModel(IKeyedCollection <string, Meaning> meanings)
 {
     _title    = "New Meaning";
     _meanings = meanings;
 }
예제 #30
0
 public EditVarietyViewModel(IKeyedCollection<string, Variety> varieties)
 {
     _title = "New Variety";
     _varieties = varieties;
 }
예제 #31
0
 public ReadOnlyKeyedCollection(IKeyedCollection <TKey, TItem> collection)
     : base(collection)
 {
     _collection = collection;
 }
예제 #32
0
 public ReadOnlyKeyedCollection(IKeyedCollection <T> collection)
 {
     _coll = (KeyedCollection <T>)collection;//new KeyedCollection<T>(collection.Keys, collection.GetItems());
 }
예제 #33
0
 protected override Guid GetKeyForItem(IKeyedCollection <string, ExtensionRegistration> item)
 {
     return(((ProjectExtensionRegistration)item).ProjectGuid);
 }