ToString() публичный статический Метод

public static ToString ( string format = null ) : string
format string
Результат string
Пример #1
0
        /// <summary>
        /// Gets a collection of assembly attributes exposed by the assembly.
        /// </summary>
        /// <returns>A System.Specialized.KeyValueCollection of assembly attributes.</returns>
        public NameValueCollection GetAttributes()
        {
            NameValueCollection assemblyAttributes = new NameValueCollection();

            //Add some values that are not in AssemblyInfo.
            assemblyAttributes.Add("Full Name", FullName);
            assemblyAttributes.Add("Name", Name);
            assemblyAttributes.Add("Version", Version.ToString());
            assemblyAttributes.Add("Image Runtime Version", ImageRuntimeVersion);
            assemblyAttributes.Add("Build Date", BuildDate.ToString());
            assemblyAttributes.Add("Location", Location);
            assemblyAttributes.Add("Code Base", CodeBase);
            assemblyAttributes.Add("GAC Loaded", GACLoaded.ToString());

            //Add all attributes available from AssemblyInfo.
            assemblyAttributes.Add("Title", Title);
            assemblyAttributes.Add("Description", Description);
            assemblyAttributes.Add("Company", Company);
            assemblyAttributes.Add("Product", Product);
            assemblyAttributes.Add("Copyright", Copyright);
            assemblyAttributes.Add("Trademark", Trademark);
            assemblyAttributes.Add("Configuration", Configuration);
            assemblyAttributes.Add("Delay Sign", DelaySign.ToString());
            assemblyAttributes.Add("Informational Version", InformationalVersion);
            assemblyAttributes.Add("Key File", KeyFile);
            assemblyAttributes.Add("Culture Name", CultureName);
            assemblyAttributes.Add("Satellite Contract Version", SatelliteContractVersion);
            assemblyAttributes.Add("Com Compatible Version", ComCompatibleVersion);
            assemblyAttributes.Add("Com Visible", ComVisible.ToString());
            assemblyAttributes.Add("Guid", Guid);
            assemblyAttributes.Add("Type Lib Version", TypeLibVersion);
            assemblyAttributes.Add("CLS Compliant", CLSCompliant.ToString());

            return(assemblyAttributes);
        }
Пример #2
0
 public override void DumpBody(XmlWriter writer)
 {
     writer.WriteElementString("product-id", ProductId.ToString());
     writer.WriteElementString("edition", Edition.ToString());
     writer.WriteElementString("major-version", MajorVersion.ToString());
     writer.WriteElementString("minor-version", MinorVersion.ToString());
     writer.WriteElementString("build-number", BuildNumber.ToString());
     writer.WriteElementString("build-date", BuildDate.ToString());
 }
Пример #3
0
 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("CPUCapabilities v{0:D}.{1:D2} [{2}]", CPU.LibraryVersion.Item1, CPU.LibraryVersion.Item2, BuildDate.ToString("yyyy-MM-dd"));
         Console.WriteLine();
         Console.WriteLine("Architecture: {0}", CPU.Architecture);
         Console.WriteLine("Count: {0}", CPU.Count);
         Console.WriteLine("Vendor: \"{0}\"", OrDefault(CPU.Vendor));
         Console.WriteLine("Information: {0}", CPU.Information);
         Console.WriteLine("Brand: \"{0}\"", OrDefault(CPU.Brand));
         Console.WriteLine("Capabilities: {0}", CPU.Capabilities);
         Console.WriteLine();
         Console.WriteLine("[Debug]");
         Console.WriteLine("IsX64Process: {0}", CPU.IsX64Process);
         Console.WriteLine();
     }
     catch (Exception e)
     {
         Console.Error.WriteLine();
         Console.Error.WriteLine("Error: Something went seriously wrong !!!");
         Console.Error.WriteLine();
         Console.Error.WriteLine(e.ToString());
     }
 }
