Example #1
0
		public string ParseStatement( PropertyInfo[] modelProperties, string sourceParamName)
		{
			var builder = new StringBuilder();
			builder.AppendLineFormat("if(Take>0 || Skip>0)");
			builder.AppendLine("{");
			builder.AppendLineFormat("switch(OrderField)");
			builder.AppendLine("{");
			foreach (var modelProperty in modelProperties)
			{
				if (modelProperty.PropertyType.IsValueType || modelProperty.PropertyType == typeof (string))
				{
					builder.AppendLineFormat("case \"{0}\":", modelProperty.Name);
					builder.AppendLineFormat(
						"{0}=(OrderDirection==Agile.Common.Data.OrderDirection.ASC)?{0}.OrderBy(o=>o.{1}):{0}.OrderByDescending(o=>o.{1});", sourceParamName,
						modelProperty.Name);
					builder.AppendLine("break;");
				}
				
			}
			builder.AppendLine("default:");
			builder.AppendLineFormat(
						"{0}=(OrderDirection==Agile.Common.Data.OrderDirection.ASC)?{0}.OrderBy(o=>o.{1}):{0}.OrderByDescending(o=>o.{1});", sourceParamName,
						KeyPropertyName);
			builder.AppendLine("break;");
			builder.AppendLine("}");
			builder.AppendLine("}");

			return builder.ToString();
		}
        public static string InitializeAutoComplete(this HtmlHelper html, string textBoxName, string fieldName, string url, object options, bool wrapInReady)
        {
            StringBuilder sb = new StringBuilder();
            if (wrapInReady) sb.AppendLineFormat("<script language='javascript'>");

            if (wrapInReady) sb.AppendLineFormat("$().ready(function() {{");
            sb.AppendLine();
            sb.AppendLineFormat("   $('#{0}').autocomplete('{1}', {{", textBoxName.Replace(".", "\\\\."), url);

            PropertyInfo[] properties = options.GetType().GetProperties();

            for (int i = 0; i < properties.Length; i++) {
                sb.AppendLineFormat("   {0} : {1}{2}",
                                        properties[i].Name,
                                        properties[i].GetValue(options, null),
                                        i != properties.Length - 1 ? "," : "");
            }
            sb.AppendLineFormat("   }});");
            sb.AppendLine();
            sb.AppendLineFormat("   $('#{0}').result(function(e, d, f) {{", textBoxName.Replace(".", "\\\\."));
            sb.AppendLineFormat("       $('#{0}').val(d[1]);", fieldName);
            sb.AppendLineFormat("    }});");
            sb.AppendLine();
            if (wrapInReady) sb.AppendLineFormat("}});");
            if (wrapInReady) sb.AppendLineFormat("</script>");
            return sb.ToString();
        }
Example #3
0
		public string ParseStatement(AnalyzeContext context)
		{
			Init();
			/**
             *      ***Navigation
             *      if(concreteQuery.UserQuery != null)
             *     {
             *          {
             *              var naviQuery = concreteQuery.UserQuery;
             *              if(naviQuery.Id != null){
             *                  source = source.Where(t=>t.User.Id == naviQuery.Id);
             *              }
			 *              if(naviQuery.RoleQuery != null){
			 *					var naviQuery_2 = naviQuery.RoleQuery;
			 *					
			 *              }
             *          }
             *      }
             */
			if (context.Depth >= MaxDepth) return "";
			var queryPropertyName = context.QueryProperty.Name;
			var modelPropertyName = context.ModelProperty.Name;
			var naviQueryParam = "naviQuery_" + (context.Depth + 1);
			var builder = new StringBuilder();
			builder.AppendLineFormat("if({0} != null)", context.QueryParamName+"."+queryPropertyName);
			builder.AppendLine("{");
			builder.AppendLineFormat("var {0}={1}.{2};", naviQueryParam, context.QueryParamName, queryPropertyName);
			var naviQueryProperties = context.QueryProperty.PropertyType.GetProperties();
			var naviModelProperties = context.ModelProperty.PropertyType.GetProperties();
			foreach (var naviQueryProperty in naviQueryProperties)
			{
				var naviContext = new AnalyzeContext()
					{
						Depth = context.Depth + 1,
						QueryProperty = naviQueryProperty,
						SourceParamName = context.SourceParamName,
						QueryParamName = naviQueryParam,
						Navigations = context.Navigations.Concat(new[] {context.ModelProperty.Name}).ToArray()
					};
				for (var index = 0; index < Analyzers.Length; index++)
				{
					var naviAnalyzer = Analyzers[index];
					var naviModelProperty = naviAnalyzer.FindAttachedModelProperty(naviQueryProperty, naviModelProperties);
					if (naviModelProperty == null) continue;
					naviContext.ModelProperty = naviModelProperty;
					var naviStatement = naviAnalyzer.ParseStatement(naviContext);
					queues[index].Add(naviStatement);
				}
				
			}
			for (var index = 0; index < Analyzers.Length; index++)
			{
				builder.Append(string.Join("", queues[index]));
			}
			builder.AppendLine("}");
			return builder.ToString();
		}
 public void AppendLineFormat()
 {
     StringBuilder Builder=new StringBuilder();
     Builder.AppendLineFormat("This is test {0}",1);
     Assert.Equal("This is test 1" + System.Environment.NewLine, Builder.ToString());
     Builder.Clear();
     Builder.AppendLineFormat("Test {0}", 2)
         .AppendLineFormat("And {0}", 3);
     Assert.Equal("Test 2" + System.Environment.NewLine + "And 3" + System.Environment.NewLine, Builder.ToString());
 }
