예제 #1
0
        /// <summary>
        /// Load piece sets from resource
        /// </summary>
        /// <returns></returns>
        public static SortedList <string, PieceSet> LoadPieceSetFromResource()
        {
            SortedList <string, PieceSet> arrRetVal;
            Assembly asm;
            string   strResName;
            string   strKeyName;
            string   strPieceSetName;

            string[]       arrPart;
            Stream         streamResource;
            ResourceReader resReader;
            PieceSet       pieceSet;

            arrRetVal      = new SortedList <string, PieceSet>(64);
            asm            = typeof(App).Assembly;
            strResName     = asm.GetName().Name + ".g.resources";
            streamResource = asm.GetManifestResourceStream(strResName);
            try {
                resReader      = new System.Resources.ResourceReader(streamResource);
                streamResource = null;
                using (resReader) {
                    foreach (DictionaryEntry dictEntry in resReader.Cast <DictionaryEntry>())
                    {
                        strKeyName = Uri.UnescapeDataString(dictEntry.Key as string);
                        if (strKeyName != null)
                        {
                            strKeyName = strKeyName.ToLower();
                            if (strKeyName.StartsWith("piecesets/") && strKeyName.EndsWith(".baml"))
                            {
                                arrPart = strKeyName.Split('/');
                                if (arrPart.Length == 3)
                                {
                                    strPieceSetName = arrPart[1];
                                    if (!arrRetVal.ContainsKey(strPieceSetName))
                                    {
                                        pieceSet = new PieceSetStandard(strPieceSetName, strPieceSetName);
                                        arrRetVal.Add(strPieceSetName, pieceSet);
                                    }
                                }
                            }
                        }
                    }
                }
            } finally {
                if (streamResource != null)
                {
                    streamResource.Dispose();
                }
            }
            return(arrRetVal);
        }
예제 #2
0
        /// <summary>
        /// Load piece sets from resource
        /// </summary>
        /// <returns></returns>
        public static SortedList<string, PieceSet> LoadPieceSetFromResource()
        {
            SortedList<string, PieceSet>    arrRetVal;
            Assembly                        asm;
            string                          strResName;
            string                          strKeyName;
            string                          strPieceSetName;
            string[]                        arrPart;
            Stream                          streamResource;
            ResourceReader                  resReader;
            PieceSet                        pieceSet;

            arrRetVal       = new SortedList<string,PieceSet>(64);
            asm             = typeof(App).Assembly;
            strResName      = asm.GetName().Name + ".g.resources";
            streamResource  = asm.GetManifestResourceStream(strResName);
            try {
                resReader       = new System.Resources.ResourceReader(streamResource);
                streamResource  = null;
                using (resReader) {
                    foreach (DictionaryEntry  dictEntry in resReader.Cast<DictionaryEntry>()) {
                        strKeyName  = dictEntry.Key as string;
                        if (strKeyName != null) {
                            strKeyName  = strKeyName.ToLower();
                            if (strKeyName.StartsWith("piecesets/") && strKeyName.EndsWith(".baml")) {
                                arrPart = strKeyName.Split('/');
                                if (arrPart.Length == 3) {
                                    strPieceSetName = arrPart[1];
                                    if (!arrRetVal.ContainsKey(strPieceSetName)) {
                                        pieceSet    = new PieceSetStandard(strPieceSetName, strPieceSetName);
                                        arrRetVal.Add(strPieceSetName, pieceSet);
                                    }
                                }
                            }
                        }
                    }
                }
            } finally {
                if (streamResource != null) {
                    streamResource.Dispose();
                }
            }
            return(arrRetVal);
        }