internal static object Deserialize(RegistryKey key, string name, object defaultValue, StreamingContextStates streamingContext)
        {
            object          obj2;
            BinaryFormatter formatter = new BinaryFormatter(null, new StreamingContext(streamingContext));

            try
            {
                byte[] buffer;
                if (SharedUtil.IsEmpty((ICollection)(buffer = GetBytes(key, name, null))))
                {
                    return(defaultValue);
                }
                using (MemoryStream stream = new MemoryStream(buffer, false))
                {
                    object obj3;
                    if (((obj3 = formatter.Deserialize(stream)) != null) && ((defaultValue == null) || defaultValue.GetType().IsAssignableFrom(obj3.GetType())))
                    {
                        return(obj3);
                    }
                    obj2 = defaultValue;
                }
            }
            catch
            {
                obj2 = defaultValue;
            }
            return(obj2);
        }
 internal static Assembly LoadAssembly(string filePath, bool forceReload)
 {
     Assembly[] assemblyArray;
     if (!forceReload && !SharedUtil.IsEmpty((ICollection)(assemblyArray = AppDomain.CurrentDomain.GetAssemblies())))
     {
         foreach (Assembly assembly in assemblyArray)
         {
             if (((assembly != null) && !(assembly is AssemblyBuilder)) && (!SharedUtil.IsEmpty(assembly.CodeBase) && IOUtil.PathEquals(assembly.CodeBase, filePath)))
             {
                 return(assembly);
             }
         }
     }
     lock (LoadedAssemblies.SyncRoot)
     {
         if (forceReload || !LoadedAssemblies.ContainsKey(filePath = IOUtil.NormalizePath(filePath)))
         {
             byte[] buffer;
             using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
             {
                 buffer = new byte[stream.Length];
                 using (MemoryStream stream2 = new MemoryStream(buffer, true))
                 {
                     IOUtil.CopyStream(stream, stream2);
                 }
             }
             LoadedAssemblies[filePath] = Assembly.Load(buffer);
         }
         return(LoadedAssemblies[filePath] as Assembly);
     }
 }
 internal static List <Assembly> GetAllAssemblies(ProgressBar progressBar)
 {
     if (allAssemblies.Count == 0)
     {
         Assembly[] assemblyArray;
         GetAllAssemblies(allAssemblies, Assembly.GetEntryAssembly());
         if (!SharedUtil.IsEmpty((ICollection)(assemblyArray = AppDomain.CurrentDomain.GetAssemblies())))
         {
             if (progressBar != null)
             {
                 progressBar.Value   = 0;
                 progressBar.Maximum = assemblyArray.Length;
                 Application.DoEvents();
             }
             foreach (Assembly assembly in assemblyArray)
             {
                 if (progressBar != null)
                 {
                     progressBar.Value++;
                     Application.DoEvents();
                 }
                 GetAllAssemblies(allAssemblies, assembly);
             }
         }
     }
     return(allAssemblies);
 }
Exemplo n.º 4
0
        internal static string[] GetQueryParameters(string queryString)
        {
            string[]  strArray;
            ArrayList list = new ArrayList();

            while (queryString.StartsWith("?"))
            {
                queryString = queryString.Substring(1);
            }
            if (!SharedUtil.IsEmpty((ICollection)(strArray = queryString.Split(new char[] { '&' }))))
            {
                foreach (string str in strArray)
                {
                    string[] strArray2;
                    if (!SharedUtil.IsEmpty((ICollection)(strArray2 = str.Split(new char[] { '=' }))))
                    {
                        foreach (string str2 in strArray2)
                        {
                            list.Add(str2);
                        }
                    }
                }
            }
            return(list.ToArray(typeof(string)) as string[]);
        }
Exemplo n.º 5
0
 private static string Extract(string value)
 {
     if (!SharedUtil.IsEmpty(value))
     {
         for (int i = 0; i < 20; i++)
         {
             value = value.Replace("%" + i, string.Empty);
         }
         value = value.Replace("\"\"", string.Empty).Trim();
         int index = value.ToLower().IndexOf(".exe");
         if (index > 0)
         {
             value = value.Substring(0, index + 4);
         }
         while (value.StartsWith("\"") || value.StartsWith("@"))
         {
             value = value.Substring(1);
         }
         while (value.EndsWith("\""))
         {
             value = value.Substring(0, value.Length - 1);
         }
     }
     return(SharedUtil.Trim(value));
 }
