Esempio n. 1
0
 public void Clear()
 {
     foreach (var item in SL.OfType <T>(Source).ToArray())
     {
         casted.Remove(item);
     }
 }
Esempio n. 2
0
 public IEnumerator <T> GetEnumerator()
 {
     if (notifyEnumerable != null)
     {
         return(notifyEnumerable.GetEnumerator());
     }
     return(SL.OfType <T>(Source).GetEnumerator());
 }
Esempio n. 3
0
    private void LoadIndexes()
    {
        if ((_indexes == null) || (_indexes.Count == 0))
        {
            var rep       = EntityFactory.GetRepository <IIndexDefinition>();
            var qry       = (IQueryable)rep;
            var ef        = qry.GetExpressionFactory();
            var crit      = qry.CreateCriteria();
            var accessExp = ef.Le("UserAccess", _userType);
            crit.Add(ef.And(accessExp, ef.Eq("Enabled", true)));
            crit.AddOrder(ef.Asc("IndexName"));
            var tempIndexes = crit.List <IIndexDefinition>();

            var interfaceAsm = Assembly.GetAssembly(typeof(IIndexDefinition));
            var types        = interfaceAsm.GetTypes();
            _tablesEntities = new Dictionary <string, Type>();
            foreach (var entity in types)
            {
                var attrs = TypeDescriptor.GetAttributes(entity);
                foreach (var activeRecord in Enumerable.OfType <ActiveRecordAttribute>(attrs))
                {
                    _tablesEntities.Add(activeRecord.Table.ToUpper(), entity);
                }
            }
            _indexes = new List <IIndexDefinition>();
            foreach (var index in tempIndexes)
            {
                if (index.Type == 1) // database index
                {
                    var dbid = DBIndexDefinition.SetFromString(index.MetaData);
                    if (_tablesEntities.ContainsKey(dbid.MainTable.ToUpper()))
                    {
                        _indexes.Add(index);
                    }
                }
                else
                {
                    _indexes.Add(index);
                }
            }
        }
    }
    /// <summary>
    /// Tries to retrieve smart part information compatible with type
    /// smartPartInfoType.
    /// </summary>
    /// <param name="smartPartInfoType">Type of information to retrieve.</param>
    /// <returns>
    /// The <see cref="T:Sage.Platform.Application.UI.ISmartPartInfo"/> instance or null if none exists in the smart part.
    /// </returns>
    public override ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
    {
        ToolsSmartPartInfo tinfo = new ToolsSmartPartInfo();

        if (BindingSource != null)
        {
            if (BindingSource.Current != null)
            {
                tinfo.Description = BindingSource.Current.ToString();
                tinfo.Title       = BindingSource.Current.ToString();
            }
        }

        foreach (SmartPartToolsContainer cont in Enumerable.OfType <SmartPartToolsContainer>(Controls))
        {
            switch (cont.ToolbarLocation)
            {
            case SmartPartToolsLocation.Right:
                foreach (Control tool in cont.Controls)
                {
                    tinfo.RightTools.Add(tool);
                }
                break;

            case SmartPartToolsLocation.Center:
                foreach (Control tool in cont.Controls)
                {
                    tinfo.CenterTools.Add(tool);
                }
                break;

            case SmartPartToolsLocation.Left:
                foreach (Control tool in cont.Controls)
                {
                    tinfo.LeftTools.Add(tool);
                }
                break;
            }
        }
        return(tinfo);
    }
Esempio n. 5
0
 public IEnumerator <T> GetEnumerator()
 {
     return(SL.OfType <T>(Source).GetEnumerator());
 }
Esempio n. 6
0
 public static IEnumerable <TResult> OfType <TResult>(this IEnumerable source) =>
 LinqEnumerable.OfType <TResult>(source);
Esempio n. 7
0
 private void Inner_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         CollectionChanged?.Invoke(this, e);
     }
     else
     {
         if (e.OldItems != null)
         {
             CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, SL.OfType <T>(e.OldItems).ToList()));
         }
         if (e.NewItems != null)
         {
             CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, SL.OfType <T>(e.NewItems).ToList()));
         }
     }
 }
 /// <summary>
 /// Obtains a filter array to the elements of a <see cref="IEnumerable"/> according to the specified type
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source"></param>
 /// <returns></returns>
 static public T[] OfType <T>(this Array source)
 {
     return(Enumerable.OfType <T>(source).ToArray());
 }