Пример #4
0
 public override string ToString()
 {
     return($"{Id} - {Platform} - {Environment} - {BuildNumber} - {BuildDate.ToString()} - {SourceBranch}");
 }
Пример #5
0
    private void WritePropertiesToFile()
    {
        var aiFile = Path.Combine(Environment.CurrentDirectory, OutputFile);

        if (!File.Exists(aiFile))
        {
            Console.WriteLine($"Could not find AssemblyInfo.cs file '{aiFile}'");
            return;
        }

        var lines = File.ReadAllLines(aiFile);

        var title       = "";
        var copyright   = Copyright.Replace("{Year}", BuildDate.Year.ToString());
        var fullVersion = "";

        for (var i = 0; i < lines.Length; i++)
        {
            var line = lines[i].Trim();
            if (line.StartsWith("[assembly: System.Reflection.AssemblyVersionAttribute("))
            {
                var version = line.Substring(line.IndexOf('"') + 1, line.LastIndexOf('"') - line.IndexOf('"') - 1);
                var vparts  = version.Split('.');
                fullVersion = $"{vparts[0]}.{vparts[1]}.{BuildDate.ToString("yyMMdd").Substring(1)}.{CommitCount}";
                //Console.WriteLine($"fullVersion == '{fullVersion}'");
            }
            if (line.StartsWith("[assembly: System.Reflection.AssemblyTitleAttribute("))
            {
                title = line.Substring(line.IndexOf('"') + 1, line.LastIndexOf('"') - line.IndexOf('"') - 1);
                //Console.WriteLine($"title == '{title}'");
            }
        }

        for (var i = 0; i < lines.Length; i++)
        {
            var line = lines[i].Trim();

            if (line.StartsWith("[assembly: System.Reflection.AssemblyProductAttribute("))
            {
                lines[i] = $"[assembly: System.Reflection.AssemblyProductAttribute(\"{title} v:{fullVersion} #{CommitHash}\")]";
            }
            else if (line.StartsWith("[assembly: System.Reflection.AssemblyCopyrightAttribute("))
            {
                lines[i] = $"[assembly: System.Reflection.AssemblyCopyrightAttribute(\"{copyright}\")]";
            }
            else if (line.StartsWith("[assembly: System.Reflection.AssemblyFileVersionAttribute("))
            {
                lines[i] = $"[assembly: System.Reflection.AssemblyFileVersionAttribute(\"{fullVersion}\")]";
            }
            else if (line.StartsWith("[assembly: System.Reflection.AssemblyInformationalVersionAttribute("))
            {
                lines[i] = $"[assembly: System.Reflection.AssemblyInformationalVersionAttribute(\"{fullVersion}\")]";
            }
            else if (line.StartsWith("[assembly: System.Reflection.AssemblyVersionAttribute("))
            {
                lines[i] = $"[assembly: System.Reflection.AssemblyVersionAttribute(\"{fullVersion}\")]";
            }
        }

        File.WriteAllLines(aiFile, lines, Encoding.UTF8);

        Console.WriteLine($"  GitVersionCore(): {title} version: {fullVersion} hash: {CommitHash}");
    }
