public void WriteClass(IJsonClassGeneratorConfig config, TextWriter sw, JsonType type)
        {
            var visibility = config.InternalVisibility ? "Friend" : "Public";

            if (config.UseNestedClasses)
            {
                sw.WriteLine("    {0} Partial Class {1}", visibility, config.MainClass);
                if (!type.IsRoot)
                {
                    if (ShouldApplyNoRenamingAttribute(config)) sw.WriteLine("        " + NoRenameAttribute);
                    if (ShouldApplyNoPruneAttribute(config)) sw.WriteLine("        " + NoPruneAttribute);
                    sw.WriteLine("        {0} Class {1}", visibility, type.AssignedName);
                }
            }
            else
            {
                if (ShouldApplyNoRenamingAttribute(config)) sw.WriteLine("    " + NoRenameAttribute);
                if (ShouldApplyNoPruneAttribute(config)) sw.WriteLine("    " + NoPruneAttribute);
                sw.WriteLine("    {0} Class {1}", visibility, type.AssignedName);
            }

            var prefix = config.UseNestedClasses && !type.IsRoot ? "            " : "        ";

            WriteClassMembers(config, sw, type, prefix);

            if (config.UseNestedClasses && !type.IsRoot)
                sw.WriteLine("        End Class");

            sw.WriteLine("    End Class");
            sw.WriteLine();
        }
Beispiel #2
1
        public void GetCode(CodeFormat format, TextWriter writer)
        {
            IOutputProvider output;
            switch (format)
            {
                case CodeFormat.Disassemble:
                    output = OutputFactory.GetDisassembleOutputProvider();
                    break;
                case CodeFormat.ControlFlowDecompile:
                    output = OutputFactory.GetDecompileCFOutputProvider();
                    break;
                case CodeFormat.FullDecompile:
                    output = OutputFactory.GetDecompileFullOutputProvider();
                    break;
                case CodeFormat.FullDecompileAnnotate:
                    output = OutputFactory.GetDecompileFullAnnotateOutputProvider();
                    break;
                case CodeFormat.CodePath:
                    output = OutputFactory.GetCodePathOutputProvider();
                    break;
                case CodeFormat.Variables:
                    output = OutputFactory.GetVariablesOutputProvider();
                    break;
                case CodeFormat.ScruffDecompile:
                    output = OutputFactory.GetScruffDecompileOutputProvider();
                    break;
                case CodeFormat.ScruffHeader:
                    output = OutputFactory.GetScruffHeaderOutputProvider();
                    break;
                default:
                    throw new ArgumentOutOfRangeException("format");
            }

            output.Process(_file, writer);
        }
Beispiel #3
1
 public static void Merge(FileDescriptorSet files, string path, TextWriter stderr, params string[] args)
 {
     if (stderr == null) throw new ArgumentNullException("stderr");
     if (files == null) throw new ArgumentNullException("files");
     if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path");
     
     bool deletePath = false;
     if(!IsValidBinary(path))
     { // try to use protoc
         path = CompileDescriptor(path, stderr, args);
         deletePath = true;
     }
     try
     {
         using (FileStream stream = File.OpenRead(path))
         {
             Serializer.Merge(stream, files);
         }
     }
     finally
     {
         if(deletePath)
         {
             File.Delete(path);
         }
     }
 }
Beispiel #4
1
      private async static Task AddConversationsToDatabaseAsync(Provider provider, Category category, 
         IEnumerable<Conversation> newConversations, TextWriter logger)
      {
         int conversationsAddedToDatabase = 0;
         int conversationsUpdatedInDatabase = 0;

         foreach (var newConversation in newConversations)
         {
            var existingCon = db.Conversations
              .Where(c => c.CategoryID == category.CategoryID &&   
                          c.Url == newConversation.Url)            
               .SingleOrDefault();

            if (existingCon != null && existingCon.LastUpdated < newConversation.LastUpdated)
            {
               existingCon.LastUpdated = newConversation.LastUpdated;
               existingCon.DbUpdated = DateTimeOffset.UtcNow;
               existingCon.Body = newConversation.Body;
               db.Entry(existingCon).State = EntityState.Modified;
               conversationsUpdatedInDatabase++;
            }
            else if (existingCon == null)
            {
               newConversation.DbUpdated = DateTimeOffset.UtcNow;
               db.Conversations.Add(newConversation);
               conversationsAddedToDatabase++;
            }
         }
         logger.WriteLine("Added {0} new conversations, updated {1} conversations", 
            conversationsAddedToDatabase, conversationsUpdatedInDatabase);
         await db.SaveChangesAsync();
      }
        public static void ToGraphic(this ByteMatrix matrix, TextWriter output)
        {
            output.WriteLine(matrix.Width.ToString());
            for (int j = 0; j < matrix.Width; j++)
            {
                for (int i = 0; i < matrix.Width; i++)
                {

                    char charToPrint;
                    switch (matrix[i, j])
                    {
                        case 0:
                            charToPrint = s_0Char;
                            break;

                        case 1:
                            charToPrint = s_1Char;
                            break;

                        default:
                            charToPrint = s_EmptyChar;
                            break;

                    }
                    output.Write(charToPrint);
                }
                output.WriteLine();
            }
        }
 public void Metas(TextWriter Output)
 {
     foreach (var meta in resourceManager.GetRegisteredMetas())
     {
         Output.WriteLine(meta.GetTag());
     }
 }
Beispiel #7
1
 public GitTfsRemote(RemoteOptions remoteOptions, Globals globals, ITfsHelper tfsHelper, TextWriter stdout)
 {
     this.remoteOptions = remoteOptions;
     this.globals = globals;
     this.stdout = stdout;
     Tfs = tfsHelper;
 }