Exemplo n.º 6
0
 internal string Undo(string currentVersion)
 {
     Trio <Modification, int, string>[] trioArray;
     if ((this.undoStack.Count != 0) && !SharedUtil.IsEmpty((ICollection)(trioArray = this.undoStack.Pop())))
     {
         return(this.Modify(currentVersion, true, trioArray));
     }
     return(currentVersion);
 }
        internal static string GetLocalDescription(Enum member)
        {
            string description = new LocalDescriptionAttribute(member.GetType(), member.ToString()).Description;

            if (!SharedUtil.IsEmpty(ref description))
            {
                return(description);
            }
            return(member.ToString());
        }
Exemplo n.º 8
0
        internal static string EnsureAttribute(XmlNode node, string attributeName, string defaultValue, bool overwrite)
        {
            XmlAttribute orCreateAttribute = GetOrCreateAttribute(node, attributeName);

            if (overwrite || SharedUtil.IsEmpty(orCreateAttribute.Value))
            {
                orCreateAttribute.Value = defaultValue;
            }
            return(orCreateAttribute.Value);
        }
Exemplo n.º 9
0
        internal static string Attribute(XmlNode node, string name, string defaultValue)
        {
            XmlAttribute attribute;

            if (((attribute = node.Attributes[name]) != null) && !SharedUtil.IsEmpty(attribute.Value))
            {
                return(attribute.Value);
            }
            return(defaultValue);
        }
Exemplo n.º 10
0
        internal string GetSettingsName(IComponent provider)
        {
            string str;

            if (componentNames.TryGetValue(provider, out str) && !SharedUtil.IsEmpty(str))
            {
                return(str);
            }
            return(null);
        }
Exemplo n.º 11
0
        internal static Duo <XmlNode, string> GetNodeAtPosition(XmlNode node, int selectionStart, int selectionLength, XmlNodeType moveUpTo, params XmlNodeType[] moveUpIf)
        {
            XmlNode parentNode = null;
            string  str        = null;
            string  str2;

            if ((((node != null) && !SharedUtil.IsEmpty(str2 = node.OuterXml)) && ((selectionStart >= 0) && (selectionStart <= str2.Length))) && ((selectionLength >= 0) && ((selectionStart + selectionLength) <= str2.Length)))
            {
                str = str2.Substring(selectionStart, selectionLength);
                if (!node.HasChildNodes)
                {
                    parentNode = node;
                }
                else
                {
                    int    num;
                    string innerXml = node.InnerXml;
                    int    num2     = num = str2.IndexOf(innerXml, str2.IndexOf('>'));
                    if (num2 < 0)
                    {
                        num2 = num = 0;
                    }
                    if (selectionStart >= num)
                    {
                        foreach (XmlNode node3 in node.ChildNodes)
                        {
                            if (((selectionStart >= num2) && (selectionStart < (num2 + node3.OuterXml.Length))) && ((parentNode = GetNodeAtPosition(node3, selectionStart - num2, selectionLength, moveUpTo, new XmlNodeType[0]).Value1) != null))
                            {
                                break;
                            }
                            num2 += node3.OuterXml.Length;
                        }
                    }
                    if (parentNode == null)
                    {
                        parentNode = node;
                    }
                }
                if (moveUpTo != XmlNodeType.None)
                {
                    while (((parentNode != null) && (parentNode.NodeType != moveUpTo)) && (parentNode.ParentNode != null))
                    {
                        parentNode = parentNode.ParentNode;
                    }
                }
                else if (!SharedUtil.IsEmpty((ICollection)moveUpIf))
                {
                    while (((parentNode != null) && SharedUtil.In <XmlNodeType>(parentNode.NodeType, moveUpIf)) && (parentNode.ParentNode != null))
                    {
                        parentNode = parentNode.ParentNode;
                    }
                }
            }
            return(new Duo <XmlNode, string>(parentNode, str));
        }
Exemplo n.º 12
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            bool   flag;
            string str = e.Value as string;

            if ((flag = !SharedUtil.IsEmpty(str)) || (FilePathTypeEditor <T> .NoFileImage != null))
            {
                e.Graphics.DrawImage(flag ? DrawingUtil.GetFileImage(str, false) : FilePathTypeEditor <T> .NoFileImage, new Rectangle(1, 2, e.Bounds.Width - 2, e.Bounds.Height - 2));
            }
            base.PaintValue(e);
        }