Пример #6
0
 public override string ToString()
 {
     return($"{OperatingSystem} {Tag} {Version} {Architecture} {Size} {BuildDate.ToString("yyyy-MM-dd hh:mm")}");
 }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        if (swipeRecognizer.GetComponent <SwipeRecognizer>().congratsPanel.activeSelf)
        {
            PauseCountdown();
        }
        else
        {
            ContinueCountdown();
        }

        if (countDown && !paused)
        {
            oneSec += Time.deltaTime;
            if (oneSec >= 1f)
            {
                oneSec = 0f;
                timeLeft--;
                if (timeLeft >= 0)
                {
                    string countTxt = "Time left: " + timeLeft.ToString();
                    GetComponent <UnityEngine.UI.Text>().text  = countTxt;
                    GetComponent <UnityEngine.UI.Text>().color = Color.white;

                    if (timeLeft <= 5)
                    {
                        GetComponent <UnityEngine.UI.Text>().color = Color.red;
                        GetComponent <AudioSource>().volume        = 1;
                        GetComponent <AudioSource>().pitch         = .9f;
                        GetComponent <AudioSource>().Play();
                    }
                }
                else
                {
                    countDown = false;
                    int tempCount = swipeRecognizer.GetComponent <SwipeRecognizer>().neutrinoCount;
                    eventPanelManager.GetComponent <EventPanelManager>().panels.Clear();
                    //trigger a restart of the game...
                    //high score list?
                    timeLeft = gameTime;
                    string countTxt = "Time left: " + timeLeft.ToString();
                    GetComponent <UnityEngine.UI.Text>().text = countTxt;
                    int tempScore = swipeRecognizer.GetComponent <SwipeRecognizer>().neutrinoScore;

                    if (swipeGame != null)
                    {
                        if (summaryPanel != null)
                        {
                            if (tempCount == 1)
                            {
                                summaryPanel.transform.GetChild(4).gameObject.GetComponent <UnityEngine.UI.Text>().text = "Game Summary: You detected " + tempCount + " neutrino source for a score of: " + tempScore;
                            }
                            else
                            {
                                summaryPanel.transform.GetChild(4).gameObject.GetComponent <UnityEngine.UI.Text>().text = "Game Summary: You detected " + tempCount + " neutrino sources for a score of: " + tempScore;
                            }

                            int numTimesTouched = Camera.main.GetComponent <TouchScript.Gestures.MultiFlickGesture>().numTouches;

                            //write out log file here
                            StreamWriter w;

                            string d = BuildDate.ToString();// DateTime.Now.ToString();
                            d = d.Replace("/", "_");
                            d = d.Replace(" ", "_");
                            d = d.Replace(":", "_");

                            using (w = File.AppendText(d + ".log"))
                            {
                                string time = DateTime.Now.ToShortTimeString();
                                string date = DateTime.Now.ToShortDateString();

                                w.WriteLine(date + ", " + time + ", " + tempCount + ", " + tempScore + ", " + numTimesTouched);
                                w.Close();
                            }

                            StreamWriter w2;
                            try
                            {
                                w2 = new StreamWriter("S:\\research_data\\Polar\\" + d + ".log", true);
                                string time = DateTime.Now.ToShortTimeString();
                                string date = DateTime.Now.ToShortDateString();
                                Debug.Log("updated scores");
                                w2.WriteLine(date + ", " + time + ", " + tempCount + ", " + tempScore + ", " + numTimesTouched);
                                w2.Close();
                            } catch (IOException e)
                            {
                                //just don't write it
                                Debug.Log("Couldn't update scores log to cave shared");
                            }

                            Camera.main.GetComponent <TouchScript.Gestures.MultiFlickGesture> ().numTouches = 0;
                            summaryPanel.SetActive(true);
                        }

                        if (swipeGame != null)
                        {
                            swipeGame.GetComponent <SwipeGameMode>().StopGame();
                        }

                        StartCoroutine(DelayedResolve(summaryPanelLength, false));
                    }

                    if (score != null)
                    {
                        //reset score..
                        swipeRecognizer.GetComponent <SwipeRecognizer>().neutrinoScore = 0;
                        swipeRecognizer.GetComponent <SwipeRecognizer>().neutrinoCount = 0;
                        score.GetComponent <UnityEngine.UI.Text>().text = "Score: 0 Points";
                        GetComponent <UnityEngine.UI.Text>().color      = Color.white;
                    }
                }
            }
        }
    }
    public string format = "g";        // see: https://msdn.microsoft.com/en-us/library/az4se3k1%28v=vs.110%29.aspx

    void Start()
    {
        GetComponent <UnityEngine.UI.Text>().text = BuildDate.ToString(format);
    }