Example #5
0
		public string GenerateQueryStatement(Type queryType)
		{
			if (!TypeUtils.IsBaseEntityQuery(queryType))
			{
				throw new ArgumentException("not a valid query type", "queryType");
			}
			Type baseType = queryType.BaseType;
			while (!baseType.IsGenericType)
			{
				baseType = baseType.BaseType;
			}
			var modelType = baseType.GetGenericArguments()[0];
			if (!TypeUtils.IsBaseEntity(modelType))
			{
				throw new ArgumentException("generic type is not a valid model type", "queryType");
			}

			var queryProperties = queryType.GetProperties();
			var modelProperties = modelType.GetProperties();
			var builder = new StringBuilder();
			builder.AppendLine("#region override DoQuery <auto-generated-code>");
			builder.AppendLineFormat("public override IQueryable<{0}> {2}(IQueryable<{0}> {1})", modelType.Name, SourceParamName, QueryFuncName);
			builder.AppendLine("{");
			foreach (var queryProperty in queryProperties)
			{
				var context = new AnalyzeContext()
					{
						QueryProperty = queryProperty,
						ModelType = modelType,
						SourceParamName = SourceParamName,
						QueryParamName = "this"
					};
				for (var index = 0; index < Analyzers.Length; index++)
				{
					var analyzer = Analyzers[index];
					var modelProperty = analyzer.FindAttachedModelProperty(queryProperty, modelProperties);
					if (modelProperty == null) continue;
					context.ModelProperty = modelProperty;
					var statment = analyzer.ParseStatement(context);
					queues[index].Add(statment);
				}
			}
			for (var index = 0; index < Analyzers.Length; index++)
			{
				builder.Append(string.Join("", queues[index]));
			}
			builder.Append(new PaginationAnalyzer().ParseStatement(modelProperties, SourceParamName));
			builder.AppendLineFormat("return {0};", SourceParamName);
			builder.AppendLine("}");
			builder.AppendLine("#endregion");
			return builder.ToString();
		}
Example #6
0
    public static void DumpGraph(this IRepository repository)
    {
        var output = new StringBuilder();

        try
        {
            ProcessHelper.Run(
                o => output.AppendLine(o),
                e => output.AppendLineFormat("ERROR: {0}", e),
                null,
                "git",
                @"log --graph --abbrev-commit --decorate --date=relative --all --remotes=*",
                repository.Info.Path);
        }
        catch (FileNotFoundException exception)
        {
            if (exception.FileName != "git")
                throw;

            output.AppendLine("Could not execute 'git log' due to the following error:");
            output.AppendLine(exception.ToString());
        }

        Trace.Write(output.ToString());
    }
Example #7
0
        public static string InspectServices(this Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider)
        {
            var builder           = new StringBuilder();
            var executingAssembly = Assembly.GetExecutingAssembly();

            foreach (var assemblyRef in executingAssembly.GetReferencedAssemblies())
            {
                if (assemblyRef.Name.StartsWith("Microsoft.VisualStudio.", "EnvDTE."))
                {
                    var assembly = Assembly.Load(assemblyRef);

                    foreach (var refType in assembly.GetTypes().Where(t => t.IsInterface && t.HasCustomAttribute <GuidAttribute>()))
                    {
                        var    attr         = refType.GetCustomAttribute <GuidAttribute>();
                        var    guid         = Guid.Parse(attr.Value);
                        var    IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
                        IntPtr pUnk;

                        if (ErrorHandler.Succeeded(serviceProvider.QueryService(ref guid, ref IID_IUnknown, out pUnk)))
                        {
                            var obj = Marshal.GetObjectForIUnknown(pUnk);

                            builder.AppendLineFormat("{0}\r\n\r\n{1}\r\n", refType.Name, obj.InspectVsComObject());
                        }
                    }
                }
            }

            return(builder.ToString());
        }
Example #8
0
        public void AppendLineFormat()
        {
            var sb = new StringBuilder();

            sb.AppendLineFormat("{0}", "Line1");
            Assert.Equal($"Line1{Environment.NewLine}", sb.ToString());
        }
Example #9
0
        /// <summary>
        /// String info for the manager
        /// </summary>
        /// <returns>The string info that the manager contains</returns>
        public override string ToString()
        {
            var Builder = new StringBuilder();

            Builder.AppendLineFormat("Formatters: {0}\r\nMessaging Systems: {1}", Formatters.ToString(x => x.Name), MessagingSystems.ToString(x => x.Value.Name));
            return(Builder.ToString());
        }
Example #10
0
        /// <summary>
        /// Outputs the profiler information as an HTML table
        /// </summary>
        /// <returns>Table containing profiler information</returns>
        public virtual string ToHTML()
        {
            CompileData();
            StringBuilder Builder = new StringBuilder();

            if (Level == 0)
            {
                Builder.Append("<table><tr><th>Called From</th><th>Function Name</th><th>Total Time</th><th>Max Time</th><th>Min Time</th><th>Average Time</th><th>Times Called</th></tr>");
            }
            Builder.AppendFormat(CultureInfo.InvariantCulture, "<tr><td>{0}</td><td>", CalledFrom);
            if (Level == 0)
            {
                Builder.AppendFormat(CultureInfo.InvariantCulture, "{0}</td><td>{1}ms</td><td>{2}ms</td><td>{3}ms</td><td>{4}ms</td><td>{5}</td></tr>", Function, 0, 0, 0, 0, Times.Count);
            }
            else
            {
                Builder.AppendFormat(CultureInfo.InvariantCulture, "{0}</td><td>{1}ms</td><td>{2}ms</td><td>{3}ms</td><td>{4}ms</td><td>{5}</td></tr>", Function, Times.Sum(), Times.Max(), Times.Min(), string.Format(CultureInfo.InvariantCulture, "{0:0.##}", Times.Average()), Times.Count);
            }
            foreach (Profiler Child in Children)
            {
                Builder.AppendLineFormat(Child.ToHTML());
            }
            if (Level == 0)
            {
                Builder.Append("</table>");
            }
            return(Builder.ToString());
        }
