Esempio n. 1
0
 public string GetUsage()
 {
     var usage = new StringBuilder();
     usage.AppendLine("Process Scheduler");
     usage.AppendLine("-i, --input [filename]");
     return usage.ToString();
 }
        public ActionResult Script()
        {
            StringBuilder sb = new StringBuilder();
            Dictionary<string, object> clientValidationRules = this.GetClientValidationRules();

            sb.AppendLine("(function () {");
            sb.AppendLine(String.Format("\tMilkshake.clientValidationRules = {0};", JsonConvert.SerializeObject(clientValidationRules)));
            sb.AppendLine("})();");

            return Content(sb.ToString(), "text/javascript");
        }
Esempio n. 3
0
 public string SerialiseToRibbonXml()
 {
     /*
      *   <MenuSection Id="dev1.ApplicationRibbon.Section11.Section" Sequence="10" DisplayMode="Menu16">
       <Controls Id="dev1.ApplicationRibbon.Section11.Section.Controls">
         <Button Id="dev1.ApplicationRibbon.Button11.Button" LabelText="$LocLabels:dev1.ApplicationRibbon.Button11.Button.LabelText" Sequence="15" />
         <Button Id="dev1.ApplicationRibbon.Button10.Button" LabelText="$LocLabels:dev1.ApplicationRibbon.Button10.Button.LabelText" Sequence="20" />
       </Controls>
     </MenuSection>*/
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("<Menu Id=\"" + Id + "\">");
     foreach (RibbonMenuSection section in Sections)
     {
         section.SerialiseToRibbonXml(sb);
     }
     sb.AppendLine("</Menu>");
     return sb.ToString();
 }
Esempio n. 4
0
        static FrameIDFactory()
        {
            CreateEntries();
            #if generate
            var writer = new System.IO.StreamWriter(@"C:\Temp\table.txt");
            _entries = new List<ID3v2FrameEntry>();

            var elements = Enum.GetNames(typeof(ID3v2FrameID));
            foreach (var element in elements)
            {
                var id = Enum.Parse(typeof(ID3v2FrameID), element);
                var id3v4ID = ID3v2FrameIDFactory.GetID((ID3v2FrameID)id, ID3Version.ID3v2_4);
                string id3v3ID;
                try
                {
                    id3v3ID = ID3v2FrameIDFactory.GetID((ID3v2FrameID)id, ID3Version.ID3v2_3);
                }
                catch (Exception)
                {
                    id3v3ID = null;
                }
                string id3v2ID;
                try
                {
                    id3v2ID = ID3v2FrameIDFactory.GetID((ID3v2FrameID)id, ID3Version.ID3v2_2);
                }
                catch (Exception)
                {
                    id3v2ID = null;
                }

                StringBuilder builder = new StringBuilder();
                builder.AppendLine("                entry = new ID3v2FrameEntry()");
                builder.AppendLine("                {");
                builder.AppendLine(String.Format("                    ID = ID3v2FrameID.{0},", ((ID3v2FrameID)id).ToString()));
                builder.AppendLine(String.Format("                    ID3v4ID = {0},", id3v4ID == null ? "null" : "\"" + id3v4ID + "\""));
                builder.AppendLine(String.Format("                    ID3v3ID = {0},", id3v3ID == null ? "null" : "\"" + id3v3ID + "\""));
                builder.AppendLine(String.Format("                    ID3v2ID = {0},", id3v2ID == null ? "null" : "\"" + id3v2ID + "\""));
                builder.AppendLine(String.Format("                    Desc = \"{0}\"", element));
                builder.AppendLine("                };");
                builder.AppendLine("                _entries.Add(entry);");
                writer.WriteLine(builder.ToString());
                writer.WriteLine();
                writer.WriteLine();
            }
            writer.Flush();
            writer.Dispose();
            #endif
        }
Esempio n. 5
0
        public void SerialiseToRibbonXml(StringBuilder sb)
        {
            /*
             *   <MenuSection Id="dev1.ApplicationRibbon.Section11.Section" Sequence="10" DisplayMode="Menu16">
              <Controls Id="dev1.ApplicationRibbon.Section11.Section.Controls">
                <Button Id="dev1.ApplicationRibbon.Button11.Button" LabelText="$LocLabels:dev1.ApplicationRibbon.Button11.Button.LabelText" Sequence="15" />
                <Button Id="dev1.ApplicationRibbon.Button10.Button" LabelText="$LocLabels:dev1.ApplicationRibbon.Button10.Button.LabelText" Sequence="20" />
              </Controls>
            </MenuSection>*/

            sb.AppendLine("<MenuSection Id=\"" + XmlHelper.Encode(Id) + (Title!=null ? "\" Title=\"" + Title.ToString() : "") + "\" Sequence=\"" + Sequence.ToString() + "\" DisplayMode=\"" + DisplayMode + "\">");
            sb.AppendLine("<Controls Id=\"" + XmlHelper.Encode(Id + ".Controls") + "\">");
            foreach (RibbonControl button in Buttons)
            {
                button.SerialiseToRibbonXml(sb);
            }
            sb.AppendLine("</Controls>");
            sb.AppendLine("</MenuSection>");
        }
