本文整理汇总了C#中ObservableCollection.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.GetType方法的具体用法?C# ObservableCollection.GetType怎么用?C# ObservableCollection.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadToObject
// Deserialize a JSON stream to a User object.
public static ObservableCollection<Podcast> ReadToObject(string json)
{
ObservableCollection<Podcast> deserializedObj = new ObservableCollection<Podcast>();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedObj.GetType());
deserializedObj = ser.ReadObject(ms) as ObservableCollection<Podcast>;
return deserializedObj;
}
示例2: Save
public static void Save(ObservableCollection<Achievement> achievements)
{
if (_currentFilePath == "") return;
using (var fs = new FileStream(_currentFilePath, FileMode.Open))
{
var serializer = new XmlSerializer(achievements.GetType());
serializer.Serialize(fs, achievements);
}
}
示例3: SaveAs
public static void SaveAs(ObservableCollection<Achievement> achievements)
{
var saveDialog = new SaveFileDialog {Filter = "Data files (*.save)|*.save;"};
var ok = saveDialog.ShowDialog();
if (ok.Value != true) return;
_currentFilePath = saveDialog.FileName;
using (var fs = saveDialog.OpenFile())
{
var serializer = new XmlSerializer(achievements.GetType());
serializer.Serialize(fs, achievements);
}
}
示例4: Settings
protected Settings(SerializationInfo info, StreamingContext context)
{
try { Comport = info.GetString("Comport"); }
catch { }
try { BaudRate = info.GetInt32("BaudRate"); }
catch { }
try { SelectedDriver = info.GetString("SelectedDriver"); }
catch { }
try { FieldWidth = info.GetDouble("FieldWidth"); }
catch { }
try { FieldHeight = info.GetDouble("FieldHeight"); }
catch { }
try { FieldMargin = info.GetDouble("FieldMargin"); }
catch { }
try { SampleWindow = info.GetDouble("SampleWindow"); }
catch { }
try { SampleLength = info.GetDouble("SampleLength"); }
catch { }
try { BeaconHeight = info.GetDouble("BeaconHeight"); }
catch { }
try { SmoothFactor = info.GetDouble("SmoothFactor"); }
catch { }
try { ChargeVoltageThreshold = info.GetDouble("ChargeVoltageThreshold"); }
catch { }
try { MatchedFilterEnabled = info.GetBoolean("MatchedFilterEnabled"); }
catch { }
try { MatchedFilterToep = info.GetBoolean("MatchedFilterToep"); }
catch { }
try { UseMeasuredSignal = info.GetBoolean("UseMeasuredSignal"); }
catch { }
try
{
ObservableCollection<Microphone> temp = new ObservableCollection<Microphone>();
temp = (ObservableCollection<Microphone>)info.GetValue("Microphones", temp.GetType());
if (temp != null)
{
_microphones = temp;
temp = null;
}
}
catch { }
}
示例5: GetSavedStocks
private ObservableCollection<StockViewModel> GetSavedStocks()
{
ObservableCollection<StockViewModel> toReturn = new ObservableCollection<StockViewModel>();
toReturn = Business.Stocks.LoadSavedStocks(toReturn.GetType()) as ObservableCollection<StockViewModel>;
foreach (StockViewModel curStock in toReturn)
{//subscribe to the events
AddEventHandlers(curStock);
}
return toReturn;
}
示例6: Write
public static void Write(string path, ObservableCollection<TileSelection> selections)
{
using (TextWriter writer = new StreamWriter(path)) {
var xs = new XmlSerializer(selections.GetType());
xs.Serialize(writer, selections);
}
}