Example #11
0
        public static void DumpGraph(string workingDirectory, Action<string> writer = null, int? maxCommits = null)
        {
            var output = new StringBuilder();

            try
            {
                ProcessHelper.Run(
                    o => output.AppendLine(o),
                    e => output.AppendLineFormat("ERROR: {0}", e),
                    null,
                    "git",
                    @"log --graph --format=""%h %cr %d"" --decorate --date=relative --all --remotes=*" + (maxCommits != null ? string.Format(" -n {0}", maxCommits) : null),
                    //@"log --graph --abbrev-commit --decorate --date=relative --all --remotes=*",
                    workingDirectory);
            }
            catch (FileNotFoundException exception)
            {
                if (exception.FileName != "git")
                {
                    throw;
                }

                output.AppendLine("Could not execute 'git log' due to the following error:");
                output.AppendLine(exception.ToString());
            }

            if (writer != null) writer(output.ToString());
            else Trace.Write(output.ToString());
        }
Example #12
0
        private static string SetupSingleProperty(string ReturnValueName, IProperty Property)
        {
            Contract.Requires <ArgumentNullException>(Property != null, "Property");
            Contract.Requires <ArgumentNullException>(Property.Mapping != null, "Property.Mapping");
            Contract.Requires <ArgumentNullException>(Property.Mapping.ObjectType != null, "Property.Mapping.ObjectType");
            var Builder = new StringBuilder();

            Builder.AppendLineFormat("if(!{0}&&Session0!=null)", Property.DerivedFieldName + "Loaded")
            .AppendLine("{")
            .AppendLineFormat("{0}=Session0.LoadProperty<{1},{2}>(this,\"{3}\");",
                              Property.DerivedFieldName,
                              Property.Mapping.ObjectType.GetName(),
                              Property.Type.GetName(),
                              Property.Name)
            .AppendLineFormat("{0}=true;", Property.DerivedFieldName + "Loaded")
            .AppendLineFormat("if({0}!=null)", Property.DerivedFieldName)
            .AppendLine("{")
            .AppendLineFormat("({0} as INotifyPropertyChanged).PropertyChanged+=(x,y)=>NotifyPropertyChanged0(\"{1}\");", Property.DerivedFieldName, Property.Name)
            .AppendLine("}")
            .AppendLine("}")
            .AppendLineFormat("{0}={1};",
                              ReturnValueName,
                              Property.DerivedFieldName);
            return(Builder.ToString());
        }
Example #13
0
        /// <summary>
        /// Setups the specified return value name.
        /// </summary>
        /// <param name="returnValueName">Name of the return value.</param>
        /// <param name="method">The method.</param>
        /// <param name="mapping">The mapping.</param>
        /// <param name="builder">The builder.</param>
        public void Setup(string returnValueName, MethodInfo method, IMapping mapping, StringBuilder builder)
        {
            if (mapping is null)
            {
                return;
            }
            var Property = mapping.MapProperties.Find(x => x.Name == method.Name.Replace("get_", string.Empty, StringComparison.Ordinal));

            if (Property is null)
            {
                return;
            }

            builder.AppendLineFormat("if(!{0}&&!(Session0 is null))", Property.InternalFieldName + "Loaded")
            .AppendLine("{")
            .AppendLineFormat("{0}=Session0.LoadProperty<{1},{2}>(this,\"{3}\");",
                              Property.InternalFieldName,
                              Property.ParentMapping.ObjectType.GetName(),
                              Property.TypeName,
                              Property.Name)
            .AppendLineFormat("{0}=true;", Property.InternalFieldName + "Loaded")
            .AppendLineFormat("if(!({0} is null))", Property.InternalFieldName)
            .AppendLine("{")
            .AppendLineFormat("({0} as INotifyPropertyChanged).PropertyChanged+=(x,y)=>NotifyPropertyChanged0(\"{1}\");", Property.InternalFieldName, Property.Name)
            .AppendLine("}")
            .AppendLine("}")
            .AppendLineFormat("{0}={1};",
                              returnValueName,
                              Property.InternalFieldName);
        }
        /// <summary>
        /// Generates this instance.
        /// </summary>
        /// <param name="assembliesUsing">The assemblies using.</param>
        /// <param name="aspects">The aspects.</param>
        /// <returns>The string version of this property</returns>
        public string Generate(List <Assembly> assembliesUsing, IEnumerable <IAspect> aspects)
        {
            aspects = aspects ?? new List <IAspect>();
            var        Builder       = new StringBuilder();
            MethodInfo GetMethodInfo = PropertyInfo.GetGetMethod();
            MethodInfo SetMethodInfo = PropertyInfo.GetSetMethod();

            if (assembliesUsing != null)
            {
                assembliesUsing.AddIfUnique(GetAssemblies(PropertyInfo.PropertyType));
            }
            if (GetMethodInfo != null && SetMethodInfo != null)
            {
                Builder.AppendLineFormat(@"
        {0}
        {{
            get
            {{
                {1}
            }}
            set
            {{
                {2}
            }}
        }}

        {3}",
                                         ToString(),
                                         SetupMethod(DeclaringType, GetMethodInfo, aspects),
                                         SetupMethod(DeclaringType, SetMethodInfo, aspects),
                                         CreateBackingField(GetMethodInfo.IsAbstract | DeclaringType.IsInterface));
            }
            else if (GetMethodInfo != null)
            {
                Builder.AppendLineFormat(@"
        {0}
        {{
            get
            {{
                {1}
            }}
        }}",
                                         ToString(),
                                         SetupMethod(DeclaringType, GetMethodInfo, aspects));
            }
            return(Builder.ToString());
        }