Esempio n. 6
0
        public override void SerialiseToRibbonXml(StringBuilder sb)
        {
            /*
             *   <MenuSection Id="dev1.ApplicationRibbon.Section11.Section" Sequence="10" DisplayMode="Menu16">
              <Controls Id="dev1.ApplicationRibbon.Section11.Section.Controls">
                <Button Id="dev1.ApplicationRibbon.Button11.Button" LabelText="$LocLabels:dev1.ApplicationRibbon.Button11.Button.LabelText" Sequence="15" />
                <Button Id="dev1.ApplicationRibbon.Button10.Button" LabelText="$LocLabels:dev1.ApplicationRibbon.Button10.Button.LabelText" Sequence="20" />
              </Controls>
            </MenuSection>*/

            sb.AppendLine("<Button Id=\"" + XmlHelper.Encode(Id) + "\" LabelText=\"" + XmlHelper.Encode(LabelText) + "\" Sequence=\"" + Sequence.ToString() + "\" Command=\"" + XmlHelper.Encode(Command) + "\"" + ((Image32by32!=null) ? (" Image32by32=\"" + XmlHelper.Encode(Image32by32) + "\"") : "") +  ((Image16by16!=null) ? (" Image16by16=\"" + XmlHelper.Encode(Image16by16) + "\"") : "") + " />");
        }
Esempio n. 7
0
        private string GetListenerTrace(ExportProvider provider)
        {
            var sb = new StringBuilder();

            var workspaceWaiter = GetListeners(provider).First(l => l.Metadata.FeatureName == FeatureAttribute.Workspace).Value as TestAsynchronousOperationListener;
            sb.AppendLine("workspace");
            sb.AppendLine(workspaceWaiter.Trace());

            var solutionCrawlerWaiter = GetListeners(provider).First(l => l.Metadata.FeatureName == FeatureAttribute.SolutionCrawler).Value as TestAsynchronousOperationListener;
            sb.AppendLine("solutionCrawler");
            sb.AppendLine(solutionCrawlerWaiter.Trace());

            return sb.ToString();
        }
 private string GenerateDbSets()
 {
     System.StringBuilder returnValue = new System.StringBuilder();
     foreach (var dbSet in this.dbSets)
     {
         returnValue.AppendFormat("\t\t public DbSet<{0}> {1}", dbSet.Key.Name, dbSet.Value);
         returnValue.AppendLine(" { get; set; }");
         returnValue.AppendLine();
     }
     return returnValue;
 }
 public DbContext CreateInstance()
 {
     var loCompiler = CodeDomProvider.CreateProvider("CSharp");
     CompilerParameters parameters = new CompilerParameters();
     parameters.GenerateInMemory = true;
     foreach (var referencedAssembly in this.ReferencedAssemblies.Distinct())
     {
         string assemblyPath = string.Format("{0}\\bin\\{1}", AppDomain.CurrentDomain.BaseDirectory, referencedAssembly);
         parameters.ReferencedAssemblies.Add((System.IO.File.Exists(assemblyPath)) ? assemblyPath : referencedAssembly);
     }
     CompilerResults compilerResult = loCompiler.CompileAssemblyFromSource(parameters, this.GetClassSource());
     if (compilerResult.Errors.HasErrors)
     {
         System.StringBuilder errors = new System.StringBuilder("Error Generating Class");
         errors.AppendLine();
         foreach (var error in compilerResult.Errors)
             errors.AppendLine(error.ToString());
         throw new InvalidOperationException(errors.ToString());
     }
     return (DbContext) compilerResult.CompiledAssembly.CreateInstance(this.FullClassName);
 }
