示例#1
0
        public static string ToGEOJson(this DataTable dt, string latColumn, string lngColumn)
        {
            StringBuilder result = new StringBuilder();
            StringBuilder line;

            foreach (DataRow r in dt.Rows)
            {
                line = new StringBuilder();

                foreach (DataColumn col in dt.Columns)
                {
                    if (col.ColumnName != latColumn && col.ColumnName != lngColumn)
                    {
                        string cValue = r[col].ToString();
                        line.Append(",\"" + col.ColumnName + "\":\"" + cValue.Replace("\"","\\\"") + "\"");
                    }

                }

                result.Append(
                    ",{\"type\":\"Feature\",\"geometry\": {\"type\":\"Point\", \"coordinates\": [" + r[lngColumn].ToString() + "," + r[latColumn].ToString() + "]},\"properties\":{" +
                    line.ToString().Substring(1) + "}}");

            }

            string geojson = "{\"type\": \"FeatureCollection\",\"features\": [" +
                result.ToString().Substring(1) + "]}";

            return geojson;
        }
示例#2
0
        public static string GetXPath(XmlNode node)
        {
            System.StringBuilder builder = new System.StringBuilder();
            while (node != null)
            {
                switch (node.NodeType)
                {
                case XmlNodeType.Attribute:
                    builder.Insert(0, "/@" + node.Name);
                    node = ((XmlAttribute)node).OwnerElement;
                    break;

                case XmlNodeType.Element:
                    if (node.Attributes["PropertyName"] != null)
                    {
                        builder.Insert(0, "/" + node.Name + "[@PropertyName='" + node.Attributes["PropertyName"].Value + "']");
                    }
                    else
                    {
                        int index = Utility.FindElementIndex((XmlElement)node);
                        builder.Insert(0, "/" + node.Name + "[" + index + "]");
                    }
                    node = node.ParentNode;
                    break;

                case XmlNodeType.Document:
                    return(builder.ToString());

                default:
                    throw new ArgumentException("Only elements and attributes are supported");
                }
            }
            throw new ArgumentException("Node was not in a document");
        }
示例#3
0
        protected internal override int decodeMiddle(BitArray row, int[] startRange, StringBuilder result)
        {
            int[] counters = decodeMiddleCounters;
            counters[0] = 0;
            counters[1] = 0;
            counters[2] = 0;
            counters[3] = 0;
            int end = row.Size;
            int rowOffset = startRange[1];

            for (int x = 0; x < 4 && rowOffset < end; x++)
            {
                int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
                result.Append(Int32Extend.ToChar(CharExtend.ToInt32('0') + bestMatch));
                for (int i = 0; i < counters.Length; i++)
                {
                    rowOffset += counters[i];
                }
            }

            int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN);
            rowOffset = middleRange[1];

            for (int x = 0; x < 4 && rowOffset < end; x++)
            {
                int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
                result.Append(Int32Extend.ToChar(CharExtend.ToInt32('0') + bestMatch));
                for (int i = 0; i < counters.Length; i++)
                {
                    rowOffset += counters[i];
                }
            }

            return rowOffset;
        }
示例#4
0
 public string GetUsage()
 {
     var usage = new StringBuilder();
     usage.AppendLine("Process Scheduler");
     usage.AppendLine("-i, --input [filename]");
     return usage.ToString();
 }
		public void DisplayData(object[] data)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append(view.uiHeaderTemplateHolder.InnerHTML.Unescape());
			if (data != null)
			{
				string currentGroupByFieldValue = "";
				for (int i = 0; i < data.Length; i++)
				{
					Dictionary<object, object> dataItem = (Dictionary<object, object>)data[i];
					if (GroupByField != "")
					{
						if (currentGroupByFieldValue != (string) dataItem[GroupByField])
						{
							currentGroupByFieldValue = (string) dataItem[GroupByField];
							sb.Append("<div class='ClientSideRepeaterGroupHeader'>" + currentGroupByFieldValue + "</div>");
						}
					}
					sb.Append(this.view.uiItemTemplate.Render(dataItem));
					if (i + 1 < data.Length)
					{
						sb.Append(view.uiBetweenTemplateHolder.InnerHTML.Unescape());
					}
				}
			}
			sb.Append(view.uiFooterTemplateHolder.InnerHTML.Unescape());
			view.uiContent.InnerHTML = sb.ToString();
		}
