Beispiel #1
0
 static SaltarelleController()
 {
     try {
         using (var entry = new DirectoryEntry("IIS://localhost/MimeMap")) {
             PropertyValueCollection properties = entry.Properties["MimeMap"];
             mimeMap = properties.Cast <object>().ToDictionary(x => ((string)x.GetType().InvokeMember("Extension", BindingFlags.GetProperty, null, x, null)).ToLowerInvariant(), x => (string)x.GetType().InvokeMember("MimeType", BindingFlags.GetProperty, null, x, null));
         }
     }
     catch (Exception) {
         // Something is probably wrong with IIS (not installed/not working/whatever. No big deal, just use the map from the registry instead if developing.
         mimeMap = (from key in Registry.ClassesRoot.GetSubKeyNames()
                    where key.StartsWith(".")
                    let value = Registry.GetValue("HKEY_CLASSES_ROOT\\" + key, "Content Type", null) as string
                                where !string.IsNullOrEmpty(value)
                                select new { key, value }
                    ).ToDictionary(x => x.key.ToLowerInvariant(), x => x.value);
     }
 }
Beispiel #2
0
        private IEnumerable <string> GetSchemaProperties(string schemaNamingContext, string objectType)
        {
            IEnumerable <string> data;

            using (var de = new DirectoryEntry())
            {
                de.Username = _username;
                de.Password = _password;

                de.Path = String.Format("LDAP://{0}CN={1},{2}", _hostname, objectType, schemaNamingContext);

                PropertyValueCollection values = de.Properties["systemMayContain"];
                data = from s in values.Cast <string>()
                       orderby s
                       select s;
            }
            return(data);
        }
Beispiel #3
0
 public static bool ContainsValue(this PropertyValueCollection propValueColl, string value)
 {
     return(propValueColl.Cast <object>().Contains(value));
 }