Example #15
0
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.AppendLineFormat("Id: {0}", Id);
            sb.AppendLineFormat("FirstName: {0}", FirstName);
            sb.AppendLineFormat("LastName: {0}", LastName);
            sb.AppendLineFormat("EmailAddress: {0}", EmailAddress);
            foreach (var language in Languages)
            {
                sb.AppendLineFormat("Language: {0}", language.LanguageCode);
            }

            sb.AppendLineFormat("Registration: {0}-{1}-{2}", RegistrationDate.Year, RegistrationNumber,
                RegistrationSuffix);

            return sb.ToString();
        }
Example #16
0
 public static StringBuilder AppendLineIfTrue(this StringBuilder builder, bool condition, string format, params object[] args)
 {
     if (condition)
     {
         builder.AppendLineFormat(format, args);
     }
     return(builder);
 }
Example #17
0
        public void AppendLineFormat2()
        {
            var sb = new StringBuilder();

            sb.AppendLineFormat(CultureInfo.CurrentCulture, "{0} {1}", "foo", "bar");

            Assert.Equal(string.Format("foo bar{0}", Environment.NewLine), sb.ToString());
        }
        public override List <SynchronizationItem> GetCreateItems()
        {
            if (DatabaseObject.PrincipalType == PrincipalType.DatabaseRole)
            {
                var sb = new StringBuilder();
                sb.AppendLineFormat(@"CREATE ROLE [{0}] {1}", DatabaseObject.PrincipalName, DatabaseObject.Owner == null ? string.Empty :
                                    string.Format("AUTHORIZATION [{0}]", DatabaseObject.Owner.ObjectName));
                foreach (var dp in DatabaseObject.ChildMembers)
                {
                    sb.AppendLineFormat("ALTER ROLE [{0}] ADD MEMBER [{1}]", DatabaseObject.ObjectName, dp.ObjectName);
                }

                return(getStandardItems(sb.ToString()));
            }

            return(getStandardItems(getLoginScript(true)));
        }
        protected override StringBuilder Respond()
        {
            var sb = new StringBuilder();

            sb.AppendLineFormat("Sendmail Result: {0}", Mailer.SendSupportMail(Recipient, "Test Subject", "Test body"));
            sb.AppendLine("Done");
            return(sb);
        }
Example #20
0
        public void StringBuilder_AppendLineFormat()
        {
            var A         = "A";
            var B         = "B";
            var C         = "C";
            var format    = "{0}{1}{2}";
            var delimiter = ";;";
            var expected  = "ABC;;CBA;;BCA";

            var sb = new StringBuilder();

            sb.AppendLineFormat(format, new object[] { A, B, C }, delimiter);
            sb.AppendLineFormat(format, new object[] { C, B, A }, delimiter);
            sb.AppendLineFormat(format, new object[] { B, C, A }, delimiter);

            Assert.AreEqual(expected, sb.ToString());
        }
Example #21
0
        public static void AppendClass(this StringBuilder builder, string name, int indent = 0, string modifier = "", params string[] summaryArray)
        {
            builder.AppendSummary(indent, summaryArray);

            var indentString = GetIndentString(indent);

            builder.AppendLineFormat("{0}public {1}class {2}", indentString, string.IsNullOrEmpty(modifier) ? "" : modifier + " ", name);
            builder.AppendLine(indentString + "{");
        }
Example #22
0
 public static StringBuilder AppendIndentedLineFormat(
     this StringBuilder stringBuilder,
     int tabulations,
     string format,
     params object[] args)
 {
     stringBuilder.AppendLineFormat(new string('\t', tabulations) + format, args);
     return(stringBuilder);
 }
        private static void LogProblem(Exception exception, string detailedMessage, string levelOfProblem)
        {
            var sb = new StringBuilder();

            sb.AppendLine("*** ProblemReportApi is about to report:");
            if (exception != null)
            {
                sb.AppendLineFormat("    exception = {0}", exception.ToString());
            }
            if (!string.IsNullOrWhiteSpace(detailedMessage))
            {
                sb.AppendLineFormat("   detailed message = {0}", detailedMessage);
            }
            sb.AppendLineFormat("    level of problem = {0}", levelOfProblem);
            var msg = sb.ToString();

            Logger.WriteEvent(msg);
        }
        private static MethodDeclarationSyntax CreateMethodDeclarationSyntax_ToString(string @string)
        {
            var builder = new StringBuilder();

            builder.AppendLine("public override string ToString() {");
            builder.AppendLineFormat("return \"{0}\";", @string);
            builder.AppendLine("}");
            return((MethodDeclarationSyntax)ParseMemberDeclaration(builder.ToString()) !);
        }
Example #25
0
        internal void DumpInfo()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Start of error dump");
            builder.AppendLineFormat("Monitors: \n {0}", string.Join("\n", _monitors.Select(x => x.ToString()).ToArray()));
            builder.AppendLine("End of error dump");

            _logger.LogMessage(builder.ToString());
        }
Example #26
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            var Builder = new StringBuilder();

            foreach (var Key in Keys)
            {
                Builder.AppendLineFormat("{0}:{{{1}}}", Key.ToString(), Items[Key].ToString(x => x.ToString()));
            }
            return(Builder.ToString());
        }
Example #27
0
        protected override StringBuilder Respond()
        {
            var sb = new StringBuilder();

            sb.AppendLine("UNICN START");
            sb.AppendLineFormat("time={0}", DateTime.Now.ToUnixDateTimeString());
            sb.AppendLine("UNICN END");

            return(sb);
        }
