iTextSharp.text.pdf.BaseFont.GetResourceStream C# (CSharp) Метод

GetResourceStream() публичный статический Метод

public static GetResourceStream ( string key ) : System.Stream
key string
Результат System.Stream
        public static Stream GetResourceStream(string key)
        {
            Stream istr = null;
            // Try to use resource loader to load the properties file.
            try {
                Assembly assm = Assembly.GetExecutingAssembly();
                istr = assm.GetManifestResourceStream(key);
            }
            catch {
            }
            if (istr != null)
                return istr;
            int count;
            lock (resourceSearch) {
                count = resourceSearch.Count;
            }
            for (int k = 0; k < count; ++k) {
                object obj;
                lock (resourceSearch) {
                    obj = resourceSearch[k];
                }
                try {
                    if (obj is Assembly) {
                        istr = ((Assembly)obj).GetManifestResourceStream(key);
                        if (istr != null)
                            return istr;
                    }
                    else if (obj is string) {
                        string dir = (string)obj;
                        try {
                            istr = Assembly.LoadFrom(dir).GetManifestResourceStream(key);
                        }
                        catch {
                        }
                        if (istr != null)
                            return istr;
                        string modkey = key.Replace('.', '/');
                        string fullPath = Path.Combine(dir, modkey);
                        if (File.Exists(fullPath)) {
                            return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                        }
                        int idx = modkey.LastIndexOf('/');
                        if (idx >= 0) {
                            modkey = modkey.Substring(0, idx) + "." + modkey.Substring(idx + 1);
                            fullPath = Path.Combine(dir, modkey);
                            if (File.Exists(fullPath))
                                return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                        }
                    }
                }
                catch {
                }
            }

            return istr;
        }

Usage Example

Пример #1
0
        internal static void ReadCmap(String name, List <char[]> planes)
        {
            String fullName = BaseFont.RESOURCE_PATH + "cmaps." + name;
            Stream inp      = BaseFont.GetResourceStream(fullName);

            if (inp == null)
            {
                throw new IOException(MessageLocalization.GetComposedMessage("the.cmap.1.was.not.found", name));
            }
            EncodeStream(inp, planes);
            inp.Close();
        }
All Usage Examples Of iTextSharp.text.pdf.BaseFont::GetResourceStream