Exemplo n.º 13
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            bool   flag;
            string str = e.Value as string;

            if ((flag = ((FolderImage != null) && !SharedUtil.IsEmpty(str)) && Directory.Exists(str)) || (NoFolderImage != null))
            {
                e.Graphics.DrawImage(flag ? FolderImage : NoFolderImage, new Rectangle(1, 2, e.Bounds.Width - 2, e.Bounds.Height - 2));
            }
            base.PaintValue(e);
        }
Exemplo n.º 14
0
 internal void SetSettingsUserScope(IComponent provider, string[] settings)
 {
     if (SharedUtil.IsEmpty((ICollection)settings))
     {
         this.userProviders.Remove(provider);
     }
     else
     {
         this.userProviders[provider] = settings;
     }
 }
Exemplo n.º 15
0
 internal void SetSettingsName(IComponent provider, string name)
 {
     if (SharedUtil.IsEmpty(name))
     {
         componentNames.Remove(provider);
     }
     else
     {
         componentNames[provider] = name;
     }
 }
Exemplo n.º 16
0
        internal static void ForEach(XmlNode node, string xpath, Action <XmlNode> action)
        {
            XmlNodeList list = node.SelectNodes(xpath);

            if (!SharedUtil.IsEmpty(list))
            {
                foreach (XmlNode node2 in list)
                {
                    action(node2);
                }
            }
        }
Exemplo n.º 17
0
        public static string GetDescription(Enum value)
        {
            DescriptionAttribute attribute;
            string name = value.ToString();

            object[] customAttributes = value.GetType().GetField(name).GetCustomAttributes(typeof(DescriptionAttribute), true);
            if ((!SharedUtil.IsEmpty((ICollection)customAttributes) && ((attribute = customAttributes[0] as DescriptionAttribute) != null)) && !SharedUtil.IsEmpty(attribute.Description))
            {
                return(attribute.Description);
            }
            return(name);
        }
Exemplo n.º 18
0
 internal ShellInfo(string filePath)
 {
     if (SharedUtil.IsEmpty(this.FilePath = SharedUtil.Trim(filePath)))
     {
         throw new ArgumentNullException("filePath");
     }
     this.DirectoryName    = Path.GetDirectoryName(this.FilePath);
     this.Extension        = Path.GetExtension(this.FilePath).ToLower();
     this.DotLessExtension = this.Extension.Replace(".", string.Empty);
     this.FileName         = Path.GetFileName(this.FilePath);
     this.Name             = Path.GetFileNameWithoutExtension(this.FilePath);
 }
Exemplo n.º 19
0
 internal static string NormalizePath(string path)
 {
     path = (SharedUtil.IsEmpty(path) || (path == ".")) ? Environment.CurrentDirectory.Trim().ToLower() : (path = path.Trim().ToLower());
     if (path.StartsWith("file:"))
     {
         path = PathFromUri(path);
     }
     while ((path.Length > 0) && path.EndsWith(Path.DirectorySeparatorChar.ToString()))
     {
         path = path.Substring(0, path.Length - 1);
     }
     return(path);
 }
        private static string TrimHex(string keyName)
        {
            int num;

            if (SharedUtil.IsEmpty(keyName))
            {
                throw new ArgumentNullException("keyName");
            }
            if (((keyName.LastIndexOf(']') == (keyName.Length - 1)) && ((num = keyName.LastIndexOf(" [0x")) > 0)) && (num < (keyName.Length - 1)))
            {
                return(keyName.Substring(0, num));
            }
            return(keyName);
        }
 internal void SetCommandKeyConsumed(ToolStripItem commandItem, string key)
 {
     if (SharedUtil.IsEmpty(key))
     {
         this.consumers.Remove(commandItem);
         commandItem.Click -= this.consumerItem_Click;
     }
     else
     {
         this.consumers[commandItem] = key;
         commandItem.Click          += this.consumerItem_Click;
     }
     this.RefreshConsumers();
 }