Example #28
0
        private string SetupFields(Type Type)
        {
            Fields = new List <IProperty>();
            var Builder = new StringBuilder();

            if (Mapper[Type] != null)
            {
                foreach (IMapping Mapping in Mapper[Type])
                {
                    foreach (IProperty Property in Mapping.Properties.Where(x => !Fields.Contains(x)))
                    {
                        Fields.Add(Property);
                        Builder.AppendLineFormat("private {0} {1};", Property.TypeName, Property.DerivedFieldName);
                        Builder.AppendLineFormat("private bool {0};", Property.DerivedFieldName + "Loaded");
                    }
                }
            }
            return(Builder.ToString());
        }
        /// <summary>
        /// The SaveFileDialog must run on a STA thread.
        /// </summary>
        private static void MakeLetterAndWordList(string jsonSettings, string allWords)
        {
            // load the settings
            var settings = JsonConvert.DeserializeObject <ReaderToolsSettings>(jsonSettings);

            // format the output
            var sb = new StringBuilder();

            sb.AppendLineFormat("Letter and word list for making decodable readers in {0}", CurrentBook.CollectionSettings.Language1Name);

            var idx = 1;

            foreach (var stage in settings.Stages)
            {
                sb.AppendLine();
                sb.AppendLineFormat("Stage {0}", idx++);
                sb.AppendLine();
                sb.AppendLineFormat("Letters: {0}", stage.Letters.Replace(" ", ", "));
                sb.AppendLine();
                sb.AppendLineFormat("New Sight Words: {0}", stage.SightWords.Replace(" ", ", "));

                Array.Sort(stage.Words);
                sb.AppendLineFormat("Decodable Words: {0}", string.Join(" ", stage.Words));
                sb.AppendLine();
            }

            // complete word list
            var words = allWords.Split(new[] { '\t' });

            Array.Sort(words);
            sb.AppendLine();
            sb.AppendLine("Complete Word List");
            sb.AppendLine(string.Join(" ", words));

            // write the file
            var fileName = Path.Combine(CurrentBook.CollectionSettings.FolderPath, "Decodable Books Letters and Words.txt");

            File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);

            // open the file
            PathUtilities.OpenFileInApplication(fileName);
        }
Example #30
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("IPAddress={0}", IPAddress);

            //RR
            base.ToString(sb);

            return(sb.ToString());
        }
Example #31
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("NSHost={0}", NSHost);

            //RR
            base.ToString(sb);

            return(sb.ToString());
        }
Example #32
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("PTRDomainName={0}", PTRDomainName);

            //RR
            base.ToString(sb);

            return(sb.ToString());
        }
Example #33
0
        private string GetPathToSingleHtmlFileOrReport(string folder)
        {
            var candidates = GetHtmFileCandidates(folder);

            if (candidates.Count() == 1)
            {
                return(candidates.First());
            }
            else
            {
                var msg = new StringBuilder();
                msg.AppendLineFormat("There should only be a single htm(l) file in each folder ({0}). [not counting configuration.html or ReadMe-*.htm]:", folder);
                foreach (var f in candidates)
                {
                    msg.AppendLineFormat("    {0}", f);
                }
                ErrorReport.NotifyUserOfProblem(msg.ToString());
                throw new ApplicationException();
            }
        }
Example #34
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("DescriptiveText={0}", DescriptiveText);

            //RR
            base.ToString(sb);

            return(sb.ToString());
        }
Example #35
0
        public void AppendLineFormat()
        {
            // Type
            var @this = new StringBuilder();

            // Exemples
            @this.AppendLineFormat("{0}{1}", "Fizz", "Buzz"); // return "FizzBuzz";

            // Unit Test
            Assert.AreEqual("FizzBuzz" + Environment.NewLine, @this.ToString());
        }
Example #36
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("MRMailbox={0}", MRMailbox);

            //RR
            base.ToString(sb);

            return(sb.ToString());
        }
Example #37
0
        private static void GetAppSettingProperty(StringBuilder stringBuilder, XmlAppSetting xmlAppSetting, SettingsClass settingsClassSettings)
        {
            const string indentation          = "    ";
            string       doubleIndentation    = string.Concat(indentation, indentation);
            string       trippleIndentation   = string.Concat(doubleIndentation, indentation);
            string       quadrupleIndentation = string.Concat(doubleIndentation, doubleIndentation);
            string       escapedSettingName   = xmlAppSetting.Name.Replace(":", "").Replace(".", "").CapitaliseFirstLetter();

            stringBuilder.AppendLineFormat("{0}public static {1} {2} {{ get {{ return GetSetting({3}.{2}); }} }}", doubleIndentation, xmlAppSetting.Type, escapedSettingName, settingsClassSettings.Name.Replace(".cs", ""));
            stringBuilder.AppendLine();
        }
        public void AppendLineFormat()
        {
            // Type
            var @this = new StringBuilder();

            // Exemples
            @this.AppendLineFormat("{0}{1}", "Fizz", "Buzz"); // return "FizzBuzz";

            // Unit Test
            Assert.AreEqual("FizzBuzz" + Environment.NewLine, @this.ToString());
        }