示例#6
0
        public void ProcessRequest(HttpContext context)
        {
            string actionName, controllerName, conditionName, conditionValue;

            actionName     = context.Request.QueryString["Action"];
            controllerName = context.Request.QueryString["Controller"];
            conditionName  = context.Request.QueryString["Name"];
            conditionValue = context.Request.QueryString["Value"];
            bool addConditionalStatement = !conditionName.IsNullEmptyOrWhiteSpace();

            System.StringBuilder scriptContent = this.GetType().Assembly.GetManifestResourceStream("").ToString();
            if (addConditionalStatement)
            {
                scriptContent.Replace(ConditionalStartBlock, ConditionStartStatement);
                scriptContent.Replace(ConditionalEndBlock, ConditionalEndStatement);
                scriptContent.Replace(ConditionName, conditionName);
                scriptContent.Replace(ConditionValue, conditionValue);
            }
            else
            {
                scriptContent.Replace(ConditionalStartBlock, string.Empty);
                scriptContent.Replace(ConditionalEndBlock, string.Empty);
            }
            context.Response.Clear();
            context.Response.ContentType = "text/javascript";
            context.Response.Write(scriptContent);
            context.Response.Flush();
            context.Response.End();
        }
        /// <summary>
        /// Converts the query string to an string.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="separator"></param>
        /// <param name="nameValueSeparator"></param>
        /// <returns></returns>
        public string ConvertQueryHashtable(Hashtable data, string separator, string nameValueSeparator)
        {
            // QueryString
            StringBuilder queryString = new StringBuilder();

            foreach ( DictionaryEntry de in data )
            {
                ArrayList itemValues = (ArrayList)de.Value;
                string key = (string)de.Key;

                if ( nameValueSeparator.Length == 0 )
                {
                    //queryString.Append(key);
                    queryString.Append(separator);
                    queryString.Append(itemValues[0]);
                }
                else
                {
                    foreach ( string s in itemValues )
                    {
                        queryString.Append(key);
                        queryString.Append(nameValueSeparator);
                        queryString.Append(s);
                        queryString.Append(separator);
                    }
                }
            }

            return queryString.ToString();
        }
示例#8
0
 public static string ReverseString(string s)
 {
     StringBuilder sb = new StringBuilder();
     for(int i = s.Length; i > 0; i--){
     sb.Append(s[i-1]);
     }
 }
示例#9
0
        internal static string SerializeForm(FormElement form) {
            DOMElement[] formElements = form.Elements;
            StringBuilder formBody = new StringBuilder();

            int count = formElements.Length;
            for (int i = 0; i < count; i++) {
                DOMElement element = formElements[i];
                string name = (string)Type.GetField(element, "name");
                if (name == null || name.Length == 0) {
                    continue;
                }

                string tagName = element.TagName.ToUpperCase();

                if (tagName == "INPUT") {
                    InputElement inputElement = (InputElement)element;
                    string type = inputElement.Type;
                    if ((type == "text") ||
                        (type == "password") ||
                        (type == "hidden") ||
                        (((type == "checkbox") || (type == "radio")) && (bool)Type.GetField(element, "checked"))) {

                        formBody.Append(name.EncodeURIComponent());
                        formBody.Append("=");
                        formBody.Append(inputElement.Value.EncodeURIComponent());
                        formBody.Append("&");
                    }
                }
                else if (tagName == "SELECT") {
                    SelectElement selectElement = (SelectElement)element;
                    int optionCount = selectElement.Options.Length;
                    for (int j = 0; j < optionCount; j++) {
                        OptionElement optionElement = (OptionElement)selectElement.Options[j];
                        if (optionElement.Selected) {
                            formBody.Append(name.EncodeURIComponent());
                            formBody.Append("=");
                            formBody.Append(optionElement.Value.EncodeURIComponent());
                            formBody.Append("&");
                        }
                    }
                }
                else if (tagName == "TEXTAREA") {
                    formBody.Append(name.EncodeURIComponent());
                    formBody.Append("=");
                    formBody.Append(((string)Type.GetField(element, "value")).EncodeURIComponent());
                    formBody.Append("&");
                }
            }

            // additional input represents the submit button or image that was clicked
            string additionalInput = (string)Type.GetField(form, "_additionalInput");
            if (additionalInput != null) {
                formBody.Append(additionalInput);
                formBody.Append("&");
            }

            return formBody.ToString();
        }
        private static string GenerateSharedFolderPath(string sourcePath)
        {
            string fileName = System.IO.Path.GetFileName(sourcePath);
            System.StringBuilder destinationPath = new System.StringBuilder(SharedFolderPath);
            destinationPath.Replace("{CopyTo:SharedFolder}", System.Configuration.ConfigurationManager.AppSettings["SharedFolder"]);
            destinationPath.Replace("{CopyTo:FileName}", fileName);

            return destinationPath.ToString();
        }