Beispiel #8
1
 private static void PrintCaseStatements(TextWriter output, int branchCount, int value, int off)
 {
     for (var i = branchCount; i > 0; i >>= 1)
     {
         if ((i & value) != 0)
         {
             switch (i)
             {
                 case 32:
                     if (gEnableAvx) output.WriteLine("\t_memcpy32_avx(dst + {0}, src + {0});", off);
                     else output.WriteLine("\t_memcpy32_sse2(dst + {0}, src + {0});", off);
                     break;
                 case 16:
                     output.WriteLine("\t_memcpy16_sse2(dst + {0}, src + {0});", off);
                     break;
                 case 8:
                     output.WriteLine("\t*reinterpret_cast<uint64_t*>(dst + {0}) = *reinterpret_cast<uint64_t const*>(src + {0});", off);
                     break;
                 case 4:
                     output.WriteLine("\t*reinterpret_cast<uint32_t*>(dst + {0}) = *reinterpret_cast<uint32_t const*>(src + {0});", off);
                     break;
                 case 2:
                     output.WriteLine("\t*reinterpret_cast<uint16_t*>(dst + {0}) = *reinterpret_cast<uint16_t const*>(src + {0});", off);
                     break;
                 case 1:
                     output.WriteLine("\tdst[{0}] = src[{0}];", off);
                     break;
             }
             off += i;
         }
     }
 }
 /// <summary>
 /// Write the current date and time to the output
 /// </summary>
 /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
 /// <param name="state">null, state is not set</param>
 /// <remarks>
 /// <para>
 /// Pass the current date and time to the <see cref="IDateFormatter"/>
 /// for it to render it to the writer.
 /// </para>
 /// <para>
 /// The date is in Universal time when it is rendered.
 /// </para>
 /// </remarks>
 /// <seealso cref="DatePatternConverter"/>
 protected override void Convert(TextWriter writer, object state) {
   try {
     m_dateFormatter.FormatDate(DateTime.UtcNow, writer);
   } catch (Exception ex) {
     LogLog.Error("UtcDatePatternConverter: Error occurred while converting date.", ex);
   }
 }
 public override void toXML(TextWriter tw)
 {
     tw.WriteLine("<" + Constants.BINC45MODELSELECTION_ELEMENT + " " +
     Constants.MIN_NO_OBJ_ATTRIBUTE + "=\"" + this.m_minNoObj + "\"   " +
     " xmlns=\"urn:mites-schema\">\n");
     tw.WriteLine("</" + Constants.BINC45MODELSELECTION_ELEMENT + ">");           
 }
Beispiel #11
1
        public virtual void HtmlDecode(string value, TextWriter output)
        {
            if (output == null)
                throw new ArgumentNullException ("output");

            output.Write (HtmlDecode (value));
        }
Beispiel #12
1
 private static void ConvertContentTo(HtmlNode node, TextWriter outText)
 {
     foreach (HtmlNode subnode in node.ChildNodes)
       {
     ConvertTo(subnode, outText);
       }
 }
Beispiel #13
1
 public InitBranch(TextWriter stdout, Globals globals, Help helper, AuthorsFile authors)
 {
     _stdout = stdout;
     _globals = globals;
     _helper = helper;
     _authors = authors;
 }
Beispiel #14
1
 public Rcheckin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer)
 {
     _stdout = stdout;
     _checkinOptions = checkinOptions;
     _checkinOptionsFactory = new CommitSpecificCheckinOptionsFactory(_stdout);
     _writer = writer;
 }
 private UpdateOutputLogCommand(IStorageBlockBlob outputBlob, Func<string, CancellationToken, Task> uploadCommand)
 {
     _outputBlob = outputBlob;
     _innerWriter = new StringWriter(CultureInfo.InvariantCulture);
     _synchronizedWriter = TextWriter.Synchronized(_innerWriter);
     _uploadCommand = uploadCommand;
 }
Beispiel #16
1
        void IDumpableAsText.DumpAsText(TextWriter writer)
        {
            var pbag = new List<KeyValuePair<String, String>>();
            Func<KeyValuePair<String, String>, String> fmt = kvp =>
            {
                var maxKey = pbag.Max(kvp1 => kvp1.Key.Length);
                return String.Format("    {0} : {1}", kvp.Key.PadRight(maxKey), kvp.Value);
            };

            Action<String> fillPbag = s =>
            {
                foreach (var line in s.SplitLines().Skip(1).SkipLast(1))
                {
                    var m = Regex.Match(line, "^(?<key>.*?):(?<value>.*)$");
                    var key = m.Result("${key}").Trim();
                    var value = m.Result("${value}").Trim();
                    pbag.Add(new KeyValuePair<String, String>(key, value));
                }
            };

            writer.WriteLine("Device #{0} \"{1}\" (/pci:{2}/dev:{3})", Index, Name, PciBusId, PciDeviceId);
            fillPbag(Simd.ToString());
            fillPbag(Clock.ToString());
            fillPbag(Memory.ToString());
            fillPbag(Caps.ToString());
            pbag.ForEach(kvp => writer.WriteLine(fmt(kvp)));
        }
Beispiel #17
1
 /// <summary>
 /// Initializes a new instance of the <see cref="QuantConnect.Logging.ConsoleLogHandler"/> class.
 /// </summary>
 public ConsoleLogHandler()
 {
     // saves references to the real console text writer since in a deployed state we may overwrite this in order
     // to redirect messages from algorithm to result handler
     _trace = Console.Out;
     _error = Console.Error;
 }
Beispiel #18
1
        public virtual void DescribeTo(TextWriter writer)
        {
            Ensure.ArgumentNotNull(writer, "writer");

            if (!this.publisher.IsAlive)
            {
                return;
            }

            writer.Write(this.Publisher.GetType().FullNameToString());

            if (this.Publisher is INamedItem)
            {
                writer.Write(", Name = ");
                writer.Write(((INamedItem)this.Publisher).EventBrokerItemName);
            }
                
            writer.Write(", Event = ");
            writer.Write(this.EventName);
            writer.Write(", matchers = ");
            foreach (IPublicationMatcher publicationMatcher in this.publicationMatchers)
            {
                publicationMatcher.DescribeTo(writer);
                writer.Write(" ");
            }
        }
        public static void Write(TextWriter writer, IEnumerable<Dictionary<string, string>> records)
        {
            if (records == null) return; //AOT

            var allKeys = new HashSet<string>();
            var cachedRecords = new List<IDictionary<string, string>>();

            foreach (var record in records)
            {
                foreach (var key in record.Keys)
                {
                    if (!allKeys.Contains(key))
                    {
                        allKeys.Add(key);
                    }
                }
                cachedRecords.Add(record);
            }

            var headers = allKeys.OrderBy(key => key).ToList();
            if (!CsvConfig<Dictionary<string, string>>.OmitHeaders)
            {
                WriteRow(writer, headers);
            }
            foreach (var cachedRecord in cachedRecords)
            {
                var fullRecord = headers.ConvertAll(header => 
                    cachedRecord.ContainsKey(header) ? cachedRecord[header] : null);
                WriteRow(writer, fullRecord);
            }
        }
Beispiel #20
1
        public JsonWriter()
        {
            inst_string_builder = new StringBuilder ();
            writer = new StringWriter (inst_string_builder);

            Init ();
        }
 public void WriteGrades(TextWriter destination)
 {
     for (int i = grades.Count; i > 0; i--)
     {
         destination.WriteLine(grades[i-1]);
     }
 }
