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


C# SteamKit2.KeyValue类代码示例

本文整理汇总了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);
 }
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:8,代码来源:GUIDCalculator.cs

示例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 );
        }
开发者ID:RaptorFactor,项目名称:SteamKit,代码行数:9,代码来源:KeyValueFacts.cs

示例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 );
        }
开发者ID:logtcn,项目名称:SteamKit,代码行数:9,代码来源:KeyValueFacts.cs

示例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();
 }
开发者ID:sy1989,项目名称:Dota2DroplistJson,代码行数:11,代码来源:vdf2json.cs

示例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.###"));
        }
开发者ID:TheFighter,项目名称:SteamDatabaseBackend,代码行数:11,代码来源:Binaries.cs

示例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;
        }
开发者ID:Netshroud,项目名称:steam-irc-bot,代码行数:12,代码来源:SteamAppInfoHandler.cs

示例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!" );
            }
        }
开发者ID:Netshroud,项目名称:steam-irc-bot,代码行数:12,代码来源:TF2GCHandlers.cs

示例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" );
        }
开发者ID:logtcn,项目名称:SteamKit,代码行数:13,代码来源:KeyValueFacts.cs

示例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 );
        }
开发者ID:Redflameman0,项目名称:SteamKit2,代码行数:50,代码来源:KeyValue.cs

示例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;
        }
开发者ID:RJacksonm1,项目名称:SteamDatabaseBackend,代码行数:16,代码来源:DbWorker.cs

示例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 );
        }
开发者ID:logtcn,项目名称:SteamKit,代码行数:16,代码来源:KeyValueFacts.cs

示例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;
            }
        }
开发者ID:sy1989,项目名称:Dota2DroplistJson,代码行数:17,代码来源:vdf2json.cs

示例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;
        }
开发者ID:Markusyatina,项目名称:steam-irc-bot,代码行数:20,代码来源:SteamAppInfoHandler.cs

示例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)));
            }
        }
开发者ID:RJacksonm1,项目名称:SteamDatabaseBackend,代码行数:37,代码来源:Binaries.cs

示例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;
        }
开发者ID:suzaku91,项目名称:SteamKit,代码行数:20,代码来源:CDNClient.cs


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