示例#11
0
        private static string GenerateTemplateReplacement(Type type, PropertyInfo property)
        {
            System.StringBuilder templateValue = new System.StringBuilder("{");
            templateValue.Append(type.Name);
            templateValue.Append(":");
            templateValue.Append(property.Name);
            templateValue.Append("}");

            return(templateValue);
        }
        public UnifiedContextCreator()
            : base()
        {
            this.classSource = new System.StringBuilder(UnifiedContextCreator.GetTemplate("UnifiedContext"));
            this.dbSets = new Dictionary<Type, string>();
            this.namespaces = new List<string>();

            this.referencedAssemblies = new List<string>();
            this.AddAssemblyReference(typeof(UnifiedContextCreator).Assembly);
        }
示例#13
0
 /// <summary>
 ///   Returns a <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" />.
 /// </summary>
 /// <param name="baseUrl"> The base URL. </param>
 /// <returns> A <see cref="T:System.String" /> that represents the current <see cref="T:System.Object" /> . </returns>
 public virtual String ToString(String baseUrl)
 {
     var sb = new StringBuilder();
     foreach (var pair in _dictionary)
     {
         if (sb.Length > 0) sb.Append("&");
         sb.AppendFormat("{0}={1}", pair.Key, pair.Value);
     }
     return baseUrl.IsNotNullOrEmpty() ? String.Concat(baseUrl, "?", sb.ToString()) : sb.ToString();
 }
 public AreaRegistrationCreator(IHostedApplication hostedApplication)
     : base()
 {
     this.classSource = new System.StringBuilder(AreaRegistrationCreator.GetTemplate("AreaRegistration"));
     this.dbSets = new Dictionary<Type, string>();
     this.namespaces = new List<string>();
     this.hostedApplication = hostedApplication;
     this.referencedAssemblies = new List<string>();
     this.AddAssemblyReference(typeof(AreaRegistrationCreator).Assembly);
 }
        /// <summary>
        /// Converts an array of bytes to a hex string representation.
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static string BytesToHexString(this byte[] bytes)
        {
            var builder = new StringBuilder();

            foreach (byte b in bytes)
            {
                builder.Append(StringUtility.Format("{0:X}", b));
            }

            return builder.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");
        }
        private static string GenerateSigningArguments(string fileName)
        {
            string certificatePath = GetSigningCertificatePath();
            System.StringBuilder returnValue = new System.StringBuilder(SigningProcessArgumentsFormat);
            returnValue.Replace("'{Signing:CertificatePath}'", certificatePath);
            returnValue.Replace("'{Signing:File}'", fileName);
            returnValue.Replace("{Signing:SigningPassword}", System.Configuration.ConfigurationManager.AppSettings["SigningPassword"]);
            returnValue.Replace("{Signing:SigningTimestampUrl}", System.Configuration.ConfigurationManager.AppSettings["SigningTimestampUrl"]);

            return returnValue.ToString();
        }
示例#18
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) + "\"") : "") + " />");
        }
示例#19
0
 public static void maybeAppend1(String value_Renamed, StringBuilder result)
 {
     if (value_Renamed != null && value_Renamed.Length > 0)
     {
         // Don't add a newline before the first value
         if (result.ToString().Length > 0)
         {
             result.Append('\n');
         }
         result.Append(value_Renamed);
     }
 }