Beispiel #22
1
 public void HeadLinks(TextWriter Output)
 {
     foreach (var link in resourceManager.GetRegisteredLinks())
     {
         Output.WriteLine(link.GetTag());
     }
 }
        public static ITriggerBindingProvider Create(INameResolver nameResolver,
            IStorageAccountProvider storageAccountProvider,
            IExtensionTypeLocator extensionTypeLocator,
            IHostIdProvider hostIdProvider,
            IQueueConfiguration queueConfiguration,
            IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
            IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter,
            IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter,
            ISharedContextProvider sharedContextProvider,
            IExtensionRegistry extensions,
            TextWriter log)
        {
            List<ITriggerBindingProvider> innerProviders = new List<ITriggerBindingProvider>();
            innerProviders.Add(new QueueTriggerAttributeBindingProvider(nameResolver, storageAccountProvider,
                queueConfiguration, backgroundExceptionDispatcher, messageEnqueuedWatcherSetter,
                sharedContextProvider, log));
            innerProviders.Add(new BlobTriggerAttributeBindingProvider(nameResolver, storageAccountProvider,
                extensionTypeLocator, hostIdProvider, queueConfiguration, backgroundExceptionDispatcher,
                blobWrittenWatcherSetter, messageEnqueuedWatcherSetter, sharedContextProvider, log));

            // add any registered extension binding providers
            foreach (ITriggerBindingProvider provider in extensions.GetExtensions(typeof(ITriggerBindingProvider)))
            {
                innerProviders.Add(provider);
            }

            return new CompositeTriggerBindingProvider(innerProviders);
        }
		public ResXResourceWriter (TextWriter textWriter)
		{
			if (textWriter == null)
				throw new ArgumentNullException ("textWriter");

			this.textwriter = textWriter;
		}
        /// <summary> Renders the HTML for this element </summary>
        /// <param name="Output"> Textwriter to write the HTML for this element </param>
        /// <param name="Bib"> Object to populate this element from </param>
        /// <param name="Skin_Code"> Code for the current skin </param>
        /// <param name="isMozilla"> Flag indicates if the current browse is Mozilla Firefox (different css choices for some elements)</param>
        /// <param name="popup_form_builder"> Builder for any related popup forms for this element </param>
        /// <param name="Current_User"> Current user, who's rights may impact the way an element is rendered </param>
        /// <param name="CurrentLanguage"> Current user-interface language </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Base_URL"> Base URL for the current request </param>
        /// <remarks> This simple element does not append any popup form to the popup_form_builder</remarks>
        public override void Render_Template_HTML(TextWriter Output, SobekCM_Item Bib, string Skin_Code, bool isMozilla, StringBuilder popup_form_builder, User_Object Current_User, Web_Language_Enum CurrentLanguage, Language_Support_Info Translator, string Base_URL )
        {
            // Check that an acronym exists
            if (Acronym.Length == 0)
            {
                const string defaultAcronym = "Enter the name(s) of the publisher(s) of the larger body of work. If your work is currently unpublished, you may enter your name as the publisher or leave the field blank. If you are adding administrative material (newsletters, handbooks, etc.) on behalf of a department within the university, enter the name of your department as the publisher.";
                switch (CurrentLanguage)
                {
                    case Web_Language_Enum.English:
                        Acronym = defaultAcronym;
                        break;

                    case Web_Language_Enum.Spanish:
                        Acronym = defaultAcronym;
                        break;

                    case Web_Language_Enum.French:
                        Acronym = defaultAcronym;
                        break;

                    default:
                        Acronym = defaultAcronym;
                        break;
                }
            }

            List<string> instanceValues = new List<string>();
            if (Bib.Bib_Info.Publishers_Count > 0)
            {
                instanceValues.AddRange(Bib.Bib_Info.Publishers.Select(thisName => thisName.Name));
            }

            render_helper(Output, instanceValues, Skin_Code, Current_User, CurrentLanguage, Translator, Base_URL);
        }
        /// <summary> Renders the HTML for this element </summary>
        /// <param name="Output"> Textwriter to write the HTML for this element </param>
        /// <param name="Bib"> Object to populate this element from </param>
        /// <param name="Skin_Code"> Code for the current skin </param>
        /// <param name="isMozilla"> Flag indicates if the current browse is Mozilla Firefox (different css choices for some elements)</param>
        /// <param name="popup_form_builder"> Builder for any related popup forms for this element </param>
        /// <param name="Current_User"> Current user, who's rights may impact the way an element is rendered </param>
        /// <param name="CurrentLanguage"> Current user-interface language </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Base_URL"> Base URL for the current request </param>
        /// <remarks> This simple element does not append any popup form to the popup_form_builder</remarks>
        public override void Render_Template_HTML(TextWriter Output, SobekCM_Item Bib, string Skin_Code, bool isMozilla, StringBuilder popup_form_builder, User_Object Current_User, Web_Language_Enum CurrentLanguage, Language_Support_Info Translator, string Base_URL )
        {
            // Check that an acronym exists
            if (Acronym.Length == 0)
            {
                const string defaultAcronym = "Enter any spatial coverage information which relates to this material.";
                switch (CurrentLanguage)
                {
                    case Web_Language_Enum.English:
                        Acronym = defaultAcronym;
                        break;

                    case Web_Language_Enum.Spanish:
                        Acronym = defaultAcronym;
                        break;

                    case Web_Language_Enum.French:
                        Acronym = defaultAcronym;
                        break;

                    default:
                        Acronym = defaultAcronym;
                        break;
                }
            }

            List<string> allValues = new List<string>();
            if (Bib.Bib_Info.Subjects_Count > 0)
            {
                allValues.AddRange(from thisSubject in Bib.Bib_Info.Subjects where thisSubject.Class_Type == Subject_Info_Type.Hierarchical_Spatial select thisSubject.ToString());
            }
            render_helper(Output, allValues, Skin_Code, Current_User, CurrentLanguage, Translator, Base_URL);
        }
        /// <summary> Renders the HTML for this element </summary>
        /// <param name="Output"> Textwriter to write the HTML for this element </param>
        /// <param name="Bib"> Object to populate this element from </param>
        /// <param name="Skin_Code"> Code for the current skin </param>
        /// <param name="IsMozilla"> Flag indicates if the current browse is Mozilla Firefox (different css choices for some elements)</param>
        /// <param name="PopupFormBuilder"> Builder for any related popup forms for this element </param>
        /// <param name="Current_User"> Current user, who's rights may impact the way an element is rendered </param>
        /// <param name="CurrentLanguage"> Current user-interface language </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Base_URL"> Base URL for the current request </param>
        /// <remarks> This simple element does not append any popup form to the popup_form_builder</remarks>
        public override void Render_Template_HTML(TextWriter Output, SobekCM_Item Bib, string Skin_Code, bool IsMozilla, StringBuilder PopupFormBuilder, User_Object Current_User, Web_Language_Enum CurrentLanguage, Language_Support_Info Translator, string Base_URL)
        {
            // Check that an acronym exists
            if (Acronym.Length == 0)
            {
                Acronym = "Enter the name(s) of the other committee members for this thesis/dissertation";
            }

            // Is there an ETD object?
            Thesis_Dissertation_Info etdInfo = Bib.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
            if ((etdInfo == null) || ( etdInfo.Committee_Members_Count == 0 ))
            {
                render_helper(Output, String.Empty, Skin_Code, Current_User, CurrentLanguage, Translator, Base_URL);
            }
            else
            {
                if (etdInfo.Committee_Members_Count == 1)
                {
                    render_helper(Output, etdInfo.Committee_Members[0], Skin_Code, Current_User, CurrentLanguage, Translator, Base_URL);
                }
                else
                {
                    render_helper(Output, etdInfo.Committee_Members, Skin_Code, Current_User, CurrentLanguage, Translator, Base_URL);
                }
            }
        }
        /// <summary> Renders the HTML for this element </summary>
        /// <param name="Output"> Textwriter to write the HTML for this element </param>
        /// <param name="Bib"> Object to populate this element from </param>
        /// <param name="Skin_Code"> Code for the current skin </param>
        /// <param name="IsMozilla"> Flag indicates if the current browse is Mozilla Firefox (different css choices for some elements)</param>
        /// <param name="PopupFormBuilder"> Builder for any related popup forms for this element </param>
        /// <param name="Current_User"> Current user, who's rights may impact the way an element is rendered </param>
        /// <param name="CurrentLanguage"> Current user-interface language </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Base_URL"> Base URL for the current request </param>
        /// <remarks> This simple element does not append any popup form to the popup_form_builder</remarks>
        public override void Render_Template_HTML(TextWriter Output, SobekCM_Item Bib, string Skin_Code, bool IsMozilla, StringBuilder PopupFormBuilder, User_Object Current_User, Web_Language_Enum CurrentLanguage, Language_Support_Info Translator, string Base_URL )
        {
            // Check that an acronym exists
            if (Acronym.Length == 0)
            {
                const string defaultAcronym = "Enter the language(s) in which the original material was written or performed.";
                switch (CurrentLanguage)
                {
                    case Web_Language_Enum.English:
                        Acronym = defaultAcronym;
                        break;

                    case Web_Language_Enum.Spanish:
                        Acronym = defaultAcronym;
                        break;

                    case Web_Language_Enum.French:
                        Acronym = defaultAcronym;
                        break;

                    default:
                        Acronym = defaultAcronym;
                        break;
                }
            }

            List<string> languages = new List<string>();
            if (Bib.Bib_Info.Languages_Count > 0)
            {
                languages.AddRange(from thisLanguage in Bib.Bib_Info.Languages where thisLanguage.Language_Text.Length > 0 select thisLanguage.Language_Text);
            }
            render_helper(Output, new ReadOnlyCollection<string>(languages), Skin_Code, Current_User, CurrentLanguage, Translator, Base_URL);
        }