Exemplo n.º 22
0
        internal static string GetXPath(XmlNode node, XmlNode stopBefore, string encodeSlash)
        {
            string str = null;
            int    num = 0;

            if (node != null)
            {
                string str2;
                str = "/" + node.LocalName;
                if (!SharedUtil.IsEmpty((ICollection)node.Attributes))
                {
                    str = str + " [";
                    foreach (XmlAttribute attribute in node.Attributes)
                    {
                        str = str + string.Format("@{0} = '{1}' and ", attribute.LocalName, attribute.Value.Replace("'", "&apos;").Replace("/", SharedUtil.IsEmpty(encodeSlash) ? "/" : encodeSlash));
                    }
                    str = str.Substring(0, str.Length - " and ".Length) + "]";
                }
                else
                {
                    XmlNodeList list;
                    if (((node.ParentNode != null) && (node.NodeType == XmlNodeType.Element)) && (!SharedUtil.IsEmpty(list = node.ParentNode.SelectNodes(node.LocalName)) && (list.Count > 1)))
                    {
                        foreach (XmlNode node2 in list)
                        {
                            num++;
                            if (node2 == node)
                            {
                                break;
                            }
                            if (num == list.Count)
                            {
                                num = 0;
                            }
                        }
                        if (num > 0)
                        {
                            object obj2 = str;
                            str = string.Concat(new object[] { obj2, " [", num, "]" });
                        }
                    }
                }
                if (((node.ParentNode != null) && (node.ParentNode != node.OwnerDocument)) && ((node.ParentNode != stopBefore) && !SharedUtil.IsEmpty(str2 = GetXPath(node.ParentNode))))
                {
                    str = str2 + str;
                }
            }
            return(str);
        }
        internal static void ExportValue(string valueName, byte[] value, StreamWriter writer)
        {
            StringBuilder builder = new StringBuilder("\"" + Normalize(valueName) + "\"=hex:");

            if (!SharedUtil.IsEmpty((ICollection)value))
            {
                builder.Append(value[0].ToString("x"));
            }
            if (value.Length > 1)
            {
                for (int i = 1; i < value.Length; i++)
                {
                    builder.AppendFormat(",{0}", value[i].ToString("x"));
                }
            }
            writer.WriteLine(builder.ToString());
        }
Exemplo n.º 24
0
 private RequestContext(string contextID)
 {
     if (SharedUtil.IsEmpty(this.ContextID = contextID))
     {
         this.ContextID = contextID = Guid.NewGuid().ToString();
     }
     try
     {
         if ((Items != null) && Items.Contains(this.ContextID))
         {
             throw new ArgumentException(null, "contextID");
         }
     }
     catch
     {
     }
 }
