Ejemplo n.º 1
0
        public void CreateCmakeList(string fullyQualifiedPath, string unqualifiedName, Dictionary<string,BuildElement> buildsys, Graph<string> buildgraph)
        {
            /*NOTE: This is a totally hacked solution to try and have a demo for the presentation. It will get much cleaner over time.  */
            string fullyQualifiedFileName = fullyQualifiedPath + "\\" + unqualifiedName;
            TextWriter txtwriter = new TextWriter();
            System.IO.StreamWriter file = new System.IO.StreamWriter(fullyQualifiedFileName);
            BuildElement elem;
            string objects = "";
            string projectname = "";
            //brute forced just for the demo

            //this is not quite as brute forced, but pretty close
            foreach(KeyValuePair<string,BuildElement> keyval in buildsys)
            {
                elem = keyval.Value;
                CustomAction action = CustomActionsBare.determineAction(elem);
                if(action == CustomAction.ConvertToProject)
                {
                    projectname = elem.name;
                    for (int i = 0; i < elem.dependencies.Count; i++)
                    {
                        objects += elem.dependencies[i].Replace(".o", ".cpp") + " ";
                    }
                }

                //System.Console.WriteLine("TEST: "+elem.Key);
               // System.Console.WriteLine(ProjectGenerator.InstructionParsing.CustomActionsBare.determineAction(elem.Value));

            }
            file.WriteLine("cmake_minimum_required (VERSION 2.6)");
            file.WriteLine("project (" + projectname + ")");
            file.WriteLine("");
            file.WriteLine("add_executable("+projectname + " " + objects+")");
            file.Close();
        }
Ejemplo n.º 2
0
 public static void Write(object element, int depth, TextWriter log)
 {
     ObjectDumper dumper = new ObjectDumper(depth);
     dumper.writer = log;
     dumper.WriteObject(null, element);
     log.WriteLine(new string('-', 20));
 }
Ejemplo n.º 3
0
	public Writer(TextWriter writer, Grammar grammar)
	{
		m_writer = writer;
		m_grammar = grammar;
		
		foreach (Rule rule in m_grammar.Rules)
		{
			List<Rule> temp;
			if (!m_rules.TryGetValue(rule.Name, out temp))
			{
				temp = new List<Rule>();
				m_rules.Add(rule.Name, temp);
			}
			temp.Add(rule);
		}
		
		foreach (string e in m_grammar.Settings["exclude-methods"].Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries))
		{
			m_engine.AddExcluded(e);
		}
		
		foreach (var entry in m_grammar.Settings)
		{
			if ("true".Equals(entry.Value))
				m_engine.AddVariable(entry.Key, true);
			else if ("false".Equals(entry.Value))
				m_engine.AddVariable(entry.Key, false);
			else
				m_engine.AddVariable(entry.Key, entry.Value);
		}
		m_engine.AddVariable("debugging", m_grammar.Settings["debug"] != "none");
		
		DoSetUsed();
	}
        public static void Main()
        {
            //string ConnetionString = "mongodb://localhost:27017";
            //string DbName = "artgallerydb";

            //var client = new MongoClient(ConnetionString);
            //MongoServer server = client.GetServer();
            //var mongoDb = server.GetDatabase(DbName);

            // var result = mongoDb.GetCollection<Artist>("artists").AsQueryable<Artist>();
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<ArtGalleryDbContext, Configuration>());

            var data = new ArtGalleryDbContext();
            var dataImporter = new MongoDb();
            var consoleWriter = new TextWriter(Console.Out);

            var msSqlDbDataImporter = new MsSqlDbDataImporter(dataImporter, data);
            msSqlDbDataImporter.Subscribe(consoleWriter);
            msSqlDbDataImporter.ImportData();

            //db.Artists.Add(new ArtistSql
            //{
            //    FirstName = "Pesho",
            //    MiddleName = "d",
            //    LastName = "Gosho"
            //});
        }
Ejemplo n.º 5
0
 private static void Log(Exception e, TextWriter w)
 {
     w.Write("\r\nLog Entry: ");
     w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString());
     w.WriteLine("{0} : {1}", e.Message , e.StackTrace);
     w.WriteLine("-------------------------------");
 }