Beispiel #29
0
        private void SetMemberValue(string member, ICell cell, TextWriter log)
        {
            var info = GetType().GetProperty(member);
            if (info == null)
            {
                log.WriteLine("Property {0} is not defined in {1}", member, GetType().Name);
                return;
            }

            if(info.PropertyType != typeof(string))
                throw new NotImplementedException("This function was only designed to work for string properties.");

            string value = null;
            switch (cell.CellType)
            {
                case CellType.Numeric:
                    value = cell.NumericCellValue.ToString(CultureInfo.InvariantCulture);
                    break;
                case CellType.String:
                    value = cell.StringCellValue;
                    break;
                case CellType.Boolean:
                    value = cell.BooleanCellValue.ToString();
                    break;
                default:
                    log.WriteLine("There is no suitable value for {0} in cell {1}{2}, sheet {3}",
                        info.Name, CellReference.ConvertNumToColString(cell.ColumnIndex), cell.RowIndex + 1,
                        cell.Sheet.SheetName);
                    break;
            }
            info.SetValue(this, value);
        }
    public void WriteTo(TextWriter writer )
    {
      Console.WriteLine(string.Format("Processing {0}", _script));
      Func<string, string> Clean = CleanBadCharCodes;
      Action<TextWriter> WriteStart = StartWriteJs;
      Action<TextWriter> WriteEnd = EndWriteJs;


      if (_isCss)
      {
        Clean = CleanCss;
        WriteStart = StartWriteCss;
        WriteEnd = EndWriteCss;
      }

      WriteStart(writer);
      using (var reader = new StreamReader(_script))
      {
        while (!reader.EndOfStream)
        {
          var line = reader.ReadLine() + "\n";
          line = Clean(line);
          writer.Write(line);
        }
      }
      WriteEnd(writer);
    }
Beispiel #31
0
/*************************************************************************************************************************/
        public void flush_recover_file()
        {
            int anz_lines;

            Log.PushStackInfo("fMRS_Util.flush_recover_file", "enter flush_recover_file()");
            Log.dbg("flush recover file");

            string[] lines = IO.File.ReadAllLines(FILES.RECOVER_TXT);
            anz_lines = lines.Length;

            IO.TextWriter file = IO.File.CreateText(FILES.RECOVER_TXT);
            while (anz_lines != 0)
            {
                file.WriteLine("");
                anz_lines--;
            }
            file.Close();

            Log.PopStackInfo("leave flush_recover_file()");
        }
Beispiel #32
0
        /// <summary>
        /// 案卷信息 a#sgwj_file.xml
        /// </summary>
        /// <param name="projectFactory"></param>
        private void GetListArchiveXML(ERM.CBLL.CreateSip projectFactory)
        {
            DataSet dsFinalArchive = projectFactory.GetListArchive(Globals.ProjectNO, "");

            dsFinalArchive.DataSetName         = "案卷信息";
            dsFinalArchive.Tables[0].TableName = "记录";
            string _filename = Application.StartupPath + "\\temp\\a#sgwj_file.xml";

            _filename = Application.StartupPath + "\\temp\\index.dat";
            System.IO.TextWriter w1 = System.IO.File.CreateText(_filename);
            if (dsFinalArchive != null && dsFinalArchive.Tables.Count > 0 && dsFinalArchive.Tables[0].Rows.Count > 0)
            {
                for (int i1 = 0; i1 < dsFinalArchive.Tables[0].Rows.Count; i1++)
                {
                    w1.WriteLine("<FileList><File>" + dsFinalArchive.Tables[0].Rows[i1][0].ToString() + ".sip</File>");
                    w1.WriteLine("<Title>" + dsFinalArchive.Tables[0].Rows[i1]["案卷题名"].ToString() + "</Title></FileList>");
                }
            }
            w1.Close();
        }
        /// <summary>
        /// Writes documentation string using a given TextWriter object.
        /// Uses HelpString properties of Option and ProgramSettings objects.
        /// </summary>
        /// <param name="writer">System.IO.TextWriter object used to write documentation.</param>
        /// <exception cref="System.ArgumentException">Thrown if writer is null.</exception>
        public void PrintHelp(System.IO.TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentException(Properties.Resources.ProgramSettings_PrintHelp_WriterNull);
            }
            printHelpHeader(writer);
            writer.WriteLine();

            printGNUOptions(writer);
            writer.WriteLine();

            printGNUStandardOptions(writer);
            writer.WriteLine();

            printPlainArguments(writer);
            writer.WriteLine();

            writer.Flush();
        }