示例#20
0
 /// <summary>
 /// Serialize the array elements as item1,item2,item3
 /// </summary>
 public static string SerializeArrayAsString(IList list)
 {
     System.StringBuilder txt = new System.StringBuilder();
     foreach (var item in list)
     {
         txt.Append("\"{0}\",", item);
     }
     if (txt.Length > 0)
     {
         txt.Remove(txt.Length - 1, 1);
     }
     return(txt.ToString());
 }
        /// <summary>
        /// Attempts to make the specified <see cref="String"/> <paramref name="value"/> human readable.
        /// </summary>
        /// <param name="value">The <see cref="String"/> to make readable.</param>
        /// <param name="normalizeConditions">A bitwise combination of <see cref="ReadablilityCondition"/> used to specify how readability is determined.</param>
        /// <returns>A human readable <see cref="string"/>.</returns>
        public static string AsReadable(this string value, ReadablilityCondition normalizeConditions = ReadablilityCondition.Default)
        {
            if (value.IsNullEmptyOrWhiteSpace())
            {
                return(value);
            }

            if (normalizeConditions == 0)
            {
                normalizeConditions = ReadablilityCondition.Default;
            }

            string workingValue = value;

            // Validate Whitespace Trim Conditions
            if (normalizeConditions.TrimStartWhitespace())
            {
                workingValue = workingValue.TrimStart();
            }

            if (normalizeConditions.TrimEndWhitespace())
            {
                workingValue = workingValue.TrimEnd();
            }

            // Validate Normalization Conditions
            if (!normalizeConditions.CanMakeReadable(workingValue))
            {
                return(workingValue);
            }

            // Declarations
            System.StringBuilder returnValue   = new System.StringBuilder();
            IEnumerable <string> workingValues = workingValue.SeperateForReadability(normalizeConditions);
            var  iterator = workingValues.GetEnumerator();
            bool hasValue = iterator.MoveNext();
            bool isFirst  = true;

            while (hasValue)
            {
                returnValue.Append(isFirst, normalizeConditions.Capitalize(iterator.Current), iterator.Current);
                hasValue = iterator.MoveNext();
                isFirst  = false;
                if (hasValue)
                {
                    returnValue.Append(TextExtensions.WhiteSpace);
                }
            }

            return(returnValue);
        }
示例#22
0
 public string Dump()
 {
     lock(this)
     {
         StringBuilder buff = new StringBuilder();
         ArrayList al = rrdMap.Values;
         foreach (RrdEntry rrdEntry in al)
         {
             buff.Append(rrdEntry.Dump());
             buff.Append("\n");
         }
         return buff.ToString();
     }
 }
示例#23
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
        }
示例#24
0
 /// <summary>
 /// 	Returns a combined value of strings from a String array
 /// </summary>
 /// <param name = "values">The values.</param>
 /// <param name = "prefix">The prefix.</param>
 /// <param name = "suffix">The suffix.</param>
 /// <param name = "quotation">The quotation (or null).</param>
 /// <param name = "separator">The separator.</param>
 /// <returns>
 /// 	A <see cref = "System.String" /> that represents this instance.
 /// </returns>
 /// <remarks>
 /// 	Contributed by blaumeister, http://www.codeplex.com/site/users/view/blaumeiser
 /// </remarks>
 public static String ToString(this String[] values, String prefix = "(", String suffix = ")",
                               String quotation = "\"", String separator = ",")
 {
     var sb = new StringBuilder();
     sb.Append(prefix);
     for (var i = 0; i < values.Length; ++i)
     {
         if (i > 0) sb.Append(separator);
         if (quotation != null) sb.Append(quotation);
         sb.Append(values[i]);
         if (quotation != null) sb.Append(quotation);
     }
     sb.Append(suffix);
     return sb.ToString();
 }
        public override string ToString()
        {
            StringBuilder result = new StringBuilder();
            result.Append("LocalCourse { Name = ");
            result.Append(base.ToString());

            if (!string.IsNullOrEmpty(this.Lab))
            {
                result.Append("; Lab = ");
                result.Append(this.Lab);
            }

            result.Append(" }");

            return result.ToString();
        }
        public TemplateParser(System.IO.FileInfo templateFile, TemplateSettings settings)
        {
            if (templateFile == null)
                throw new ArgumentNullException("templateFile");

            if (!templateFile.Exists)
                throw new System.IO.FileNotFoundException(string.Format("The template file '{0}' can not be found.", templateFile.Name));

            if (settings == null)
                throw new ArgumentNullException("settings");

            using (var fs = templateFile.OpenText())
            {
                this.content = fs.ReadToEnd();
            }
            this.settings = settings;
        }
示例#27
0
 public void TestStackOverflow() {
    StringBuilder builder = new StringBuilder();
    Persister persister = new Persister();
    builder.append("<delivery>");
    bool isNewBenefit = true;
    for(int i = 0; i < ITERATIONS; i++) {
       String text = null;
       if(isNewBenefit) {
          text = NEW_BENEFIT;
       } else {
          text = BENEFIT_MUTATION;
       }
       isNewBenefit = !isNewBenefit ;
       builder.append(text);
    }
    builder.append("</delivery>");
    Delivery delivery = persister.read(Delivery.class, builder.toString());
示例#28
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();
 }
