Beispiel #1
0
 /// <summary>
 /// 생성자
 /// </summary>
 /// <param name="source">컬렉션</param>
 public CommonILC(System.Collections.ICollection source)
 {
     foreach (var item in source.Cast <T>())
     {
         this.Add(item);
     }
 }
Beispiel #2
0
        public static List <ManagementObject> CollectionToList(this System.Collections.ICollection collection)
        {
            var result = new List <ManagementObject>();

            result.AddRange(collection.Cast <ManagementObject>());
            return(result);
        }
Beispiel #3
0
    public static List <T> CollectionToList <T>(this System.Collections.ICollection other)
    {
        var output = new List <T>(other.Count);

        output.AddRange(other.Cast <T>());

        return(output);
    }
        private static ICollection SnapshotIfNotObservable(ICollection collection)
        {
            if (!(collection is INotifyCollectionChanged))
            {
                return(collection.Cast <object>().ToArray());
            }

            return(collection);
        }
Beispiel #5
0
 private static Assembly[] GetLoadAssemblies()
 {
     if (IsAspnetApp)
     {
         System.Collections.ICollection collection = System.Web.Compilation.BuildManager.GetReferencedAssemblies();
         return((from a in collection.Cast <Assembly>() select a).ToArray());
     }
     else
     {
         return(System.AppDomain.CurrentDomain.GetAssemblies());
     }
 }
Beispiel #6
0
        private Paragraph PropParagraph(string name, System.Collections.ICollection props)
        {
            Paragraph p = new Paragraph();
            bool      appendSeparator = false;

            if (props != null)
            {
                foreach (dynamic value in props.Cast <object>().OrderBy(x => x.ToString()))
                {
                    if (appendSeparator)
                    {
                        p.Inlines.Add("\r\n");
                    }
                    else
                    {
                        appendSeparator = true;
                    }
                    string valueString = ((Object)value).ToString();
                    if (name == "userAccountControl:")
                    {
                        p.Inlines.Add(new Run(GetUserAccountControl(value)));
                    }
                    else if (valueString == "System.__ComObject")
                    {
                        try
                        {
                            // Try an ADSI Large Integer
                            Object o    = value;
                            Object low  = o.GetType().InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, o, null);
                            Object high = o.GetType().InvokeMember("HighPart", System.Reflection.BindingFlags.GetProperty, null, o, null);

                            //long dateValue = (value.HighPart * &H100000000) + value.LowPart;
                            long     dateValue = ((long)((int)high) << 32) + (long)((int)low);
                            DateTime dt        = DateTime.FromFileTime(dateValue);
                            if (dt.ToString("dd-MMM-yyyy HH:mm") != "01-Jan-1601 11:00")
                            {
                                if (dt.Year == 1601)
                                {
                                    p.Inlines.Add(dt.ToString("HH:mm"));
                                }
                                else
                                {
                                    p.Inlines.Add(dt.ToString("dd-MMM-yyyy HH:mm"));
                                }
                            }
                        }
                        catch
                        {
                            p.Inlines.Add(valueString);
                        }
                    }
                    else if (valueString == "System.Byte[]")
                    {
                        byte[] bytes = value as byte[];
                        if (bytes.Length == 16)
                        {
                            Guid guid = new Guid(bytes);
                            p.Inlines.Add(guid.ToString("B"));
                        }
                        else if (bytes.Length == 28)
                        {
                            System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(bytes, 0);
                            p.Inlines.Add(sid.ToString());
                        }
                        else
                        {
                            System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
                            try
                            {
                                BitmapImage photoBitmap = new BitmapImage();
                                photoBitmap.BeginInit();
                                photoBitmap.StreamSource = ms;
                                photoBitmap.EndInit();
                                Image img = new Image();
                                img.Source  = photoBitmap;
                                img.Stretch = Stretch.None;
                                p.Inlines.Add(img);
                            }
                            catch
                            {
                                p.Inlines.Add(valueString);
                            }
                        }
                    }
                    else
                    {
                        if (valueString.StartsWith("CN=") || valueString.ToLower().StartsWith("http://"))
                        {
                            //string display = Regex.Match(valueString + ",", "CN=(.*?),").Groups[1].Captures[0].Value;
                            //Hyperlink h = new Hyperlink(new Run(display));
                            Hyperlink h = new Hyperlink(new Run(valueString));
                            h.NavigateUri = new Uri(valueString, valueString.ToLower().StartsWith("http://") ? UriKind.Absolute : UriKind.Relative);
                            h.Click      += new RoutedEventHandler(HyperlinkClicked);
                            //p.TextIndent = -20;
                            //p.Margin = new Thickness(20, p.Margin.Top, p.Margin.Right, p.Margin.Bottom);
                            p.Inlines.Add(h);
                        }
                        else
                        {
                            p.Inlines.Add(new Run(valueString));
                        }
                    }
                }
            }

            return(p);
        }
Beispiel #7
0
 public void InsertObjects(int index, System.Collections.ICollection modelObjects)
 {
     base.InsertRange(index, modelObjects.Cast <Title>());
 }
Beispiel #8
0
 public void AddObjects(System.Collections.ICollection modelObjects)
 {
     base.AddRange(modelObjects.Cast <Title>());
 }
Beispiel #9
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public void AMethodWithNotNullCollectionItems(System.Collections.ICollection items)
        {
            LogCall("AMethodWithNotNullCollectionItems", items.Cast <object>().ToArray());
        }