Beispiel #34
0
        public BuildStatus(Core core, bool LogWarnings, bool logErrors, bool displayBuildResult, System.IO.TextWriter writer = null)
        {
            this.core               = core;
            this.LogWarnings        = LogWarnings;
            this.logErrors          = logErrors;
            this.displayBuildResult = displayBuildResult;

            warnings = new List <BuildData.WarningEntry>();
            errors   = new List <BuildData.ErrorEntry>();

            if (writer != null)
            {
                consoleOut = System.Console.Out;
                System.Console.SetOut(writer);
            }

            // Create a default console output stream, and this can
            // be overwritten in IDE by assigning it a different value.
            this.MessageHandler = new ConsoleOutputStream();
        }
Beispiel #35
0
        public override void SyntaxError(System.IO.TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        {
            StringBuilder builder = new StringBuilder();

            // the human readable message
            object[] format = new object[] { line, charPositionInLine + 1 };
            builder.AppendFormat("Error on line {0} at position {1}:\n", format);
            // the actual error message
            builder.AppendLine(msg);

            // the line with the error on it
            string input = offendingSymbol.TokenSource.InputStream.ToString();

            string[] lines     = input.Split('\n');
            string   errorLine = lines[line - 1];

            builder.AppendLine(errorLine);

            // adding indicator symbols pointing out where the error is on the line
            int start = offendingSymbol.StartIndex;
            int stop  = offendingSymbol.StopIndex;

            if (start >= 0 && stop >= 0)
            {
                // the end point of the error in "line space"
                int end = (stop - start) + charPositionInLine + 1;
                for (int i = 0; i < end; i++)
                {
                    // move over until we are at the point we need to be
                    if (i >= charPositionInLine && i < end)
                    {
                        builder.Append("^");
                    }
                    else
                    {
                        builder.Append(" ");
                    }
                }
            }
            throw new Yarn.ParseException(builder.ToString());
        }
Beispiel #36
0
        protected override void AddReturn(System.IO.TextWriter writer)
        {
            var returnType = this._methodInfo.ReturnType;

            if (returnType == null || returnType.FullName == "System.Void")
            {
                return;
            }


            writer.WriteLine("<div class=\"sectionbody\">");
            writer.WriteLine("<div class=\"returnType\">");
            writer.WriteLine("<strong class=\"subHeading\">Return Value</strong><br />");
            writer.WriteLine("</div>");

            string url, target;

            returnType.GetHelpURL(this._version, out url, out target);

            if (url == null)
            {
                writer.WriteLine("<div class=\"returnTypeName\">Type: {0}</div>", returnType.GetDisplayName(false));
            }
            else
            {
                writer.WriteLine("<div class=\"returnTypeName\">Type: <a href=\"{0}\" {2}>{1}</a></div>", url, returnType.GetDisplayName(false), target);
            }

            var ndoc = GetSummaryDocumentation();

            if (ndoc != null)
            {
                var returnDoc = NDocUtilities.FindReturnDocumentation(ndoc);
                if (returnDoc != null)
                {
                    writer.WriteLine("<div class=\"returnTypeDoc\">{0}</div>", returnDoc);
                }
            }

            writer.WriteLine("</div>");
        }
Beispiel #37
0
        /// <summary>
        /// 添加系统日志()
        /// </summary>
        /// <param name="sMessage">日志内容</param>
        /// <returns>无</returns>
        public static string WriteLog(string sMessage)
        {
            try
            {
                m_Mutex.WaitOne();
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
            try
            {
                string sPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\SysErr\\";
                if (!System.IO.Directory.Exists(sPath))
                {
                    System.IO.Directory.CreateDirectory(sPath);
                }

                if (sPath.Substring(sPath.Length - 1, 1) != "\\")
                {
                    sPath += "\\";
                }
                string sFileName            = sPath + "Srv" + System.DateTime.Today.ToString("yyyyMMdd") + ".log";
                string sTime                = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
                System.IO.TextWriter oWrite = System.IO.File.AppendText(sFileName);
                oWrite.WriteLine(sTime + ": " + sMessage);
                oWrite.Close();
                return("ok");
            }
            catch (Exception e)
            {
                EventLog myLog = new EventLog();
                myLog.Source = " VbsServer";
                myLog.WriteEntry("Err:" + sMessage + "\t" + e.ToString());
                return(e.ToString());
            }
            finally
            {
                m_Mutex.ReleaseMutex();
            }
        }
Beispiel #38
0
        public void ImprimirArchivoEncabezados(string path, System.IO.TextWriter outputstream)
        {
            using (var reader = new System.IO.StreamReader(path))
            {
                var fieldsandnames = GetFields(typeof(EncabezadoIngresoTabaco));

                fieldsandnames = fieldsandnames.OrderBy(x => x.Field.Position).ToList();

                outputstream.WriteLine(String.Format("File properties:"));
                outputstream.WriteLine(String.Format("- Name: {0}", System.IO.Path.GetFileName(path)));
                outputstream.WriteLine(String.Format("- FullName: {0}", System.IO.Path.GetFullPath(path)));
                outputstream.WriteLine(String.Format("- Encoding: {0}", reader.CurrentEncoding));
                outputstream.WriteLine();
                outputstream.WriteLine();
                outputstream.WriteLine(String.Format("Posicion - Tipo - Longitud - Nombre - Valor"));

                var linecounter = 1;

                while (!reader.EndOfStream)
                {
                    var line           = reader.ReadLine();
                    var carretposition = 0;

                    outputstream.WriteLine("Line: " + linecounter);

                    foreach (var item in fieldsandnames)
                    {
                        var name  = item.Name;
                        var field = item.Field;
                        var value = line.Substring(carretposition, field.Size);
                        carretposition += field.Size;

                        var format = String.Format("{0,2} - {1,3} - {2,2} - {3,50} - {4}", field.Position, field.Type.Name.Substring(0, 3), field.Size, name, value);
                        outputstream.WriteLine(format);
                    }

                    linecounter++;
                    outputstream.WriteLine();
                }
            }
        }
Beispiel #39
0
        public override void WriteTo(System.IO.TextWriter output, bool suppressMetadataKeyword = false)
        {
            if (this.NullIfEmpty && this.IsEmpty)
            {
                return;
            }

            if (Index.HasValue)
            {
                if (!suppressMetadataKeyword)
                {
                    output.Write("metadata ");
                }

                output.Write("!");
                output.Write(Index.Value);
                return;
            }

            this.WriteValueTo(output, suppressMetadataKeyword);
        }
Beispiel #40
0
        public void Initialize(string user, string host, int port, string password, string identity, string passphrase, string root, bool debug)
        {
            user_       = user;
            host_       = host;
            port_       = port;
            identity_   = identity;
            password_   = password;
            passphrase_ = passphrase;

            root_ = root;

            debug_ = debug;

            if (debug_ && tw_ != null)
            {
                System.IO.StreamWriter sw = new System.IO.StreamWriter(Application.UserAppDataPath + "\\error.txt");
                sw.AutoFlush = true;
                tw_          = System.IO.TextWriter.Synchronized(sw);
                Console.SetError(tw_);
            }
        }
Beispiel #41
0
        private void WriteString(System.IO.TextWriter writer, object value)
        {
            string?svalue = value.ToString();

            if (svalue != null)
            {
                //var escaped_value = svalue;
                // Escape '\' first
                string?escaped_value = svalue.Replace("\\", "\\u005c");
                // Escape '"'
                escaped_value = escaped_value.Replace("\"", "\\u0022");
                if (writingPrimitiveValue)
                {
                    writer.Write($"\"{escaped_value}\"");
                }
                else
                {
                    writer.Write($"{GetIndent()}\"{escaped_value}\"");
                }
            }
        }
Beispiel #42
0
            public myFile(Byte[] name, FileMode mode, FileAccess access, bool BinaryMode)
            {
                string Filename = to_string(name);

                this.stream = null;
                try {
                    this.stream = new FileStream(Filename, mode, access);
                    if ((access == FileAccess.Read) || (access == FileAccess.ReadWrite))
                    {
                        this.reader = new StreamReader(this.stream);
                    }
                    if ((access == FileAccess.Write) || (access == FileAccess.ReadWrite))
                    {
                        this.writer = new StreamWriter(this.stream);
                    }
                    files.Add(this);
                    this.fd = files.IndexOf(this) + 3;
                } catch {
                    this.fd = -1;
                }
            }
        public void Start()
        {
            string logFileName = AssemblyFolder + "/PluginData/" + AssemblyName + ".log";

            if (File.Exists(logFileName))
            {
                DateTime dateTime         = File.GetCreationTime(logFileName);
                string   dateTimeFileName = AssemblyFolder + "/PluginData/" + AssemblyName + dateTime.ToString("MMddyyyyHHmmssfff") + ".log";
                if (File.Exists(dateTimeFileName))
                {
                    File.Delete(dateTimeFileName);
                }
                File.Copy(logFileName, dateTimeFileName);
                File.Delete(logFileName);
            }
            Tw = new StreamWriter(logFileName);
            Tw.WriteLine(AssemblyName + Assembly.GetExecutingAssembly().GetName().Version);
            Tw.WriteLine("Loaded up on " + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + ".");
            Tw.WriteLine();
            GameEvents.onGameSceneLoadRequested.Add(logSceneSwitch);
        }
Beispiel #44
0
        public void Write(System.IO.TextWriter writer, string rootNodeID)
        {
            System.Diagnostics.Debug.Assert(Manager != null && Tree != null, "'Tree' is not supposed to be null");
            System.Diagnostics.Debug.Assert(Writer == null, "'Writer' property should have been reset at the end of the method");

            try
            {
                Writer = writer;

                Writer.Write("<div id='" + rootNodeID + "' class='" + CssRoot + "'>");
                foreach (var element in Tree.Children)
                {
                    Explore(element, MaxDepth);
                }
                Writer.Write("</div>");
            }
            finally
            {
                Writer = null;
            }
        }
Beispiel #45
0
        private static async Task GenerujTrescFormularza(IHtmlHelper helper, string actionName,
                                                         string controllerName, System.IO.TextWriter writer,
                                                         object model,
                                                         string akcjaAnuluj = null)
        {
            using (helper.BeginForm(actionName, controllerName, FormMethod.Post,
                                    new { enctype = "multipart/form-data" }))
            {
                helper.AntiForgeryToken();
                await writer.WriteLineAsync("<div class=\"form-horizontal\">");

                await writer.WriteLineAsync("<hr/>");

                writer.WriteLine(helper.ValidationSummary(true, "", new { @class = "text-danger" }));

                helper.DopiszEdytoryDlaPropertiesow(model, writer);
                helper.GenerujPrzyciskiFormularza(akcjaAnuluj).WriteTo(writer, HtmlEncoder.Default);

                await writer.WriteAsync("</div>");
            }
        }
Beispiel #46
0
        private bool createLog()
        {
            //using (lock_log.AcquireExclusiveUsing())
            //{
            try { deleteIfExists("ewar.log"); } catch { }
            try { deleteIfExists("log.txt"); } catch { }
            for (int i = 0; i < 10; i++)
            {
                if (logWriter == null)
                {
                    try { logWriter = MyAPIGateway.Utilities.WriteFileInLocalStorage("log-" + i + ".txt", typeof(Logger)); } catch { }
                }
                else
                {
                    try { deleteIfExists("log-" + i + ".txt"); } catch { }
                }
            }

            return(logWriter != null);
            //}
        }
        public static void LogComPortData(string comName, byte[] bytes)
        {
            if (LoggingConfiguration.LoggingEnabled &&
                LoggingConfiguration.HeavyTraceLevelEnabled)
            {
                if (!LoggingConfiguration.LoggingEnabled)
                {
                    return;
                }

                System.IO.TextWriter logWriter = null;

                try
                {
                    if (!Directory.Exists(logFileFolder))
                    {
                        Directory.CreateDirectory(logFileFolder);
                    }

                    string currentDayStamp = DateTime.Now.ToString(LogDateFormat);
                    string logFilePath     =
                        System.IO.Path.Combine(logFileFolder, comName + "_" + currentDayStamp + ".log");

                    logWriter = System.IO.File.AppendText(logFilePath);

                    logWriter.Write(Encoding.ASCII.GetString(bytes));
                }
                catch
                {
                }
                finally
                {
                    if (logWriter != null)
                    {
                        // Ensure file is not kept open.
                        logWriter.Close();
                    }
                }
            }
        }
Beispiel #48
0
        /// <seealso cref="NVelocity.Runtime.Paser.Node.SimpleNode.render(org.apache.velocity.context.InternalContextAdapter, java.io.Writer)">
        /// </seealso>
        public override bool Render(IInternalContextAdapter context, System.IO.TextWriter writer)
        {
            /*
             * Check if the #if(expression) construct evaluates to true:
             * if so render and leave immediately because there
             * is nothing left to do!
             */
            if (GetChild(0).Evaluate(context))
            {
                GetChild(1).Render(context, writer);
                return(true);
            }

            int totalNodes = GetNumChildren();

            /*
             * Now check the remaining nodes left in the
             * if construct. The nodes are either elseif
             *  nodes or else nodes. Each of these node
             * types knows how to Evaluate themselves. If
             * a node evaluates to true then the node will
             * render itself and this method will return
             * as there is nothing left to do.
             */
            for (int i = 2; i < totalNodes; i++)
            {
                if (GetChild(i).Evaluate(context))
                {
                    GetChild(i).Render(context, writer);
                    return(true);
                }
            }

            /*
             * This is reached when an ASTIfStatement
             * consists of an if/elseif sequence where
             * none of the nodes Evaluate to true.
             */
            return(true);
        }
Beispiel #49
0
/*************************************************************************************************************************/
        public void write_save_values_to_file()
        {
            Log.PushStackInfo("FMRS_Util.write_save_values_to_file", "entering write_save_values_to_file()");

            set_save_value(save_cat.SETTING, "Window_X", Convert.ToInt32(windowPos.x).ToString());
            set_save_value(save_cat.SETTING, "Window_Y", Convert.ToInt32(windowPos.y).ToString());
            set_save_value(save_cat.SETTING, "Armed", _SETTING_Armed.ToString());
            set_save_value(save_cat.SETTING, "Minimized", _SETTING_Minimize.ToString());
            set_save_value(save_cat.SETTING, "Enabled", _SETTING_Enabled.ToString());
            //set_save_value(save_cat.SETTING, "Messages", _SETTING_Messages.ToString());
            //set_save_value(save_cat.SETTING, "Auto_Cut_Off", _SETTING_Auto_Cut_Off.ToString());
            //set_save_value(save_cat.SETTING, "Auto_Recover", _SETTING_Auto_Recover.ToString());
            //set_save_value(save_cat.SETTING, "Throttle_Log", _SETTING_Throttle_Log.ToString());
            set_save_value(save_cat.SAVE, "Main_Vessel", _SAVE_Main_Vessel.ToString());
            set_save_value(save_cat.SAVE, "Has_Launched", _SAVE_Has_Launched.ToString());
            set_save_value(save_cat.SAVE, "Launched_At", _SAVE_Launched_At.ToString());
            set_save_value(save_cat.SAVE, "Flight_Reset", _SAVE_Flight_Reset.ToString());
            set_save_value(save_cat.SAVE, "Kick_To_Main", _SAVE_Kick_To_Main.ToString());
            set_save_value(save_cat.SAVE, "Switched_To_Dropped", _SAVE_Switched_To_Dropped.ToString());
            set_save_value(save_cat.SAVE, "Switched_To_Savefile", _SAVE_Switched_To_Savefile);
            set_save_value(save_cat.SAVE, "SaveFolder", _SAVE_SaveFolder);

            write_vessel_dict_to_Save_File_Content();

            IO.TextWriter file = IO.File.CreateText(FILES.SAVE_TXT);
            file.Flush();
            file.Close();
            file = IO.File.CreateText(FILES.SAVE_TXT);
            foreach (KeyValuePair <save_cat, Dictionary <string, string> > save_cat_block in Save_File_Content)
            {
                foreach (KeyValuePair <string, string> writevalue in save_cat_block.Value)
                {
                    file.WriteLine(save_cat_toString(save_cat_block.Key) + "=" + writevalue.Key + "=" + writevalue.Value);
                }
            }
            file.Close();

            Log.dbg("Save File written in private void write_save_values_to_file()");
            Log.PopStackInfo("leaving save_values_to_file()");
        }
Beispiel #50
0
        public void G_User_Tomb(Controler_Cadastrar Dado)
        {
            string Texto_Formato = "<html><title>Banco TXT</title><body background ='red'><table border='1'><tr><td colspan = '7'><center>Cadastro de Custódia</center></td>" +
                                   "</tr><tr><td>id_user</td><td>nome_cliente</td><td>lotacao</td><td>ramal</td><td>coordenador</td><td>email</td><td>id_tomb</td></tr>";
            string formatando_texto = null;

            formatando_texto += "<tr><td>" + "\n" + Controler_Cadastrar.ID_user + "\n" + "</td><td>" + "\n" + Dado.Nom_cliente + "\n" + "</td><td>" + "\n" + Dado.Lotacao + "\n" + "</td><td>" + "\n" + Dado.Ramal + "\n" +
                                "</td><td>" + "\n" + Dado.Coordenador + "\n" + "</td><td>" + "\n" + Dado.Email + "\n" + "</td><td>" + "\n" + Controler_Cadastrar.ID_tomb + "\n" + "</td></tr></table></body></html>";
            Registrar.Status_Label = "Armazenando TXT Localmente¹...";
            Texto_Formato         += formatando_texto;
            if (!System.IO.File.Exists(Path))
            {
                System.IO.File.Create(Path).Close();
            }
            else
            {
                System.IO.File.Delete(Path);
            }
            System.IO.TextWriter arquivo = System.IO.File.AppendText(Path);
            arquivo.WriteLine(Texto_Formato);
            arquivo.Close();
        }
Beispiel #51
0
 private void WriteValueType(System.IO.TextWriter writer, object value)
 {
     if (value is bool bvalue)
     {
         if (writingPrimitiveValue)
         {
             writer.Write(bvalue.ToString().ToLower());
             //#pragma warning disable CS8602 // Dereference of a possibly null reference.
             //                    writer.Write(value.ToString().ToLower());
             //#pragma warning restore CS8602 // Dereference of a possibly null reference.
         }
         else
         {
             writer.Write($"{GetIndent()}{bvalue.ToString().ToLower()}");
             //#pragma warning disable CS8602 // Dereference of a possibly null reference.
             //                    writer.Write($"{GetIndent()}{value.ToString().ToLower()}");
             //#pragma warning restore CS8602 // Dereference of a possibly null reference.
         }
     }
     else
     {
         if (writingPrimitiveValue)
         {
             writer.Write(value.ToString());
         }
         else
         {
             if ((value is float) || (value is double) || (value is int) || (value is long) ||
                 (value is string))
             {
                 writer.Write(value.ToString());
             }
             else
             {
                 writer.Write($"{GetIndent()}{value}");
             }
         }
     }
 }
Beispiel #52
0
        public static void Write()
        {
            FileMaster master = new FileMaster("Profiler master.txt", "Profiler - ", 10);

            System.IO.TextWriter writer = master.GetTextWriter(DateTime.UtcNow.Ticks + ".csv");
            writer.WriteLine("Class Name, Method Name, Seconds, Invokes, Seconds per Invoke, Worst Time, Ratio of Sum, Ratio of Game Time");

            using (ProfileValues.m_lock.AcquireExclusiveUsing())
            {
                WriteBlock(writer, "Game Time,", new Stats()
                {
                    TimeSpent = MyTimeSpan.FromSeconds(Globals.ElapsedTime.TotalSeconds)
                });
                WriteBlock(writer, "Sum,", ProfileValues.m_total);
                foreach (var pair in ProfileValues.m_profile)
                {
                    WriteBlock(writer, pair.Key, pair.Value);
                }
            }

            writer.Close();
        }
Beispiel #53
0
        static void PrintComponents(GameObject gameObject, System.IO.TextWriter textWriter, int indentation = 1)
        {
            _MonoBehaviours.Clear();
            gameObject.GetComponents <MonoBehaviour>(_MonoBehaviours);

            textWriter.WriteIndented(gameObject.name, indentation);
            textWriter.Write(":\n");

            indentation++;
            foreach (MonoBehaviour monoBehaviour in _MonoBehaviours)
            {
                PrintComponentFactory.PrintComponent(monoBehaviour, textWriter, indentation);
            }

            Transform transform = gameObject.transform;
            int       children  = transform.childCount;

            for (int i = 0; i < children; i++)
            {
                PrintComponents(transform.GetChild(i).gameObject, textWriter, indentation);
            }
        }
Beispiel #54
0
        private void LogToExceptionFile(List <LogInfo> exceptions)
        {
            StringBuilder sb = new StringBuilder();

            foreach (LogInfo logInfo in exceptions)
            {
                sb.AppendFormat("{0}\t{1}\t{2}\t\r\n{3}\r\n", logInfo.LogTime, logInfo.ThreadId, ((Exception)logInfo.Message).Message, ((Exception)logInfo.Message).StackTrace);
            }
            if (_exceptionWriter == null)
            {
                string file =
                    FilePathUtil.GetMapPath("/log/" + DateTime.Now.ToString("yyyyMMdd") + "ex." +
                                            LogFileExtendName);
                FileInfo fileInfo = new FileInfo(file);
                if (!fileInfo.Directory.Exists)
                {
                    fileInfo.Directory.Create();
                }
                _exceptionWriter = new System.IO.StreamWriter(file, true, Encoding.UTF8);
            }
            _exceptionWriter.Write(sb.ToString());
        }
Beispiel #55
0
 public static void dump_DOT(System.IO.TextWriter str,
                             Dictionary <EntityLink, double> graph)
 {
     // This function has some ugliness, but IO/format
     // conversions often do.
     str.WriteLine("digraph SimpleGraph {");
     foreach (KeyValuePair <EntityLink, double> g in graph)
     {
         string lname;
         string rname;
         if (((EntityLink)g.Key).leftmost.Type ==
             SourceCodeEntityType.COMMENT)
         {
             lname = "commentL" +
                     g.Key.leftmost.LineStart.ToString() +
                     "C" + g.Key.leftmost.ColumnStart.ToString() +
                     " (" + g.Key.leftmost.parent_file.FileName + ")";
         }
         else
         {
             lname = g.Key.leftmost.Name + " (" + g.Key.leftmost.parent_file.FileName + ")";
         }
         if (g.Key.rightmost.Type ==
             SourceCodeEntityType.COMMENT)
         {
             rname = "commentL" +
                     g.Key.rightmost.LineStart.ToString() +
                     "C" + g.Key.rightmost.ColumnStart.ToString();
         }
         else
         {
             rname = g.Key.rightmost.Name + " (" + g.Key.rightmost.parent_file.FileName + ")";
         }
         str.WriteLine("\"" + lname.Replace("\"", "\'\'") + "\" -> \"" +
                       rname.Replace("\"", "\'\'") + "\" [weight=" +
                       g.Value.ToString("F16") + " penwidth=" + g.Value.ToString("F16") + "];");
     }
     str.WriteLine("}");
 }
Beispiel #56
0
 private void Write(System.IO.TextWriter writer, object value)
 {
     if (value is null)
     {
         WriteNull(writer);
     }
     else if (value is byte[] x)
     {
         WriteBytes(writer, x);
     }
     else if (value is string)
     {
         WriteString(writer, value);
     }
     else if (value is IDictionary)
     {
         WriteIDictionary(writer, value);
     }
     else if (value is double[, ])
     {
         WriteDoubleArray2D(writer, value);
     }
     else if (value is IEnumerable)
     {
         WriteIEnumerable(writer, value);
     }
     else if (value is DateTime dateTime)
     {
         WriteString(writer, dateTime.ToString("o"));
     }
     else if (value is ISerializable serializable)
     {
         WriteISerializable(writer, serializable);
     }
     else
     {
         WriteValueType(writer, value);
     }
 }
Beispiel #57
0
        //  logs all errors and warnings by default
        //
        public BuildStatus(Core core, bool warningAsError, System.IO.TextWriter writer = null, bool errorAsWarning = false)
        {
            this.core           = core;
            warnings            = new List <BuildData.WarningEntry>();
            errors              = new List <BuildData.ErrorEntry>();
            this.warningAsError = warningAsError;
            this.errorAsWarning = errorAsWarning;

            if (writer != null)
            {
                consoleOut = System.Console.Out;
                System.Console.SetOut(writer);
            }

            // Create a default console output stream, and this can
            // be overwritten in IDE by assigning it a different value.
            this.MessageHandler = new ConsoleOutputStream();
            if (core.Options.WebRunner)
            {
                this.WebMsgHandler = new WebOutputStream(core);
            }
        }
Beispiel #58
0
        private void BuildFileNameMaps(System.IO.TextWriter verboseOutput)
        {
            for (int x = FileChunksFirstIndex; x < mFiles.Count;)
            {
                var file = mFiles[x];

                EraFileEntryChunk existingFile;
                if (mFileNameToChunk.TryGetValue(file.FileName, out existingFile))
                {
                    if (verboseOutput != null)
                    {
                        verboseOutput.WriteLine("Removing duplicate {0} entry at #{1}",
                                                file.FileName, FileIndexToListingIndex(x));
                    }
                    mFiles.RemoveAt(x);
                    continue;
                }

                mFileNameToChunk.Add(file.FileName, file);
                x++;
            }
        }
        public void FormatDocument(string mimeType, System.IO.TextWriter writer, IDocumentElement rootElement, bool fragment)
        {
            if (string.Equals(mimeType, "text/html", StringComparison.OrdinalIgnoreCase))
            {
                FormatHtml(writer, rootElement, fragment);
            }

            else if (string.Equals(mimeType, "text/x-markdown", StringComparison.OrdinalIgnoreCase))
            {
                FormatMarkdown(writer, rootElement, fragment);
            }

            else if (string.Equals(mimeType, "text/plain", StringComparison.OrdinalIgnoreCase))
            {
                FormatPlainText(writer, rootElement, fragment);
            }

            else
            {
                throw new NotImplementedException();
            }
        }
Beispiel #60
0
        public static void rteval(string str, System.IO.TextWriter ot)
        {
            TextWriter tw0 = con;

            con = ot;
            try
            {
                ot.WriteLine("<<< " + str);

                Object o      = str;
                Object result =
                    apply(_ss("p-read-compile-eval"),
                          new Object[] { o });
                Object resx = apply(_to_string, new Object[] { result });
                ot.WriteLine(">>> " + resx);
            }
            catch (Exception e)
            {
                ot.WriteLine(e.ToString());
            }
            con = tw0;
        }