Esempio n. 10
0
        public static void Main(string[] args)
        {
#if SAVE_ALL_TYPES
            List<string> fieldTypes = new List<string>();
#endif
            var generatorList = new List<ProtobufPacketGenerator>();


            // Those ID's are not supported and should be parsed manually.
            var bannedIDs = new int[] { 0x20, 0x22, 0x26, 0x34, 0x37, 0x38, 0x44, 0x45 };

            var protocols = GetProtocolTables();
            foreach (var protocol in protocols)
            {
                var className = $"{protocol.Name.Replace("-", "").Replace("_", "")}Packet";
                var id = new VarInt(int.Parse(protocol.GetAt(0, 0).Remove(0, 2), NumberStyles.AllowHexSpecifier));
                if (bannedIDs.Contains(id))
                    continue;

                var state = (State) Enum.Parse(typeof(State), protocol.GetAt(0, 1).ExceptBlanks());
                var boundTo = (BoundTo) Enum.Parse(typeof(BoundTo), protocol.GetAt(0, 2).ExceptBlanks());

                var builder = new ProtobufPacketGenerator(className, id, boundTo, state);

                for (int ix = 0; ix < protocol.Height; ix++)
                {
                    var fieldName = protocol.GetAt(ix, 3).Replace("-", "").ExceptBlanks();
                    if (fieldName == "nofields")
                        continue;

                    var fieldType = protocol.GetAt(ix, 4).Replace("-", "").ExceptBlanks();
                    var note = protocol.GetAt(ix, 5);

                    builder.AddField(fieldName, ReplaceTypes(fieldType));

#if SAVE_ALL_TYPES
                    if (!fieldTypes.Contains(fieldType))
                        fieldTypes.Add(fieldType);
#endif
                }

                generatorList.Add(builder);
            }

#if SAVE_ALL_TYPES
            var fieldTypesBuilder = new StringBuilder();
            foreach (string str in fieldTypes)
                fieldTypesBuilder.AppendLine(str);

            var fileTypeFile = FileSystemWrapper.OutputFolder.CreateFileAsync("FileTypes.txt", CreationCollisionOption.ReplaceExisting).Result;
            using (StreamWriter stream = new StreamWriter(fileTypeFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite).Result))
                stream.Write(fieldTypesBuilder.ToString());
#endif

            foreach (var generator in generatorList)
            {
                var folder = FileSystemWrapper.OutputFolder.CreateFolderAsync("Generated", CreationCollisionOption.OpenIfExists).Result;

                if (generator.BoundTo != BoundTo.NONE)
                    folder = folder.CreateFolderAsync(generator.BoundTo.ToString(), CreationCollisionOption.OpenIfExists).Result;
                if (generator.State != State.NONE)
                    folder = folder.CreateFolderAsync(generator.State.ToString(), CreationCollisionOption.OpenIfExists).Result;

                var classFile = folder.CreateFileAsync($"{generator.ClassName}.cs", CreationCollisionOption.ReplaceExisting).Result;
                using (StreamWriter stream = new StreamWriter(classFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite).Result))
                    stream.Write(generator.GenerateClass());
            }
        }
Esempio n. 11
0
 public override string ToString()
 {
     StringBuilder text = new StringBuilder();
     text.AppendLine("Дата приема " + DateReceiving.ToString());
     text.AppendLine("Описание проблемы " + DiscriptionTrouble);
     text.AppendLine(Dog.ToString());
     return text.ToString();
 }
Esempio n. 12
0
 /// <summary>
 ///   Returns the matrix in a textual form.
 /// </summary>
 public override String ToString()
 {
     var sb = new StringBuilder();
     var rows = Rows;
     var cols = Cols;
     sb.Append("┌");
     for (var i = 0; i < cols; ++i) sb.Append("{0,12}", String.Empty);
     sb.AppendLine("┐");
     for (var i = 0; i < rows; ++i)
     {
         sb.Append("│");
         for (var j = 0; j < cols; ++j)
         {
             var format =
                 //"+0.##;-0.##"; // +0.03
                 //"G3"; // +3e-2
                 "#.####;-#.####;0"; // +.03
             sb.Append("{0,10}  ", _matrix[i, j].ToString(format));
         }
         sb.AppendLine("│");
     }
     sb.Append("└");
     for (var i = 0; i < cols; ++i) sb.Append("{0,12}", String.Empty);
     sb.AppendLine("┘");
     return sb.ToString();
 }
Esempio n. 13
0
 public override void SerialiseToRibbonXml(StringBuilder sb)
 {
     sb.AppendLine("<FlyoutAnchor Id=\"" + XmlHelper.Encode(Id) + "\" LabelText=\"" + XmlHelper.Encode(LabelText) + "\" Sequence=\"" + Sequence.ToString() + "\" Command=\"" + XmlHelper.Encode(Command) + "\"" + ((Image32by32 != null) ? (" Image32by32=\"" + XmlHelper.Encode(Image32by32) + "\"") : "") + ((Image16by16 != null) ? (" Image16by16=\"" + XmlHelper.Encode(Image16by16) + "\"") : "") + " PopulateDynamically=\"false\">");
     sb.AppendLine(Menu.SerialiseToRibbonXml());
     sb.AppendLine("</FlyoutAnchor>");
 }