Example #39
0
        public string ToConfigurationFile()
        {
            StringBuilder sb    = new StringBuilder();
            var           type  = this.GetType();
            var           props = type.GetProperties();

            foreach (var prop in props)
            {
                sb.AppendLineFormat("{0}={1}", prop.Name, prop.GetValue(this, null));
            }

            var records = this.GetRecords().OrderBy(i => i.RecordTypeText);

            var soarecord = records.FirstOrDefault(i => i.RecordType == typeof(DNSManagement.RR.SOAType));

            if (soarecord != null)
            {
                sb.AppendLine("SOA Record");
                sb.AppendLine(soarecord.TextRepresentation);
            }

            var rectype = "";

            foreach (var rec in records)
            {
                if (rec == soarecord)
                {
                    continue;
                }

                if (rectype != rec.RecordTypeText)
                {
                    rectype = rec.RecordTypeText;
                    sb.AppendLineFormat("{0} Records:", rec.RecordTypeText);
                }

                sb.AppendLineFormat(rec.TextRepresentation);
            }

            return(sb.ToString());
        }
		public string ParseStatement(AnalyzeContext context)
		{
			var queryPropertyName = context.QueryProperty.Name;
			var modelPropertyName = context.ModelProperty.Name;
			var navigation = new List<string>(context.Navigations) { modelPropertyName };
			var builder = new StringBuilder();
			builder.AppendLineFormat("if({0} != null)", context.QueryParamName + "." + queryPropertyName)
			       .AppendLine("{")
				   .AppendLineFormat("{0}={0}.Where(o=>o.{1}.Contains({2}));", context.SourceParamName, string.Join(".", navigation), context.QueryParamName + "." + queryPropertyName)
			       .AppendLine("}");
			return builder.ToString();
		}
Example #41
0
        public virtual string ToConfigurationFile()
        {
            StringBuilder sb = new StringBuilder();

            Type type = this.GetType();
            var props = type.GetProperties();
            foreach (var prop in props)
            {
                sb.AppendLineFormat("{0}={1}", prop.Name, prop.GetValue(this, null));
            }

            return sb.ToString();
        }
        public void AppendLineFormatTestCase1()
        {
            var value0 = RandomValueEx.GetRandomString();

            var sb = new StringBuilder();
            sb.AppendLine( "Line 1" );
            sb.AppendLineFormat( "Test: {0}", value0 );
            sb.AppendLine( "Line 3" );

            var expected = "Line 1\r\nTest: {0}\r\nLine 3\r\n".F( value0 );
            var actual = sb.ToString();
            Assert.AreEqual( expected, actual );
        }
        /// <summary>
        /// Writes the output header.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="programName">Name of the program.</param>
        public void WriteOutputHeader(TextWriter writer, string programName)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(programName);
            sb.AppendLine();
            sb.AppendLineFormat("Today's Date: {0}", context.TodaysDate.ToString(Constants.DATE_FORMAT));
            sb.AppendLineFormat("Start Date: {0}", context.StartDate.ToString(Constants.DATE_FORMAT));
            sb.AppendLineFormat("Target End Date: {0}", context.TargetEndDate.ToString(Constants.DATE_FORMAT));
            sb.AppendLineFormat("Balance: {0}", context.Balance.ToString("c"));
            sb.AppendLineFormat("Interest Rate: {0}%", context.InterestRate.ToString("n2"));
            sb.AppendLineFormat("Min. Repayment Amount: {0}", context.MinRepaymentAmount.ToString("c"));
            sb.AppendLineFormat("Min. Repayment Day: {0}", context.MinRepaymentDay);
            sb.AppendLineFormat("Extra Repayment Amount: {0}", context.ExtraRepaymentAmount.ToString("c"));
            sb.AppendLineFormat("Extra Repayment Day: {0}", context.ExtraRepaymentDay);
            sb.AppendLine();
            sb.AppendLine();
            writer.Write(sb.ToString());
        }
 /// <summary>
 /// Generates the specified assemblies using.
 /// </summary>
 /// <param name="assembliesUsing">The assemblies using.</param>
 /// <param name="aspects">The aspects.</param>
 /// <returns></returns>
 public string Generate(List<Assembly> assembliesUsing, IEnumerable<IAspect> aspects)
 {
     var Builder = new StringBuilder();
     Builder.AppendLineFormat(@"
         public {0}()
             {1}
         {{
             {2}
         }}",
         DeclaringType.Name + "Derived",
         DeclaringType.IsInterface ? "" : ":base()",
         aspects.ToString(x => x.SetupDefaultConstructor(DeclaringType)));
     return Builder.ToString();
 }
Example #45
0
    public static void DumpGraph(this IRepository repository)
    {
        var output = new StringBuilder();

        ProcessHelper.Run(
            o => output.AppendLine(o),
            e => output.AppendLineFormat("ERROR: {0}", e),
            null,
            "git",
            @"log --graph --abbrev-commit --decorate --date=relative --all",
            repository.Info.Path);

        Trace.Write(output.ToString());
    }
        public void Post(string formName)
        {
            if (string.IsNullOrEmpty(formName))
                throw new ArgumentNullException("formName");

            var formBuilder = new StringBuilder();
            formBuilder.AppendLine("<html><head>");
            formBuilder.AppendLineFormat("</head><body onload=\"document.{0}.submit()\">", formName);
            formBuilder.AppendLineFormat("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", formName, Method.ToString(), Url);
            for (int i = 0; i < _inputValues.Keys.Count; i++) {
                formBuilder.AppendLineFormat("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">",
                    HttpUtility.HtmlEncode(_inputValues.Keys[i]), HttpUtility.HtmlEncode(_inputValues[_inputValues.Keys[i]]));
            }
            formBuilder.AppendLine("</form>");
            formBuilder.AppendLine("</body></html>");

            #if DEBUG
                Debug.Write(formBuilder.ToString());
            #endif

            _httpContext.Response.Clear();
            _httpContext.Response.Write(formBuilder.ToString());
            _httpContext.Response.End();
        }
