当前位置: 首页>>代码示例>>C#>>正文


C# List.GetType方法代码示例

本文整理汇总了C#中System.Windows.Documents.List.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# List.GetType方法的具体用法?C# List.GetType怎么用?C# List.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.List的用法示例。


在下文中一共展示了List.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DequeueRequestRecord

        /// <summary>
        /// Dequeue the first record 
        /// </summary>
        public static RequestRecord DequeueRequestRecord()
        {
            List<RequestRecord> requests = new List<RequestRecord>();
            DataContractJsonSerializer dc = new DataContractJsonSerializer(requests.GetType());

            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            {
                lock (fileLock)
                {
                    using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(@"RequestRecords.xml", FileMode.Open, file))
                    {
                        try
                        {
                            // if the file opens, read the contents
                            requests = dc.ReadObject(stream) as List<RequestRecord>;
                            if (requests.Count > 0)
                            {
                                RequestRecord record = requests[0];
                                requests.Remove(record);  // remove the first entry
                                stream.SetLength(0);
                                stream.Position = 0;
                                dc.WriteObject(stream, requests);

                                record.DeserializeBody();
                                return record;
                            }
                            else
                                return null;
                        }
                        catch (Exception)
                        {
                            stream.Position = 0;
                            string s = new StreamReader(stream).ReadToEnd();
                            return null;
                        }
                    }
                }
            }
        }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:42,代码来源:RequestQueue.cs

示例2: ExportClicked

        public void ExportClicked(object sender, EventArgs e)
        {
            WriteLog("Starting export");
            List<Role> roles = new List<Role>();
            URM.UserRoleManager urmServer = new URM.UserRoleManager();
            using (urmServer.CreateConnection())
            {
                urmServer.Connection.Open(ConnectionString);
                WriteLog("Connected to K2 server");

                string[] serverRoles = urmServer.GetRoleNameList();

                foreach (string role in serverRoles)
                {
                    WriteLog("Exporting role {0}", role);
                    URM.Role urmRole = urmServer.GetRole(role);
                    Role r = this.CopyToLocalRole(urmRole);
                    roles.Add(r);
                }

                WriteLog("Writing {0} roles to XML file", roles.Count);

                XmlSerializer xmlSer = new XmlSerializer(roles.GetType());
                XmlTextWriter writer = new XmlTextWriter(txtFileLocation.Text, Encoding.Unicode);
                writer.Formatting = Formatting.Indented;
                xmlSer.Serialize(writer, roles);
                writer.Flush();
                writer.Close();

                WriteLog("Closing K2 connection.");
            }
        }
开发者ID:cyclops1982,项目名称:K2RolesImportExport,代码行数:32,代码来源:Window1.xaml.cs

示例3: EnqueueRequestRecord

        /// <summary>
        /// Enqueue a Web Service record into the record queue
        /// </summary>
        public static void EnqueueRequestRecord(RequestRecord newRecord)
        {
            bool enableQueueOptimization = false;  // turn off the queue optimization (doesn't work with introduction of tags)

            List<RequestRecord> requests = new List<RequestRecord>();
            DataContractJsonSerializer dc = new DataContractJsonSerializer(requests.GetType());

            if (newRecord.SerializedBody == null)
                newRecord.SerializeBody();

            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            {
                lock (fileLock)
                {
                    // if the file opens, read the contents
                    using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(@"RequestRecords.xml", FileMode.OpenOrCreate, file))
                    {
                        try
                        {
                            // if the file opened, read the record queue
                            requests = dc.ReadObject(stream) as List<RequestRecord>;
                            if (requests == null)
                                requests = new List<RequestRecord>();
                        }
                        catch (Exception)
                        {
                            stream.Position = 0;
                            string s = new StreamReader(stream).ReadToEnd();
                        }

                        if (enableQueueOptimization == true)
                        {
                            OptimizeQueue(newRecord, requests);
                        }
                        else
                        {
                            // this is a new record so add the new record at the end
                            requests.Add(newRecord);
                        }

                        // reset the stream and write the new record queue back to the file
                        stream.SetLength(0);
                        stream.Position = 0;
                        dc.WriteObject(stream, requests);
                        stream.Flush();
                    }
                }
            }
        }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:52,代码来源:RequestQueue.cs