Ejemplo n.º 6
0
        public static void QueueBackup([Queue("backupqueue")] ICollector<CopyItem> message, TextWriter log)
        {
            try
            {
                // The schedule for this Web Job is Monday-Thursday at 11:30pm UTC, defined in settings.job 


                // Using storage connection tokens rather than the connection strings themselves so they are not leaked onto the queue.
                // When DmlExec reads the queue it will look up the tokens from App Settings.
                // Format is: key = "MySourceAccount" value = "DefaultEndpointsProtocol=https;AccountName=[account name];AccountKey=[account key]"
                string sourceAccountToken = "MySourceAccount";
                string destinationAccountToken = "MyDestinationAccount";

                // Backup type of "full" or "incremental"
                // Blob is always copied if it does not exist in destination container
                // When Incremental = false, overwrite blob even if it exists in destination container
                // When Incremental = true only copy if source is newer than the destination
                bool isIncremental = true;

                // Pop messages on the queue to copy one or more containers between two storage accounts
                message.Add(CreateJob("Incremental images backup", sourceAccountToken, destinationAccountToken, "images", "", "imagesbackup", "", isIncremental, log));
                message.Add(CreateJob("Incremental docs backup", sourceAccountToken, destinationAccountToken, "docs", "", "docsbackup", "", isIncremental, log));
            }
            catch (Exception ex)
            {
                log.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 7
0
 private static void DoLog(String logMessage, TextWriter w)
 {
     w.Write("{0}", DateTime.Now.ToString("MM/dd/yy HH:mm"));
     w.Write(" {0}", logMessage);
     w.Write("\r\n");
     w.Flush();
 }
Ejemplo n.º 8
0
        public static void Host(TextWriter log, CancellationToken cancellationToken)
        {
            var defaultFactory = LogManager.Use<DefaultFactory>();
            defaultFactory.Level(LogLevel.Info);

            var configuration = new BusConfiguration();
            configuration.EndpointName("APIComparer.Backend");
            configuration.DisableFeature<SecondLevelRetries>();
            configuration.DisableFeature<Sagas>();
            configuration.DisableFeature<TimeoutManager>();


            configuration.UseTransport<AzureStorageQueueTransport>()
                .ConnectionString(AzureEnvironment.GetConnectionString);
            configuration.UsePersistence<AzureStoragePersistence>();
            configuration.EnableInstallers();

            using (Bus.Create(configuration).Start())
            {
                log.WriteLine("APIComparer.Backend - bus started");

                cancellationToken.WaitHandle.WaitOne();
            }

            log.WriteLine("APIComparer.Backend cancelled at " + DateTimeOffset.UtcNow);
        }
Ejemplo n.º 9
0
 public static void WriteToStream(TextWriter stream, DataTable table, bool header, bool quoteall, char separator)
 {
     if (header)
     {
         for (int i = 0; i < table.Columns.Count; i++)
         {
             WriteItem(stream, table.Columns[i].Caption, quoteall, separator);
             if (i < table.Columns.Count - 1)
                 stream.Write(separator);
             else
                 stream.Write('\n');
         }
     }
     foreach (DataRow row in table.Rows)
     {
         for (int i = 0; i < table.Columns.Count; i++)
         {
             WriteItem(stream, row[i], quoteall, separator);
             if (i < table.Columns.Count - 1)
                 stream.Write(separator);
             else
                 stream.Write('\n');
         }
     }
 }
Ejemplo n.º 10
0
    internal static void PrettyPrint(TextWriter output, object result)
    {
        if (result == null){
            p (output, "null");
            return;
        }

        if (result is Array){
            Array a = (Array) result;

            p (output, "{ ");
            int top = a.GetUpperBound (0);
            for (int i = a.GetLowerBound (0); i <= top; i++){
                PrettyPrint (output, a.GetValue (i));
                if (i != top)
                    p (output, ", ");
            }
            p (output, " }");
        } else if (result is bool){
            if ((bool) result)
                p (output, "true");
            else
                p (output, "false");
        } else if (result is string){
            p (output, "\"");
            EscapeString (output, (string)result);
            p (output, "\"");
        } else if (result is IDictionary){
            IDictionary dict = (IDictionary) result;
            int top = dict.Count, count = 0;

            p (output, "{");
            foreach (DictionaryEntry entry in dict){
                count++;
                p (output, "{ ");
                PrettyPrint (output, entry.Key);
                p (output, ", ");
                PrettyPrint (output, entry.Value);
                if (count != top)
                    p (output, " }, ");
                else
                    p (output, " }");
            }
            p (output, "}");
        } else if (WorksAsEnumerable (result)) {
            int i = 0;
            p (output, "{ ");
            foreach (object item in (IEnumerable) result) {
                if (i++ != 0)
                    p (output, ", ");

                PrettyPrint (output, item);
            }
            p (output, " }");
        } else if (result is char) {
            EscapeChar (output, (char) result);
        } else {
            p (output, result.ToString ());
        }
    }
Ejemplo n.º 11
0
    public static int run(string[] args, Ice.Communicator communicator, TextWriter @out)
    {
        //
        // When running as a MIDlet the properties for the server may be
        // overridden by configuration. If it isn't then we assume
        // defaults.
        //
        if(communicator.getProperties().getProperty("TestAdapter.Endpoints").Length == 0)
        {
            communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010");
        }
        if(communicator.getProperties().getProperty("ControllerAdapter.Endpoints").Length == 0)
        {
            communicator.getProperties().setProperty("ControllerAdapter.Endpoints", "tcp -p 12011");
            communicator.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1");
        }

        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
        Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("ControllerAdapter");

        BackgroundControllerI backgroundController = new BackgroundControllerI(adapter);

        adapter.add(new BackgroundI(backgroundController), communicator.stringToIdentity("background"));
        adapter.add(new LocatorI(backgroundController), communicator.stringToIdentity("locator"));
        adapter.add(new RouterI(backgroundController), communicator.stringToIdentity("router"));
        adapter.activate();

        adapter2.add(backgroundController, communicator.stringToIdentity("backgroundController"));
        adapter2.activate();

        communicator.waitForShutdown();
        return 0;
    }
Ejemplo n.º 12
0
	static void Footer (TextWriter tw)
	{
		tw.WriteLine (@"## Feedback

Please report any documentation errors, typos or suggestions to the 
[[Gendarme Google Group|http://groups.google.com/group/gendarme]]. Thanks!");
	}
		public XmlWriterTraceListener (TextWriter writer, string name)
			: base (writer, name)
			{
			XmlWriterSettings settings = new XmlWriterSettings ();
			settings.OmitXmlDeclaration = true;
			w = XmlWriter.Create (writer, settings);
			}
Ejemplo n.º 14
0
 public AcceptItem(string newText, TextWriter newWriter, Texture2D newTexture, Vector2 newPos)
 {
     text = newText;
     writer = newWriter;
     texture = newTexture;
     position = newPos;
     interactive_position = position - new Vector2(25, 17);
 }
Ejemplo n.º 15
0
 public void Print(TextWriter tw, string indent = "")
 {
     tw.WriteLine(indent + this.Name + "\\" + "    " + this.GetSize() + " B");
     foreach (var file in this.Files)
         tw.WriteLine(indent + "    " + file.Name + "    " + file.Size + " B");
     foreach (var folder in this.Folders)
         folder.Print(tw, indent + "    ");
 }
Ejemplo n.º 16
0
	static void Footer (TextWriter tw)
	{
		tw.WriteLine (@"= Feedback =

Please report any documentation errors, typos or suggestions to the 
[http://groups.google.com/group/gendarme Gendarme Google Group]. Thanks!
[[Category:Gendarme]]");
	}
Ejemplo n.º 17
0
 public void renderSendFormIfNecessary(TextWriter tw)
 {
     if (postPaymentRequestToRender != null)
     {
       postPaymentRequestToRender.RenderPaymentRequestForm(tw);
       postPaymentRequestToRender = null;
     }
 }
 public override void brain_restart()
 {
     output = Console.Out;
     Console.SetOut(TextWriter.Null);
     ai = new NewAiPlayer();
     ai.SetSize(width);
     Console.SetOut(output);
     Console.WriteLine("OK");
 }
Ejemplo n.º 19
0
        public ShortForm(Boss boss, TextWriter writer)
        {
            m_boss = boss;
            m_writer = writer;

            var editor = m_boss.Get<IDirectoryEditor>();
            m_addSpace = editor.AddSpace;
            m_addBraceLine = editor.AddBraceLine;
        }
Ejemplo n.º 20
0
 private void LogDictionary(TextWriter logger, IDictionary<string, object> dictionary)
 {
     foreach (KeyValuePair<string, object> pair in dictionary)
     {
         logger.WriteLine("{0} - T:{1}, V:{2}", pair.Key,
             (pair.Value == null ? "(null)" : pair.Value.GetType().FullName),
             (pair.Value == null ? "(null)" : pair.Value.ToString()));
     }
 }
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     _cacheKey = ComputeCacheKey(filterContext);
     var cachedOutput = (String) filterContext.HttpContext.Cache[_cacheKey];
     if (null != cachedOutput)
         filterContext.Result = new ContentResult { Content = cachedOutput };
     else
         _originalWriter = (TextWriter) _switchWriterMethod.Invoke(HttpContext.Current.Response, new object[] { new HtmlTextWriter(new StringWriter()) });
 }
Ejemplo n.º 22
0
 public CcsParser_t(string fname, TextWriter errwriter)
 {
     errpool = new CcsErrorPool_t(errwriter);
     scanner = new CcsScanner_t(errpool, fname);
     t = la = null;
     /*---- constructor ----*/
     maxT = 12;
     /*---- enable ----*/
 }
Ejemplo n.º 23
0
 public static void Log(string logMessage, TextWriter w)
 {
     w.Write("\r\nLog Entry : ");
     w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
         DateTime.Now.ToLongDateString());
     w.WriteLine("  :");
     w.WriteLine("  :{0}", logMessage);
     w.WriteLine("-------------------------------");
 }
Ejemplo n.º 24
0
    void Update()
    {
        textWriter = GameObject.FindGameObjectWithTag("InteractChat").GetComponent<TextWriter>();

        if (textWriter.diagStarted && textWriter.currentInteraction == "Laptop")
            laptopOpen.SetActive(true);
        else
            laptopOpen.SetActive(false);
    }
		public TextWriterTraceListener (Stream stream, string name)
			: base (name ?? "")
			{
			if (stream == null)
				throw new ArgumentNullException ("stream");
			if (stream.GetType () == typeof (Stream))
				writer = new StreamWriter (stream);
			else
				mwriter = new MStreamWriter (stream);
			}
Ejemplo n.º 26
0
 private void LogHeaders(TextWriter logger, IDictionary<string, string[]> headers)
 {
     foreach (KeyValuePair<string, string[]> header in headers)
     {
         foreach (string value in header.Value)
         {
             logger.WriteLine("{0}: {1}", header.Key, value ?? "(null)");
         }
     }
 }
Ejemplo n.º 27
0
 private static void WriteItem(TextWriter stream, object item, bool quoteall, char separator)
 {
     if (item == null)
         return;
     string s = item.ToString();
     if (quoteall || s.IndexOfAny(new char[] { '"', '\x0A', '\x0D', separator }) > -1)
         stream.Write("\"" + s.Replace("\"", "\"\"") + "\"");
     else
         stream.Write(s);
 }
Ejemplo n.º 28
0
 public void Render(ViewContext viewContext, TextWriter writer)
 {
     foreach (PartialView part in _parts)
     {
         viewContext.ViewData = part.Data;
         writer.WriteLine(string.Format("<div id=\"update-{0}\">", part.ForId));
         part.View.Render(viewContext, writer);
         writer.WriteLine(string.Format("</div>"));
     }
 }
 public void Error(String ErrorMessage, bool writeinFile)
 {
     if (writeinFile == true)/*Write in a file located at C:\Users\Public\Documents\VisualBlock*/{
         TextWriter errorInFile = new TextWriter();
         errorInFile.Write(ErrorMessage, @"C:\Users\Public\Documents\VisualBlock\Error.txt");
         errorInFile.Close();
     }
     else{
         MessageBox.Show(ErrorMessage, "Error");
     }
 }
Ejemplo n.º 30
0
	public static void Usage(TextWriter w)
	{
		w.WriteLine("Usage: WiFile.exe package.msi /l [filename,filename2,...]");
		w.WriteLine("Usage: WiFile.exe package.msi /x [filename,filename2,...]");
		w.WriteLine("Usage: WiFile.exe package.msi /u [filename,filename2,...]");
		w.WriteLine();
		w.WriteLine("Lists (/l), extracts (/x) or updates (/u) files in an MSI or MSM.");
		w.WriteLine("Files are extracted using their source path relative to the package.");
		w.WriteLine("Specified filenames do not include paths.");
		w.WriteLine("Filenames may be a pattern such as *.exe or file?.dll");
	}
Ejemplo n.º 31
0
 /// <summary>
 ///   Renders the tag to the specified <see cref = "TextWriter" />.
 /// </summary>
 /// <param name = "writer">The writer.</param>
 public void WriteTo(TextWriter writer, HtmlEncoder encoder)
 {
     _tag?.WriteTo(writer, encoder);
 }
Ejemplo n.º 32
0
 private void WriteCloseNamespace(TextWriter output)
 {
     output.Write(subComponent != null
         ? "}}"
         : "}");
 }
Ejemplo n.º 33
0
 public static void WriteObjectType(TextWriter writer, object value)
 {
     writer.Write(JsWriter.EmptyMap);
 }
Ejemplo n.º 34
0
        public static void WriteProperties(TextWriter writer, object value)
        {
            if (typeof(TSerializer) == typeof(JsonTypeSerializer) && JsState.WritingKeyCount > 0)
            {
                writer.Write(JsWriter.QuoteChar);
            }

            writer.Write(JsWriter.MapStartChar);

            var i = 0;

            if (WriteTypeInfo != null || JsState.IsWritingDynamic)
            {
                if (JsConfig.PreferInterfaces && TryWriteSelfType(writer))
                {
                    i++;
                }
                else if (TryWriteTypeInfo(writer, value))
                {
                    i++;
                }
                JsState.IsWritingDynamic = false;
            }

            if (PropertyWriters != null)
            {
                var len     = PropertyWriters.Length;
                var exclude = JsConfig.ExcludePropertyReferences ?? new string[0];
                ConvertToUpper(exclude);
                for (int index = 0; index < len; index++)
                {
                    var propertyWriter = PropertyWriters[index];

                    if (propertyWriter.shouldSerialize != null && !propertyWriter.shouldSerialize((T)value))
                    {
                        continue;
                    }

                    var propertyValue = value != null
                        ? propertyWriter.GetterFn((T)value)
                        : null;

                    if (propertyWriter.propertySuppressDefaultAttribute && Equals(propertyWriter.DefaultValue, propertyValue))
                    {
                        continue;
                    }
                    if ((propertyValue == null ||
                         (propertyWriter.propertySuppressDefaultConfig && Equals(propertyWriter.DefaultValue, propertyValue))) &&
                        !Serializer.IncludeNullValues
                        )
                    {
                        continue;
                    }

                    if (exclude.Any() && exclude.Contains(propertyWriter.propertyCombinedNameUpper))
                    {
                        continue;
                    }

                    if (i++ > 0)
                    {
                        writer.Write(JsWriter.ItemSeperator);
                    }

                    Serializer.WritePropertyName(writer, propertyWriter.PropertyName);
                    writer.Write(JsWriter.MapKeySeperator);

                    if (typeof(TSerializer) == typeof(JsonTypeSerializer))
                    {
                        JsState.IsWritingValue = true;
                    }
                    if (propertyValue == null)
                    {
                        writer.Write(JsonUtils.Null);
                    }
                    else
                    {
                        propertyWriter.WriteFn(writer, propertyValue);
                    }
                    if (typeof(TSerializer) == typeof(JsonTypeSerializer))
                    {
                        JsState.IsWritingValue = false;
                    }
                }
            }

            writer.Write(JsWriter.MapEndChar);

            if (typeof(TSerializer) == typeof(JsonTypeSerializer) && JsState.WritingKeyCount > 0)
            {
                writer.Write(JsWriter.QuoteChar);
            }
        }
Ejemplo n.º 35
0
 // Note: Should be used with using(var modelchecker = new ...)
 protected MdpModelChecker(MarkovDecisionProcess mdp, TextWriter output = null)
 {
     MarkovDecisionProcess = mdp;
     _output = output;
 }
Ejemplo n.º 36
0
 public void Describe(JasperRuntime runtime, TextWriter writer)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 37
0
 public static void Serialize(decimal value, TextWriter sw)
 {
     sw.Write(value);
 }
Ejemplo n.º 38
0
 /// <summary>
 /// This must be called before <tt>getInstance</tt> is called or
 /// it will have no effect.
 /// </summary>
 /// <remarks>
 /// This must be called before <tt>getInstance</tt> is called or
 /// it will have no effect.
 /// </remarks>
 public static void SetInstance(TextWriter other)
 {
     //inst = new Jcifs.Util.LogStream();
     _inst = new LogStream(other);
 }
Ejemplo n.º 39
0
 private static void writeToFile(string value, string path)
 {
     using (var writer = new StreamWriter(path, true))
         using (var syncWriter = TextWriter.Synchronized(writer))
             syncWriter.WriteLine(value);
 }
 public void ToEPL(TextWriter writer, EPStatementFormatter formatter)
 {
     writer.Write("@now");
 }
Ejemplo n.º 41
0
 // This function will get triggered/executed when a new message is written
 // on an Azure Queue called queue.
 public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
 {
     log.WriteLine(message);
 }
Ejemplo n.º 42
0
        private static void CompareDirectories(DirectoryInfo[] dirs1, DirectoryInfo[] dirs2, TextWriter writer)
        {
            int pos1 = 0;
            int pos2 = 0;

            while (pos1 < dirs1.Length || pos2 < dirs2.Length)
            {
                DirectoryInfo dir1 = pos1 < dirs1.Length ? dirs1[pos1] : null;
                DirectoryInfo dir2 = pos2 < dirs2.Length ? dirs2[pos2] : null;

                string name1 = dir1 == null ? null : dir1.Name;
                string name2 = dir2 == null ? null : dir2.Name;

                int nameCompare = CompareName(name1, name2);

                if (nameCompare == 0)
                {
                    CompareDirectoryInfo(dir1, dir2, writer);
                    pos1++;
                    pos2++;
                }
                else if (nameCompare < 0)
                {
                    writer.Write(dir1.FullName);
                    writer.WriteLine("    无对应目录");
                    pos1++;
                }
                else
                {
                    writer.Write(dir2.FullName);
                    writer.WriteLine("    无对应目录");
                    pos2++;
                }
            }
        }
Ejemplo n.º 43
0
            protected InfoWriter(TextWriter output)
            {
                _output = output ?? throw new ArgumentNullException(nameof(output));

                BeginInfo();
            }
Ejemplo n.º 44
0
 private void WriteOpenNamespace(TextWriter output)
 {
     output.Write(subComponent != null
         ? $"\"{component}\":{{\"{subComponent}\":{{"
         : $"\"{component}\":{{");
 }
Ejemplo n.º 45
0
        public int TransformResolver(string szXmlFile, XmlResolver xr, bool errorCase, TransformType transformType, DocType docType)
        {
            lock (s_outFileMemoryLock)
            {
                szXmlFile = FullFilePath(szXmlFile);

                _output.WriteLine("Loading XML {0}", szXmlFile);
                IXPathNavigable xd = LoadXML(szXmlFile, docType);

                _output.WriteLine("Executing transform");
                xrXSLT = null;
                Stream strmTemp = null;

                switch (transformType)
                {
                case TransformType.Reader:
                    xrXSLT = xslt.Transform(xd, null, xr);

                    using (FileStream outFile = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite))
                        using (XmlWriter writer = XmlWriter.Create(outFile))
                        {
                            writer.WriteNode(xrXSLT, true);
                        }

                    if (errorCase)
                    {
                        try
                        {
                            while (xrXSLT.Read())
                            {
                            }
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                        finally
                        {
                            if (xrXSLT != null)
                            {
                                xrXSLT.Dispose();
                            }
                        }
                    }
                    break;

                case TransformType.Stream:
                    try
                    {
                        strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
                        xslt.Transform(xd, null, strmTemp, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (strmTemp != null)
                        {
                            strmTemp.Dispose();
                        }
                    }
                    break;

                case TransformType.Writer:
                    XmlWriter xw = null;
                    try
                    {
                        xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
                        xw.WriteStartDocument();
                        xslt.Transform(xd, null, xw, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (xw != null)
                        {
                            xw.Dispose();
                        }
                    }
                    break;

                case TransformType.TextWriter:
                    TextWriter tw = null;
                    try
                    {
                        using (FileStream outFile = new FileStream(_strOutFile, FileMode.Create, FileAccess.Write))
                        {
                            tw = new StreamWriter(outFile, Encoding.UTF8);
                            xslt.Transform(xd, null, tw, xr);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    break;
                }
                return(1);
            }
        }
Ejemplo n.º 46
0
 /// <inheritdoc />
 public override void WriteDescriptionTo(TextWriter writer)
 {
     writer.Write("Predicate Constraint");
 }
Ejemplo n.º 47
0
		void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module)
		{
			const string ns = "http://schemas.microsoft.com/developer/msbuild/2003";
			string platformName = CSharpLanguage.GetPlatformName(module);
			Guid guid = App.CommandLineArguments.FixedGuid ?? Guid.NewGuid();
			using (XmlTextWriter w = new XmlTextWriter(writer)) {
				w.Formatting = Formatting.Indented;
				w.WriteStartDocument();
				w.WriteStartElement("Project", ns);
				w.WriteAttributeString("ToolsVersion", "4.0");
				w.WriteAttributeString("DefaultTargets", "Build");

				w.WriteStartElement("PropertyGroup");
				w.WriteElementString("ProjectGuid", guid.ToString("B").ToUpperInvariant());

				w.WriteStartElement("Configuration");
				w.WriteAttributeString("Condition", " '$(Configuration)' == '' ");
				w.WriteValue("Debug");
				w.WriteEndElement(); // </Configuration>

				w.WriteStartElement("Platform");
				w.WriteAttributeString("Condition", " '$(Platform)' == '' ");
				w.WriteValue(platformName);
				w.WriteEndElement(); // </Platform>

				switch (module.Kind) {
					case ModuleKind.Windows:
						w.WriteElementString("OutputType", "WinExe");
						break;
					case ModuleKind.Console:
						w.WriteElementString("OutputType", "Exe");
						break;
					default:
						w.WriteElementString("OutputType", "Library");
						break;
				}

				w.WriteElementString("AssemblyName", module.Assembly.Name.Name);
				bool useTargetFrameworkAttribute = false;
				var targetFrameworkAttribute = module.Assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.FullName == "System.Runtime.Versioning.TargetFrameworkAttribute");
				if (targetFrameworkAttribute != null && targetFrameworkAttribute.ConstructorArguments.Any()) {
					string frameworkName = (string)targetFrameworkAttribute.ConstructorArguments[0].Value;
					string[] frameworkParts = frameworkName.Split(',');
					string frameworkVersion = frameworkParts.FirstOrDefault(a => a.StartsWith("Version="));
					if (frameworkVersion != null) {
						w.WriteElementString("TargetFrameworkVersion", frameworkVersion.Substring("Version=".Length));
						useTargetFrameworkAttribute = true;
					}
					string frameworkProfile = frameworkParts.FirstOrDefault(a => a.StartsWith("Profile="));
					if (frameworkProfile != null)
						w.WriteElementString("TargetFrameworkProfile", frameworkProfile.Substring("Profile=".Length));
				}
				if (!useTargetFrameworkAttribute) {
					switch (module.Runtime) {
						case TargetRuntime.Net_1_0:
							w.WriteElementString("TargetFrameworkVersion", "v1.0");
							break;
						case TargetRuntime.Net_1_1:
							w.WriteElementString("TargetFrameworkVersion", "v1.1");
							break;
						case TargetRuntime.Net_2_0:
							w.WriteElementString("TargetFrameworkVersion", "v2.0");
							// TODO: Detect when .NET 3.0/3.5 is required
							break;
						default:
							w.WriteElementString("TargetFrameworkVersion", "v4.0");
							break;
					}
				}
				w.WriteElementString("WarningLevel", "4");

				w.WriteEndElement(); // </PropertyGroup>

				w.WriteStartElement("PropertyGroup"); // platform-specific
				w.WriteAttributeString("Condition", " '$(Platform)' == '" + platformName + "' ");
				w.WriteElementString("PlatformTarget", platformName);
				w.WriteEndElement(); // </PropertyGroup> (platform-specific)

				w.WriteStartElement("PropertyGroup"); // Debug
				w.WriteAttributeString("Condition", " '$(Configuration)' == 'Debug' ");
				w.WriteElementString("OutputPath", "bin\\Debug\\");
				w.WriteElementString("DebugSymbols", "true");
				w.WriteElementString("DebugType", "full");
				w.WriteElementString("Optimize", "false");
				w.WriteEndElement(); // </PropertyGroup> (Debug)

				w.WriteStartElement("PropertyGroup"); // Release
				w.WriteAttributeString("Condition", " '$(Configuration)' == 'Release' ");
				w.WriteElementString("OutputPath", "bin\\Release\\");
				w.WriteElementString("DebugSymbols", "true");
				w.WriteElementString("DebugType", "pdbonly");
				w.WriteElementString("Optimize", "true");
				w.WriteEndElement(); // </PropertyGroup> (Release)


				w.WriteStartElement("ItemGroup"); // References
				foreach (AssemblyNameReference r in module.AssemblyReferences) {
					if (r.Name != "mscorlib") {
						w.WriteStartElement("Reference");
						w.WriteAttributeString("Include", r.Name);
						w.WriteEndElement();
					}
				}
				w.WriteEndElement(); // </ItemGroup> (References)

				foreach (IGrouping<string, string> gr in (from f in files group f.Item2 by f.Item1 into g orderby g.Key select g)) {
					w.WriteStartElement("ItemGroup");
					foreach (string file in gr.OrderBy(f => f, StringComparer.OrdinalIgnoreCase)) {
						w.WriteStartElement(gr.Key);
						w.WriteAttributeString("Include", file);
						w.WriteEndElement();
					}
					w.WriteEndElement();
				}
				
				w.WriteStartElement("ItemGroup"); // Imports
				foreach (var import in projectImports.OrderBy(x => x)) {
					w.WriteStartElement("Import");
					w.WriteAttributeString("Include", import);
					w.WriteEndElement();
				}
				w.WriteEndElement(); // </ItemGroup> (Imports)

				w.WriteStartElement("Import");
				w.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.VisualBasic.targets");
				w.WriteEndElement();

				w.WriteEndDocument();
			}
		}
Ejemplo n.º 48
0
        private ViewContext CreateViewContext(ActionContext actionContext, ViewDataDictionary viewData, TextWriter output)
        {
            var viewContext = new ViewContext(
                actionContext,
                NullView.Instance,
                viewData,
                _tempDataFactory.GetTempData(actionContext.HttpContext),
                output,
                _mvcViewOptions.Value.HtmlHelperOptions
                );

            return(viewContext);
        }
Ejemplo n.º 49
0
 public abstract void WriteGrades(TextWriter destination);
Ejemplo n.º 50
0
 public CliInfoWriter(TextWriter output) : base(output)
 {
 }
Ejemplo n.º 51
0
 public LogStream(TextWriter other) : base(other)
 {
 }
Ejemplo n.º 52
0
 public static void TypeInfoWriter(TextWriter writer, object obj)
 {
     TryWriteTypeInfo(writer, obj);
 }
Ejemplo n.º 53
0
        public override void WriteHtml(TextWriter writer)
        {
            int graphId = 0;

            foreach (var agentBuffData in buffData.AgentBuffData.Values)
            {
                writer.WriteLine($"<div class='title is-4'>Agent: {agentBuffData.Agent.Name}</div>");

                foreach (var collections in agentBuffData.StackCollectionsBySkills.Values)
                {
                    var buff     = collections.Buff;
                    var segments = collections.BuffSegments.ToArray();

                    if (segments.Length == 0)
                    {
                        continue;
                    }

                    writer.WriteLine($"<div class='title is-6'>{buff.Name}</div>");

                    var graphStartTime = segments.First().TimeStart;

                    writer.Write(
                        $"<div id=\"buff-graph{graphId}\" style=\"height: 400px;width:800px; display:inline-block \"></div>");
                    writer.Write("<script>");
                    writer.Write("document.addEventListener(\"DOMContentLoaded\", function() {");
                    writer.Write("var data = [");
                    writer.Write("{y: [");
                    {
                        foreach (var segment in segments)
                        {
                            writer.Write("'" + segment.StackCount + "',");
                        }

                        writer.Write("'" + segments.Last().StackCount + "'");
                    }
                    writer.Write("],");
                    writer.Write("x: [");
                    {
                        foreach (var segment in segments)
                        {
                            double segmentStart = Math.Round(Math.Max(segment.TimeStart - graphStartTime, 0) / 1000.0,
                                                             3);
                            writer.Write($"'{segmentStart}',");
                        }

                        writer.Write("'" + Math.Round((segments.Last().TimeEnd - graphStartTime) / 1000.0, 3) + "'");
                    }
                    writer.Write("],");
                    writer.Write("yaxis: 'y', type: 'scatter',");
                    writer.Write(" line: {color:'red', shape: 'hv'},");
                    writer.Write($" fill: 'tozeroy', name: \"{buff.Name}\"");
                    writer.Write("}");
                    writer.Write("];");
                    writer.Write("var layout = {");
                    writer.Write("barmode:'stack',");
                    writer.Write(
                        "yaxis: { title: 'Boons', fixedrange: true, dtick: 1.0, tick0: 0, gridcolor: '#909090' }," +
                        "legend: { traceorder: 'reversed' }," +
                        "hovermode: 'compare'," +
                        "font: { color: '#000000' }," +
                        "paper_bgcolor: 'rgba(255, 255, 255, 0)'," +
                        "plot_bgcolor: 'rgba(255, 255, 255, 0)'");

                    writer.Write("};");
                    writer.Write($"Plotly.newPlot('buff-graph{graphId++}', data, layout);");
                    writer.Write("});");
                    writer.Write("</script> ");

                    writer.WriteLine($@"
    <table class='table is-narrow is-striped is-hoverable'>
        <thead>
        <tr>
            <th>Stack Count</th>
			<th>Time From</th>
			<th>Time To</th>
        </tr>
        </thead>
        <tbody>");
                    foreach (var segment in segments)
                    {
                        writer.WriteLine($@"
            <tr>
                <td>{segment.StackCount}</td>
                <td>{segment.TimeStart}</td>
                <td>{segment.TimeEnd}</td>
            </tr>");
                    }

                    writer.WriteLine($@"
        </tbody>
    </table>");
                }
            }
        }
Ejemplo n.º 54
0
 public MockDescription(string id, TextWriter writer, int boxWidth, int boxHeight)
 {
     this.id = id;
     this.writer = writer;
     this.boxes = new Size(boxWidth, boxHeight);
 }
Ejemplo n.º 55
0
 /// <summary>
 /// Writes data from a data table to a text stream, formatted as delimited values
 /// </summary>
 /// <param name="dataTable">The data table with the data to write</param>
 /// <param name="outputStream">The text stream to which the delimited data will be written</param>
 /// <param name="formatOptions">The delimited text stream formatting options</param>
 public static void DataTableToStream(DataTable dataTable, TextWriter outputStream, DelimitedFormatOptions formatOptions)
 {
     DataTableToStream(dataTable, outputStream, formatOptions, null, null, BackgroundWorkerReportingOptions.None);
 }
Ejemplo n.º 56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActorRuntimeLogTextFormatter"/> class.
 /// </summary>
 public ActorRuntimeLogTextFormatter()
 {
     this.Logger = new ConsoleLogger();
 }
Ejemplo n.º 57
0
        /// <summary>
        /// Writes data from a data table to a text stream, formatted as delimited values
        /// </summary>
        /// <param name="dataTable">The data table with the data to write</param>
        /// <param name="outputStream">The text stream to which the delimited data will be written</param>
        /// <param name="formatOptions">The delimited text stream formatting options</param>
        /// <param name="bgWorker">BackgroundWorker (may be null), in order to show progress</param>
        /// <param name="e">Arguments from a BackgroundWorker (may be null), in order to support canceling</param>
        /// <param name="reportingOption">Indicates how the BackgroundWorker should report progress</param>
        private static void DataTableToStream(DataTable dataTable, TextWriter outputStream, DelimitedFormatOptions formatOptions, BackgroundWorker bgWorker, DoWorkEventArgs e, BackgroundWorkerReportingOptions reportingOption)
        {
            // Check that columns are present
            int columnCount = dataTable.Columns.Count;

            if (columnCount == 0)
            {
                return;
            }

            // Get the number of rows in the table
            long totalSteps              = 0;
            long currentStep             = 0;
            int  previousPercentComplete = 0;

            // Background worker updates
            if (bgWorker != null)
            {
                // Check for cancel
                if (e != null && bgWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                // Report progress
                if (bgWorker.WorkerReportsProgress == true && reportingOption != BackgroundWorkerReportingOptions.None)
                {
                    if (reportingOption == BackgroundWorkerReportingOptions.UserStateAndProgress)
                    {
                        bgWorker.ReportProgress(0, "Reading data...");
                    }
                    else if (reportingOption == BackgroundWorkerReportingOptions.ProgressOnly)
                    {
                        bgWorker.ReportProgress(0);
                    }

                    totalSteps = dataTable.Rows.Count;
                }
            }


            // Write the column headers
            if (formatOptions.IncludeHeaders)
            {
                // Background worker updates
                if (bgWorker != null)
                {
                    // Check for cancel
                    if (e != null && bgWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    // Report progress
                    if (bgWorker.WorkerReportsProgress && reportingOption != BackgroundWorkerReportingOptions.None)
                    {
                        if (reportingOption == BackgroundWorkerReportingOptions.UserStateAndProgress)
                        {
                            bgWorker.ReportProgress(0, "Reading column headers...");
                        }
                        else if (reportingOption == BackgroundWorkerReportingOptions.ProgressOnly)
                        {
                            bgWorker.ReportProgress(0);
                        }

                        totalSteps = dataTable.Rows.Count;
                    }
                }

                // Write each column name from the data table
                for (int i = 0; i < columnCount; i++)
                {
                    var item = FormatDataItem(dataTable.Columns[i].ColumnName, formatOptions.Delimiter);
                    if (i > 0)
                    {
                        outputStream.Write(formatOptions.Delimiter + item);
                    }
                    else
                    {
                        outputStream.Write(item);
                    }
                }

                outputStream.Write(Environment.NewLine);
            }

            //date time column index
            int dateTimeColumnIndex = -1;

            for (int i = 0; i < columnCount; i++)
            {
                if (dataTable.Columns[i].DataType == typeof(DateTime))
                {
                    dateTimeColumnIndex = i;
                    break;
                }
            }

            //set correct culture info - decimal point formatting option
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;

            if (formatOptions.UseInvariantCulture)
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            }


            // Write the data
            foreach (DataRow row in dataTable.Rows)
            {
                // Background worker updates
                if (bgWorker != null)
                {
                    // Check for cancel
                    if (e != null && bgWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    // Report progress
                    if (bgWorker.WorkerReportsProgress == true && reportingOption != BackgroundWorkerReportingOptions.None)
                    {
                        currentStep++;
                        int percentComplete = (int)(100 * currentStep / totalSteps);
                        if (percentComplete > previousPercentComplete)
                        {
                            if (reportingOption == BackgroundWorkerReportingOptions.UserStateAndProgress)
                            {
                                bgWorker.ReportProgress(percentComplete, "Writing line " + currentStep + " of " + totalSteps + "...");
                            }
                            else if (reportingOption == BackgroundWorkerReportingOptions.ProgressOnly)
                            {
                                bgWorker.ReportProgress(percentComplete);
                            }

                            previousPercentComplete = percentComplete;
                        }
                    }
                }

                // write data for each row
                for (int i = 0; i < columnCount; i++)
                {
                    var rowValue = row[i] ?? String.Empty;

                    string item;

                    if (i != dateTimeColumnIndex)
                    {
                        item = FormatDataItem(rowValue.ToString(), formatOptions.Delimiter);
                    }
                    else if (!formatOptions.UseShortDateFormat)
                    {
                        item = FormatDataItem((Convert.ToDateTime(rowValue)).ToString(formatOptions.DateTimeFormat), formatOptions.Delimiter);
                    }
                    else
                    {
                        item = FormatDataItem((Convert.ToDateTime(rowValue)).ToString("yyyy-MM-dd"), formatOptions.Delimiter);
                    }

                    if (i > 0)
                    {
                        outputStream.Write(formatOptions.Delimiter + item);
                    }
                    else
                    {
                        outputStream.Write(item);
                    }
                }

                outputStream.Write(System.Environment.NewLine);
            }

            //reset the culture info
            if (Thread.CurrentThread.CurrentCulture != originalCulture)
            {
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }

            // Background worker updates
            if (bgWorker != null)
            {
                // Check for cancel
                if (e != null && bgWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                // Report progress
                if (bgWorker.WorkerReportsProgress && reportingOption != BackgroundWorkerReportingOptions.None)
                {
                    if (reportingOption == BackgroundWorkerReportingOptions.UserStateAndProgress)
                    {
                        bgWorker.ReportProgress(100, "All lines written");
                    }
                    else if (reportingOption == BackgroundWorkerReportingOptions.ProgressOnly)
                    {
                        bgWorker.ReportProgress(100);
                    }
                }
            }
        }
Ejemplo n.º 58
0
        private static void WriteProperties(IEnumerable <KeyValuePair <string, LogEventPropertyValue> > properties, TextWriter output)
        {
            var precedingDelimiter = "";

            foreach (var property in properties)
            {
                output.Write(precedingDelimiter);
                precedingDelimiter = ",";

                JsonValueFormatter.WriteQuotedJsonString(property.Key, output);
                output.Write(':');
                ValueFormatter.Instance.Format(property.Value, output);
            }
        }
Ejemplo n.º 59
0
        private static void CompareDirectoryInfo(DirectoryInfo di1, DirectoryInfo di2, TextWriter writer)
        {
            FileInfo[] files1 = GetSortedFiles(di1);
            FileInfo[] files2 = GetSortedFiles(di2);

            CompareFiles(files1, files2, writer);

            DirectoryInfo[] dirs1 = GetSortedDirectories(di1);
            DirectoryInfo[] dirs2 = GetSortedDirectories(di2);

            CompareDirectories(dirs1, dirs2, writer);
        }
Ejemplo n.º 60
0
 public HtmlInfoWriter(TextWriter output) : base(output)
 {
 }