Пример #9
0
        public Engine(HostType hostType, ICommandLine commandLine, string gameDirectory, EngineConfiguration engineConfiguration, ILogger logger, ForwardingTextWriter forwardingTextWriter)
        {
            _hostType = hostType;

            CommandLine         = commandLine ?? throw new ArgumentNullException(nameof(commandLine));
            GameDirectory       = gameDirectory ?? throw new ArgumentNullException(nameof(gameDirectory));
            EngineConfiguration = engineConfiguration ?? throw new ArgumentNullException(nameof(engineConfiguration));
            Log.Logger          = Logger = logger ?? throw new ArgumentNullException(nameof(logger));
            LogTextWriter       = forwardingTextWriter ?? throw new ArgumentNullException(nameof(forwardingTextWriter));

            FileSystem = new DiskFileSystem();

            SetupFileSystem(GameDirectory);

            CommandSystem = new SharpLife.CommandSystem.CommandSystem(Logger, CultureInfo.InvariantCulture);

            EngineContext = CommandSystem.CreateContext("EngineContext");

            var startupState = new EngineStartupState(Logger, GameDirectory,
                                                      new IModelFormatProvider[]
            {
                new SpriteModelFormatProvider(),
                new StudioModelFormatProvider(),
                //BSP loader comes last due to not having a way to positively recognize the format
                new BSPModelFormatProvider(Framework.BSPModelNamePrefix)
            });

            //Add the engine assembly so builtin data gets added
            startupState.EntitySystemMetaData.AddAssembly(typeof(Engine).Assembly);

            //create the game window if this is a client
            if (_hostType == HostType.Client)
            {
                Client = new EngineClient(this, startupState);
            }

            Server = new EngineServer(this, Logger, startupState);

            PluginManager = startupState.PluginManager.Build();

            //Automatically add in all plugin assemblies to the entity system
            foreach (var pluginAssembly in PluginManager.Assemblies)
            {
                startupState.EntitySystemMetaData.AddAssembly(pluginAssembly);
            }

            var renderer = (IRenderer)Client?.UserInterface.Renderer ?? new ServerRenderer();

            World = new WorldState(
                Logger,
                EventSystem,
                FileSystem,
                startupState.EntitySystemMetaData.Build(),
                renderer,
                startupState.ModelFormats);

            _engineTimeStopwatch.Start();

            EngineContext.AddStuffCmds(Logger, CommandLine);
            EngineContext.AddExec(Logger, FileSystem, ExecPathIDs);
            EngineContext.AddEcho(Logger);
            EngineContext.AddAlias(Logger);
            EngineContext.AddFind(Logger);
            EngineContext.AddHelp(Logger);

            _fpsMax = EngineContext.RegisterVariable(
                new VirtualVariableInfo <uint>("fps_max", DefaultFPS)
                .WithHelpInfo("Sets the maximum frames per second")
                .WithChangeHandler((ref VariableChangeEvent <uint> @event) =>
            {
                @event.Value = Math.Min(@event.Value, MaximumFPS);

                var desiredFPS = @event.Value;

                if (desiredFPS == 0)
                {
                    desiredFPS = MaximumFPS;
                }

                _desiredFrameLengthSeconds = 1.0 / desiredFPS;
            }));

            EngineContext.RegisterVariable("engine_builddate", () => BuildDate, "The engine's build date");

            EngineContext.RegisterCommand(new CommandInfo("map", StartNewMap).WithHelpInfo("Loads the specified map"));

            //Get the build date from the generated resource file
            var assembly = typeof(Engine).Assembly;

            using (var reader = new StreamReader(assembly.GetManifestResourceStream($"{assembly.GetName().Name}.Resources.BuildDate.txt")))
            {
                string buildTimestamp = reader.ReadToEnd();

                BuildDate = DateTimeOffset.Parse(buildTimestamp);

                Logger.Information($"Exe: {BuildDate.ToString("HH:mm:ss MMM dd yyyy")}");
            }

            //TODO: initialize subsystems
        }