示例4: GetRequestRecord

        /// <summary>
        /// Get the first RequestRecord in the queue
        /// </summary>
        public static RequestRecord GetRequestRecord()
        {
            List<RequestRecord> requests = new List<RequestRecord>();
            DataContractJsonSerializer dc = new DataContractJsonSerializer(requests.GetType());

            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            {
                lock (fileLock)
                {
                    // try block because the using block below will throw if the file doesn't exist
                    try
                    {
                        // if the file opens, read the contents
                        using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(@"RequestRecords.xml", FileMode.Open, file))
                        {
                            try
                            {
                                // if the file opens, read the contents
                                requests = dc.ReadObject(stream) as List<RequestRecord>;
                                if (requests.Count > 0)
                                {
                                    RequestRecord record = requests[0];
                                    record.DeserializeBody();
                                    return record;
                                }
                                else
                                    return null;
                            }
                            catch (Exception)
                            {
                                stream.Position = 0;
                                string s = new StreamReader(stream).ReadToEnd();
                                return null;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // could not open the isolated storage file
                        return null;
                    }
                }
            }
        }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:47,代码来源:RequestQueue.cs

示例5: ConstructJson

        private static string ConstructJson(List<FreeSlot> FreeList)
        {
            MemoryStream ms = new MemoryStream();
            DataContractJsonSerializer ser = new DataContractJsonSerializer(FreeList.GetType());

            ser.WriteObject(ms, FreeList);
            byte[] json = ms.ToArray();
            ms.Close();

            return Encoding.UTF8.GetString(json, 0, json.Length);
        }
开发者ID:smartboyathome,项目名称:How-About-Coffee,代码行数:11,代码来源:Service.cs

示例6: GetAllRequestRecords

        /// <summary>
        /// Get all RequestRecords in the queue
        /// </summary>
        public static List<RequestRecord> GetAllRequestRecords()
        {
            List<RequestRecord> requests = new List<RequestRecord>();
            DataContractJsonSerializer dc = new DataContractJsonSerializer(requests.GetType());

            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
            {
                lock (fileLock)
                {
                    // try block because the using block below will throw if the file doesn't exist
                    try
                    {
                        // if the file opens, read the contents
                        using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(@"RequestRecords.xml", FileMode.Open, file))
                        {
                            try
                            {
                                // if the file opens, read the contents
                                requests = dc.ReadObject(stream) as List<RequestRecord>;
                                foreach (var req in requests)
                                {
                                    req.DeserializeBody();
                                }
                                return requests;
                            }
                            catch (Exception)
                            {
                                return null;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // could not open the isolated storage file
                        return null;
                    }
                }
            }
        }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:42,代码来源:RequestQueue.cs

示例7: newsRecuperees

 private void newsRecuperees(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         List<News> deserializedUser = new List<News>();
         DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedUser.GetType());
         deserializedUser = ser.ReadObject(e.Result) as List<News>;
         foreach (News i in deserializedUser)
         {
             News.Add(new NewsViewModel() { prenom = i.Prenom, date = i.date, contenu = i.news, titre = i.titre });
         }
     }
 }
开发者ID:apuyou,项目名称:polar-bear,代码行数:13,代码来源:MainViewModel.cs

示例8: horairesDownloader_OpenReadCompleted

        private void horairesDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {

                List<Horaire> deserializedUser = new List<Horaire>();
                DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedUser.GetType());
                deserializedUser = ser.ReadObject(e.Result) as List<Horaire>;
                foreach (Horaire i in deserializedUser)
                {
                    Horaires.Add(new HorairesViewModel() { Jour = i.jour, Heures = i.heures});
                }
            }
        }
开发者ID:apuyou,项目名称:polar-bear,代码行数:14,代码来源:MainViewModel.cs

示例9: annalesRecuperees

 private void annalesRecuperees(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         List<Annale> deserializedUser = new List<Annale>();
         DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedUser.GetType());
         deserializedUser = ser.ReadObject(e.Result) as List<Annale>;
         foreach (Annale i in deserializedUser)
         {
             UVs.Add(new UVViewModel() { NomUV = i.Nom, NbPages = i.Pages });
         }
     }
 }
开发者ID:apuyou,项目名称:polar-bear,代码行数:13,代码来源:MainViewModel.cs

示例10: ReadFavoritesFromDisk

        private static List<FavoriteRouteAndStop> ReadFavoritesFromDisk(string fileName)
        {
            List<FavoriteRouteAndStop> favoritesFromFile = new List<FavoriteRouteAndStop>();

            try
            {
                using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (appStorage.FileExists(fileName) == true)
                    {
                        using (IsolatedStorageFileStream favoritesFile = appStorage.OpenFile(fileName, FileMode.Open))
                        {
                            List<Type> knownTypes = new List<Type>(2);
                            knownTypes.Add(typeof(FavoriteRouteAndStop));
                            knownTypes.Add(typeof(RecentRouteAndStop));

                            DataContractSerializer serializer = new DataContractSerializer(favoritesFromFile.GetType(), knownTypes);
                            favoritesFromFile = serializer.ReadObject(favoritesFile) as List<FavoriteRouteAndStop>;
                        }

                        // This is required because we changed the data format between versions 
                        if (favoritesFromFile.Count > 0 && favoritesFromFile[0].version != FavoriteRouteAndStop.CurrentVersion)
                        {
                            // Currently we don't support backwards compatability, just delete all their favorites/recents
                            appStorage.DeleteFile(fileName);
                            favoritesFromFile = new List<FavoriteRouteAndStop>();
                        }
                    }
                    else
                    {
                        favoritesFromFile = new List<FavoriteRouteAndStop>();
                    }
                }
            }
            catch (Exception)
            {
                Debug.Assert(false);

                // We hit an error deserializing the file so delete it if it exists
                using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (appStorage.FileExists(fileName) == true)
                    {
                        appStorage.DeleteFile(fileName);
                    }
                }

                throw;
            }

            return favoritesFromFile;
        }
开发者ID:Reagankm,项目名称:onebusaway-windows-phone,代码行数:52,代码来源:AppDataModel.cs

示例11: WriteFavoritesToDisk

        private static void WriteFavoritesToDisk(List<FavoriteRouteAndStop> favoritesToWrite, string fileName)
        {
            using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream favoritesFile = appStorage.OpenFile(fileName, FileMode.Create))
                {
                    List<Type> knownTypes = new List<Type>(2);
                    knownTypes.Add(typeof(FavoriteRouteAndStop));
                    knownTypes.Add(typeof(RecentRouteAndStop));

                    DataContractSerializer serializer = new DataContractSerializer(favoritesToWrite.GetType(), knownTypes);
                    serializer.WriteObject(favoritesFile, favoritesToWrite);
                }
            }
        }
开发者ID:Reagankm,项目名称:onebusaway-windows-phone,代码行数:15,代码来源:AppDataModel.cs


注:本文中的System.Windows.Documents.List.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。