Esempio n. 14
0
        public void Report( string charName )
        {
            StringBuilder html = new StringBuilder();
            html.Append( "<html>" );
            html.Append( "<head>" );
            html.Append( "</head>" );
            html.AppendLine();
            html.Append( css );
            html.AppendLine();
            html.Append( "<body>" );
            html.AppendLine();
            foreach( CombatEntity entity in this.entities.Values )
            {
                if( charName != null && entity.Name != charName ) continue;

                if( charName == null && !entity.IsPlayerCharacter ) continue;

                html.Append( "<table border='1' cellpadding='3' cellspacing='0'>" );
                html.AppendLine();
                html.Append( "<tr>" );
                html.Append( "<td colspan='15'>" + entity.Name + "</td>" );
                html.Append( "</tr>" );
                html.Append( "<tr>" );
                this.AddHeaders( html );
                //html.Append( "<th>time</th><th class='lt'>summary</th><th>m:ss</th><th>took</th><th>heal</th><th>died</th><th>hits</th><th>miss</th><th>range</th><th>auto</th><th>dots</th><th>norm</th><th>crits</th><th>avg</th><th>dps</th>" );
                html.Append( "</tr>" );
                html.AppendLine();

                foreach( CombatSession session in entity.GetSessions() )
                {
                    string s = this.ToHtml( session );
                    if( s == string.Empty ) continue;

                    html.Append( "<tr class='hl'>" );
                    html.AppendLine();

                    this.AddRow( html, session );

                    //html.Append( s );
                    html.AppendLine();
                    html.Append( "</tr>" );
                    if( entity.Pets.Count > 0 )
                    {
                        foreach( CombatEntity pet in entity.Pets )
                        {
                            CombatSession petSession = pet.GetSessionWith( session.Target );
                            if( petSession != null )
                            {
                                string t = this.ToHtml( petSession );
                                if( t != string.Empty )
                                {
                                    html.Append( "<tr class='pet'>" );
                                    html.AppendLine();

                                    this.AddRow( html, session );

                                    //html.Append( t );
                                    html.AppendLine();
                                    html.Append( "</tr>" );
                                }
                            }
                        }
                    }
                }
                html.AppendLine();
                html.Append( "</table>" );
            }
            html.AppendLine();
            html.Append( "</body>" );
            Console.WriteLine( html );
        }
Esempio n. 15
0
        public static void SaveCustomFilters()
        {
            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair<string, ConstellationFilter> kv in Families)
            {
                if (!kv.Value.Internal)
                {
                    sb.Append(kv.Key);
                    sb.Append(";");
                    sb.AppendLine(kv.Value.ToString());

                }
            }

            //Properties.Settings.Default.SavedFilters = sb.ToString();
        }
Esempio n. 16
0
        // Used for diagnostic purposes.
        internal void DumpStats()
        {
            var sb = new StringBuilder();
            sb.AppendLine("Nodes length: " + _nodes.Length);
            var childCountHistogram = new Dictionary<int, int>();

            foreach (var node in _nodes)
            {
                var childCount = node.EdgeCount;
                int existing;
                childCountHistogram.TryGetValue(childCount, out existing);

                childCountHistogram[childCount] = existing + 1;
            }

            sb.AppendLine();
            sb.AppendLine("Child counts:");
            foreach (var kvp in childCountHistogram.OrderBy(kvp => kvp.Key))
            {
                sb.AppendLine(kvp.Key + "\t" + kvp.Value);
            }

            // An item is dense if, starting from 1, at least 80% of it's array would be full.
            var densities = new int[11];
            var empyCount = 0;

            foreach (var node in _nodes)
            {
                if (node.EdgeCount == 0)
                {
                    empyCount++;
                    continue;
                }

                var maxEditDistance = -1;
                var startInclusive = node.FirstEdgeIndex;
                var endExclusive = startInclusive + node.EdgeCount;
                for (var i = startInclusive; i < endExclusive; i++)
                {
                    maxEditDistance = Max(maxEditDistance, _edges[i].EditDistance);
                }

                var editDistanceCount = node.EdgeCount;

                var bucket = 10 * editDistanceCount / maxEditDistance;
                densities[bucket]++;
            }

            var nonEmptyCount = _nodes.Length - empyCount;
            sb.AppendLine();
            sb.AppendLine("NoChildren: " + empyCount);
            sb.AppendLine("AnyChildren: " + nonEmptyCount);
            sb.AppendLine("Densities:");
            for (var i = 0; i < densities.Length; i++)
            {
                sb.AppendLine("<=" + i + "0% = " + densities[i] + ", " + ((float)densities[i] / nonEmptyCount));
            }

            var result = sb.ToString();
        }