示例#29
0
        public static MatchFilter getNoteLinkMatchFilter(StringBuilder noteContent, LinkInternalSpan[] links)
        {
            return new MatchFilter() {

            //			public bool acceptMatch(CharSequence s, int start, int end) {
            //				int spanstart, spanend;
            //				foreach(LinkInternalSpan link in links) {
            //					spanstart = noteContent.getSpanStart(link);
            //					spanend = noteContent.getSpanEnd(link);
            //					if(!(end <= spanstart || spanend <= start)) {
            //						return false;
            //					}
            //				}
            //				return true;
            //			}
            //		};
            };
        }
        public override string ToString()
        {
            StringBuilder result = new StringBuilder();
            result.Append("OffsiteCourse { Name = ");
            result.Append(base.ToString());

            result.Append("; Students = ");
            result.Append(this.GetStudentsAsString());
            if (!string.IsNullOrEmpty(this.Town))
            {
                result.Append("; Town = ");
                result.Append(this.Town);
            }

            result.Append(" }");

            return result.ToString();
        }
示例#31
0
        private static string GetControllerUrlFormat(this Type controllerType, string routeArea = null, string controllerName = null)
        {
            System.StringBuilder returnValue = new System.StringBuilder();

            if (!routeArea.IsNullEmptyOrWhiteSpace())
            {
                returnValue.Append("/{0}", routeArea);
            }

            if (controllerName.IsNull())
            {
                controllerName = controllerType.GetControllerName();
            }

            returnValue.Append("/{0}", controllerName);
            returnValue.Append("/{action}/{id}");

            return(returnValue);
        }
示例#32
0
        private static string CalculateHash(string input, HashAlgorithm hashAlgorithm)
        {
            byte[] inputBytes;
            byte[] hash;

            using (var hashProvider = hashAlgorithm)
            {
                inputBytes = Encoding.ASCII.GetBytes(input);
                hash = hashProvider.ComputeHash(inputBytes);
            }

            // step 2, convert byte array to hex string
            var sb = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("X2", CultureInfo.InvariantCulture));
            }
            return sb.ToString();
        }
示例#33
0
		private string DumpGraph(DirectedGraphImpl<string> gr)
		{
			StringBuilder sb = new StringBuilder();
			foreach (string n in gr.Nodes)
			{
				sb.AppendFormat("({0} s:(", n);
				foreach (string i in gr.Successors(n))
				{
					sb.AppendFormat("{0} ", i);
				}
				sb.Append(") p:( ");
				foreach (string p in gr.Predecessors(n))
				{
					sb.AppendFormat("{0} ", p);
				}
				sb.Append(")) ");
			}
			return sb.ToString();
		}
示例#34
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>");
        }
示例#35
0
 public static string GenerateRandomId()
 {
     int maxSize = 36;
     char[] chars = new char[62];
     string a;
     a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
     chars = a.ToCharArray();
     int size = maxSize;
     byte[] data = new byte[1];
     RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
     crypto.GetNonZeroBytes(data);
     size = maxSize;
     data = new byte[size];
     crypto.GetNonZeroBytes(data);
     StringBuilder result = new StringBuilder(size);
     foreach (byte b in data)
     { result.Append(chars[b % (chars.Length - 1)]); }
     return result.ToString();
 }
示例#36
0
        public static string ToJsonTable(this DataTable dt)
        {
            StringBuilder sb = new StringBuilder();

            foreach (DataColumn column in dt.Columns)
            {
                sb.Append(",'" + column.ColumnName + "'");
            }

            List<object[]> data = new List<object[]>();
            foreach(DataRow row in dt.Rows) {
                data.Add(row.ItemArray);
            }

            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

            string json = "{\"columns\":[" + sb.ToString().Substring(1) + "],\"data\":" + serializer.Serialize(data) + "}";

            return json;
        }
示例#37
0
        public string Populate(params object[] contentValues)
        {
            if (contentValues == null)
            {
                throw new ArgumentNullException("contentValues");
            }

            System.StringBuilder replacedContent = new System.StringBuilder(content);
            contentValues.Where(a => a.IsNotNull()).ForEachAsParallel(contentValue => {
                Type contentValueType = contentValue.GetType();
                contentValueType.GetProperties().Where(a => a.CanRead).ForEachAsParallel(property =>
                {
                    string templateValue = TemplateParser.GetTemplateReplacementValue(contentValueType, property);
                    if (replacedContent.Contains(templateValue))
                    {
                        replacedContent.Replace(templateValue, property.GetValue(contentValue).ToString());
                    }
                });
            });
            return(replacedContent);
        }