Ejemplo n.º 1
0
 public void Add(T item)
 {
     lock (this)
     {
         if (!_items.Contains(item))
         {
             _items.Add(item, item);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///メタデータからファイル名を決める
        /// </summary>
        private string getFileName(string metadataHeader)
        {
            string[] musicInfos = metadataHeader.Split(';');
            var      d          = new System.Collections.Specialized.OrderedDictionary();

            foreach (var Info in musicInfos)
            {
                int j = Info.IndexOf("=");
                if (j < 0)
                {
                    d[Info] = null;
                    Debug.WriteLine("[metadataHeaderKey,Value]:" + Info + ",null");
                }
                else
                {
                    j++;//"="の分1文字分進ませる
                    d.Add(Info.Substring(0, j), Info.Substring(j));
                    Debug.WriteLine("[metadataHeaderKey,Value]:" + Info.Substring(0, j) + "," + Info.Substring(j));
                }
            }

            var fileName = (d.Contains("StreamTitle") ? (string)d["StreamTitle"] : (string)d[0]);

            return(fileName);
        }
Ejemplo n.º 3
0
        public int FirstUniqChar(string s)
        {
            System.Collections.Specialized.OrderedDictionary d = new System.Collections.Specialized.OrderedDictionary();

            for (int i = 0; i < s.Length; i++)
            {
                if (d.Contains(s[i]))
                {
                    Tuple <int, int> t = (Tuple <int, int>)(d[s[i]]);
                    d[(object)s[i]] = Tuple.Create(t.Item1 + 1, t.Item2);
                }
                else
                {
                    d[(object)s[i]] = Tuple.Create(1, i);
                }
            }

            for (int i = 0; i < d.Count; i++)
            {
                Tuple <int, int> t = (Tuple <int, int>)d[i];
                if (t.Item1 == 1)
                {
                    return(t.Item2);
                }
            }

            return(-1);
        }
Ejemplo n.º 4
0
        public string[] PredicateOf(string subjectUri)
        {
            string[] x = new string[] { "" };
            System.Collections.Specialized.OrderedDictionary test = new System.Collections.Specialized.OrderedDictionary();
            int i = 0;

            foreach (Triple t in GetTriplesWithSubject(this.CreateUriNode(new Uri(subjectUri))))
            {
                if (!test.Contains(t.Predicate.ToString()))
                {
                    test.Add(t.Predicate.ToString(), "");
                    x[i++] = t.Predicate.ToString();
                    Array.Resize <string>(ref x, i + 1);
                }
            }
            return(x);
        }
 static void Main(string[] args)
 {
     System.Collections.Specialized.OrderedDictionary orderedDictionary = new System.Collections.Specialized.OrderedDictionary();
     orderedDictionary.Add("Test1", "Test@123");
     orderedDictionary.Add("Admin", "Admin@123");
     orderedDictionary.Add("Temp", "Temp@123");
     orderedDictionary.Add("Demo", "Demo@123");
     orderedDictionary.Add("Test2", "Test2@123");
     orderedDictionary.Remove("Admin");
     if (orderedDictionary.Contains("Admin"))
     {
         Console.WriteLine("UserName already Esists");
     }
     else
     {
         orderedDictionary.Add("Admin", "Admin@123");
         Console.WriteLine("User added succesfully.");
     }
     // Insert a new key to the beginning of the OrderedDictionary
     orderedDictionary.Insert(0, "Test3", "Test3@123");
     // Modify the value of the entry with the key "Test1"
     orderedDictionary["Test1"] = "Test1@333";
     // Get a collection of the keys.
     Console.WriteLine("UserName" + ": " + "Password");
     foreach (DictionaryEntry entry in orderedDictionary)
     {
         Console.WriteLine(entry.Key + ": " + entry.Value);
     }
     String[] myKeys   = new String[orderedDictionary.Count];
     String[] myValues = new String[orderedDictionary.Count];
     orderedDictionary.Keys.CopyTo(myKeys, 0);
     orderedDictionary.Values.CopyTo(myValues, 0);
     Console.WriteLine("");
     // Displays the contents of the OrderedDictionary
     Console.WriteLine(" INDEX KEY  VALUE");
     for (int i = 0; i < orderedDictionary.Count; i++)
     {
         Console.WriteLine("   {0} {1} {2}",
                           i, myKeys[i], myValues[i]);
     }
     Console.WriteLine();
     Console.ReadKey();
 }
Ejemplo n.º 6
0
 private void RegisterForms()
 {
     for (int i = 0; i < eCommon.SBO_Application.Forms.Count; i++)
     {
         if (!oOpenForms.Contains(eCommon.SBO_Application.Forms.Item(i).UniqueID))
         {
             FormAttribute oAttrib = Forms[eCommon.SBO_Application.Forms.Item(i).TypeEx] as FormAttribute;
             if (oAttrib != null)
             {
                 try
                 {
                     //Execute the constructor
                     System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
                     Type oType = asm.GetType(oAttrib.TypeName);
                     System.Reflection.ConstructorInfo ctor = oType.GetConstructor(new Type[1] {
                         typeof(String)
                     });
                     if (ctor != null)
                     {
                         object oForm = ctor.Invoke(new Object[1] {
                             eCommon.SBO_Application.Forms.Item(i).UniqueID
                         });
                     }
                     else
                     {
                         throw new Exception("No constructor which accepts the formUID found for form type - " + oAttrib.FormType);
                     }
                 }
                 catch (Exception ex)
                 {
                     eCommon.SBO_Application.MessageBox(ex.Message);
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
        public string[] PredicateOf(string subjectUri)
        {
            string[] x = new string[] { "" };
            System.Collections.Specialized.OrderedDictionary test = new System.Collections.Specialized.OrderedDictionary();
            int i = 0;

            foreach (Triple t in GetTriplesWithSubject(this.CreateUriNode(new Uri(subjectUri))))
            {
                if (!test.Contains(t.Predicate.ToString()))
                {
                    test.Add(t.Predicate.ToString(),"");
                    x[i++] = t.Predicate.ToString();
                    Array.Resize<string>(ref x, i + 1);
                }
            }
            return x;
        }
Ejemplo n.º 8
0
        static List <string> GetAssembliesList()
        {
            DirectoryInfo[] DefaultAssemblyFolders =
            {
                // %ProgramData%\Grasshopper\Libraries-Inside-Revit-20XX
                new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Grasshopper", $"Libraries-{Rhinoceros.SchemeName}")),

                // %APPDATA%\Grasshopper\Libraries-Inside-Revit-20XX
                new DirectoryInfo(Folders.DefaultAssemblyFolder.Substring(0,                                               Folders.DefaultAssemblyFolder.Length - 1) + '-' + Rhinoceros.SchemeName)
            };

            var map = new System.Collections.Specialized.OrderedDictionary();

            foreach (var folder in DefaultAssemblyFolders)
            {
                IEnumerable <FileInfo> assemblyFiles;
                try { assemblyFiles = folder.EnumerateFiles("*.gha", SearchOption.AllDirectories); }
                catch (System.IO.DirectoryNotFoundException) { continue; }

                foreach (var assemblyFile in assemblyFiles)
                {
                    // https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=netframework-4.8
                    // If the specified extension is exactly three characters long,
                    // the method returns files with extensions that begin with the specified extension.
                    // For example, "*.xls" returns both "book.xls" and "book.xlsx"
                    if (assemblyFile.Extension.ToLower() != ".gha")
                    {
                        continue;
                    }

                    var key = assemblyFile.FullName.Substring(folder.FullName.Length);
                    if (map.Contains(key))
                    {
                        map.Remove(key);
                    }

                    map.Add(key, assemblyFile);
                }

                IEnumerable <FileInfo> linkFiles;
                try { linkFiles = folder.EnumerateFiles("*.ghlink", SearchOption.TopDirectoryOnly); }
                catch (System.IO.DirectoryNotFoundException) { continue; }

                foreach (var linkFile in linkFiles)
                {
                    var key = linkFile.FullName.Substring(folder.FullName.Length);
                    if (map.Contains(key))
                    {
                        map.Remove(key);
                    }

                    map.Add(key, linkFile);
                }
            }

            var assembliesList = new List <string>();

            foreach (var entry in map.Values.Cast <FileInfo>())
            {
                var extension = entry.Extension.ToLower();
                if (extension == ".gha")
                {
                    assembliesList.Add(entry.FullName);
                }
                else if (extension == ".ghlink")
                {
                    EnumGHLink(entry.FullName, assembliesList);
                }
            }

            return(assembliesList);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Populates the filters dictionary with formatted and unformatted string
        /// representations of each unique value in the column, accounting for all
        /// filters except the current column's. Also adds special filter options.
        /// </summary>
        private void PopulateFilters()
        {
            ArrayList list = null;
            Boolean   containsBlanks;
            Boolean   containsNonBlanks;
            String    oldFilter = "";

            // Continue only if there is a DataGridView.
            if (this.DataGridView == null)
            {
                return;
            }

            // Cast the data source to a BindingSource.
            BindingSource data = this.DataGridView.DataSource as BindingSource;

            Debug.Assert((data != null && data.SupportsFiltering && OwningColumn != null) || (Retriever != null),
                         "DataSource is not a BindingSource, or does not support filtering, or OwningColumn is null");

            containsBlanks    = false;
            containsNonBlanks = false;

            // Reset the filters dictionary and initialize some flags
            // to track whether special filter options are needed.
            filters.Clear();

            if (data != null)
            {
                // Prevent the data source from notifying the DataGridView of changes.
                data.RaiseListChangedEvents = false;

                // Cache the current BindingSource.Filter value and then change
                // the Filter property to temporarily remove any filter for the
                // current column.

                oldFilter = data.Filter;
                //data.Filter = FilterWithoutCurrentColumn(oldFilter);

                // Initialize an ArrayList to store the values in their original
                // types. This enables the values to be sorted appropriately.
                list = new ArrayList(data.Count);

                // Retrieve each value and add it to the ArrayList if it isn't
                // already present.
                foreach (Object item in data)
                {
                    Object value = null;

                    // Use the ICustomTypeDescriptor interface to retrieve properties
                    // if it is available; otherwise, use reflection. The
                    // ICustomTypeDescriptor interface is useful to customize
                    // which values are exposed as properties. For example, the
                    // DataRowView class implements ICustomTypeDescriptor to expose
                    // cell values as property values.
                    //
                    // Iterate through the property names to find a case-insensitive
                    // match with the DataGridViewColumn.DataPropertyName value.
                    // This is necessary because DataPropertyName is case-
                    // insensitive, but the GetProperties and GetProperty methods
                    // used below are case-sensitive.
                    ICustomTypeDescriptor ictd = item as ICustomTypeDescriptor;
                    if (ictd != null)
                    {
                        PropertyDescriptorCollection properties = ictd.GetProperties();
                        foreach (PropertyDescriptor property in properties)
                        {
                            if (String.Compare(this.OwningColumn.DataPropertyName,
                                               property.Name, true /*case insensitive*/,
                                               System.Globalization.CultureInfo.InvariantCulture) == 0)
                            {
                                value = property.GetValue(item);
                                break;
                            }
                        }
                    }
                    else
                    {
                        PropertyInfo[] properties = item.GetType().GetProperties(
                            BindingFlags.Public | BindingFlags.Instance);
                        foreach (PropertyInfo property in properties)
                        {
                            if (String.Compare(this.OwningColumn.DataPropertyName,
                                               property.Name, true /*case insensitive*/,
                                               System.Globalization.CultureInfo.InvariantCulture) == 0)
                            {
                                value = property.GetValue(item, null /*property index*/);
                                break;
                            }
                        }
                    }

                    // Skip empty values, but note that they are present.
                    if (value == null || value == DBNull.Value)
                    {
                        containsBlanks = true;
                        continue;
                    }

                    // Add values to the ArrayList if they are not already there.
                    if (!list.Contains(value))
                    {
                        list.Add(value);
                    }
                }
            }
            else
            {
                // Initialize an ArrayList to store the values in their original
                // types. This enables the values to be sorted appropriately.

                DataTable dataTable = new DataTable();

                try
                {
                    IBE.Program.DBCon.Execute(String.Format("{0} {1}", RetrieverSQLSelect, Retriever.BaseStatement), dataTable);
                    list = new ArrayList(dataTable.Rows.Count);

                    foreach (DataRow selectableItem in dataTable.Rows)
                    {
                        list.Add(selectableItem[0]);
                    }
                }
                catch (Exception)
                {
                    list = new ArrayList();
                }
            }

            // Sort the ArrayList. The default Sort method uses the IComparable
            // implementation of the stored values so that string, numeric, and
            // date values will all be sorted correctly.
            list.Sort();

            // Convert each value in the ArrayList to its formatted representation
            // and store both the formatted and unformatted string representations
            // in the filters dictionary.
            foreach (Object value in list)
            {
                // Use the cell's GetFormattedValue method with the column's
                // InheritedStyle property so that the dropDownListBox.FilterListBox format
                // will match the display format used for the column's cells.
                String formattedValue       = null;
                DataGridViewCellStyle style = OwningColumn.InheritedStyle;
                formattedValue = (String)GetFormattedValue(value, -1, ref style,
                                                           null, null, DataGridViewDataErrorContexts.Formatting);

                if (String.IsNullOrEmpty(formattedValue))
                {
                    // Skip empty values, but note that they are present.
                    containsBlanks = true;
                }
                else if (!filters.Contains(formattedValue))
                {
                    // Note whether non-empty values are present.
                    containsNonBlanks = true;

                    // For all non-empty values, add the formatted and
                    // unformatted string representations to the filters
                    // dictionary.
                    filters.Add(formattedValue, value.ToString());
                }
            }

            if (data != null)
            {
                // Restore the filter to the cached filter string and
                // re-enable data source change notifications.
                if (oldFilter != null)
                {
                    data.Filter = oldFilter;
                }
                data.RaiseListChangedEvents = true;
            }

            // Add special filter options to the filters dictionary
            // along with null values, since unformatted representations
            // are not needed.
            if (containsBlanks && containsNonBlanks)
            {
                filters.Add("(Blanks)", null);
                filters.Add("(NonBlanks)", null);
            }
        }
Ejemplo n.º 10
0
 public bool ContainsKey(TKey key)
 {
     return(super.Contains(key));
 }