本文整理汇总了C#中SteamKit2.KeyValue类的典型用法代码示例。如果您正苦于以下问题:C# KeyValue类的具体用法?C# KeyValue怎么用?C# KeyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyValue类属于SteamKit2命名空间,在下文中一共展示了KeyValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAppManifestValue
private static KeyValue GetAppManifestValue(string manifestPath, string key)
{
var acfKeys = new KeyValue();
var reader = new StreamReader(manifestPath);
var acfReader = new KVTextReader(acfKeys, reader.BaseStream);
reader.Close();
return acfKeys.Children.FirstOrDefault(k => k.Name == key);
}
示例2: KeyValueInitializesCorrectly
public void KeyValueInitializesCorrectly()
{
KeyValue kv = new KeyValue( "name", "value" );
Assert.Equal( "name", kv.Name );
Assert.Equal( "value", kv.Value );
Assert.Empty( kv.Children );
}
示例3: KeyValueIndexerReturnsValidAndInvalid
public void KeyValueIndexerReturnsValidAndInvalid()
{
KeyValue kv = new KeyValue();
kv.Children.Add( new KeyValue( "exists", "value" ) );
Assert.Equal( kv["exists"].Value, "value" );
Assert.Equal( kv["thiskeydoesntexist"], KeyValue.Invalid );
}
示例4: Convert
static string Convert(KeyValue kv, bool compactJSON)
{
var jo = new JObject();
var rootNode = new JObject();
jo[kv.Name] = ConvertRecursive(kv);
StringWriter textWriter = new StringWriter();
JsonWriter jsonWriter = new JsonTextWriter(textWriter);
jsonWriter.Formatting = compactJSON ? Formatting.None : Formatting.Indented;
jo.WriteTo(jsonWriter);
return textWriter.GetStringBuilder().ToString();
}
示例5: PrintBinary
private static void PrintBinary(CommandArguments command, KeyValue kv, string key)
{
if (kv[key].Children.Count == 0)
{
return;
}
kv = kv[key];
CommandHandler.ReplyToCommand(command, "{0}{1} {2}({3} MB)", CDN, kv["file"].AsString(), Colors.DARKGRAY, (kv["size"].AsLong() / 1048576.0).ToString("0.###"));
}
示例6: GetPackageInfo
public bool GetPackageInfo( uint packageId, out KeyValue packageInfo )
{
packageInfo = KeyValue.LoadAsBinary( GetPackageCachePath( packageId ) );
if ( packageInfo == null )
return false;
packageInfo = packageInfo.Children
.FirstOrDefault();
return packageInfo != null;
}
示例7: GCClientNotificationHandler
public GCClientNotificationHandler( GCManager manager )
: base(manager)
{
new GCCallback<CMsgGCClientDisplayNotification>( ClientNotification, OnNotification, manager );
tfEnglish = KeyValue.LoadAsText( Path.Combine( Application.StartupPath, "tf_english.txt" ) );
if ( tfEnglish == null )
{
Log.WriteWarn( "GCClientNotificationHandler", "Unable to load tf_english.txt, localizations will be unavailable!" );
}
}
示例8: KeyValueIndexerUpdatesKey
public void KeyValueIndexerUpdatesKey()
{
KeyValue kv = new KeyValue();
KeyValue subkey = new KeyValue();
Assert.Null( subkey.Name );
kv["subkey"] = subkey;
Assert.Equal( subkey.Name, "subkey" );
Assert.Equal( kv["subkey"].Name, "subkey" );
}
示例9: KVTextReader
public KVTextReader( KeyValue kv, Stream input )
: base( input )
{
bool wasQuoted;
bool wasConditional;
KeyValue currentKey = kv;
do
{
bool bAccepted = true;
string s = ReadToken( out wasQuoted, out wasConditional );
if ( string.IsNullOrEmpty( s ) )
break;
if ( currentKey == null )
{
currentKey = new KeyValue( s );
}
else
{
currentKey.Name = s;
}
s = ReadToken( out wasQuoted, out wasConditional );
if ( wasConditional )
{
bAccepted = ( s == "[$WIN32]" );
// Now get the '{'
s = ReadToken( out wasQuoted, out wasConditional );
}
if ( s.StartsWith( "{" ) && !wasQuoted )
{
// header is valid so load the file
currentKey.RecursiveLoadFromBuffer( this );
}
else
{
throw new Exception( "LoadFromBuffer: missing {" );
}
currentKey = null;
}
while ( !EndOfStream );
}
示例10: JsonifyKeyValue
public static string JsonifyKeyValue(KeyValue keys)
{
string value = string.Empty;
using (var sw = new StringWriter(new StringBuilder()))
{
using (JsonWriter w = new JsonTextWriter(sw))
{
DbWorker.JsonifyKeyValue(w, keys.Children);
}
value = sw.ToString();
}
return value;
}
示例11: KeyValueIndexerDoesntallowDuplicates
public void KeyValueIndexerDoesntallowDuplicates()
{
KeyValue kv = new KeyValue();
kv["key"] = new KeyValue();
Assert.Equal( kv.Children.Count, 1 );
kv["key"] = new KeyValue();
Assert.Equal( kv.Children.Count, 1 );
kv["key2"] = new KeyValue();
Assert.Equal( kv.Children.Count, 2 );
}
示例12: ConvertRecursive
static JToken ConvertRecursive(KeyValue kv)
{
var jo = new JObject();
if (kv.Children.Count > 0)
{
foreach (var child in kv.Children)
{
jo[child.Name] = ConvertRecursive(child);
}
return jo;
}
else
{
return (JToken)kv.Value;
}
}
示例13: GetAppInfo
public bool GetAppInfo( uint appId, out KeyValue appInfo )
{
appInfo = KeyValue.LoadAsText( GetAppCachePath( appId ) );
// cache off the name
if ( appInfo != null )
{
string name = appInfo[ "common" ][ "name" ].AsString();
string type = appInfo[ "common" ][ "type" ].AsString();
bool isGame = string.Equals( type, "game", StringComparison.OrdinalIgnoreCase );
if ( name != null )
{
appNameCache[ name ] = new AppCacheEntry { AppID = appId, IsGame = isGame };
}
}
return appInfo != null;
}
示例14: OnCommand
public override void OnCommand(CommandArguments command)
{
using (var webClient = new WebClient())
{
webClient.DownloadDataCompleted += delegate(object sender, DownloadDataCompletedEventArgs e)
{
var kv = new KeyValue();
using (var ms = new MemoryStream(e.Result))
{
try
{
kv.ReadAsText(ms);
}
catch
{
CommandHandler.ReplyToCommand(command, "Something went horribly wrong and keyvalue parser died.");
return;
}
}
if (kv["bins_osx"].Children.Count == 0)
{
CommandHandler.ReplyToCommand(command, "Failed to find binaries in parsed response.");
return;
}
kv = kv["bins_osx"];
CommandHandler.ReplyToCommand(command, "You're on your own:{0} {1}{2} {3}({4} MB)", Colors.DARKBLUE, CDN, kv["file"].AsString(), Colors.DARKGRAY, (kv["size"].AsLong() / 1048576.0).ToString("0.###"));
};
webClient.DownloadDataAsync(new Uri(string.Format("{0}steam_client_publicbeta_osx?_={1}", CDN, DateTime.UtcNow.Ticks)));
}
}
示例15: DoCommand
KeyValue DoCommand( Server server, string command, string data = null, string method = WebRequestMethods.Http.Get, bool doAuth = false, string args = "" )
{
byte[] resultData = DoRawCommand( server, command, data, method, doAuth, args );
var dataKv = new KeyValue();
using ( MemoryStream ms = new MemoryStream( resultData ) )
{
try
{
dataKv.ReadAsText( ms );
}
catch ( Exception ex )
{
throw new InvalidDataException( "An internal error occurred while attempting to parse the response from the CS server.", ex );
}
}
return dataKv;
}