Exemplo n.º 1
0
        private bool ConfigureRPC()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString() + "\\MultiChain\\" + chainName + "\\multichain.conf";

            try
            {
                StreamWriter file = new StreamWriter(path, false);
                Console.WriteLine(file.GetHashCode());
                file.Write(ConfigReader.GetRpcData());
                file.Close();
                Console.WriteLine(path.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(true);
        }
Exemplo n.º 2
0
        private GpuProgram CreateGpuProgram(Program shaderProgram, ProgramWriter programWriter, string language,
                                            string profiles, string[] profilesList, string cachePath)
        {
            StreamWriter sourceCodeStringStream = null;

            int programHashCode;

            string programName;

            //Generate source code
            programWriter.WriteSourceCode(sourceCodeStringStream, shaderProgram);

            programHashCode = sourceCodeStringStream.GetHashCode();

            //Generate program name
            programName = programHashCode.ToString();

            if (shaderProgram.Type == GpuProgramType.Vertex)
            {
                programName += "_VS";
            }
            else if (shaderProgram.Type == GpuProgramType.Fragment)
            {
                programName += "_FS";
            }

            HighLevelGpuProgram gpuProgram;

            //Try to get program by name
            gpuProgram = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName(programName);

            //Case the program doesn't exist yet
            if (gpuProgram == null)
            {
                //Create new GPU program.
                gpuProgram = HighLevelGpuProgramManager.Instance.CreateProgram(programName,
                                                                               ResourceGroupManager.
                                                                               DefaultResourceGroupName, language,
                                                                               shaderProgram.Type);

                //Case cache directory specified -> create program from file
                if (cachePath == string.Empty)
                {
                    string programFullName = programName + "." + language;
                    string programFileName = cachePath + programFullName;
                    bool   writeFile       = true;

                    //Check if program file already exists
                    if (File.Exists(programFileName))
                    {
                        writeFile = true;
                    }
                    else
                    {
                        writeFile = false;
                    }

                    if (writeFile)
                    {
                        var outFile = new StreamWriter(programFileName);

                        outFile.Write(sourceCodeStringStream);
                        outFile.Close();
                    }

                    gpuProgram.SourceFile = programFullName;
                }
                else                 // no cache directory specified -> create program from system memory
                {
                    //TODO
                    // gpuProgram.Source = sourceCodeStringStream;
                }
                var gpuParams = new Collections.NameValuePairList();
                gpuParams.Add("entry_point", shaderProgram.EntryPointFunction.Name);
                gpuProgram.SetParameters(gpuParams);

                gpuParams.Clear();

                // HLSL program requires specific target profile settings - we have to split the profile string.
                if (language == "hlsl")
                {
                    foreach (var it in profilesList)
                    {
                        if (GpuProgramManager.Instance.IsSyntaxSupported(it))
                        {
                            gpuParams.Add("target", it);
                            gpuProgram.SetParameters(gpuParams);
                            gpuParams.Clear();
                            break;
                        }
                    }
                }
                gpuParams.Add("profiles", profiles);
                gpuProgram.SetParameters(gpuParams);
                gpuProgram.Load();

                //Case an error occurred
                if (gpuProgram.HasCompileError)
                {
                    gpuProgram = null;
                    return(gpuProgram);
                }

                //Add the created GPU prgram to local cache
                if (gpuProgram.Type == GpuProgramType.Vertex)
                {
                    this.vertexShaderMap[programName] = gpuProgram;
                }
                else if (gpuProgram.Type == GpuProgramType.Fragment)
                {
                    this.fragmentShaderMap[programName] = gpuProgram;
                }
            }
            return(gpuProgram);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a difference string from a shelveset
        /// Also sets the URl to the file on the TFS Server
        /// </summary>
        /// <param name="set">The selected PendingSet</param>
        /// <returns>the diff String which is sent to Codestriker</returns>
        public string ReviewShelveset(
            PendingSet set)
        {
            if (set == null)
            {
                throw new ArgumentNullException(nameof(set));
            }


            MemoryStream stream = new MemoryStream();

            StreamWriter writer = new StreamWriter(stream);

            {
                DiffOptions options = new DiffOptions
                {
                    Flags          = DiffOptionFlags.EnablePreambleHandling,
                    OutputType     = DiffOutputType.Unified,
                    TargetEncoding = Encoding.UTF8,
                    SourceEncoding = Encoding.UTF8,
                    Recursive      = true,
                    StreamWriter   = writer
                };

                StringBuilder sb        = new StringBuilder();
                int           streampos = 0;
                foreach (var pendingchange in set.PendingChanges)
                {
                    if (pendingchange.ItemType != ItemType.Folder)
                    {
                        string fileUrl = string.Format(pendingchange.VersionControlServer.TeamProjectCollection.Uri.AbsoluteUri);
                        fileUrl += s_LinkCompletionVersioncontrol;
                        fileUrl +=
                            $"{HttpUtility.UrlEncode(pendingchange.PendingSetName + ";" + pendingchange.PendingSetOwner)}{s_PathParameter}";
                        fileUrl += HttpUtility.UrlEncode(pendingchange.LocalOrServerItem);
                        //the semicolons after s_ActionParameter and pendingchange.FileName are important for the right parsing on codestriker
                        fileUrl += $"{s_ActionParameter}&#path={HttpUtility.UrlEncode(pendingchange.LocalOrServerItem)}{s_ActionParameter};{pendingchange.LocalOrServerItem};";

                        var diffChange  = new DiffItemShelvedChange(set.Name, pendingchange);
                        var diffVersion = Difference.CreateTargetDiffItem(m_VersionControl, pendingchange, null);

                        Difference.DiffFiles(
                            m_VersionControl,
                            diffVersion,
                            diffChange,
                            options,
                            string.Empty,
                            true);

                        writer.Flush();
                        sb.Append(writer.GetHashCode()).Append(Environment.NewLine);
                        string pendingChangeString = Encoding.UTF8.GetString(stream.ToArray().Skip(streampos).ToArray());

                        Regex rgx = new Regex(s_RegexPattern);

                        //replace the filename with the tfs url path of the file
                        //necessary for the link between codestriker and TFS
                        pendingChangeString = rgx.Replace(
                            pendingChangeString,
                            m => m.Groups["prefix"].Value + ": " + fileUrl,
                            1);

                        sb.Append(pendingChangeString);
                        streampos = stream.ToArray().Length;
                    }
                }

                return(sb.ToString());
            }

            #endregion
        }
Exemplo n.º 4
0
 /// <summary>
 /// ハッシュコードを取得します。オープンしているファイルに基づくハッシュコードです。
 /// </summary>
 /// <returns>ハッシュ値</returns>
 public override int GetHashCode()
 {
     return(sw_.GetHashCode());
 }