Exemplo n.º 25
0
 private static string AppDesc(ref string value)
 {
     try
     {
         RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\ShellNoRoam\MUICache", false);
         if (key != null)
         {
             using (key)
             {
                 string[] strArray;
                 if (!SharedUtil.IsEmpty((ICollection)(strArray = key.GetValueNames())))
                 {
                     foreach (string str in strArray)
                     {
                         if (value.ToLower().IndexOf(str.ToLower()) >= 0)
                         {
                             return(SharedUtil.Trim(key.GetValue(str, value, RegistryValueOptions.None) as string));
                         }
                     }
                     foreach (string str2 in strArray)
                     {
                         if (str2.ToLower().IndexOf(value.ToLower()) >= 0)
                         {
                             value = str2;
                             return(SharedUtil.Trim(key.GetValue(str2, value, RegistryValueOptions.None) as string));
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
     try
     {
         return("(" + Path.GetFileNameWithoutExtension(Extract(value)) + ")");
     }
     catch
     {
         return("(" + value + ")");
     }
 }
        internal static MethodInfo GetBaseDefinition(MethodInfo methodInfo, bool findInterfaceProperty, out System.Type interfaceType, out PropertyInfo interfaceProperty)
        {
            MethodInfo info;

            System.Type[] typeArray;
            SharedUtil.ThrowIfNull(methodInfo, "methodInfo");
            interfaceType     = null;
            interfaceProperty = null;
            if (((info = methodInfo.GetBaseDefinition()) == methodInfo) && !SharedUtil.IsEmpty((ICollection)(typeArray = methodInfo.DeclaringType.GetInterfaces())))
            {
                foreach (System.Type type in typeArray)
                {
                    InterfaceMapping interfaceMap = methodInfo.DeclaringType.GetInterfaceMap(type);
                    for (int i = 0; i < interfaceMap.InterfaceMethods.Length; i++)
                    {
                        if (interfaceMap.TargetMethods[i] != methodInfo)
                        {
                            continue;
                        }
                        if (findInterfaceProperty)
                        {
                            PropertyInfo[] infoArray;
                            System.Type    type2;
                            interfaceType = type2 = type;
                            if (!SharedUtil.IsEmpty((ICollection)(infoArray = type2.GetProperties())))
                            {
                                foreach (PropertyInfo info2 in infoArray)
                                {
                                    if ((info2.GetGetMethod() == interfaceMap.InterfaceMethods[i]) || (info2.GetSetMethod() == interfaceMap.InterfaceMethods[i]))
                                    {
                                        interfaceProperty = info2;
                                        break;
                                    }
                                }
                            }
                        }
                        return(interfaceMap.InterfaceMethods[i]);
                    }
                }
            }
            return(info);
        }
 internal void RefreshConsumers(ToolStripItem providerToolStripItem, string providerCommandKey)
 {
     foreach (KeyValuePair <ToolStripItem, string> pair in this.consumers)
     {
         ToolStripItem item;
         if (((!SharedUtil.IsEmpty(providerCommandKey) && (pair.Value == providerCommandKey)) && ((item = providerToolStripItem) != null)) || ((item = this[pair.Value]) != null))
         {
             ToolStripMenuItem item2;
             ToolStripMenuItem item3;
             pair.Key.Enabled = item.Enabled;
             pair.Key.Image   = item.Image;
             pair.Key.Text    = item.Text;
             if (((item2 = pair.Key as ToolStripMenuItem) != null) && ((item3 = item as ToolStripMenuItem) != null))
             {
                 item2.Checked = item3.Checked;
                 item2.ShortcutKeyDisplayString = item3.ShortcutKeyDisplayString;
                 item2.ShortcutKeys             = item3.ShortcutKeys;
                 item2.ShowShortcutKeys         = item3.ShowShortcutKeys;
             }
             else
             {
                 ToolStripButton button2;
                 if (((item2 = pair.Key as ToolStripMenuItem) != null) && ((button2 = item as ToolStripButton) != null))
                 {
                     item2.Checked = button2.Checked;
                 }
                 else
                 {
                     ToolStripButton button;
                     if (((button = pair.Key as ToolStripButton) != null) && ((button2 = item as ToolStripButton) != null))
                     {
                         button.Checked = button2.Checked;
                     }
                     else if (((button = pair.Key as ToolStripButton) != null) && ((item3 = item as ToolStripMenuItem) != null))
                     {
                         button.Checked = item3.Checked;
                     }
                 }
             }
         }
     }
 }
        protected virtual void ProviderItem_EnabledChanged(object sender, EventArgs e)
        {
            string        str;
            ToolStripItem providerToolStripItem = sender as ToolStripItem;

            if ((providerToolStripItem != null) && !SharedUtil.IsEmpty(str = this[providerToolStripItem]))
            {
                this.RefreshConsumers(providerToolStripItem, str);
            }
            if (e != null)
            {
                foreach (CommandManager manager in globalInstances)
                {
                    if ((manager != this) && manager.isGlobal)
                    {
                        manager.ProviderItem_EnabledChanged(sender, null);
                    }
                }
            }
        }
 internal static void Export(RegistryKey key, string filePath, bool recursive, string preface, Encoding encoding)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     if (SharedUtil.IsEmpty(filePath))
     {
         throw new ArgumentNullException("filePath");
     }
     if (SharedUtil.IsEmpty(preface))
     {
         preface = "Windows Registry Editor Version 5.00";
     }
     using (StreamWriter writer = new StreamWriter(filePath, false, encoding))
     {
         writer.WriteLine(preface);
         ExportKey(key, recursive, writer);
     }
 }
Exemplo n.º 30
0
        internal static XmlDocument Expand(XmlDocument document)
        {
            XmlNode     node = null;
            XmlNodeList list;

            if (((document != null) && (document.DocumentElement != null)) && !SharedUtil.IsEmpty(list = document.DocumentElement.SelectNodes("dsxc_values")))
            {
                foreach (XmlNode node2 in list)
                {
                    document.DocumentElement.RemoveChild(node = node2);
                }
                Dictionary <string, string> valueTable  = new Dictionary <string, string>();
                Dictionary <string, string> symbolTable = new Dictionary <string, string>();
                if (SharedUtil.IsEmpty(list = document.SelectNodes("processing-instruction()")))
                {
                    return(document);
                }
                foreach (XmlProcessingInstruction instruction in list)
                {
                    if (instruction.Name.StartsWith("n_"))
                    {
                        document.RemoveChild(instruction);
                        symbolTable[instruction.Name] = instruction.Value;
                    }
                }
                if (SharedUtil.IsEmpty((ICollection)symbolTable))
                {
                    return(document);
                }
                foreach (XmlNode node3 in node)
                {
                    if ((node3.FirstChild != null) && (node3.FirstChild.NodeType == XmlNodeType.CDATA))
                    {
                        valueTable[node3.LocalName] = node3.FirstChild.Value;
                    }
                }
                Expand(symbolTable, valueTable, document.DocumentElement);
            }
            return(document);
        }