Example #47
0
		public string ParseStatement(AnalyzeContext context)
		{
			var queryPropertyName = context.QueryProperty.Name;
			var modelPropertyName = context.ModelProperty.Name;
			var navigation = new List<string>(context.Navigations) { modelPropertyName };
			var builder = new StringBuilder();
			var modelPropertyType = context.ModelProperty.PropertyType;

			builder.AppendLineFormat("if({0}.{1} != null)", context.QueryParamName, queryPropertyName)
			       .AppendLine("{");
			if (modelPropertyType.IsGenericType)
			{
				builder.AppendLineFormat("{0} = {0}.Where(o=>{3}.{1}.Contains(o.{2}.Value));", context.SourceParamName, queryPropertyName,
				                         string.Join(".", navigation), context.QueryParamName);
			}
			else
			{
				builder.AppendLineFormat("{0} = {0}.Where(o=>{3}.{1}.Contains(o.{2}));", context.SourceParamName, queryPropertyName,
										 string.Join(".", navigation), context.QueryParamName);
			}
			       
			builder.AppendLine("}");
			return builder.ToString();
		}
Example #48
0
		public string ParseStatement(AnalyzeContext context)
		{
			var propertyName = context.QueryProperty.Name;
			//if(Id != null)
			//{
			//	  source = source.Where(o=>o.Id == Id);
			//}
			var navigation = new List<string>(context.Navigations) {propertyName};
			var builder = new StringBuilder();
			builder.AppendLineFormat("if({0}.{1} != null)", context.QueryParamName, propertyName)
			       .AppendLine("{")
			       .AppendLineFormat("{0} = {0}.Where(o=>o.{1} == {2}.{3});", context.SourceParamName,
			                         string.Join(".", navigation),
			                         context.QueryParamName, propertyName)
			       .AppendLine("}");
			return builder.ToString();
		}
 public static string ToString(this Exception exception, string prefix, string suffix = "")
 {
     if (exception == null)
         return "";
     var builder = new StringBuilder();
     builder.AppendLine(prefix);
     try
     {
         builder.AppendLineFormat("Exception: {0}", exception.Message);
         builder.AppendLineFormat("Exception Type: {0}", exception.GetType().FullName);
         foreach (var Object in exception.Data)
             builder.AppendLineFormat("Data: {0}:{1}", Object, exception.Data[Object]);
         builder.AppendLineFormat("StackTrace: {0}", exception.StackTrace);
         builder.AppendLineFormat("Source: {0}", exception.Source);
         builder.AppendLineFormat("TargetSite: {0}", exception.TargetSite);
         builder.Append(exception.InnerException.ToString(prefix, suffix));
     }
     catch
     {
     }
     builder.AppendLine(suffix);
     return builder.ToString();
 }
 /// <summary>
 /// Converts the exception to a string and appends the specified prefix/suffix (used for logging)
 /// </summary>
 /// <param name="Exception">Exception to convert</param>
 /// <param name="Prefix">Prefix</param>
 /// <param name="Suffix">Suffix</param>
 /// <returns>The exception as a string</returns>
 public static string ToString(this Exception Exception, string Prefix, string Suffix = "")
 {
     if (Exception == null)
         return "";
     var Builder = new StringBuilder();
     Builder.AppendLine(Prefix);
     try
     {
         Builder.AppendLineFormat("Exception: {0}", Exception.Message);
         Builder.AppendLineFormat("Exception Type: {0}", Exception.GetType().FullName);
         if (Exception.Data != null)
         {
             foreach (object Object in Exception.Data)
                 Builder.AppendLineFormat("Data: {0}:{1}", Object, Exception.Data[Object]);
         }
         Builder.AppendLineFormat("StackTrace: {0}", Exception.StackTrace);
         Builder.AppendLineFormat("Source: {0}", Exception.Source);
         Builder.AppendLineFormat("TargetSite: {0}", Exception.TargetSite);
         Builder.Append(Exception.InnerException.ToString(Prefix, Suffix));
     }
     catch { }
     Builder.AppendLine(Suffix);
     return Builder.ToString();
 }
		 /// ------------------------------------------------------------------------------------
		private void SetMetsPairsForFiles()
		{
			if (_fileLists.Any())
			{
				string value = GetMode();
				if (value != null)
					_metsPairs.Add(value);

				if (!IsMetadataPropertySet(MetadataProperties.Files))
				{
					// Return JSON array of files with their descriptions.
					_metsPairs.Add(JSONUtils.MakeArrayFromValues(kSourceFilesForMets,
						GetSourceFilesForMetsData(_fileLists)));
					MarkMetadataPropertyAsSet(MetadataProperties.Files);
				}

				if (ImageCount > 0)
					_metsPairs.Add(JSONUtils.MakeKeyValuePair(kImageExtent, string.Format("{0} image{1}.",
						_imageCount.ToString(CultureInfo.InvariantCulture),
						(_imageCount == 1) ? "" : "s")));

				var avExtent = new StringBuilder();
				const string delimiter = "; ";

				if (ShowRecordingCountNotLength)
				{
					if (_audioCount > 0)
						avExtent.AppendLineFormat("{0} audio recording file{1}", new object[] { _audioCount, (_audioCount == 1) ? "" : "s" }, delimiter);

					if (_videoCount > 0)
						avExtent.AppendLineFormat("{0} video recording file{1}", new object[] { _videoCount, (_videoCount == 1) ? "" : "s" }, delimiter);

					SetAudioVideoExtent(avExtent + ".");
				}
			}
		}
Example #52
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("CollectionId={0}", CollectionId);
            sb.AppendLineFormat("CollectionName={0}", CollectionName);
            sb.AppendLineFormat("DnsServerName={0}", DnsServerName);
            sb.AppendLineFormat("Name={0}", Name);
            sb.AppendLineFormat("StringValue={0}", StringValue);
            sb.AppendLineFormat("Value={0}", Value);

            return sb.ToString();
        }
Example #53
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("InternetAddress={0}", InternetAddress);
            sb.AppendLineFormat("IPProtocol={0}", IPProtocol);
            sb.AppendLineFormat("Services={0}", Services);

            //RR
            base.ToString(sb);

            return sb.ToString();
        }
Example #54
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("CacheTimeout={0}", CacheTimeout);
            sb.AppendLineFormat("LookupTimeout={0}", LookupTimeout);
            sb.AppendLineFormat("MappingFlag={0}", MappingFlag);
            sb.AppendLineFormat("ResultDomain={0}", ResultDomain);

            //RR
            base.ToString(sb);

            return sb.ToString();
        }
 /// <summary>
 /// Outputs the information to a table
 /// </summary>
 /// <returns>an html string containing the information</returns>
 public override string ToString()
 {
     CompileData();
     StringBuilder Builder = new StringBuilder();
     Level.Times(x => { Builder.Append("\t"); });
     Builder.AppendLineFormat("{0} ({1} ms)", Function, Times.Sum());
     foreach (Profiler Child in Children)
     {
         Builder.AppendLineFormat(Child.ToString());
     }
     return Builder.ToString();
 }
 /// <summary>
 /// Outputs the profiler information as an HTML table
 /// </summary>
 /// <returns>Table containing profiler information</returns>
 public virtual string ToHTML()
 {
     CompileData();
     StringBuilder Builder = new StringBuilder();
     if (Level == 0)
         Builder.Append("<table><tr><th>Called From</th><th>Function Name</th><th>Total Time</th><th>Max Time</th><th>Min Time</th><th>Average Time</th><th>Times Called</th></tr>");
     Builder.AppendFormat(CultureInfo.InvariantCulture, "<tr><td>{0}</td><td>", CalledFrom);
     if (Level == 0)
         Builder.AppendFormat(CultureInfo.InvariantCulture, "{0}</td><td>{1}ms</td><td>{2}ms</td><td>{3}ms</td><td>{4}ms</td><td>{5}</td></tr>", Function, 0, 0, 0, 0, Times.Count);
     else
         Builder.AppendFormat(CultureInfo.InvariantCulture, "{0}</td><td>{1}ms</td><td>{2}ms</td><td>{3}ms</td><td>{4}ms</td><td>{5}</td></tr>", Function, Times.Sum(), Times.Max(), Times.Min(), string.Format(CultureInfo.InvariantCulture, "{0:0.##}", Times.Average()), Times.Count);
     foreach (Profiler Child in Children)
     {
         Builder.AppendLineFormat(Child.ToHTML());
     }
     if (Level == 0)
         Builder.Append("</table>");
     return Builder.ToString();
 }
 /// <summary>
 /// String info for the manager
 /// </summary>
 /// <returns>The string info that the manager contains</returns>
 public override string ToString()
 {
     var Builder = new StringBuilder();
     Builder.AppendLineFormat("Compressors: {0}", Compressors.OrderBy(x => x.Key).ToString(x => x.Key, ", "));
     return Builder.ToString();
 }
Example #58
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("NSHost={0}", NSHost);

            //RR
            base.ToString(sb);

            return sb.ToString();
        }
        private static string RunYuiCompressor(ICompressor compressor, IList<string> pSourceFilePaths,
                                               string pOutputFilePath, bool pCompressFileContents = true,
                                               string pHeaderComment = null, bool pIncludeGenDateInHeaderComment = true)
        {
            compressor.CompressionType = pCompressFileContents ? CompressionType.Standard : CompressionType.None;
            compressor.LineBreakPosition = 0; //Default is -1 (never add a line break)... 0 (zero) means add a line break after every semicolon (good for debugging)
            var sbSourceText = new StringBuilder();
            var sbHeadComment = new StringBuilder();

            sbHeadComment.AppendLine("/*");
            sbHeadComment.AppendLine();

            if (pHeaderComment != null)
                sbHeadComment.AppendLine(pHeaderComment);
            if (pIncludeGenDateInHeaderComment)
                sbHeadComment.AppendLineFormat(" Generated: {0}", DateTime.Now);

            sbHeadComment.AppendLine(" Merged File List:");
            var postpendLength = pSourceFilePaths.Select(Path.GetFileName).Max(x => x.Length) + 4;

            string sourceFilePath = null;
            foreach (var filepath in pSourceFilePaths)
            {
                if (string.IsNullOrWhiteSpace(sourceFilePath))
                    sourceFilePath = Path.GetDirectoryName(filepath);

                var contentsOrig = io.ReadASCIITextFile(filepath);
                var contentsMin = compressor.Compress(contentsOrig);

                var sizeNote = string.Format("[Orig: {0} KB", contentsOrig.Length / 1024);
                if (pCompressFileContents)
                    sizeNote += string.Format(", Min'd: {0} KB", contentsMin.Length / 1024);
                sizeNote += "]";

                var fileComment = string.Format("{0} : {1}", str.Postpend(Path.GetFileName(filepath), postpendLength, ' '), sizeNote);
                sbHeadComment.AppendLineFormat(" -> {0}", fileComment);

                sbSourceText.AppendLine(contentsMin); //concat the file contents
            }

            sbHeadComment.AppendLine();
            sbHeadComment.AppendLine("*/");
            sbHeadComment.AppendLine();

            if (pSourceFilePaths.Count == 1 && !str.ToString(Path.GetFileName(pOutputFilePath)).Contains(".")) //single file w/o a diff filename
                io.WriteTextFile(Path.Combine(pOutputFilePath, Path.GetFileName(pSourceFilePaths.First())), sbHeadComment.ToString() + sbSourceText.ToString());
            else
                io.WriteTextFile(pOutputFilePath, sbHeadComment.ToString() + sbSourceText.ToString()); //bundled file or file w/a diff filename

            return sbHeadComment.ToString();
        }
Example #60
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLineFormat("IPv6Address={0}", IPv6Address);

            //RR
            base.ToString(sb);

            return sb.ToString();
        }