string.IndexOf(string, int, int, System.StringComparison)

Here are the examples of the csharp api string.IndexOf(string, int, int, System.StringComparison) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

574 Examples 7

19 View Source File : ScriptEditorControl.cs
License : GNU General Public License v3.0
Project Creator : anotak

private void scriptedit_KeyUp(object sender, KeyEventArgs e)
		{
			bool showcalltip = false;
			int highlightstart = 0;
			int highlightend = 0;
			
			// Enter pressed?
			if((e.KeyCode == Keys.Enter) && (e.Modifiers == Keys.None))
			{
				// Do we want auto-indent?
				if(General.Settings.ScriptAutoIndent)
				{
					// Get the current line index and check if its not the first line
					int curline = scriptedit.LineFromPosition(scriptedit.CurrentPos);
					if(curline > 0)
					{
						// Apply identation of the previous line to this line
						int ident = scriptedit.GetLineIndentation(curline - 1);
						int tabs = ident ;// / scriptedit.Indent;
						if(scriptedit.GetLineIndentation(curline) == 0)
						{
							scriptedit.SetLineIndentation(curline, ident);
							scriptedit.SetSel(scriptedit.SelectionStart + tabs, scriptedit.SelectionStart + tabs);
						}
					}
				}
			}
			
			UpdatePositionInfo();
			
			// Call tip shown
			if(scriptedit.IsCallTipActive)
			{
				// Should we hide the call tip?
				if(curfunctionname.Length == 0)
				{
					// Hide the call tip
					scriptedit.CallTipCancel();
				}
				else
				{
					// Update the call tip
					showcalltip = true;
				}
			}
			// No call tip
			else
			{
				// Should we show a call tip?
				showcalltip = (curfunctionname.Length > 0) && !scriptedit.IsAutoCActive;
			}
			
			// Show or update call tip
			if(showcalltip)
			{
				string functiondef = scriptconfig.GetFunctionDefinition(curfunctionname);
				if(functiondef != null)
				{
					// Determine the range to highlight
					int argsopenpos = functiondef.IndexOf(scriptconfig.FunctionOpen);
					int argsclosepos = functiondef.LastIndexOf(scriptconfig.FunctionClose);
					if((argsopenpos > -1) && (argsclosepos > -1))
					{
						string argsstr = functiondef.Substring(argsopenpos + 1, argsclosepos - argsopenpos - 1);
						string[] args = argsstr.Split(scriptconfig.ArgumentDelimiter[0]);
						if((curargumentindex >= 0) && (curargumentindex < args.Length))
						{
							int argoffset = 0;
							for(int i = 0; i < curargumentindex; i++) argoffset += args[i].Length + 1;
							highlightstart = argsopenpos + argoffset + 1;
							highlightend = highlightstart + args[curargumentindex].Length;
						}
					}
					
					// Show tip
					scriptedit.CallTipShow(curfunctionstartpos, functiondef);
					scriptedit.CallTipSetHlt(highlightstart, highlightend);
				}
			}
		}

19 View Source File : DialogController.cs
License : GNU General Public License v3.0
Project Creator : arycama

private string CheckForTopicsInText(string text)
	{
		// Loops through every available topic to see if it is contained in the text.
		foreach (var topic in topics)
		{
			// Add new topics to the journal and the list of available topics for this dialog. (Should trigger some kind of callback)
			// This currently does not remove the text from the string, but should so that other topics do not detect it.
			var index = text.IndexOf(topic.name, StringComparison.OrdinalIgnoreCase);
			if (index == -1)
			{
				continue;
			}

			// Should also make the text blue here
			// Make text blue()
			var hyperlinkText = "<color=#707ecfff>";
			text = text.Insert(index, hyperlinkText);
			text = text.Insert(index + hyperlinkText.Length + topic.name.Length, "</color>");

			// If the player already knows this topic, it will already be included, so we wouldn't need to check for it. 
			// However we do need to check for it for hyperlinks sadly, so evenetually skip this check. 
			// Maybe we could check for available topics for hyperlinks instead?
			if (player.Journal.Topics.ContainsKey(topic.name))
			{
				continue;
			}

			// Add the topic to the journal
			player.Journal.AddTopic(topic.name, topic);
			dialogView.AddTopic(topic);
		}

		// The text may have had it's color modified, so return this
		return text;
	}

19 View Source File : TemplatePass.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

void FetchVertexAndInterpData( TemplateModulesData subShaderModule, int offsetIdx, string body )
		{
			// Vertex Data
			try
			{
				int vertexDataTagBegin = body.IndexOf( TemplatesManager.TemplateVertexDataTag );
				if( vertexDataTagBegin > -1 )
				{
					m_vertexDataContainer = new VertexDataContainer();
					m_vertexDataContainer.VertexDataStartIdx = offsetIdx + vertexDataTagBegin;
					int vertexDataTagEnd = body.IndexOf( TemplatesManager.TemplateEndOfLine, vertexDataTagBegin );
					m_vertexDataContainer.VertexDataId = body.Substring( vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin );
					int dataBeginIdx = body.LastIndexOf( '{', vertexDataTagBegin, vertexDataTagBegin );
					string vertexData = body.Substring( dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx );

					int parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
					string parameters = body.Substring( parametersBegin, vertexDataTagEnd - parametersBegin );
					m_vertexDataContainer.VertexData = TemplateHelperFunctions.CreateVertexDataList( vertexData, parameters );
					m_templateProperties.AddId( body, m_vertexDataContainer.VertexDataId );
				}
			}
			catch( Exception e )
			{
				Debug.LogException( e );
			}

			// Available interpolators
			try
			{
				int interpDataBegin = body.IndexOf( TemplatesManager.TemplateInterpolatorBeginTag );
				if( interpDataBegin > -1 )
				{
					int interpDataEnd = body.IndexOf( TemplatesManager.TemplateEndOfLine, interpDataBegin );
					string interpDataId = body.Substring( interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin );

					int dataBeginIdx = body.LastIndexOf( '{', interpDataBegin, interpDataBegin );
					string interpData = body.Substring( dataBeginIdx + 1, interpDataBegin - dataBeginIdx );

					int interpolatorAmount = TemplateHelperFunctions.AvailableInterpolators["2.5"];

					if( m_modules.ShaderModel.IsValid )
					{
						interpolatorAmount = m_modules.ShaderModel.InterpolatorAmount;
					}
					else if( subShaderModule.ShaderModel.IsValid )
					{
						interpolatorAmount = subShaderModule.ShaderModel.InterpolatorAmount;
					}

					m_interpolatorDataContainer = TemplateHelperFunctions.CreateInterpDataList( interpData, interpDataId, interpolatorAmount );
					m_interpolatorDataContainer.InterpDataId = interpDataId;
					m_interpolatorDataContainer.InterpDataStartIdx = offsetIdx + interpDataBegin;
					m_templateProperties.AddId( body, interpDataId );

				}
			}
			catch( Exception e )
			{
				Debug.LogException( e );
			}
		}

19 View Source File : NumberBoxParser.cs
License : MIT License
Project Creator : amwx

public static IList<MathToken> GetTokens(ReadOnlySpan<char> input)
        {
            var tokens = new List<MathToken>();

            bool expectNumber = true;
            while (input.Length > 0)
            {
                var nextChar = input[0];
                if (nextChar != ' ')
                {
                    if (expectNumber)
                    {
                        if (nextChar == '(')
                        {
                            tokens.Add(new MathToken(MathTokenType.Parenthesis, nextChar));
                        }
                        else
                        {
                            var (value, charLen) = GetNextNumber(input);

                            if (charLen > 0)
                            {
                                tokens.Add(new MathToken(MathTokenType.Numeric, value));
                                input = input.Slice(charLen - 1);
                                expectNumber = false;
                            }
                            else
                            {
                                // Error case -- next token is not a number
                                return null;
                            }
                        }
                    }
                    else
                    {
                        if (numberBoxOperators.IndexOf(nextChar) != -1)
                        {
                            tokens.Add(new MathToken(MathTokenType.Operator, nextChar));
                            expectNumber = true;
                        }
                        else if (nextChar == ')')
                        {
                            // Closed parens are also acceptable, but don't change the next expected token type.
                            tokens.Add(new MathToken(MathTokenType.Parenthesis, nextChar));
                        }
                        else
                        {
                            // Error case -- could not evaluate part of the expression
                            return null;
                        }
                    }
                }
                input = input.Slice(1);
            }

            return tokens;
        }

19 View Source File : Level.cs
License : MIT License
Project Creator : AlFasGD

private void GetLevelStringInformation(string levelString)
        {
            string infoString = levelString.Substring(0, levelString.IndexOf(';', StringComparison.InvariantCulture));
            string[] split = infoString.Split(',');
            for (int i = 0; i < split.Length; i += 2)
                GetLevelStringParameterInformation(split[i], split[i + 1]);
            LevelObjects = ParseObjects(GetObjectString(levelString));
        }

19 View Source File : TemplatePostProcessor.cs
License : MIT License
Project Creator : alexismorin

static void OnPostprocessAllreplacedets( string[] importedreplacedets, string[] deletedreplacedets, string[] movedreplacedets, string[] movedFromreplacedetPaths )
		{
			if( UIUtils.CurrentWindow == null )
				return;

			TemplatesManager templatesManager = UIUtils.CurrentWindow.TemplatesManagerInstance;
			if( templatesManager == null )
				return;

			if( !templatesManager.Initialized )
			{
				templatesManager.Init();
			}

			bool refreshMenuItems = false;
			for( int i = 0; i < importedreplacedets.Length; i++ )
			{
				if( TemplateHelperFunctions.CheckIfTemplate( importedreplacedets[ i ] ) )
				{
					string guid = replacedetDatabase.replacedetPathToGUID( importedreplacedets[ i ] );
					TemplateDataParent templateData = templatesManager.GetTemplate( guid );
					if( templateData != null )
					{
						refreshMenuItems = templateData.Reload() || refreshMenuItems;
						int windowCount = IOUtils.AllOpenedWindows.Count;
						for( int windowIdx = 0; windowIdx < windowCount; windowIdx++ )
						{
							if( IOUtils.AllOpenedWindows[ windowIdx ].OutsideGraph.CurrentCanvasMode == NodeAvailability.TemplateShader )
							{
								if( IOUtils.AllOpenedWindows[ windowIdx ].OutsideGraph.MultiPreplacedMasterNodes.NodesList[ 0 ].CurrentTemplate == templateData )
								{
									IOUtils.AllOpenedWindows[ windowIdx ].OutsideGraph.ForceMultiPreplacedMasterNodesRefresh();
								}
							}
						}
					}
					else
					{
						refreshMenuItems = true;
						string name = TemplatesManager.OfficialTemplates.ContainsKey( guid ) ? TemplatesManager.OfficialTemplates[ guid ] : string.Empty;
						TemplateMultiPreplaced mp = TemplateMultiPreplaced.CreateInstance<TemplateMultiPreplaced>();
						mp.Init( name, guid, true );
						templatesManager.AddTemplate( mp );
					}
				}
			}

			if( deletedreplacedets.Length > 0 )
			{
				if( deletedreplacedets[ 0 ].IndexOf( Constants.InvalidPostProcessDatapath ) < 0 )
				{
					for( int i = 0; i < deletedreplacedets.Length; i++ )
					{
						string guid = replacedetDatabase.replacedetPathToGUID( deletedreplacedets[ i ] );
						TemplateDataParent templateData = templatesManager.GetTemplate( guid );
						if( templateData != null )
						{
							// Close any window using that template
							int windowCount = IOUtils.AllOpenedWindows.Count;
							for( int windowIdx = 0; windowIdx < windowCount; windowIdx++ )
							{
								TemplateMasterNode masterNode = IOUtils.AllOpenedWindows[ windowIdx ].CurrentGraph.CurrentMasterNode as TemplateMasterNode;
								if( masterNode != null && masterNode.CurrentTemplate.GUID.Equals( templateData.GUID ) )
								{
									IOUtils.AllOpenedWindows[ windowIdx ].Close();
								}
							}

							templatesManager.RemoveTemplate( templateData );
							refreshMenuItems = true;
						}
					}
				}
			}

			//for ( int i = 0; i < movedreplacedets.Length; i++ )
			//{
			//	if ( TemplateHelperFunctions.CheckIfTemplate( movedreplacedets[ i ] ) )
			//	{
			//		refreshMenuItems = true;
			//		break;
			//	}
			//}

			//for ( int i = 0; i < movedFromreplacedetPaths.Length; i++ )
			//{
			//	if ( TemplateHelperFunctions.CheckIfTemplate( movedFromreplacedetPaths[ i ] ) )
			//	{
			//		refreshMenuItems = true;
			//		break;
			//	}
			//}

			if( refreshMenuItems )
			{
				//UnityEngine.Debug.Log( "Refresh Menu Items" );
				refreshMenuItems = false;
				templatesManager.CreateTemplateMenuItems();

				int windowCount = IOUtils.AllOpenedWindows.Count;
				for( int windowIdx = 0; windowIdx < windowCount; windowIdx++ )
				{
					IOUtils.AllOpenedWindows[ windowIdx ].CurrentGraph.ForceCategoryRefresh();
				}
			}
		}

19 View Source File : TemplateDocument.cs
License : MIT License
Project Creator : aprilyush

private void ParseString(Template ownerTemplate, Tag container, string text)
        {
            //设置根文档模板
            this.DoreplacedentElement = ownerTemplate;
            //this.Text = text;

            if (string.IsNullOrEmpty(text)) return;

            int charOffset = 0, offset = 0;
            bool isClosedTag;
            Match match = null;

            //标签堆栈
            Stack<Tag> tagStack = new Stack<Tag>();
            tagStack.Push(container);

            try
            {
                while (offset < text.Length)
                {
                    if (ParserHelper.IsVariableTagStart(text, offset) && (match = ParserRegex.VarTagRegex.Match(text, offset)).Success)  //匹配到模板变量
                    {
                        //构建文本节点
                        ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
                        //构建模板变量
                        ParserHelper.CreateVariableTag(ownerTemplate, container, match);
                    }
                    else if (ParserHelper.IsTagStart(text, offset) && (match = ParserRegex.TagRegex.Match(text, offset)).Success)  //匹配到某种类型的标签
                    {
                        //构建文本节点
                        ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
                        //构建标签
                        Tag tag = ParserHelper.CreateTag(ownerTemplate, match, out isClosedTag);

                        //将标签加入堆栈
                        tagStack.Push(tag);
                        //将解析权交给标签
                        bool flag = tag.ProcessBeginTag(ownerTemplate, container, tagStack, text, ref match, isClosedTag);
                        //非已闭合标签或者是单标签则处理标签的结束标签
                        if (flag)
                        {
                            tag.ProcessEndTag(ownerTemplate, tag, tagStack, text, ref match);
                        }
                        if (tagStack.Count > 0 && tagStack.Peek() == tag && isClosedTag)
                        {
                            //闭合标签则回滚一级
                            tagStack.Pop();
                        }
                        //取得容器
                        if (tagStack.Count > 0) container = tagStack.Peek();
                    }
                    else if (ParserHelper.IsCloseTagStart(text, offset) && (match = ParserRegex.EndTagRegex.Match(text, offset)).Success)            //匹配到某个结束标签
                    {
                        //取得标签名称
                        string name = match.Groups["tagname"].Value;
                        //非匹配的结束标签.则模板有错
                        throw new ParserException("无效的结束标签");
                    }
                    else if (ParserHelper.IsVTExpressionStart(text, offset))
                    {
                        char s = ParserHelper.ReadChar(text, offset + ParserHelper.VTExpressionHead.Length);
                        int startOffset = offset + ParserHelper.VTExpressionHead.Length + 1;
                        int lastOffset = text.IndexOf(s, offset + ParserHelper.VTExpressionHead.Length + 1);
                        if (lastOffset == -1) throw new ParserException(string.Format("无法找到VT表达式\"{0}\"的结束标记", ParserHelper.VTExpressionHead));
                        string code = text.Substring(startOffset, lastOffset - startOffset);
                        if (code.Length > 0)
                        {
                            //构建文本节点
                            ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, offset - charOffset);
                            //解析表达式里的代码
                            new TemplateDoreplacedent(ownerTemplate, container, code, ownerTemplate.OwnerDoreplacedent.DoreplacedentConfig);
                        }
                        offset = lastOffset + 1;
                        charOffset = offset;
                        continue;
                    }
                    else if (ParserHelper.IsCommentTagStart(text, offset))
                    {
                        //构建文本节点
                        ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, offset - charOffset);

                        //找到注释的起始标记"<!--vt[",则直接查找结束标记"]-->"
                        offset = text.IndexOf(ParserHelper.CommentTagEnd, offset + ParserHelper.CommentTagStart.Length);
                        if (offset == -1) throw new ParserException("无法找到注释的结束标记");
                        offset += ParserHelper.CommentTagEnd.Length;
                        charOffset = offset;
                        continue;
                    }
                    //处理偏移位置
                    if (match != null && match.Success)
                    {
                        charOffset = offset = match.Index + match.Length;
                        match = null;
                    }
                    else
                    {
                        offset++;
                    }
                }
                //处理文本字符
                ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, text.Length - charOffset);
                if (tagStack.Count > 1)
                {
                    //堆栈里还有其它元素.则有错误
                    throw new ParserException(string.Format("{0}标签未闭合", tagStack.Pop()));
                }
            }
            catch (ParserException ex)
            {
                //如果错误中不包含行号与列号.则计算行号与列号
                if (!ex.HaveLineAndColumnNumber && match != null && match.Success)
                {
                    //获取当前出错时正在解析的模板文件
                    string file = string.Empty;
                    Tag tag = container;
                    while (string.IsNullOrEmpty(file) && tag != null)
                    {
                        if (tag is Template)
                        {
                            file = ((Template)tag).File;
                        }
                        else if (tag is IncludeTag)
                        {
                            file = ((IncludeTag)tag).File;
                        }
                        tag = tag.Parent;
                    }
                    if (string.IsNullOrEmpty(file))
                    {
                        throw new ParserException(Utility.GetLineAndColumnNumber(text, match.Index), match.ToString(), ex.Message);
                    }
                    else
                    {
                        throw new ParserException(file, Utility.GetLineAndColumnNumber(text, match.Index), match.ToString(), ex.Message);
                    }
                }
                else
                {
                    //继续抛出错误
                    throw;
                }
            }
            finally
            {
                //清空堆栈
                tagStack.Clear();
                tagStack = null;
            }
        }

19 View Source File : TemplateData.cs
License : MIT License
Project Creator : alexismorin

void FetchCommonTags()
		{
			// Name
			try
			{
				int nameBegin = m_templateBody.IndexOf( TemplatesManager.TemplateShaderNameBeginTag );
				if( nameBegin < 0 )
				{
					// Not a template
					return;
				}

				int nameEnd = m_templateBody.IndexOf( TemplatesManager.TemplateFullEndTag, nameBegin );
				int defaultBegin = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length;
				int defaultLength = nameEnd - defaultBegin;
				m_defaultShaderName = m_templateBody.Substring( defaultBegin, defaultLength );
				int[] nameIdx = m_defaultShaderName.AllIndexesOf( "\"" );
				nameIdx[ 0 ] += 1; // Ignore the " character from the string
				m_defaultShaderName = m_defaultShaderName.Substring( nameIdx[ 0 ], nameIdx[ 1 ] - nameIdx[ 0 ] );
				m_shaderNameId = m_templateBody.Substring( nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin );
				AddId( m_shaderNameId, false );

			}
			catch( Exception e )
			{
				Debug.LogException( e );
				m_isValid = false;
			}

			FetchSubShaderProperties();
			// Vertex Data
			{
				int vertexDataTagBegin = m_templateBody.IndexOf( TemplatesManager.TemplateVertexDataTag );
				if( vertexDataTagBegin > -1 )
				{
					m_vertexDataContainer.VertexDataStartIdx = vertexDataTagBegin;
					int vertexDataTagEnd = m_templateBody.IndexOf( TemplatesManager.TemplateEndOfLine, vertexDataTagBegin );
					m_vertexDataContainer.VertexDataId = m_templateBody.Substring( vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin );
					int dataBeginIdx = m_templateBody.LastIndexOf( '{', vertexDataTagBegin, vertexDataTagBegin );
					string vertexData = m_templateBody.Substring( dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx );

					int parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
					string parameters = m_templateBody.Substring( parametersBegin, vertexDataTagEnd - parametersBegin );
					m_vertexDataContainer.VertexData = TemplateHelperFunctions.CreateVertexDataList( vertexData, parameters );
					AddId( m_vertexDataContainer.VertexDataId );
				}
			}

			// Available interpolators
			try
			{
				int interpDataBegin = m_templateBody.IndexOf( TemplatesManager.TemplateInterpolatorBeginTag );
				if( interpDataBegin > -1 )
				{
					int interpDataEnd = m_templateBody.IndexOf( TemplatesManager.TemplateEndOfLine, interpDataBegin );
					string interpDataId = m_templateBody.Substring( interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin );

					int dataBeginIdx = m_templateBody.LastIndexOf( '{', interpDataBegin, interpDataBegin );
					string interpData = m_templateBody.Substring( dataBeginIdx + 1, interpDataBegin - dataBeginIdx );

					m_interpolatorDataContainer = TemplateHelperFunctions.CreateInterpDataList( interpData, interpDataId, 8 );
					m_interpolatorDataContainer.InterpDataId = interpDataId;
					m_interpolatorDataContainer.InterpDataStartIdx = interpDataBegin;
					AddId( interpDataId );
				}
			}
			catch( Exception e )
			{
				Debug.LogException( e );
				m_isValid = false;
			}


			try
			{
				Dictionary<string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary<string, TemplateShaderPropertyData>();
				m_availableShaderProperties = new List<TemplateShaderPropertyData>();

				// Common Tags
				for( int i = 0; i < TemplatesManager.CommonTags.Length; i++ )
				{
					int idx = m_templateBody.IndexOf( TemplatesManager.CommonTags[ i ].Id );
					if( idx > -1 )
					{
						string currentId = TemplatesManager.CommonTags[ i ].Id;

						TemplateCommonTagId commonTagId = (TemplateCommonTagId)i;
						switch( commonTagId )
						{
							// Properties
							case TemplateCommonTagId.Property:
							{
								TemplateHelperFunctions.CreateShaderPropertiesList( m_templateBody.Substring( 0, idx + TemplatesManager.CommonTags[ i ].Id.Length ), ref m_availableShaderProperties, ref duplicatesHelper );
							}
							break;
							// Globals
							case TemplateCommonTagId.Global:
							{
								TemplateHelperFunctions.CreateShaderGlobalsList( m_templateBody.Substring( 0, idx + TemplatesManager.CommonTags[ i ].Id.Length ), ref m_availableShaderProperties, ref duplicatesHelper );
							}
							break;

							//Tags
							//case TemplateCommonTagId.Tag:
							//{
							//	m_propertyList[ m_propertyList.Count - 1 ].Indentation = " ";
							//}
							//break;
							//case TemplateCommonTagId.CullMode:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
							//	string cullParams = m_templateBody.Substring( newId, end - newId );
							//	currentId = m_templateBody.Substring( idx, end - idx );
							//	m_cullModeData.CullModeId = currentId;
							//	TemplateHelperFunctions.CreateCullMode( cullParams, ref m_cullModeData );
							//}
							//break;
							//Blend Mode
							//case TemplateCommonTagId.BlendMode:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
							//	string blendParams = m_templateBody.Substring( newId, end - newId );
							//	currentId = m_templateBody.Substring( idx, end - idx );
							//	m_blendData.BlendModeId = currentId;
							//	TemplateHelperFunctions.CreateBlendMode( blendParams, ref m_blendData );
							//}break;
							//case TemplateCommonTagId.BlendOp:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
							//	currentId = m_templateBody.Substring( idx, end - idx );
							//	BlendData.BlendOpId = currentId;
							//	TemplateHelperFunctions.CreateBlendOp( m_templateBody.Substring( newId, end - newId ), ref m_blendData );
							//}break;
							//case TemplateCommonTagId.ColorMask:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
							//	string colorMaskParams = m_templateBody.Substring( newId, end - newId );
							//	currentId = m_templateBody.Substring( idx, end - idx );
							//	m_colorMaskData.ColorMaskId = currentId;
							//	TemplateHelperFunctions.CreateColorMask( colorMaskParams, ref m_colorMaskData );
							//}
							//break;
							//case TemplateCommonTagId.StencilOp:
							//{
							//    int id = m_templateBody.LastIndexOf( "Stencil" );
							//    if( id > -1 )
							//    {
							//        string stencilParams = m_templateBody.Substring( id, idx - id );
							//        currentId = stencilParams + TemplatesManager.TemplateStencilOpTag;
							//        m_stencilData.StencilBufferId = currentId;
							//        TemplateHelperFunctions.CreateStencilOps( stencilParams, ref m_stencilData );
							//    }

							//}
							//break;
							default:
							break;
						}

						//AddId( TemplatesManager.CommonTags[ i ] );
						AddId( currentId, TemplatesManager.CommonTags[ i ].SearchIndentation, TemplatesManager.CommonTags[ i ].CustomIndentation );
					}
				}

				duplicatesHelper.Clear();
				duplicatesHelper = null;
			}
			catch( Exception e )
			{
				Debug.LogException( e );
				m_isValid = false;
			}
		}

19 View Source File : OpenidConnectAuthenticationHandler.cs
License : Apache License 2.0
Project Creator : aspnet

private AuthenticationProperties GetPropertiesFromState(string state)
        {
            // replacedume a well formed query string: <a=b&>OpenIdConnectAuthenticationDefaults.AuthenticationPropertiesKey=kasjd;fljasldkjflksdj<&c=d>
            int startIndex = 0;
            if (string.IsNullOrWhiteSpace(state) || (startIndex = state.IndexOf(OpenIdConnectAuthenticationDefaults.AuthenticationPropertiesKey, StringComparison.Ordinal)) == -1)
            {
                return null;
            }

            int authenticationIndex = startIndex + OpenIdConnectAuthenticationDefaults.AuthenticationPropertiesKey.Length;
            if (authenticationIndex == -1 || authenticationIndex == state.Length || state[authenticationIndex] != '=')
            {
                return null;
            }

            // scan rest of string looking for '&'
            authenticationIndex++;
            int endIndex = state.Substring(authenticationIndex, state.Length - authenticationIndex).IndexOf("&", StringComparison.Ordinal);

            // -1 => no other parameters are after the AuthenticationPropertiesKey
            if (endIndex == -1)
            {
                return Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(state.Substring(authenticationIndex).Replace('+', ' ')));
            }
            else
            {
                return Options.StateDataFormat.Unprotect(Uri.UnescapeDataString(state.Substring(authenticationIndex, endIndex).Replace('+', ' ')));
            }
        }

19 View Source File : TemplateMultiPass.cs
License : MIT License
Project Creator : alexismorin

void LoadTemplateBody( string guid )
		{
			m_preplacedUniqueIdData.Clear();
			m_guid = guid;
			string datapath = replacedetDatabase.GUIDToreplacedetPath( guid );
			string shaderBody = string.Empty;
			shaderBody = IOUtils.LoadTextFileFromDisk( datapath );
			shaderBody = shaderBody.Replace( "\r\n", "\n" );

			// Insert Before Tag
			MatchCollection col = Regex.Matches( shaderBody, TemplateHelperFunctions.BeforePragmaPattern, RegexOptions.Singleline );
			for( int i = col.Count - 1; i >= 0; i-- )
			{
				if( col[ i ].Groups.Count == 3 )
				{
					shaderBody = shaderBody.Insert( col[ i ].Groups[ 2 ].Index, TemplatesManager.TemplatePragmaBeforeTag + "\n" + col[ i ].Groups[ 1 ].Value );
				}
			}

			m_shaderData = TemplateShaderInfoUtil.CreateShaderData( shaderBody );
			if( m_shaderData == null )
			{
				m_isValid = false;
				return;
			}

			m_templateIdManager = new TemplateIdManager( shaderBody );

			try
			{
				int nameBegin = shaderBody.IndexOf( TemplatesManager.TemplateShaderNameBeginTag );
				if( nameBegin < 0 )
				{
					// Not a template
					return;
				}

				int nameEnd = shaderBody.IndexOf( TemplatesManager.TemplateFullEndTag, nameBegin );
				if( nameEnd < 0 )
					return;

				
				m_shaderBody = shaderBody;
				int defaultBegin = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length;
				int defaultLength = nameEnd - defaultBegin;
				m_defaultShaderName = shaderBody.Substring( defaultBegin, defaultLength );
				int[] nameIdx = m_defaultShaderName.AllIndexesOf( "\"" );
				nameIdx[ 0 ] += 1; // Ignore the " character from the string
				m_defaultShaderName = m_defaultShaderName.Substring( nameIdx[ 0 ], nameIdx[ 1 ] - nameIdx[ 0 ] );
				m_shaderNameId = shaderBody.Substring( nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin );
				m_templateProperties.AddId( shaderBody, m_shaderNameId, false );
				m_templateIdManager.RegisterId( nameBegin, m_shaderNameId, m_shaderNameId );
				shaderBody = shaderBody.Substring( nameEnd + TemplatesManager.TemplateFullEndTag.Length );
			}
			catch( Exception e )
			{
				Debug.LogException( e );
				m_isValid = false;
			}

			m_customTemplatePropertyUI = TemplateHelperFunctions.FetchCustomUI( shaderBody );
			TemplateHelperFunctions.FetchDependencies( m_dependenciesContainer, ref m_shaderBody );
			if( m_dependenciesContainer.IsValid )
			{
				int index = m_dependenciesContainer.Id.IndexOf( TemplatesManager.TemplateDependenciesListTag );
				m_templateProperties.AddId( new TemplateProperty( m_dependenciesContainer.Id, m_dependenciesContainer.Id.Substring( 0, index ), true ) );
				m_templateIdManager.RegisterId( m_dependenciesContainer.Index, m_dependenciesContainer.Id, m_dependenciesContainer.Id );
			}

			TemplateHelperFunctions.FetchCustomInspector( m_customInspectorContainer, ref m_shaderBody );
			if( m_customInspectorContainer.IsValid )
			{
				int index = m_customInspectorContainer.Id.IndexOf( "CustomEditor" );
				m_templateProperties.AddId( new TemplateProperty( m_customInspectorContainer.Id, m_customInspectorContainer.Id.Substring( 0, index ), true ) );
				m_templateIdManager.RegisterId( m_customInspectorContainer.Index, m_customInspectorContainer.Id, m_customInspectorContainer.Id );
			}

			TemplateHelperFunctions.FetchFallback( m_fallbackContainer, ref m_shaderBody );
			if( m_fallbackContainer.IsValid )
			{
				int index = m_fallbackContainer.Id.IndexOf( "Fallback",StringComparison.InvariantCultureIgnoreCase );
				m_templateProperties.AddId( new TemplateProperty( m_fallbackContainer.Id, m_fallbackContainer.Id.Substring( 0, index ), true ) );
				m_templateIdManager.RegisterId( m_fallbackContainer.Index, m_fallbackContainer.Id, m_fallbackContainer.Id );
			}
			// Shader body may have been changed to inject inexisting tags like fallback
			m_templateIdManager.ShaderBody = m_shaderBody;

			m_propertyTag = new TemplateTagData( m_shaderData.PropertyStartIdx, TemplatesManager.TemplatePropertyTag, true );
			m_templateIdManager.RegisterId( m_shaderData.PropertyStartIdx, TemplatesManager.TemplatePropertyTag, TemplatesManager.TemplatePropertyTag );
			m_templateProperties.AddId( shaderBody, TemplatesManager.TemplatePropertyTag, true );
			Dictionary<string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary<string, TemplateShaderPropertyData>();
			TemplateHelperFunctions.CreateShaderPropertiesList( m_shaderData.Properties, ref m_availableShaderProperties, ref duplicatesHelper );
			int subShaderCount = m_shaderData.SubShaders.Count;

			int mainSubShaderIdx = -1;
			int mainPreplacedIdx = -1;

			int firstVisibleSubShaderId = -1;
			int firstVisiblePreplacedId = -1;
			bool foundMainPreplaced = false;
			bool foundFirstVisible = false;

			m_templateIdManager.RegisterTag( TemplatesManager.TemplatePreplacedesEndTag );
			m_templateIdManager.RegisterTag( TemplatesManager.TemplateMainPreplacedTag );

			for( int i = 0; i < subShaderCount; i++ )
			{
				TemplateSubShader subShader = new TemplateSubShader( i, m_templateIdManager, "SubShader" + i, m_shaderData.SubShaders[ i ], ref duplicatesHelper );

				if( subShader.FoundMainPreplaced )
				{
					if( !foundMainPreplaced )
					{
						foundMainPreplaced = true;
						mainSubShaderIdx = i;
						mainPreplacedIdx = subShader.MainPreplaced;
					}
				}
				else if( subShader.MainPreplaced > -1 )
				{
					if( !foundFirstVisible )
					{
						foundFirstVisible = true;
						firstVisibleSubShaderId = i;
						firstVisiblePreplacedId = subShader.MainPreplaced;
					}
				}

				m_subShaders.Add( subShader );
				m_masterNodesRequired += subShader.Preplacedes.Count;
			}


			if( !foundMainPreplaced && foundFirstVisible )
			{
				mainSubShaderIdx = firstVisibleSubShaderId;
				mainPreplacedIdx = firstVisiblePreplacedId;
			}

			for( int subShaderIdx = 0; subShaderIdx < subShaderCount; subShaderIdx++ )
			{
				int preplacedCount = m_subShaders[ subShaderIdx ].Preplacedes.Count;
				for( int preplacedIdx = 0; preplacedIdx < preplacedCount; preplacedIdx++ )
				{
					m_subShaders[ subShaderIdx ].Preplacedes[ preplacedIdx ].IsMainPreplaced = ( mainSubShaderIdx == subShaderIdx && mainPreplacedIdx == preplacedIdx );
				}
			}

			duplicatesHelper.Clear();
			duplicatesHelper = null;
			m_isSinglePreplaced = ( m_subShaders.Count == 1 && m_subShaders[ 0 ].PreplacedAmount == 1 );
			
		}

19 View Source File : ModFinder.cs
License : MIT License
Project Creator : amazingalek

private IModData GetMod(string manifestFilename)
		{
			var manifest = JsonHelper.LoadJsonObject<ModManifest>(manifestFilename);
			manifest.ModFolderPath = manifestFilename.Substring(0, manifestFilename.IndexOf(Constants.ModManifestFileName));
			return InitModData(manifest);
		}

19 View Source File : AopJsonParser.cs
License : Apache License 2.0
Project Creator : alipay

private static string ParseSignSourceData(string body, string rootNode, int indexOfRootNode)
        {
            int signDataStartIndex = indexOfRootNode + rootNode.Length + 2;
            int indexOfSign = body.IndexOf("\"" + AlipayConstants.SIGN + "\"", StringComparison.Ordinal);
            if (indexOfSign < 0)
            {
                return null;
            }
            SignSourceData signSourceData = AlipaySignature.ExtractSignContent(body, signDataStartIndex);

            //如果提取的待验签原始内容后还有rootNode
            if (body.LastIndexOf(rootNode, StringComparison.Ordinal) > signSourceData.EndIndex)
            {
                throw new AopException("检测到响应报文中有重复的" + rootNode + ",验签失败。");
            }

            return signSourceData.SourceData;
        }

19 View Source File : TemplatePass.cs
License : MIT License
Project Creator : alexismorin

void FetchCodeAreas( int offsetIdx, string begin, MasterNodePortCategory category, string body )
		{
			int areaBeginIndexes = body.IndexOf( begin );
			if( areaBeginIndexes > -1 )
			{
				int beginIdx = areaBeginIndexes + begin.Length;
				int endIdx = body.IndexOf( TemplatesManager.TemplateEndOfLine, beginIdx );
				int length = endIdx - beginIdx;

				string parameters = body.Substring( beginIdx, length );

				string[] parametersArr = parameters.Split( IOUtils.FIELD_SEPARATOR );

				string id = body.Substring( areaBeginIndexes, endIdx + TemplatesManager.TemplateEndOfLine.Length - areaBeginIndexes );
				string inParameters = parametersArr[ 0 ];
				string outParameters = ( parametersArr.Length > 1 ) ? parametersArr[ 1 ] : string.Empty;
				if( category == MasterNodePortCategory.Fragment )
				{
					string mainBodyName = string.Empty;
					int mainBodyLocalIndex = -1;

					Match mainBodyNameMatch = Regex.Match( body, TemplateHelperFunctions.FragmentPragmaPattern );
					if( mainBodyNameMatch != null && mainBodyNameMatch.Groups.Count == 2 )
					{
						mainBodyName = mainBodyNameMatch.Groups[ 1 ].Value;
						string pattern = string.Format( TemplateHelperFunctions.FunctionBodyStartPattern, mainBodyName );
						Match mainBodyIdMatch = Regex.Match( body, pattern );
						if( mainBodyIdMatch != null && mainBodyIdMatch.Groups.Count > 0 )
						{
							mainBodyLocalIndex = mainBodyIdMatch.Index;
						}

					}

					m_fragmentFunctionData = new TemplateFunctionData( mainBodyLocalIndex, mainBodyName, id, offsetIdx + areaBeginIndexes, inParameters, outParameters, category );
				}
				else
				{
					string mainBodyName = string.Empty;
					int mainBodyLocalIndex = -1;

					Match mainBodyNameMatch = Regex.Match( body, TemplateHelperFunctions.VertexPragmaPattern );
					if( mainBodyNameMatch != null && mainBodyNameMatch.Groups.Count == 2 )
					{
						mainBodyName = mainBodyNameMatch.Groups[ 1 ].Value;
						string pattern = string.Format( TemplateHelperFunctions.FunctionBodyStartPattern, mainBodyName );
						Match mainBodyIdMatch = Regex.Match( body, pattern );
						if( mainBodyIdMatch != null && mainBodyIdMatch.Groups.Count > 0 )
						{
							mainBodyLocalIndex = mainBodyIdMatch.Index;
						}
					}

					m_vertexFunctionData = new TemplateFunctionData( mainBodyLocalIndex, mainBodyName, id, offsetIdx + areaBeginIndexes, inParameters, outParameters, category );
				}
				m_templateProperties.AddId( body, id, true );
			}
		}

19 View Source File : InfoboxExtractor.cs
License : MIT License
Project Creator : AnnoDesigner

public List<(string replacedle, string infobox)> ExtractInfobox(string content)
        {
            var result = new List<(string replacedle, string infobox)>();

            if (string.IsNullOrWhiteSpace(content))
            {
                return result;
            }

            var indexInfoboxOldAndNewWorldStart = content.IndexOf(_commons.InfoboxTemplateStartOldAndNewWorld, StringComparison.OrdinalIgnoreCase);
            var indexInfobox2RegionsStart = content.IndexOf(_commons.InfoboxTemplateStart2Regions, StringComparison.OrdinalIgnoreCase);
            var indexInfobox3RegionsStart = content.IndexOf(_commons.InfoboxTemplateStart3Regions, StringComparison.OrdinalIgnoreCase);
            var indexInfoboxStart = content.IndexOf(_commons.InfoboxTemplateStart, StringComparison.OrdinalIgnoreCase);
            var isInfoboxMultiple = false;

            var startIndex = -1;
            if (indexInfoboxOldAndNewWorldStart != -1)
            {
                startIndex = indexInfoboxOldAndNewWorldStart;
            }
            else if (indexInfobox2RegionsStart != -1)
            {
                startIndex = indexInfobox2RegionsStart;
                isInfoboxMultiple = true;
            }
            else if (indexInfobox3RegionsStart != -1)
            {
                startIndex = indexInfobox3RegionsStart;
                isInfoboxMultiple = true;
            }
            else if (indexInfoboxStart != -1)
            {
                //check for multiple infoboxes (only single region)
                var matches = regexMultipleInfoboxes.Matches(content);
                if (matches.Count > 1)
                {
                    foreach (Match curMatch in matches)
                    {
                        var localInfobox = GetInfobox(content, curMatch.Index);
                        var localreplacedle = _replacedleParserSingle.GetBuildingreplacedle(localInfobox);
                        result.Add((localreplacedle, localInfobox));
                    }

                    return result;
                }

                startIndex = indexInfoboxStart;
            }

            var containsNoKnownTemplateStart = startIndex == -1;
            if (containsNoKnownTemplateStart)
            {
                return result;
            }

            var infobox = GetInfobox(content, startIndex);
            string replacedle = null;
            if (!isInfoboxMultiple)
            {
                replacedle = _replacedleParserSingle.GetBuildingreplacedle(infobox);
            }
            result.Add((replacedle, infobox));
            return result;
        }

19 View Source File : TemplateData.cs
License : MIT License
Project Creator : alexismorin

void LoadTemplateBody( string body )
		{

			m_templateBody = body.Replace( "\r\n", "\n" ); ;

			if( m_templateBody.IndexOf( TemplatesManager.TemplateShaderNameBeginTag ) < 0 )
			{
				m_isValid = false;
				return;
			}

			//Fetching common tags
			FetchCommonTags();

			//Fetch function code areas
			FetchCodeAreas( TemplatesManager.TemplateVertexCodeBeginArea, MasterNodePortCategory.Vertex );
			FetchCodeAreas( TemplatesManager.TemplateFragmentCodeBeginArea, MasterNodePortCategory.Fragment );

			//Fetching inputs
			FetchInputs( MasterNodePortCategory.Fragment );
			FetchInputs( MasterNodePortCategory.Vertex );


			//Fetch local variables must be done after fetching code areas as it needs them to see is variable is on vertex or fragment
			TemplateHelperFunctions.FetchLocalVars( m_templateBody, ref m_localVarsList, m_vertexFunctionData, m_fragmentFunctionData );

			//Fetch snippets
		}

19 View Source File : StringExtensions.cs
License : MIT License
Project Creator : aprilyush

public static String Substring(this String str, String after, String? before = null, Int32 startIndex = 0, Int32[]? positions = null)
        {
            if (String.IsNullOrEmpty(str)) return str;
            if (String.IsNullOrEmpty(after) && String.IsNullOrEmpty(before)) return str;

            /*
             * 1,只有start,从该字符串之后部分
             * 2,只有end,从开头到该字符串之前
             * 3,同时start和end,取中间部分
             */

            var p = -1;
            if (!String.IsNullOrEmpty(after))
            {
                p = str.IndexOf(after, startIndex);
                if (p < 0) return null;
                p += after.Length;

                // 记录位置
                if (positions != null && positions.Length > 0) positions[0] = p;
            }

            if (String.IsNullOrEmpty(before)) return str.Substring(p);

            var f = str.IndexOf(before, p >= 0 ? p : startIndex);
            if (f < 0) return null;

            // 记录位置
            if (positions != null && positions.Length > 1) positions[1] = f;

            if (p >= 0)
                return str.Substring(p, f - p);
            else
                return str.Substring(0, f);
        }

19 View Source File : TemplateData.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

void FetchSubShaderProperties()
		{
			Match match = Regex.Match( m_templateBody, @"Preplaced\s*{" );
			if( match.Groups.Count == 0 )
			{
				return;
			}

			int beginSubShader = m_templateBody.IndexOf( "SubShader" );
			int endSubShader = match.Groups[ 0 ].Index;
			if( beginSubShader > 0 && endSubShader > 0 && endSubShader > beginSubShader )
			{
				// ADD A PLACE TO INSERT GRAB PreplacedES
				int preplacedIndex = m_templateBody.IndexOf( TemplatesManager.TemplatePreplacedTag );
				if( preplacedIndex < 0 )
				{
					int currIdx = endSubShader - 1;
					string identation = string.Empty;
					for( ; currIdx > 0; currIdx-- )
					{
						if( m_templateBody[ currIdx ] != '\n' )
						{
							identation = m_templateBody[ currIdx ] + identation;
						}
						else
						{
							identation = m_templateBody[ currIdx ] + identation;
							break;
						}
					}
					if( currIdx > 0 )
					{
						m_templateBody = m_templateBody.Insert( currIdx, identation + TemplatesManager.TemplatePreplacedTag );
					}
				}

				// GET ALL THE MODULES
				string subBody = m_templateBody.Substring( beginSubShader, endSubShader - beginSubShader );
				//CULL MODE
				{
					int cullIdx = subBody.IndexOf( "Cull" );
					if( cullIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, cullIdx );
						string cullParams = subBody.Substring( cullIdx, end - cullIdx );
						m_cullModeData.CullModeId = cullParams;
						TemplateHelperFunctions.CreateCullMode( cullParams, ref m_cullModeData );
						if( m_cullModeData.DataCheck == TemplateDataCheck.Valid )
							AddId( cullParams, false, string.Empty );
					}
				}
				//COLOR MASK
				{
					int colorMaskIdx = subBody.IndexOf( "ColorMask" );
					if( colorMaskIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, colorMaskIdx );
						string colorMaskParams = subBody.Substring( colorMaskIdx, end - colorMaskIdx );
						m_colorMaskData.ColorMaskId = colorMaskParams;
						TemplateHelperFunctions.CreateColorMask( colorMaskParams, ref m_colorMaskData );
						if( m_colorMaskData.DataCheck == TemplateDataCheck.Valid )
							AddId( colorMaskParams, false );
					}
				}
				//BlEND MODE
				{
					int blendModeIdx = subBody.IndexOf( "Blend" );
					if( blendModeIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, blendModeIdx );
						string blendParams = subBody.Substring( blendModeIdx, end - blendModeIdx );
						m_blendData.BlendModeId = blendParams;
						TemplateHelperFunctions.CreateBlendMode( blendParams, ref m_blendData );
						if( m_blendData.ValidBlendMode )
						{
							AddId( blendParams, false );
						}
					}
				}
				//BLEND OP
				{
					int blendOpIdx = subBody.IndexOf( "BlendOp" );
					if( blendOpIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, blendOpIdx );
						string blendOpParams = subBody.Substring( blendOpIdx, end - blendOpIdx );
						BlendData.BlendOpId = blendOpParams;
						TemplateHelperFunctions.CreateBlendOp( blendOpParams, ref m_blendData );
						if( m_blendData.ValidBlendOp )
						{
							AddId( blendOpParams, false );
						}
					}

					m_blendData.DataCheck = ( m_blendData.ValidBlendMode || m_blendData.ValidBlendOp ) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
				}

				//STENCIL
				{
					int stencilIdx = subBody.IndexOf( "Stencil" );
					if( stencilIdx > -1 )
					{
						int stencilEndIdx = subBody.IndexOf( "}", stencilIdx );
						if( stencilEndIdx > 0 )
						{
							string stencilParams = subBody.Substring( stencilIdx, stencilEndIdx + 1 - stencilIdx );
							m_stencilData.StencilBufferId = stencilParams;
							TemplateHelperFunctions.CreateStencilOps( stencilParams, ref m_stencilData );
							if( m_stencilData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( stencilParams, true );
							}
						}
					}
				}

				//ZWRITE
				{
					int zWriteOpIdx = subBody.IndexOf( "ZWrite" );
					if( zWriteOpIdx > -1 )
					{
						int zWriteEndIdx = subBody.IndexOf( TemplatesManager.TemplateNewLine, zWriteOpIdx );
						if( zWriteEndIdx > 0 )
						{
							m_depthData.ZWriteModeId = subBody.Substring( zWriteOpIdx, zWriteEndIdx + 1 - zWriteOpIdx );
							TemplateHelperFunctions.CreateZWriteMode( m_depthData.ZWriteModeId, ref m_depthData );
							if( m_depthData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( m_depthData.ZWriteModeId, true );
							}
						}
					}
				}

				//ZTEST
				{
					int zTestOpIdx = subBody.IndexOf( "ZTest" );
					if( zTestOpIdx > -1 )
					{
						int zTestEndIdx = subBody.IndexOf( TemplatesManager.TemplateNewLine, zTestOpIdx );
						if( zTestEndIdx > 0 )
						{
							m_depthData.ZTestModeId = subBody.Substring( zTestOpIdx, zTestEndIdx + 1 - zTestOpIdx );
							TemplateHelperFunctions.CreateZTestMode( m_depthData.ZTestModeId, ref m_depthData );
							if( m_depthData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( m_depthData.ZTestModeId, true );
							}
						}
					}
				}

				//ZOFFSET
				{
					int zOffsetIdx = subBody.IndexOf( "Offset" );
					if( zOffsetIdx > -1 )
					{
						int zOffsetEndIdx = subBody.IndexOf( TemplatesManager.TemplateNewLine, zOffsetIdx );
						if( zOffsetEndIdx > 0 )
						{
							m_depthData.OffsetId = subBody.Substring( zOffsetIdx, zOffsetEndIdx + 1 - zOffsetIdx );
							TemplateHelperFunctions.CreateZOffsetMode( m_depthData.OffsetId, ref m_depthData );
							if( m_depthData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( m_depthData.OffsetId, true );
							}
						}
					}
				}

				//TAGS
				{
					int tagsIdx = subBody.IndexOf( "Tags" );
					if( tagsIdx > -1 )
					{
						int tagsEndIdx = subBody.IndexOf( "}", tagsIdx );
						if( tagsEndIdx > -1 )
						{
							m_tagData.Reset();
							m_tagData.TagsId = subBody.Substring( tagsIdx, tagsEndIdx + 1 - tagsIdx );
							TemplateHelperFunctions.CreateTags( ref m_tagData, true );
							m_tagData.DataCheck = TemplateDataCheck.Valid;
							AddId( m_tagData.TagsId, false );
						}
						else
						{
							m_tagData.DataCheck = TemplateDataCheck.Invalid;
						}
					}
					else
					{
						m_tagData.DataCheck = TemplateDataCheck.Invalid;
					}
				}
			}
		}

19 View Source File : CSharpCodeProvider.cs
License : MIT License
Project Creator : arasplm

private bool CodeIndexInMethodRegions(SyntaxNode root, int index)
		{
			string code = root.ToString();
			int regionStartEndex = code.IndexOf(GlobalConsts.RegionMethodCode);
			int regionEndIndex = code.IndexOf(GlobalConsts.EndregionMethodCode);
			return regionStartEndex < index && index < regionEndIndex;
		}

19 View Source File : CustomCompletionProvider.cs
License : MIT License
Project Creator : Actipro

public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup) {
			//
			// IMPORTANT NOTE:
			// The items and filters for this completion list are hard coded in this sample and
			// are simply meant to illustrate the rich features of the SyntaxEditor completion list.
			// When implementing a real language, you should vary the items and filters based
			// on the current context of the caret.
			//

			// Create a session
			CompletionSession session = new CompletionSession();
			session.CanCommitWithoutPopup = canCommitWithoutPopup;
			session.CanFilterUnmatchedItems = this.FilterUnmatchedItems;
			session.MatchOptions = CompletionMatchOptions.UseAcronyms | CompletionMatchOptions.UseShorthand;

			// Add some items
			var highlightingStyleRegistry = view.HighlightingStyleRegistry;
			session.Items.Add(new CompletionItem("_intValue", new CommonImageSourceProvider(CommonImageKind.FieldPrivate), 
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>Foo._intValue</b><br/><span style=\"color: " + 
					HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">An integer value.</span>")));
			session.Items.Add(new CompletionItem("Equals", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">bool</span> <b>object.Equals</b>(<span style=\"color: " + 
					HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">object</span> obj)<br/><span style=\"color: " + 
					HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Determines whether the specified <b>System.Object</b> is equal to the current <b>System.Object</b>.</span>")));
			session.Items.Add(new CompletionItem("GetHashCode", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>object.GetHashCode</b>()<br/><span style=\"color: " + 
					HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Gets a hash code for this <b>System.Object</b>.</span>")));
			session.Items.Add(new CompletionItem("GetType", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Type</span> <b>object.GetType</b>()<br/><span style=\"color: " + 
					HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Gets the <b>System.Type</b> of the current instance.</span>")));
			session.Items.Add(new CompletionItem("IntValue", new CommonImageSourceProvider(CommonImageKind.PropertyPublic), 
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>Foo.IntValue</b><br/><span style=\"color: " + 
					HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">An integer value.</span>")));
			session.Items.Add(new CompletionItem("IntValueChanged", new CommonImageSourceProvider(CommonImageKind.EventPublic),
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">EventHandler</span> <b>Foo.IntValueChanged</b>")));
			session.Items.Add(new CompletionItem("OnIntValueChanged", new CommonImageSourceProvider(CommonImageKind.MethodProtected),
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">void</span> <b>Foo.OnIntValueChanged</b>(<span style=\"color: " + 
					HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">EventArgs</span> e)")));
			session.Items.Add(new CompletionItem("ToString", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
				new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">string</span> <b>object.ToString</b>()<br/><span style=\"color: " + 
					HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Returns the string representation of the object.</span>")));

			//
			// NOTE: In the filters below, the filtering conditions are just looking at the item text and image used.
			//   Normally you would store some contextual object in the Tag property and examine that instead.
			//

			if (this.MemberTypeFilterButtonsVisible == true) {
				// Add member type filters
				session.Filters.Add(new CompletionFilter("Events",
					(mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Event"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
					) {
						DisplayMode = CompletionFilterDisplayMode.ToggleButton,
						GroupName = "MemberType",
						ToolTip = "Events",
						Content = new Image() { Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.EventPublic).GetImageSource() },
						KeyGesture = new KeyGesture(VKey.E, VModifierKeys.Alt)
					});
				session.Filters.Add(new CompletionFilter("Fields",
					(mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Field"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
					) {
						DisplayMode = CompletionFilterDisplayMode.ToggleButton,
						GroupName = "MemberType",
						ToolTip = "Fields",
						Content = new Image() { Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.FieldPublic).GetImageSource() },
						KeyGesture = new KeyGesture(VKey.F, VModifierKeys.Alt)
					});
				session.Filters.Add(new CompletionFilter("Methods",
					(mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Method"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
					) {
						DisplayMode = CompletionFilterDisplayMode.ToggleButton,
						GroupName = "MemberType",
						ToolTip = "Methods",
						Content = new Image() { Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.MethodPublic).GetImageSource() },
						KeyGesture = new KeyGesture(VKey.M, VModifierKeys.Alt)
					});
				session.Filters.Add(new CompletionFilter("Properties",
					(mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Property"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
					) {
						DisplayMode = CompletionFilterDisplayMode.ToggleButton,
						GroupName = "MemberType",
						ToolTip = "Properties",
						Content = new Image() { Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.PropertyPublic).GetImageSource() },
						KeyGesture = new KeyGesture(VKey.P, VModifierKeys.Alt)
					});
			}

			if (this.InheritedFilterButtonVisible == true) {
				// Add inherited filter
				session.Filters.Add(new CompletionFilter("Inherited",
					(CompletionFilterPredicate)delegate(ICompletionSession mysession, ICompletionItem item) { return ("Equals,GetHashCode,GetType,ToString".IndexOf(item.Text) != -1) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded; }) {
						DisplayMode = CompletionFilterDisplayMode.ToggleButton,
						GroupName = "Inherited",
						ToolTip = "Inherited members",
						Content = "Inherited",
						KeyGesture = new KeyGesture(VKey.I, VModifierKeys.Alt)
					});
			}

			if (this.FilterTabsVisible == true) {
				// Add access filters
				session.Filters.Add(new CompletionFilter("All",
					(mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().EndsWith("Public"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
					) {
						DisplayMode = CompletionFilterDisplayMode.AllTab,
						ToolTip = "All members",
						Content = "All members",
						KeyGesture = new KeyGesture(VKey.A, VModifierKeys.Alt)
					});
				session.Filters.Add(new CompletionFilter("Public",
					(mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().EndsWith("Public"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
					) {
						DisplayMode = CompletionFilterDisplayMode.Tab,
						ToolTip = "Public members",
						Content = "Public members",
						KeyGesture = new KeyGesture(VKey.B, VModifierKeys.Alt)
					});
			}

			if (session.Items.Count > 0) {
				// Ensure the caret is visible
				view.Scroller.ScrollToCaret();

				// Ensure the items are sorted and open the session
				session.Sorreplacedems();
				session.Open(view);
				return true;
			}

			return false;
		}

19 View Source File : ErrorPageMiddleware.cs
License : Apache License 2.0
Project Creator : aspnet

public Chunk Advance(string delimiter)
            {
                int indexOf = HasValue ? Text.IndexOf(delimiter, Start, End - Start, StringComparison.Ordinal) : -1;
                if (indexOf < 0)
                {
                    return new Chunk();
                }

                var chunk = new Chunk { Text = Text, Start = Start, End = indexOf };
                Start = indexOf + delimiter.Length;
                return chunk;
            }

19 View Source File : TemplatePostProcessor.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

static void OnPostprocessAllreplacedets( string[] importedreplacedets, string[] deletedreplacedets, string[] movedreplacedets, string[] movedFromreplacedetPaths )
		{
			if( UIUtils.CurrentWindow == null )
				return;

			TemplatesManager templatesManager = UIUtils.CurrentWindow.TemplatesManagerInstance;
			if( templatesManager == null )
				return;

			if ( !templatesManager.Initialized )
            {
				templatesManager.Init();
            }

			bool refreshMenuItems = false;
			for ( int i = 0; i < importedreplacedets.Length; i++ )
			{
				if ( TemplateHelperFunctions.CheckIfTemplate( importedreplacedets[ i ] ) )
				{
					refreshMenuItems = true;
					string guid = replacedetDatabase.replacedetPathToGUID( importedreplacedets[ i ] );
					TemplateDataParent templateData = templatesManager.GetTemplate( guid );
					if( templateData != null )
					{
						templateData.Reload();
					}
					else
					{
						string name = TemplatesManager.OfficialTemplates.ContainsKey( guid ) ? TemplatesManager.OfficialTemplates[ guid ] : string.Empty;
						TemplateMultiPreplaced mp = TemplateMultiPreplaced.CreateInstance<TemplateMultiPreplaced>();
						mp.Init( name, guid );
						templatesManager.AddTemplate( mp );
					}
				}
			}
			
			if ( deletedreplacedets.Length > 0 )
			{
				if ( deletedreplacedets[ 0 ].IndexOf( Constants.InvalidPostProcessDatapath ) < 0 )
				{
					for ( int i = 0; i < deletedreplacedets.Length; i++ )
					{
						string guid = replacedetDatabase.replacedetPathToGUID( deletedreplacedets[ i ] );
						TemplateDataParent templateData = templatesManager.GetTemplate( guid );
						if ( templateData != null )
						{
							// Close any window using that template
							int windowCount = IOUtils.AllOpenedWindows.Count;
							for ( int windowIdx = 0; windowIdx < windowCount; windowIdx++ )
							{
								TemplateMasterNode masterNode = IOUtils.AllOpenedWindows[ windowIdx ].CurrentGraph.CurrentMasterNode as TemplateMasterNode;
								if ( masterNode != null && masterNode.CurrentTemplate.GUID.Equals( templateData.GUID ) )
								{
									IOUtils.AllOpenedWindows[ windowIdx ].Close();
								}
							}

							templatesManager.RemoveTemplate( templateData );
							refreshMenuItems = true;
						}
					}
				}
			}

			for ( int i = 0; i < movedreplacedets.Length; i++ )
			{
				if ( TemplateHelperFunctions.CheckIfTemplate( movedreplacedets[ i ] ) )
				{
					refreshMenuItems = true;
					break;
				}
			}

			for ( int i = 0; i < movedFromreplacedetPaths.Length; i++ )
			{
				if ( TemplateHelperFunctions.CheckIfTemplate( movedFromreplacedetPaths[ i ] ) )
				{
					refreshMenuItems = true;
					break;
				}
			}
			if( refreshMenuItems )
			{
				refreshMenuItems = false;
				templatesManager.CreateTemplateMenuItems();

				int windowCount = IOUtils.AllOpenedWindows.Count;
				for( int windowIdx = 0; windowIdx < windowCount; windowIdx++ )
				{
					IOUtils.AllOpenedWindows[ windowIdx ].CurrentGraph.ForceCategoryRefresh();
				}
			}
		}

19 View Source File : TemplateShaderData.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

public static TemplateShaderInfo CreateShaderData( string body )
		{
			int nameBegin = body.IndexOf( TemplatesManager.TemplateShaderNameBeginTag );
			if( nameBegin < 0 )
			{
				// Not a template
				return null;
			}

			TemplateShaderInfo shaderData = null;
			//SHADER
			MatchCollection shaderMatch = Regex.Matches( body, "\\bShader\\b" );
			if( shaderMatch.Count > 0 )
			{
				//SUBSHADER
				MatchCollection subShaderMatch = Regex.Matches( body, TemplatesManager.TemplateMPSubShaderTag );
				int subShaderAmount = subShaderMatch.Count;
				if( subShaderAmount > 0 )
				{
					shaderData = new TemplateShaderInfo();
					shaderData.Body = body;
					int length = subShaderMatch[ 0 ].Index - shaderMatch[ 0 ].Groups[ 0 ].Index;
					shaderData.Properties = body.Substring( shaderMatch[ 0 ].Index, length );
					shaderData.PropertyStartIdx = body.IndexOf( TemplatesManager.TemplatePropertyTag );

					for( int subShaderIdx = 0; subShaderIdx < subShaderAmount; subShaderIdx++ )
					{
						TemplateSubShaderInfo subShaderData = new TemplateSubShaderInfo();
						int subshaderBeginIndex = subShaderMatch[ subShaderIdx ].Index;
						int subShaderEndIndex = ( subShaderIdx == ( subShaderAmount - 1 ) ) ? body.Length - 1 : subShaderMatch[ subShaderIdx + 1 ].Index;
						subShaderData.Data = body.Substring( subshaderBeginIndex, subShaderEndIndex - subshaderBeginIndex );
						subShaderData.StartIdx = subshaderBeginIndex;

						//Preplaced
						MatchCollection preplacedMatch = Regex.Matches( subShaderData.Data, TemplatesManager.TemplateMPPreplacedTag );
						int preplacedCount = preplacedMatch.Count;
						if( preplacedCount > 0 )
						{
							subShaderData.Modules = subShaderData.Data.Substring( 0, preplacedMatch[ 0 ].Index );
							for( int preplacedIdx = 0; preplacedIdx < preplacedCount; preplacedIdx++ )
							{
								int preplacedBeginIndex = preplacedMatch[ preplacedIdx ].Index;
								int preplacedEndIdx = ( preplacedIdx == ( preplacedCount - 1 ) ) ? subShaderData.Data.Length - 1 : preplacedMatch[ preplacedIdx + 1 ].Index;
								TemplatePreplacedInfo preplacedData = new TemplatePreplacedInfo();
								preplacedData.Data = subShaderData.Data.Substring( preplacedBeginIndex, preplacedEndIdx - preplacedBeginIndex );
								preplacedData.GlobalStartIdx = subshaderBeginIndex + preplacedBeginIndex;
								preplacedData.LocalStartIdx = preplacedBeginIndex;
								subShaderData.Preplacedes.Add( preplacedData );
							}
							shaderData.SubShaders.Add( subShaderData );
						}
					}
				}
			}
			return shaderData;
		}

19 View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro

private void OnTreeListBoxItemSelecting(object sender, TreeListBoxItemEventArgs e) {
			if (true.Equals(this.CanBlockNames)) {
				var model = e.Item as TreeNodeModel;
				if ((model != null) && (!string.IsNullOrEmpty(model.Name)))
					e.Cancel = ("ABCDE".IndexOf(model.Name[0].ToString(), StringComparison.OrdinalIgnoreCase) != -1);
			}
		}

19 View Source File : Reader.cs
License : Apache License 2.0
Project Creator : Algoryx

public static GameObject Instantiate( string urdfFilePath,
                                          Func<string, AGXUnity.IO.URDF.Model.ResourceType, GameObject> resourceLoader = null,
                                          bool silent = true )
    {
      GameObject instance = null;
      agx.Timer timer = null;
      var pColor = InspectorGUISkin.BrandColorBlue;
      try {
        if ( !silent ) {
          Debug.Log( $"Reading URDF: '{AddColor( urdfFilePath, pColor )}'..." );
          timer = new agx.Timer( true );
        }

        // Reading model, will throw if anything goes wrong.
        var model = AGXUnity.IO.URDF.Model.Read( urdfFilePath );

        if ( !silent )
          Debug.Log( $"Successfully read " +
                     $"{AddColor( $"{model.Links.Count()} links", pColor )}, " +
                     $"{AddColor( $"{model.Joints.Count()} joints", pColor )} and " +
                     $"{AddColor( $"{model.Materials.Count()} materials", pColor )} in " +
                     $"{AddColor( timer.getTime().ToString("0.00"), pColor )} ms." );

        // Open "select folder" panel if the model requires resources
        // and no resource loader callback is provided.
        var dataDirectory = string.Empty;
        if ( resourceLoader == null && model.RequiresResourceLoader ) {
          var resourcePath = model.RequiredResources.First();
          var sugestedDirectory = System.IO.Path.GetDirectoryName( urdfFilePath ).Replace( '\\', '/' );
          var packageRootFound = false;
          // Finding package root directory.
          if ( resourcePath.StartsWith( "package://" ) ) {
            resourcePath = resourcePath.Substring( "package://".Length );
            try {
              var files = ( from filename in System.IO.Directory.GetFiles( "replacedets",
                                                                            System.IO.Path.GetFileName( resourcePath ),
                                                                            System.IO.SearchOption.AllDirectories )
                            select filename.Replace( '\\', '/' ) ).ToArray();

              var numFound = 0;
              foreach ( var file in files ) {
                var startIndex = file.IndexOf( resourcePath );
                if ( startIndex >= 0 ) {
                  // Selecting first found if many as sugestedDirectory for folder panel.
                  if ( numFound == 0 )
                    sugestedDirectory = file.Substring( 0, startIndex - 1 );
                  ++numFound;
                }
              }
              packageRootFound = numFound == 1;
            }
            catch ( System.IO.IOException ) {
            }
          }
          // replaceduming path is relative to the URDF file.
          else {
            packageRootFound = System.IO.File.Exists( sugestedDirectory + '/' + resourcePath );
          }

          if ( packageRootFound )
            dataDirectory = sugestedDirectory;
          else {
            dataDirectory = EditorUtility.OpenFolderPanel( $"Select '{urdfFilePath}' root data folder.",
                                                           sugestedDirectory,
                                                           "" );
            if ( !string.IsNullOrEmpty( dataDirectory ) )
              dataDirectory = Utils.MakeRelative( dataDirectory, Application.dataPath );
          }

          if ( !replacedetDatabase.IsValidFolder( dataDirectory ) ) {
            Debug.LogWarning( $"Unable to find given '{dataDirectory}' in the project replacedets folder." );
            dataDirectory = string.Empty;
          }
          else if ( !silent )
            Debug.Log( $"Using data directory: '{AddColor( dataDirectory, pColor )}'." );
        }

        if ( !silent )
          timer.reset( true );

        // Instantiating the model, will throw if anything goes wrong.
        using ( new AGXUnityEditor.Utils.UndoCollapseBlock( $"Instantiating model {model.Name}" ) )
          instance = model.Instantiate( resourceLoader ?? CreateDefaultResourceLoader( dataDirectory ),
                                        obj => Undo.RegisterCreatedObjectUndo( obj, $"Created: {obj.name}" ) );

        if ( !silent )
          Debug.Log( $"Successfully instantiated URDF robot: '{AddColor( instance.name, pColor )}' in " +
                     $"{AddColor( timer.getTime().ToString( "0.00" ), pColor )} ms." );
      }
      catch ( System.Xml.XmlException e ) {
        Debug.LogException( e );
        return null;
      }

      return instance;
    }

19 View Source File : TemplateData.cs
License : MIT License
Project Creator : alexismorin

void FetchCodeAreas( string begin, MasterNodePortCategory category )
		{
			int areaBeginIndexes = m_templateBody.IndexOf( begin );

			if( areaBeginIndexes > -1 )
			{
				int beginIdx = areaBeginIndexes + begin.Length;
				int endIdx = m_templateBody.IndexOf( TemplatesManager.TemplateEndOfLine, beginIdx );
				int length = endIdx - beginIdx;

				string parameters = m_templateBody.Substring( beginIdx, length );

				string[] parametersArr = parameters.Split( IOUtils.FIELD_SEPARATOR );

				string id = m_templateBody.Substring( areaBeginIndexes, endIdx + TemplatesManager.TemplateEndOfLine.Length - areaBeginIndexes );
				string inParameters = parametersArr[ 0 ];
				string outParameters = ( parametersArr.Length > 1 ) ? parametersArr[ 1 ] : string.Empty;
				if( category == MasterNodePortCategory.Fragment )
				{
					m_fragmentFunctionData = new TemplateFunctionData(-1, string.Empty, id, areaBeginIndexes, inParameters, outParameters, category );
				}
				else
				{
					m_vertexFunctionData = new TemplateFunctionData( -1, string.Empty,id, areaBeginIndexes, inParameters, outParameters, category );
				}
				AddId( id, true );
			}
		}

19 View Source File : ProcessRenamer.cs
License : GNU Lesser General Public License v3.0
Project Creator : Alois-xx

public string Rename(string exeName, string cmdLine)
            {
                string lret = exeName;
                if (ExeName.Equals(exeName, StringComparison.OrdinalIgnoreCase))
                {
                    bool hasMatches = CmdLineSubstrings.All(substr => cmdLine.IndexOf(substr, StringComparison.OrdinalIgnoreCase) != -1);

                    // empty filter counts a no filter
                    if (CmdLineSubstrings.Count == 0)
                    {
                        hasMatches = true;
                    }
                    bool hasNotMatches = NotCmdLineSubstrings.Where(x=> !String.IsNullOrEmpty(x)).Any(substr => cmdLine.IndexOf(substr, StringComparison.OrdinalIgnoreCase) != -1);

                    if (hasMatches && !hasNotMatches)
                    {
                        lret = NewExeName;
                    }
                }

                return lret;
            }

19 View Source File : AopJsonParser.cs
License : Apache License 2.0
Project Creator : alipay

private static EncryptParseItem ParseEncrypreplacedem(string body, string rootNode, int indexOfRootNode)
        {
            int signDataStartIndex = indexOfRootNode + rootNode.Length + 2;
            int indexOfSign = body.IndexOf("\"" + AlipayConstants.SIGN + "\"", StringComparison.Ordinal);

            int signDataEndIndex = extractJsonBase64ValueEndPosition(body, signDataStartIndex);

            if (signDataEndIndex < 0)
            {
                signDataEndIndex = body.Length - 1;
            }

            int length = signDataEndIndex - signDataStartIndex;

            string encyptContent = body.Substring(signDataStartIndex + 1, length - 2);

            EncryptParseItem item = new EncryptParseItem();
            item.encryptContent = encyptContent;
            item.startIndex = signDataStartIndex;
            item.endIndex = signDataEndIndex;


            return item;
        }

19 View Source File : TemplatePass.cs
License : MIT License
Project Creator : alexismorin

void FetchVertexAndInterpData( TemplateModulesData subShaderModule, int offsetIdx, string body )
		{
			// Vertex Data
			try
			{
				int vertexDataTagBegin = body.IndexOf( TemplatesManager.TemplateVertexDataTag );
				if( vertexDataTagBegin > -1 )
				{
					m_vertexDataContainer = new VertexDataContainer();
					m_vertexDataContainer.VertexDataStartIdx = offsetIdx + vertexDataTagBegin;
					int vertexDataTagEnd = body.IndexOf( TemplatesManager.TemplateEndOfLine, vertexDataTagBegin );
					m_vertexDataContainer.VertexDataId = body.Substring( vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin );
					int dataBeginIdx = body.LastIndexOf( '{', vertexDataTagBegin, vertexDataTagBegin );
					string vertexData = body.Substring( dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx );

					int parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
					string parameters = body.Substring( parametersBegin, vertexDataTagEnd - parametersBegin );
					m_vertexDataContainer.VertexData = TemplateHelperFunctions.CreateVertexDataList( vertexData, parameters );
					m_templateProperties.AddId( body, m_vertexDataContainer.VertexDataId );
				}
			}
			catch( Exception e )
			{
				Debug.LogException( e );
			}

			// Available interpolators
			try
			{
				int interpDataBegin = body.IndexOf( TemplatesManager.TemplateInterpolatorBeginTag );
				if( interpDataBegin > -1 )
				{
					int interpDataEnd = body.IndexOf( TemplatesManager.TemplateEndOfLine, interpDataBegin );
					string interpDataId = body.Substring( interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin );

					int dataBeginIdx = body.LastIndexOf( '{', interpDataBegin, interpDataBegin );
					string interpData = body.Substring( dataBeginIdx + 1, interpDataBegin - dataBeginIdx );

					int interpolatorAmount = TemplateHelperFunctions.AvailableInterpolators[ "2.5" ];

					if( m_modules.ShaderModel.IsValid )
					{
						interpolatorAmount = m_modules.ShaderModel.InterpolatorAmount;
					}
					else if( subShaderModule.ShaderModel.IsValid )
					{
						interpolatorAmount = subShaderModule.ShaderModel.InterpolatorAmount;
					}

					m_interpolatorDataContainer = TemplateHelperFunctions.CreateInterpDataList( interpData, interpDataId, interpolatorAmount );
					m_interpolatorDataContainer.InterpDataId = interpDataId;
					m_interpolatorDataContainer.InterpDataStartIdx = offsetIdx + interpDataBegin;
					m_templateProperties.AddId( body, interpDataId );

				}
			}
			catch( Exception e )
			{
				Debug.LogException( e );
			}
		}

19 View Source File : CommitItemTest.cs
License : Apache License 2.0
Project Creator : AmpScm

[Test]
        public void CommitMultipleRepositories()
        {
            // we need a second repos
            string repos2Path = Path.Combine( @"\tmp", "repos2" );
            string repos2Url = ExtractRepos( "Ankh.Tests.repos2.zip", repos2Path, this.GetType() );
            string wc2Path = this.FindDirName( Path.Combine(@"\tmp", "wc2") );
            this.RunCommand( "svn", String.Format( "co {0} {1}", repos2Url, wc2Path ) );
            string path1 = Path.Combine( wc2Path, "replacedemblyInfo.cs" );
            this.Modify( path1 );
            SvnItem item1 = this.ctx.StatusCache[path1];
            
            string path2 = Path.Combine( this.WcPath, "Clreplaced1.cs" );
            this.Modify( path2 );
            SvnItem item2 = this.ctx.StatusCache[path2];

            replacedert.AreEqual( item1.Status.TextStatus, StatusKind.Modified );
            replacedert.AreEqual( item2.Status.TextStatus, StatusKind.Modified );

            this.uiShell.Commireplacedems = new SvnItem[]{ item1, item2 };
            this.cmd.Execute( this.ctx, "" );

            replacedert.AreEqual( item1.Status.TextStatus, StatusKind.Normal );
            replacedert.AreEqual( item2.Status.TextStatus, StatusKind.Normal );

            replacedert.IsTrue( this.ctx.Description.IndexOf( item1.Status.Entry.Uuid ) >= 0 );
            replacedert.IsTrue( this.ctx.Description.IndexOf( item2.Status.Entry.Uuid ) >= 0 );
            
        }

19 View Source File : Clipboard.cs
License : MIT License
Project Creator : alexismorin

public Vector3 GetDataFromEditorPrefs()
		{
			Vector3 initialPos = Vector3.zero;
			m_clipboardStrData.Clear();
			m_clipboardAuxData.Clear();
			string clipboardData = EditorPrefs.GetString( ClipboardId, string.Empty );
			if ( !string.IsNullOrEmpty( clipboardData ) )
			{
				string[] clipboardDataArray = clipboardData.Split( ClipboardTagId, StringSplitOptions.None );
				initialPos = IOUtils.StringToVector3( clipboardDataArray[0] );
				for ( int i = 1; i < clipboardDataArray.Length; i++ )
				{
					if ( !string.IsNullOrEmpty( clipboardDataArray[ i ] ) )
					{
						int wiresIndex = clipboardDataArray[ i ].IndexOf( IOUtils.LINE_TERMINATOR );
						string nodeData = string.Empty;
						string connections = string.Empty;
						if ( wiresIndex < 0 )
						{
							nodeData = clipboardDataArray[ i ];
						}
						else
						{
							nodeData = clipboardDataArray[ i ].Substring( 0, wiresIndex );
							connections = clipboardDataArray[ i ].Substring( wiresIndex + 1 );
						}
						string[] nodeDataArr = nodeData.Split( IOUtils.FIELD_SEPARATOR );
						if ( nodeDataArr.Length > 2 )
						{
							int nodeId = Convert.ToInt32( nodeDataArr[ 2 ] );
							ClipboardData data = new ClipboardData( nodeData, connections, nodeId );
							m_clipboardStrData.Add( data );
							m_clipboardAuxData.Add( nodeId, data );
						}

					}
				}
			}
			return initialPos;
		}

19 View Source File : InfoboxExtractor.cs
License : MIT License
Project Creator : AnnoDesigner

private string GetInfobox(string content, int startIndex)
        {
            string result = null;

            //handle files with no infobox
            if (startIndex == -1)
            {
                return result;
            }

            //find {{ before
            //if before = {{Goodsicon, search further for }}
            //repeat until false

            var endIndex = content.IndexOf(_commons.InfoboxTemplateEnd, startIndex, StringComparison.OrdinalIgnoreCase);
            var subStartIndex = startIndex;
            while (endIndex != -1)
            {
                var subContent = content.Substring(subStartIndex, content.Length - subStartIndex);
                if (subContent.Contains("{{Goodsicon"))
                {
                    subStartIndex = endIndex + _commons.InfoboxTemplateEnd.Length;
                    endIndex = content.IndexOf(_commons.InfoboxTemplateEnd, subStartIndex, StringComparison.OrdinalIgnoreCase);
                }
                else
                {
                    endIndex = content.IndexOf(_commons.InfoboxTemplateEnd, subStartIndex, StringComparison.OrdinalIgnoreCase);
                    break;
                }
            }

            int length = endIndex - startIndex + _commons.InfoboxTemplateEnd.Length;

            var infoBox = content.Substring(startIndex, length);
            if (!string.IsNullOrWhiteSpace(infoBox))
            {
                result = FormatInfobox(infoBox);
            }

            return result;
        }

19 View Source File : TemplatePass.cs
License : MIT License
Project Creator : alexismorin

void FetchInputs( int offset, MasterNodePortCategory portCategory, string body )
		{
			string beginTag = ( portCategory == MasterNodePortCategory.Fragment ) ? TemplatesManager.TemplateInputsFragBeginTag : TemplatesManager.TemplateInputsVertBeginTag;
			int[] inputBeginIndexes = body.AllIndexesOf( beginTag );
			if( inputBeginIndexes != null && inputBeginIndexes.Length > 0 )
			{
				for( int i = 0; i < inputBeginIndexes.Length; i++ )
				{
					int inputEndIdx = body.IndexOf( TemplatesManager.TemplateEndSectionTag, inputBeginIndexes[ i ] );
					int defaultValueBeginIdx = inputEndIdx + TemplatesManager.TemplateEndSectionTag.Length;
					int endLineIdx = body.IndexOf( TemplatesManager.TemplateFullEndTag, defaultValueBeginIdx );

					string defaultValue = body.Substring( defaultValueBeginIdx, endLineIdx - defaultValueBeginIdx );
					string tagId = body.Substring( inputBeginIndexes[ i ], endLineIdx + TemplatesManager.TemplateFullEndTag.Length - inputBeginIndexes[ i ] );

					int beginIndex = inputBeginIndexes[ i ] + beginTag.Length;
					int length = inputEndIdx - beginIndex;
					string inputData = body.Substring( beginIndex, length );
					string[] inputDataArray = inputData.Split( IOUtils.FIELD_SEPARATOR );

					if( inputDataArray != null && inputDataArray.Length > 0 )
					{
						try
						{
							string portName = inputDataArray[ (int)TemplatePortIds.Name ];
							WirePortDataType dataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), inputDataArray[ (int)TemplatePortIds.DataType ].ToUpper() );
							if( inputDataArray.Length == 3 )
							{
								int portOrderId = m_inputDataList.Count;
								int portUniqueId = -1;
								bool isInt = int.TryParse( inputDataArray[ 2 ], out portUniqueId );
								if( isInt )
								{
									if( portUniqueId < 0 )
										portUniqueId = m_inputDataList.Count;

									m_inputDataList.Add( new TemplateInputData( inputBeginIndexes[ i ], offset + inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, string.Empty ) );
									m_templateProperties.AddId( body, tagId, false );
								}
								else
								{
									portUniqueId = m_inputDataList.Count;
									m_inputDataList.Add( new TemplateInputData( inputBeginIndexes[ i ], offset + inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, inputDataArray[ 2 ] ) );
									m_templateProperties.AddId( body, tagId, false );
								}
							}
							else
							{
								int portUniqueIDArrIdx = (int)TemplatePortIds.UniqueId;
								int portUniqueId = ( portUniqueIDArrIdx < inputDataArray.Length ) ? Convert.ToInt32( inputDataArray[ portUniqueIDArrIdx ] ) : -1;
								if( portUniqueId < 0 )
									portUniqueId = m_inputDataList.Count;

								int portOrderArrayIdx = (int)TemplatePortIds.OrderId;
								int portOrderId = ( portOrderArrayIdx < inputDataArray.Length ) ? Convert.ToInt32( inputDataArray[ portOrderArrayIdx ] ) : -1;
								if( portOrderId < 0 )
									portOrderId = m_inputDataList.Count;

								int portLinkIdx = (int)TemplatePortIds.Link;
								string linkId = ( portLinkIdx < inputDataArray.Length ) ? inputDataArray[ portLinkIdx ] : string.Empty;
								m_inputDataList.Add( new TemplateInputData( inputBeginIndexes[ i ], offset + inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, linkId ) );
								m_templateProperties.AddId( body, tagId, false );
							}
						}
						catch( Exception e )
						{
							Debug.LogException( e );
						}
					}
				}
			}
		}

19 View Source File : ScriptDocumentTab.cs
License : GNU General Public License v3.0
Project Creator : anotak

public bool FindNext(FindReplaceOptions options)
		{
			byte[] data = editor.GetText();
			string text = Encoding.GetEncoding(config.CodePage).GetString(data);
			StringComparison mode = options.CaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;
			int startpos = Math.Max(editor.SelectionStart, editor.SelectionEnd);
			bool wrapped = false;
			
			while(true)
			{
				int result = text.IndexOf(options.FindText, startpos, mode);
				if(result > -1)
				{
					// Check to see if it is the whole word
					if(options.WholeWord)
					{
						// Veryfy that we have found a whole word
						string foundword = editor.GetWordAt(result + 1);
						if(foundword.Length != options.FindText.Length)
						{
							startpos = result + 1;
							result = -1;
						}
					}
					
					// Still ok?
					if(result > -1)
					{
						// Select the result
						editor.SelectionStart = result;
						editor.SelectionEnd = result + options.FindText.Length;
						editor.EnsureLineVisible(editor.LineFromPosition(editor.SelectionEnd));
						return true;
					}
				}
				else
				{
					// If we haven't tried from the start, try from the start now
					if((startpos > 0) && !wrapped)
					{
						startpos = 0;
						wrapped = true;
					}
					else
					{
						// Can't find it
						return false;
					}
				}
			}
		}

19 View Source File : ITextSource.cs
License : MIT License
Project Creator : Abdesol

public int IndexOf(string searchText, int startIndex, int count, StringComparison comparisonType)
		{
			return text.IndexOf(searchText, startIndex, count, comparisonType);
		}

19 View Source File : UTF8String.cs
License : GNU General Public License v3.0
Project Creator : anydream

public int IndexOf(string value, int startIndex, int count, StringComparison comparisonType) {
			return String.IndexOf(value, startIndex, count, comparisonType);
		}

19 View Source File : TemplateShaderData.cs
License : MIT License
Project Creator : alexismorin

public static TemplateShaderInfo CreateShaderData( string body )
		{
			int nameBegin = body.IndexOf( TemplatesManager.TemplateShaderNameBeginTag );
			if( nameBegin < 0 )
			{
				// Not a template
				return null;
			}

			TemplateShaderInfo shaderData = null;
			//SHADER
			MatchCollection shaderMatch = Regex.Matches( body, "\\bShader\\b" );
			if( shaderMatch.Count > 0 )
			{
				//SUBSHADER
				MatchCollection subShaderMatch = Regex.Matches( body, TemplatesManager.TemplateMPSubShaderTag );
				int subShaderAmount = subShaderMatch.Count;
				if( subShaderAmount > 0 )
				{
					shaderData = new TemplateShaderInfo();
					shaderData.Body = body;
					int length = subShaderMatch[ 0 ].Index - shaderMatch[ 0 ].Groups[ 0 ].Index;
					shaderData.Properties = body.Substring( shaderMatch[ 0 ].Index, length );
					shaderData.PropertyStartIdx = body.IndexOf( TemplatesManager.TemplatePropertyTag );

					for( int subShaderIdx = 0; subShaderIdx < subShaderAmount; subShaderIdx++ )
					{
						TemplateSubShaderInfo subShaderData = new TemplateSubShaderInfo();
						int subshaderBeginIndex = subShaderMatch[ subShaderIdx ].Index;
						int subShaderEndIndex = ( subShaderIdx == ( subShaderAmount - 1 ) ) ? body.Length - 1 : subShaderMatch[ subShaderIdx + 1 ].Index;
						subShaderData.Data = body.Substring( subshaderBeginIndex, subShaderEndIndex - subshaderBeginIndex );
						subShaderData.StartIdx = subshaderBeginIndex;

						//Preplaced
						MatchCollection preplacedMatch = Regex.Matches( subShaderData.Data, TemplatesManager.TemplatePreplacedTagPattern );
						if( preplacedMatch.Count == 0 )
						{
							preplacedMatch = Regex.Matches( subShaderData.Data, TemplatesManager.TemplateMPPreplacedTag );
						}

						int preplacedCount = preplacedMatch.Count;
						if( preplacedCount > 0 )
						{
							int lastPreplacedIndex = subShaderData.Data.LastIndexOf( TemplatesManager.TemplatePreplacedesEndTag );
							if( lastPreplacedIndex < 0 )
							{
								lastPreplacedIndex = subShaderData.Data.Length - 1;
							}

							subShaderData.Modules = subShaderData.Data.Substring( 0, preplacedMatch[ 0 ].Index );
							for( int preplacedIdx = 0; preplacedIdx < preplacedCount; preplacedIdx++ )
							{
								int preplacedBeginIndex = preplacedMatch[ preplacedIdx ].Index;
								int preplacedEndIdx = ( preplacedIdx == ( preplacedCount - 1 ) ) ? lastPreplacedIndex : preplacedMatch[ preplacedIdx + 1 ].Index;
								TemplatePreplacedInfo preplacedData = new TemplatePreplacedInfo();
								preplacedData.Data = subShaderData.Data.Substring( preplacedBeginIndex, preplacedEndIdx - preplacedBeginIndex );
								preplacedData.GlobalStartIdx = subshaderBeginIndex + preplacedBeginIndex;
								preplacedData.LocalStartIdx = preplacedBeginIndex;
								subShaderData.Preplacedes.Add( preplacedData );
							}
							shaderData.SubShaders.Add( subShaderData );
						}
					}
				}
			}
			return shaderData;
		}

19 View Source File : Tag.cs
License : MIT License
Project Creator : aprilyush

public virtual void ProcessEndTag(Template ownerTemplate, Tag container, Stack<Tag> tagStack, string text, ref Match match)
        {
            int charOffset = 0, offset = 0;
            bool isClosedTag;

            charOffset = offset = match.Index + match.Length;
            match = null;
            while (offset < text.Length)
            {
                if (ParserHelper.IsVariableTagStart(text, offset) && (match = ParserRegex.VarTagRegex.Match(text, offset)).Success)                //匹配到模板变量
                {
                    //构建文本节点
                    ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
                    //构建模板变量
                    ParserHelper.CreateVariableTag(ownerTemplate, container, match);
                }
                else if (ParserHelper.IsTagStart(text, offset) && (match = ParserRegex.TagRegex.Match(text, offset)).Success)                     //匹配到某种类型的标签
                {
                    //构建文本节点
                    ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
                    //构建标签
                    Tag tag = ParserHelper.CreateTag(ownerTemplate, match, out isClosedTag);

                    if (container.IsSingleTag && tag.IsSingleTag)
                    {
                        //如果前容器是单一标签并且当前标签也是单一标签.则回退到上一级非单元素标签
                        while (tagStack.Count > 0)
                        {
                            container = tagStack.Peek();
                            if (container.IsSingleTag)
                            {
                                tagStack.Pop();
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    //将当前标签加入堆栈
                    tagStack.Push(tag);

                    //将解析权交给标签
                    bool flag = tag.ProcessBeginTag(ownerTemplate, container, tagStack, text, ref match, isClosedTag);
                    //非已闭合标签或者是单标签则处理标签的结束标签
                    if (flag)
                    {
                        tag.ProcessEndTag(ownerTemplate, tag, tagStack, text, ref match);
                    }
                    if (tagStack.Count > 0 && tagStack.Peek() == tag && isClosedTag)
                    {
                        //闭合标签则回滚一级
                        tagStack.Pop();
                    }
                    if (tag.IsSingleTag)
                    {
                        //如果标签是单标签则退出寻找
                        break;
                    }
                    else
                    {
                        //取得容器
                        if (tagStack.Count > 0) container = tagStack.Peek();
                    }
                }
                else if (ParserHelper.IsCloseTagStart(text, offset) && (match = ParserRegex.EndTagRegex.Match(text, offset)).Success)            //匹配到某个结束标签
                {
                    //构建文本节点
                    ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, match.Index - charOffset);
                    //取得标签名称
                    string name = match.Groups["tagname"].Value;

                    //回滚标签堆栈.直到回滚到同名称元素的上级为此
                    while (tagStack.Count > 0)
                    {
                        Tag popTag = tagStack.Pop();
                        if (name.Equals(popTag.TagName, StringComparison.InvariantCultureIgnoreCase)) break;
                        if (!name.Equals(popTag.EndTagName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            //非匹配的结束标签.则模板有错
                            throw new ParserException(string.Format("无效的结束标签,原期望的是{0}结束标签", popTag.EndTagName));
                        }
                    }
                    break;
                }
                else if (ParserHelper.IsVTExpressionStart(text, offset))
                {
                    char s = ParserHelper.ReadChar(text, offset + ParserHelper.VTExpressionHead.Length);
                    int startOffset = offset + ParserHelper.VTExpressionHead.Length + 1;
                    int lastOffset = text.IndexOf(s, offset + ParserHelper.VTExpressionHead.Length + 1);
                    if (lastOffset == -1) throw new ParserException(string.Format("无法找到VT表达式[{0}{1}]的结束标记[{1}]", ParserHelper.VTExpressionHead, s));
                    string code = text.Substring(startOffset, lastOffset - startOffset);
                    if (code.Length > 0)
                    {
                        //构建文本节点
                        ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, offset - charOffset);
                        //解析表达式里的代码
                        new TemplateDoreplacedent(ownerTemplate, container, code, ownerTemplate.OwnerDoreplacedent.DoreplacedentConfig);
                    }
                    offset = lastOffset + 1;
                    charOffset = offset;
                    continue;
                }
                else if (ParserHelper.IsCommentTagStart(text, offset))
                {
                    //构建文本节点
                    ParserHelper.CreateTextNode(ownerTemplate, container, text, charOffset, offset - charOffset);

                    //找到注释的起始标记"<!--vt[",则直接查找结束标记"]-->"
                    offset = text.IndexOf(ParserHelper.CommentTagEnd, offset + ParserHelper.CommentTagStart.Length);
                    if (offset == -1) throw new ParserException("无法找到注释的结束标记");
                    offset += ParserHelper.CommentTagEnd.Length;
                    charOffset = offset;
                    continue;
                }
                //处理偏移位置
                if (match != null && match.Success)
                {
                    charOffset = offset = match.Index + match.Length;
                    match = null;
                }
                else
                {
                    offset++;
                }
            }

            if (match == null) throw new ParserException(string.Format("{0}标签未闭合", container.TagName));
        }

19 View Source File : TemplateData.cs
License : MIT License
Project Creator : alexismorin

void FetchSubShaderProperties()
		{
			Match match = Regex.Match( m_templateBody, @"Preplaced\s*{" );
			if( match.Groups.Count == 0 )
			{
				return;
			}

			int beginSubShader = m_templateBody.IndexOf( "SubShader" );
			int endSubShader = match.Groups[ 0 ].Index;
			if( beginSubShader > 0 && endSubShader > 0 && endSubShader > beginSubShader )
			{
				// ADD A PLACE TO INSERT GRAB PreplacedES
				int preplacedIndex = m_templateBody.IndexOf( TemplatesManager.TemplatePreplacedTag );
				if( preplacedIndex < 0 )
				{
					int currIdx = endSubShader - 1;
					string identation = string.Empty;
					for( ; currIdx > 0; currIdx-- )
					{
						if( m_templateBody[ currIdx ] != '\n' )
						{
							identation = m_templateBody[ currIdx ] + identation;
						}
						else
						{
							identation = m_templateBody[ currIdx ] + identation;
							break;
						}
					}
					if( currIdx > 0 )
					{
						m_templateBody = m_templateBody.Insert( currIdx, identation + TemplatesManager.TemplatePreplacedTag );
					}
				}

				// GET ALL THE MODULES
				string subBody = m_templateBody.Substring( beginSubShader, endSubShader - beginSubShader );
				//CULL MODE
				{
					int cullIdx = subBody.IndexOf( "Cull" );
					if( cullIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, cullIdx );
						string cullParams = subBody.Substring( cullIdx, end - cullIdx );
						m_cullModeData.CullModeId = cullParams;
						TemplateHelperFunctions.CreateCullMode( cullParams, ref m_cullModeData );
						if( m_cullModeData.DataCheck == TemplateDataCheck.Valid )
							AddId( cullParams, false, string.Empty );
					}
				}
				//COLOR MASK
				{
					int colorMaskIdx = subBody.IndexOf( "ColorMask" );
					if( colorMaskIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, colorMaskIdx );
						string colorMaskParams = subBody.Substring( colorMaskIdx, end - colorMaskIdx );
						m_colorMaskData.ColorMaskId = colorMaskParams;
						TemplateHelperFunctions.CreateColorMask( colorMaskParams, ref m_colorMaskData );
						if( m_colorMaskData.DataCheck == TemplateDataCheck.Valid )
							AddId( colorMaskParams, false );
					}
				}
				//BlEND MODE
				{
					int blendModeIdx = subBody.IndexOf( "Blend" );
					if( blendModeIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, blendModeIdx );
						string blendParams = subBody.Substring( blendModeIdx, end - blendModeIdx );
						m_blendData.BlendModeId = blendParams;
						TemplateHelperFunctions.CreateBlendMode( blendParams, ref m_blendData );
						if( m_blendData.ValidBlendMode )
						{
							AddId( blendParams, false );
						}
					}
				}
				//BLEND OP
				{
					int blendOpIdx = subBody.IndexOf( "BlendOp" );
					if( blendOpIdx > 0 )
					{
						int end = subBody.IndexOf( TemplatesManager.TemplateNewLine, blendOpIdx );
						string blendOpParams = subBody.Substring( blendOpIdx, end - blendOpIdx );
						BlendData.BlendOpId = blendOpParams;
						TemplateHelperFunctions.CreateBlendOp( blendOpParams, ref m_blendData );
						if( m_blendData.ValidBlendOp )
						{
							AddId( blendOpParams, false );
						}
					}

					m_blendData.DataCheck = ( m_blendData.ValidBlendMode || m_blendData.ValidBlendOp ) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
				}

				//STENCIL
				{
					int stencilIdx = subBody.IndexOf( "Stencil" );
					if( stencilIdx > -1 )
					{
						int stencilEndIdx = subBody.IndexOf( "}", stencilIdx );
						if( stencilEndIdx > 0 )
						{
							string stencilParams = subBody.Substring( stencilIdx, stencilEndIdx + 1 - stencilIdx );
							m_stencilData.StencilBufferId = stencilParams;
							TemplateHelperFunctions.CreateStencilOps( stencilParams, ref m_stencilData );
							if( m_stencilData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( stencilParams, true );
							}
						}
					}
				}

				//ZWRITE
				{
					int zWriteOpIdx = subBody.IndexOf( "ZWrite" );
					if( zWriteOpIdx > -1 )
					{
						int zWriteEndIdx = subBody.IndexOf( TemplatesManager.TemplateNewLine, zWriteOpIdx );
						if( zWriteEndIdx > 0 )
						{
							m_depthData.ZWriteModeId = subBody.Substring( zWriteOpIdx, zWriteEndIdx + 1 - zWriteOpIdx );
							TemplateHelperFunctions.CreateZWriteMode( m_depthData.ZWriteModeId, ref m_depthData );
							if( m_depthData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( m_depthData.ZWriteModeId, true );
							}
						}
					}
				}

				//ZTEST
				{
					int zTestOpIdx = subBody.IndexOf( "ZTest" );
					if( zTestOpIdx > -1 )
					{
						int zTestEndIdx = subBody.IndexOf( TemplatesManager.TemplateNewLine, zTestOpIdx );
						if( zTestEndIdx > 0 )
						{
							m_depthData.ZTestModeId = subBody.Substring( zTestOpIdx, zTestEndIdx + 1 - zTestOpIdx );
							TemplateHelperFunctions.CreateZTestMode( m_depthData.ZTestModeId, ref m_depthData );
							if( m_depthData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( m_depthData.ZTestModeId, true );
							}
						}
					}
				}

				//ZOFFSET
				{
					int zOffsetIdx = subBody.IndexOf( "Offset" );
					if( zOffsetIdx > -1 )
					{
						int zOffsetEndIdx = subBody.IndexOf( TemplatesManager.TemplateNewLine, zOffsetIdx );
						if( zOffsetEndIdx > 0 )
						{
							m_depthData.OffsetId = subBody.Substring( zOffsetIdx, zOffsetEndIdx + 1 - zOffsetIdx );
							TemplateHelperFunctions.CreateZOffsetMode( m_depthData.OffsetId, ref m_depthData );
							if( m_depthData.DataCheck == TemplateDataCheck.Valid )
							{
								AddId( m_depthData.OffsetId, true );
							}
						}
					}

					m_depthData.SetDataCheck(); 
				}
				
				//TAGS
				{
					int tagsIdx = subBody.IndexOf( "Tags" );
					if( tagsIdx > -1 )
					{
						int tagsEndIdx = subBody.IndexOf( "}", tagsIdx );
						if( tagsEndIdx > -1 )
						{
							m_tagData.Reset();
							m_tagData.TagsId = subBody.Substring( tagsIdx, tagsEndIdx + 1 - tagsIdx );
							TemplateHelperFunctions.CreateTags( ref m_tagData, true );
							m_tagData.DataCheck = TemplateDataCheck.Valid;
							AddId( m_tagData.TagsId, false );
						}
						else
						{
							m_tagData.DataCheck = TemplateDataCheck.Invalid;
						}
					}
					else
					{
						m_tagData.DataCheck = TemplateDataCheck.Invalid;
					}
				}
			}
		}

19 View Source File : CSharpCodeProvider.cs
License : MIT License
Project Creator : arasplm

private GeneratedCodeInfo CreatePartialClreplacedes(GeneratedCodeInfo methodInfo)
		{
			var resultGeneratedCode = new GeneratedCodeInfo(methodInfo);
			resultGeneratedCode.MethodCodeInfo.Code = resultGeneratedCode.MethodCodeInfo.Code.Replace("//[PartialPath", "[PartialPath");

			var tree = CSharpSyntaxTree.ParseText(resultGeneratedCode.MethodCodeInfo.Code);
			var root = tree.GetRoot();

			var members = root.DescendantNodes()
				.OfType<AttributeSyntax>()
				.Where(a => a.Name.ToString() == "PartialPath")
				.Select(a => new { AttributeInfo = a, Parent = a.Parent.Parent })
				.Where(m =>
					m.Parent is FieldDeclarationSyntax ||
					m.Parent is EnumDeclarationSyntax ||
					m.Parent is ConstructorDeclarationSyntax ||
					m.Parent is DestructorDeclarationSyntax ||
					m.Parent is PropertyDeclarationSyntax ||
					m.Parent is MethodDeclarationSyntax ||
					m.Parent is OperatorDeclarationSyntax ||
					m.Parent is IndexerDeclarationSyntax ||
					m.Parent is ClreplacedDeclarationSyntax ||
					m.Parent is StructDeclarationSyntax ||
					m.Parent is InterfaceDeclarationSyntax)
				.ToList();

			int argumentIndex = 0;

			foreach (var member in members)
			{
				var path = member.AttributeInfo.ArgumentList.Arguments.FirstOrDefault()?.ToString();
				path = path.Replace("/", "\\").Replace("\"", string.Empty);
				path = Path.Combine(resultGeneratedCode.MethodName, path);
				if (path != null)
				{
					string partialString = string.Empty;
					string stringForReplace = string.Empty;
					string shouldBeReplaced = member.Parent.ToFullString();

					if (member.AttributeInfo.ArgumentList.Arguments.Count == 1)
					{
						argumentIndex += 1;

						var newAttribute =  member.AttributeInfo.AddArgumentListArguments(AttributeArgument(ParseExpression(argumentIndex.ToString())).WithLeadingTrivia(Space));
						partialString = member.Parent.ReplaceNode(member.AttributeInfo, newAttribute).ToFullString();
					}
					else
					{
						partialString = shouldBeReplaced = member.Parent.ToFullString();
					}

					if (partialString.Contains(GlobalConsts.EndregionMethodCode))
					{
						int indexofEndRegion = partialString.IndexOf(GlobalConsts.EndregionMethodCode);
						stringForReplace = partialString.Substring(indexofEndRegion, partialString.Length - indexofEndRegion);
						partialString = partialString.Replace(stringForReplace, "}");
						stringForReplace = '\t' + stringForReplace;
					}

					var existingPartialInfo = resultGeneratedCode.PartialCodeInfoList.FirstOrDefault(pi => pi.Path == path);
					if (existingPartialInfo != null)
					{
						existingPartialInfo.Code += "\r\n" + partialString;
					}
					else
					{
						resultGeneratedCode.PartialCodeInfoList.Add(new CodeInfo() { Code = partialString, Path = path });
					}

					resultGeneratedCode.MethodCodeInfo.Code = resultGeneratedCode.MethodCodeInfo.Code.Replace(shouldBeReplaced, stringForReplace);
					if (!string.IsNullOrEmpty(stringForReplace))
					{
						string pattern = string.Concat(@"(\r\n|\n)?( |\t)*}( |\t)*(\r\n|\n)?( |\t)*", GlobalConsts.EndregionMethodCode);
						string insertRegion = string.Concat(Environment.NewLine, GlobalConsts.EndregionMethodCode);
						string replacedCode = Regex.Replace(resultGeneratedCode.MethodCodeInfo.Code, pattern, insertRegion);
						resultGeneratedCode.MethodCodeInfo.Code = resultGeneratedCode.IsUseVSFormatting ? this.codeFormatter.Format(replacedCode) : replacedCode;
					}
				}
			}

			var partialUsings = string.Empty;
			if (resultGeneratedCode.PartialCodeInfoList.Count != 0)
			{
				var mainUsingDirectiveSyntaxes = root.DescendantNodes().OfType<UsingDirectiveSyntax>();
				partialUsings = string.Join("\r\n", mainUsingDirectiveSyntaxes);
				if (!string.IsNullOrEmpty(partialUsings))
				{
					partialUsings += "\r\n";
				}
			}

			string partialClreplacedTemplate = "{0}using Common;\r\nusing Common.Attributes;\r\nnamespace {3} \r\n{{public partial clreplaced {1} \r\n{{\r\n{2}\r\n}}\r\n}}";
			foreach (var partialCodeInfo in resultGeneratedCode.PartialCodeInfoList)
			{
				string code = string.Format(partialClreplacedTemplate, partialUsings, resultGeneratedCode.MethodCodeParentClreplacedName, partialCodeInfo.Code, resultGeneratedCode.Namespace);
				partialCodeInfo.Code = resultGeneratedCode.IsUseVSFormatting ? this.codeFormatter.Format(code) : code;
			}

			return resultGeneratedCode;
		}

19 View Source File : TemplateMultiPass.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

void LoadTemplateBody( string guid )
		{
			m_guid = guid;
			string datapath = replacedetDatabase.GUIDToreplacedetPath( guid );
			string shaderBody = string.Empty;
			shaderBody = IOUtils.LoadTextFileFromDisk( datapath );
			shaderBody = shaderBody.Replace( "\r\n", "\n" );
			m_shaderData = TemplateShaderInfoUtil.CreateShaderData( shaderBody );
			if( m_shaderData == null )
			{
				m_isValid = false;
				return;
			}

			m_templateIdManager = new TemplateIdManager( shaderBody );

			try
			{
				int nameBegin = shaderBody.IndexOf( TemplatesManager.TemplateShaderNameBeginTag );
				if( nameBegin < 0 )
				{
					// Not a template
					return;
				}

				int nameEnd = shaderBody.IndexOf( TemplatesManager.TemplateFullEndTag, nameBegin );
				if( nameEnd < 0 )
					return;

				
				m_shaderBody = shaderBody;
				int defaultBegin = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length;
				int defaultLength = nameEnd - defaultBegin;
				m_defaultShaderName = shaderBody.Substring( defaultBegin, defaultLength );
				int[] nameIdx = m_defaultShaderName.AllIndexesOf( "\"" );
				nameIdx[ 0 ] += 1; // Ignore the " character from the string
				m_defaultShaderName = m_defaultShaderName.Substring( nameIdx[ 0 ], nameIdx[ 1 ] - nameIdx[ 0 ] );
				m_shaderNameId = shaderBody.Substring( nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin );
				m_templateProperties.AddId( shaderBody, m_shaderNameId, false );
				m_templateIdManager.RegisterId( nameBegin, m_shaderNameId, m_shaderNameId );
				shaderBody = shaderBody.Substring( nameEnd + TemplatesManager.TemplateFullEndTag.Length );
			}
			catch( Exception e )
			{
				Debug.LogException( e );
				m_isValid = false;
			}

			TemplateHelperFunctions.FetchDependencies( m_dependenciesContainer, ref m_shaderBody );
			if( m_dependenciesContainer.IsValid )
			{
				int index = m_dependenciesContainer.Id.IndexOf( TemplatesManager.TemplateDependenciesListTag );
				m_templateProperties.AddId( new TemplateProperty( m_dependenciesContainer.Id, m_dependenciesContainer.Id.Substring( 0, index ), true ) );
				m_templateIdManager.RegisterId( m_dependenciesContainer.Index, m_dependenciesContainer.Id, m_dependenciesContainer.Id );
			}



			TemplateHelperFunctions.FetchCustomInspector( m_customInspectorContainer, ref m_shaderBody );
			if( m_customInspectorContainer.IsValid )
			{
				int index = m_customInspectorContainer.Id.IndexOf( "CustomEditor" );
				m_templateProperties.AddId( new TemplateProperty( m_customInspectorContainer.Id, m_customInspectorContainer.Id.Substring( 0, index ), true ) );
				m_templateIdManager.RegisterId( m_customInspectorContainer.Index, m_customInspectorContainer.Id, m_customInspectorContainer.Id );
			}

			TemplateHelperFunctions.FetchFallback( m_fallbackContainer, ref m_shaderBody );
			if( m_fallbackContainer.IsValid )
			{
				int index = m_fallbackContainer.Id.IndexOf( "Fallback" );
				m_templateProperties.AddId( new TemplateProperty( m_fallbackContainer.Id, m_fallbackContainer.Id.Substring( 0, index ), true ) );
				m_templateIdManager.RegisterId( m_fallbackContainer.Index, m_fallbackContainer.Id, m_fallbackContainer.Id );
			}
			// Shader body may have been changed to inject inexisting tags like fallback
			m_templateIdManager.ShaderBody = m_shaderBody;

			m_propertyTag = new TemplateTagData( m_shaderData.PropertyStartIdx, TemplatesManager.TemplatePropertyTag, true );
			m_templateIdManager.RegisterId( m_shaderData.PropertyStartIdx, TemplatesManager.TemplatePropertyTag, TemplatesManager.TemplatePropertyTag );
			m_templateProperties.AddId( shaderBody, TemplatesManager.TemplatePropertyTag, true );
			Dictionary<string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary<string, TemplateShaderPropertyData>();
			TemplateHelperFunctions.CreateShaderPropertiesList( m_shaderData.Properties, ref m_availableShaderProperties, ref duplicatesHelper );
			int subShaderCount = m_shaderData.SubShaders.Count;

			int mainSubShaderIdx = -1;
			int mainPreplacedIdx = -1;

			int firstVisibleSubShaderId = -1;
			int firstVisiblePreplacedId = -1;
			bool foundMainPreplaced = false;
			bool foundFirstVisible = false;

			for( int i = 0; i < subShaderCount; i++ )
			{
				TemplateSubShader subShader = new TemplateSubShader( i, m_templateIdManager, "SubShader" + i, m_shaderData.SubShaders[ i ], ref duplicatesHelper );

				if( subShader.FoundMainPreplaced )
				{
					if( !foundMainPreplaced )
					{
						foundMainPreplaced = true;
						mainSubShaderIdx = i;
						mainPreplacedIdx = subShader.MainPreplaced;
					}
				}
				else if( subShader.MainPreplaced > -1 )
				{
					if( !foundFirstVisible )
					{
						foundFirstVisible = true;
						firstVisibleSubShaderId = i;
						firstVisiblePreplacedId = subShader.MainPreplaced;
					}
				}

				m_subShaders.Add( subShader );
				m_masterNodesRequired += subShader.Preplacedes.Count;
			}


			if( !foundMainPreplaced && foundFirstVisible )
			{
				mainSubShaderIdx = firstVisibleSubShaderId;
				mainPreplacedIdx = firstVisiblePreplacedId;
			}

			for( int subShaderIdx = 0; subShaderIdx < subShaderCount; subShaderIdx++ )
			{
				int preplacedCount = m_subShaders[ subShaderIdx ].Preplacedes.Count;
				for( int preplacedIdx = 0; preplacedIdx < preplacedCount; preplacedIdx++ )
				{
					m_subShaders[ subShaderIdx ].Preplacedes[ preplacedIdx ].IsMainPreplaced = ( mainSubShaderIdx == subShaderIdx && mainPreplacedIdx == preplacedIdx );
				}
			}

			duplicatesHelper.Clear();
			duplicatesHelper = null;
			m_isSinglePreplaced = ( m_subShaders.Count == 1 && m_subShaders[ 0 ].PreplacedAmount == 1 );
			
		}

19 View Source File : DashboardWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : armandoalonso

private bool SearchFilter(object obj)
        {
            if (string.IsNullOrEmpty(AddonFilter.Text))
            {
                return true;
            }

            return obj.ToString().IndexOf(AddonFilter.Text, StringComparison.OrdinalIgnoreCase) >= 0;
        }

19 View Source File : MessageController.cs
License : Apache License 2.0
Project Creator : 0nise

public static MessageModel main(String message,string fromQQ) {
            string resultContent = "\n无数据";
            string content = message;
            MessageModel messageModel = null;
            if (message == null || message == "" || message.Length == 0)
            {
                messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
                return messageModel;
            }
            resultContent = "\n无数据";
            message = executeCodeReplace(message);
            message = message.Trim();
            if (message.Length == 0 || message == "")
            {
                messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
                return messageModel;
            }
            else if (message.Contains(MessageConstant.RANDOM_CONTENT_replacedLE)) {
                // 标题查询随机文章
                message = message.Replace(MessageConstant.RANDOM_CONTENT_replacedLE, "").Trim();
                resultContent = DBHelperMySQL.GetContentRandomByreplacedle(message);
                // 标题查询随机课程
                string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_replacedLE);
            }
            else if (message.Contains(MessageConstant.DESC_CONTENT_replacedLE)) {
                // 标题查询最新文章
                message = message.Replace(MessageConstant.DESC_CONTENT_replacedLE, "").Trim();
                string clreplacedContent = "";
                if (message.Length == 0 || message == "" || "".Equals(message) || message == null)
                {
                    // 调用每日最新
                    resultContent = DBHelperMySQL.getContentDateByToday();
                    // 标题查询最新课程
                    clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
                }
                else
                {
                    resultContent = DBHelperMySQL.getContentDateByreplacedle(message);
                    clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
                }
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_replacedLE);
            }
            else if (message.Contains(MessageConstant.DESC_CONTENT_AUTHOR)) {
                // 作者查询最新文章
                message = message.Replace(MessageConstant.DESC_CONTENT_AUTHOR, "").Trim();
                resultContent = DBHelperMySQL.getContentDateByAuthor(message);
                // 作者查询最新课程
                string clreplacedContent = DBHelperMySQL.getClreplacedDateByAuthor(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_AUTHOR);
            } else if (message.Contains(MessageConstant.RANDOM_CONTENT_AUTHOR)) {
                // 作者查询随机文章
                message = message.Replace(MessageConstant.RANDOM_CONTENT_AUTHOR, "").Trim();
                resultContent = DBHelperMySQL.getContentRandomByAuthor(message);
                // 作者查询随机课程
                string clreplacedContent = DBHelperMySQL.getClreplacedRandomByAuthor(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_AUTHOR);
            }
            else if (message.Contains(MessageConstant.DESC_CONTENT_TODAY) || message.Contains(MessageConstant.DESC_CONTENT))
            {
                // 今日最新
                message = message.Replace(MessageConstant.DESC_CONTENT_TODAY, "").Trim();
                resultContent = DBHelperMySQL.getContentDateByToday();
                string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_TODAY);
            } else if (message.Contains(MessageConstant.GONG_GAO)) {
                // 公告处理
                bool flag = DBHelperMySQL.isAdmin(fromQQ);
                // 判断是否管理员
                if (flag) {
                    message = message.Replace(MessageConstant.GONG_GAO, "来自i春秋机器人的智能推送\n");
                    resultContent = message;
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.GONG_GAO);
                }
                else {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.GONG_GAO);
                }
            }
            else if (message.Contains(MessageConstant.AITE_ALL))
            {
                // 艾特全体处理
                bool flag = DBHelperMySQL.isAdmin(fromQQ);
                if (flag)
                {
                    message = message.Replace(MessageConstant.AITE_ALL, "来自i春秋机器人的智能推送\n");
                    resultContent = message;
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.AITE_ALL);
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.AITE_ALL);
                }
            }
            else if (message.Contains(MessageConstant.HELP) || message.Contains(MessageConstant.HELP_TWO))
            {
                // Help 帮助等指令
                resultContent = MessageConstant.HELP_CONTENT;
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP_TWO);
            } else if (message.Contains(MessageConstant.DESC_VIDEO)) {
                // 标题查询最新教程
                message = message.Replace(MessageConstant.DESC_VIDEO, "").Trim();
                resultContent = DBHelperMySQL.getCourseDateByreplacedle(message);
                // 标题查询最新课程
                string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_VIDEO);
            }
            else if (message.Contains(MessageConstant.RANDOM_VIDEO))
            {
                // 标题查询随机教程
                message = message.Replace(MessageConstant.RANDOM_VIDEO, "").Trim();
                resultContent = DBHelperMySQL.getCourseRandomByreplacedle(message);
                // 标题查询随机课程
                string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_VIDEO);
            }
            else if (message.Contains(MessageConstant.TEST))
            {
                // 测试命令
                resultContent = " [CQ:image,file=photo.jpg]";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.TEST);
            } else if (message.Contains(MessageConstant.SELECT_MONEY)) {
                // 查询余额
                string money = DBHelperMySQL.getBlankMoney(fromQQ);
                if (money == "" || money == null || money.Length == 0)
                {
                    resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
                }
                else
                {
                    resultContent = "\n当前余额为 " + money;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.SELECT_MONEY);
            }
            else if (message.Contains(MessageConstant.HISTORY_MONEY))
            {
                // 提现记录
                string historyMoney = DBHelperMySQL.getBlankHistory(fromQQ);
                // 查询当前余额
                string money = DBHelperMySQL.getBlankMoney(fromQQ);
                if (money == "" || money == null || money.Length == 0) {
                    resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
                }
                else {
                    resultContent = "\n当前余额为 " + money + "\n";
                    // 查询历史记录
                    resultContent += "提现记录\n";
                    resultContent += "金额\t\t时间\n" + historyMoney;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HISTORY_MONEY);
            }
            else if (message.Contains(MessageConstant.APPLY_MONEY))
            {
                // 申请提现
                resultContent = "请联系【坏蛋】,QQ号:286894635。\n[CQ:at,qq=286894635]";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.APPLY_MONEY);
            } else if (message.Contains(MessageConstant.ABOUT)) {
                resultContent = "i春秋社区机器人,研发人员为:0nise!";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.ABOUT);
            } else if (message.Contains(MessageConstant.UPDATE_MONEY)) {
                // 更新金额
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin) {
                    try
                    {
                        int moneyIndex = message.IndexOf("提现:");
                        int index = message.IndexOf(MessageConstant.UPDATE_MONEY);
                        if (moneyIndex >= 0 && index >= 0)
                        {
                           decimal money = Convert.ToDecimal(message.Substring(moneyIndex).Replace("提现:", "").Replace(" ",""));
                           string qq = message.Replace(message.Substring(moneyIndex), "").Replace(MessageConstant.UPDATE_MONEY, "").Replace(" ", "");
                           resultContent = DBHelperMySQL.updateBlank(qq,money);
                        }
                    }
                    catch (Exception)
                    {
                        resultContent = "更新失败。";
                    }
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.UPDATE_MONEY);
            }
            else if (message.Contains(MessageConstant.TODAY_COUNT))
            {
                // 今日使用数量
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    int count = DBHelperMySQL.getToday();
                    resultContent = "今日使用人数达"+count+"人";
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.TODAY_COUNT);
            }
            else if (message.Contains(MessageConstant.USER_TOTAL))
            {
                // 总人数
                // 判定是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    int count = DBHelperMySQL.getUserTotal();
                    DateTime dt = DateTime.Now;
                    // 获取日期
                    string date = dt.ToLongDateString().ToString();
                    resultContent = "截止" + date + ",机器人历史使用人数达"+count+"人。";
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
            }
            else if (message.Contains(MessageConstant.THIS_WEEK))
            {
                // 七日使用
                // 判定是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    Hashtable hashtable = DBHelperMySQL.getThisWeek();
                    resultContent = "";
                    foreach (Object item in hashtable.Keys)
                    {
                        string dateData =  item.ToString();
                        string count = hashtable[item].ToString();
                        resultContent += dateData + " 使用人数为:" + count + "人;\n";
                    }
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
            }
            else if (message.Contains(MessageConstant.QUN_TOTAL))
            {
                // 群数量
                // 判定是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    resultContent = "群数量";
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.QUN_TOTAL);
            }
            else
            {
                // 其他内容
                resultContent = MessageConstant.HELP_CONTENT;
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: "");
            }

            if (resultContent == "" || resultContent == null || resultContent.Length == 0) {
                messageModel.SendMessage = "\n无数据";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP);
            }
            // 记录用户操作数据
            DBHelperMySQL.addUserData(fromQQ, content, resultContent);
            return messageModel;
        }

19 View Source File : ChildProcessTest_EnvironmentVariables.cs
License : MIT License
Project Creator : asmichi

private static KV[] ExecuteForEnvironmentVariables(
            ChildProcessCreationContext? context,
            KV[] extraEnvVars,
            bool inheritFromContext)
        {
            var si = new ChildProcessStartInfo(TestUtil.TestChildNativePath, "DumpEnvironmentVariables")
            {
                StdOutputRedirection = OutputRedirection.OutputPipe,
                Flags = inheritFromContext ? ChildProcessFlags.None : ChildProcessFlags.DisableEnvironmentVariableInheritance,
                CreationContext = context,
                ExtraEnvironmentVariables = extraEnvVars,
            };

            var output = ExecuteForStandardOutput(si);
            var childEnvVars =
                output.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(ToKeyValuePair)
                .ToArray();
            return childEnvVars;

            static KV ToKeyValuePair(string envVar)
            {
                int index = envVar.IndexOf('=', StringComparison.Ordinal);
                var name = envVar.Substring(0, index);
                var value = envVar.Substring(index + 1);
                return new(name, value);
            }
        }

19 View Source File : TemplatePass.cs
License : GNU General Public License v3.0
Project Creator : alexismorin

void FetchInputs( int offset, MasterNodePortCategory portCategory, string body )
		{
			string beginTag = ( portCategory == MasterNodePortCategory.Fragment ) ? TemplatesManager.TemplateInputsFragBeginTag : TemplatesManager.TemplateInputsVertBeginTag;
			int[] inputBeginIndexes = body.AllIndexesOf( beginTag );
			if( inputBeginIndexes != null && inputBeginIndexes.Length > 0 )
			{
				for( int i = 0; i < inputBeginIndexes.Length; i++ )
				{
					int inputEndIdx = body.IndexOf( TemplatesManager.TemplateEndSectionTag, inputBeginIndexes[ i ] );
					int defaultValueBeginIdx = inputEndIdx + TemplatesManager.TemplateEndSectionTag.Length;
					int endLineIdx = body.IndexOf( TemplatesManager.TemplateFullEndTag, defaultValueBeginIdx );

					string defaultValue = body.Substring( defaultValueBeginIdx, endLineIdx - defaultValueBeginIdx );
					string tagId = body.Substring( inputBeginIndexes[ i ], endLineIdx + TemplatesManager.TemplateFullEndTag.Length - inputBeginIndexes[ i ] );

					int beginIndex = inputBeginIndexes[ i ] + beginTag.Length;
					int length = inputEndIdx - beginIndex;
					string inputData = body.Substring( beginIndex, length );
					string[] inputDataArray = inputData.Split( IOUtils.FIELD_SEPARATOR );
					
					if( inputDataArray != null && inputDataArray.Length > 0 )
					{
						try
						{
							string portName = inputDataArray[ (int)TemplatePortIds.Name ];
							WirePortDataType dataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), inputDataArray[ (int)TemplatePortIds.DataType ].ToUpper() );
							if( inputDataArray.Length == 3 )
							{
								int portOrderId = m_inputDataList.Count;
								int portUniqueId = -1;
								bool isInt = int.TryParse( inputDataArray[ 2 ], out portUniqueId );
								if( isInt )
								{
									if( portUniqueId < 0 )
										portUniqueId = m_inputDataList.Count;

									m_inputDataList.Add( new TemplateInputData( inputBeginIndexes[ i ], offset + inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, string.Empty ) );
									m_templateProperties.AddId( body, tagId, false );
								}
								else
								{
									portUniqueId = m_inputDataList.Count;
									m_inputDataList.Add( new TemplateInputData( inputBeginIndexes[ i ], offset + inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, inputDataArray[ 2 ] ) );
									m_templateProperties.AddId( body, tagId, false );
								}
							}
							else
							{
								int portUniqueIDArrIdx = (int)TemplatePortIds.UniqueId;
								int portUniqueId = ( portUniqueIDArrIdx < inputDataArray.Length ) ? Convert.ToInt32( inputDataArray[ portUniqueIDArrIdx ] ) : -1;
								if( portUniqueId < 0 )
									portUniqueId = m_inputDataList.Count;

								int portOrderArrayIdx = (int)TemplatePortIds.OrderId;
								int portOrderId = ( portOrderArrayIdx < inputDataArray.Length ) ? Convert.ToInt32( inputDataArray[ portOrderArrayIdx ] ) : -1;
								if( portOrderId < 0 )
									portOrderId = m_inputDataList.Count;

								int portLinkIdx = (int)TemplatePortIds.Link;
								string linkId = ( portLinkIdx < inputDataArray.Length ) ? inputDataArray[ portLinkIdx ] : string.Empty;
								m_inputDataList.Add( new TemplateInputData( inputBeginIndexes[ i ], offset + inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, linkId ) );
								m_templateProperties.AddId( body, tagId, false );
							}
						}
						catch( Exception e )
						{
							Debug.LogException( e );
						}
					}
				}
			}
		}

19 View Source File : TemplateModulesData.cs
License : MIT License
Project Creator : alexismorin

public void ConfigureCommonTag( TemplateTagData tagData, TemplatePropertyContainer propertyContainer, TemplateIdManager idManager, string uniquePrefix, int offsetIdx, string subBody )
		{
			int id = subBody.IndexOf( tagData.Id );
			if ( id >= 0 )
			{
				tagData.StartIdx = offsetIdx + id;
				idManager.RegisterId( tagData.StartIdx, uniquePrefix + tagData.Id, tagData.Id );
				propertyContainer.AddId( subBody, tagData.Id, tagData.SearchIndentation );
			}
		}

19 View Source File : MessageController.cs
License : Apache License 2.0
Project Creator : 0nise

public static MessageModel main(String message,string fromQQ) {
            string resultContent = "\n无数据";
            string content = message;
            MessageModel messageModel = null;
            if (message == null || message == "" || message.Length == 0)
            {
                messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
                return messageModel;
            }
            resultContent = "\n无数据";
            message = executeCodeReplace(message);
            message = message.Trim();
            if (message.Length == 0 || message == "")
            {
                messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
                return messageModel;
            }
            else if (message.Contains(MessageConstant.RANDOM_CONTENT_replacedLE)) {
                // 标题查询随机文章
                message = message.Replace(MessageConstant.RANDOM_CONTENT_replacedLE, "").Trim();
                resultContent = DBHelperMySQL.GetContentRandomByreplacedle(message);
                // 标题查询随机课程
                string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_replacedLE);
            }
            else if (message.Contains(MessageConstant.DESC_CONTENT_replacedLE)) {
                // 标题查询最新文章
                message = message.Replace(MessageConstant.DESC_CONTENT_replacedLE, "").Trim();
                string clreplacedContent = "";
                if (message.Length == 0 || message == "" || "".Equals(message) || message == null)
                {
                    // 调用每日最新
                    resultContent = DBHelperMySQL.getContentDateByToday();
                    // 标题查询最新课程
                    clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
                }
                else
                {
                    resultContent = DBHelperMySQL.getContentDateByreplacedle(message);
                    clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
                }
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_replacedLE);
            }
            else if (message.Contains(MessageConstant.DESC_CONTENT_AUTHOR)) {
                // 作者查询最新文章
                message = message.Replace(MessageConstant.DESC_CONTENT_AUTHOR, "").Trim();
                resultContent = DBHelperMySQL.getContentDateByAuthor(message);
                // 作者查询最新课程
                string clreplacedContent = DBHelperMySQL.getClreplacedDateByAuthor(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_AUTHOR);
            } else if (message.Contains(MessageConstant.RANDOM_CONTENT_AUTHOR)) {
                // 作者查询随机文章
                message = message.Replace(MessageConstant.RANDOM_CONTENT_AUTHOR, "").Trim();
                resultContent = DBHelperMySQL.getContentRandomByAuthor(message);
                // 作者查询随机课程
                string clreplacedContent = DBHelperMySQL.getClreplacedRandomByAuthor(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_AUTHOR);
            }
            else if (message.Contains(MessageConstant.DESC_CONTENT_TODAY) || message.Contains(MessageConstant.DESC_CONTENT))
            {
                // 今日最新
                message = message.Replace(MessageConstant.DESC_CONTENT_TODAY, "").Trim();
                resultContent = DBHelperMySQL.getContentDateByToday();
                string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_TODAY);
            } else if (message.Contains(MessageConstant.GONG_GAO)) {
                // 公告处理
                bool flag = DBHelperMySQL.isAdmin(fromQQ);
                // 判断是否管理员
                if (flag) {
                    message = message.Replace(MessageConstant.GONG_GAO, "来自i春秋机器人的智能推送\n");
                    resultContent = message;
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.GONG_GAO);
                }
                else {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.GONG_GAO);
                }
            }
            else if (message.Contains(MessageConstant.AITE_ALL))
            {
                // 艾特全体处理
                bool flag = DBHelperMySQL.isAdmin(fromQQ);
                if (flag)
                {
                    message = message.Replace(MessageConstant.AITE_ALL, "来自i春秋机器人的智能推送\n");
                    resultContent = message;
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.AITE_ALL);
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                    messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.AITE_ALL);
                }
            }
            else if (message.Contains(MessageConstant.HELP) || message.Contains(MessageConstant.HELP_TWO))
            {
                // Help 帮助等指令
                resultContent = MessageConstant.HELP_CONTENT;
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP_TWO);
            } else if (message.Contains(MessageConstant.DESC_VIDEO)) {
                // 标题查询最新教程
                message = message.Replace(MessageConstant.DESC_VIDEO, "").Trim();
                resultContent = DBHelperMySQL.getCourseDateByreplacedle(message);
                // 标题查询最新课程
                string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_VIDEO);
            }
            else if (message.Contains(MessageConstant.RANDOM_VIDEO))
            {
                // 标题查询随机教程
                message = message.Replace(MessageConstant.RANDOM_VIDEO, "").Trim();
                resultContent = DBHelperMySQL.getCourseRandomByreplacedle(message);
                // 标题查询随机课程
                string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
                if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
                {
                    resultContent += clreplacedContent;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_VIDEO);
            }
            else if (message.Contains(MessageConstant.TEST))
            {
                // 测试命令
                resultContent = " [CQ:image,file=photo.jpg]";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.TEST);
            } else if (message.Contains(MessageConstant.SELECT_MONEY)) {
                string tmpStr = message.Replace(MessageConstant.SELECT_MONEY, "").Trim();
                // 判断是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                string money = "";
                if (tmpStr.Length > 0 && isAdmin)
                {
                    // 查询余额
                    money = DBHelperMySQL.getBlankMoney(tmpStr);
                }
                else
                {
                    // 查询余额
                    money = DBHelperMySQL.getBlankMoney(fromQQ);
                }
                if (money == "" || money == null || money.Length == 0)
                {
                    resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
                }
                else
                {
                    resultContent = "\n当前余额为 " + money;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.SELECT_MONEY);
            }
            else if (message.Contains(MessageConstant.HISTORY_MONEY))
            {
                // 提现记录
                string historyMoney = DBHelperMySQL.getBlankHistory(fromQQ);
                // 查询当前余额
                string money = DBHelperMySQL.getBlankMoney(fromQQ);
                if (money == "" || money == null || money.Length == 0) {
                    resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
                }
                else {
                    resultContent = "\n当前余额为 " + money + "\n";
                    // 查询历史记录
                    resultContent += "提现记录\n";
                    resultContent += "金额\t\t时间\n" + historyMoney;
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HISTORY_MONEY);
            }
            else if (message.Contains(MessageConstant.APPLY_MONEY))
            {
                // 申请提现
                resultContent = "请联系【坏蛋】,QQ号:286894635。\n[CQ:at,qq=286894635]";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.APPLY_MONEY);
            } else if (message.Contains(MessageConstant.ABOUT)) {
                resultContent = "i春秋社区机器人,研发人员为:0nise,产品设计为:坏蛋!";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.ABOUT);
            } else if (message.Contains(MessageConstant.UPDATE_MONEY)) {
                // 更新金额
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin) {
                    try
                    {
                        decimal tmpMoney = 0.0M;
                        // 提现
                        if (message.Contains(MessageConstant.PUT_FORWARD))
                        {
                            int moneyIndex = message.IndexOf(MessageConstant.PUT_FORWARD + ":");
                            int index = message.IndexOf(MessageConstant.UPDATE_MONEY);
                            if (moneyIndex >= 0 && index >= 0)
                            {
                                decimal money = Convert.ToDecimal(message.Substring(moneyIndex).Replace("提现:", "").Replace(" ", ""));
                                if (money > tmpMoney)
                                {
                                    string qq = message.Replace(message.Substring(moneyIndex), "").Replace(MessageConstant.UPDATE_MONEY, "").Replace(" ", "");
                                    resultContent = DBHelperMySQL.updateBlank(qq, money,"0");
                                }
                                else
                                {
                                    resultContent = "提现金额必须大于0!";
                                }
                            }
                        }
                        // 加钱
                        else if (message.Contains(MessageConstant.ADD_MONEY))
                        {
                            int moneyIndex = message.IndexOf(MessageConstant.ADD_MONEY + ":");
                            int index = message.IndexOf(MessageConstant.ADD_MONEY);
                            if (moneyIndex >= 0 && index >= 0)
                            {
                                decimal money = Convert.ToDecimal(message.Substring(moneyIndex).Replace("加钱:", "").Replace(" ", ""));
                                if (money > tmpMoney)
                                {
                                    string qq = message.Replace(message.Substring(moneyIndex), "").Replace(MessageConstant.UPDATE_MONEY, "").Replace(" ", "");
                                    resultContent = DBHelperMySQL.updateBlank(qq, money,"1");
                                }
                                else
                                {
                                    resultContent = "加钱金额必须大于0!";
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        resultContent = "更新失败。";
                    }
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.UPDATE_MONEY);
            }
            else if (message.Contains(MessageConstant.TODAY_COUNT))
            {
                // 今日使用数量
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    int count = DBHelperMySQL.getToday();
                    resultContent = "今日使用人数达"+count+"人";
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.TODAY_COUNT);
            }
            else if (message.Contains(MessageConstant.USER_TOTAL))
            {
                // 总人数
                // 判定是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    int count = DBHelperMySQL.getUserTotal();
                    DateTime dt = DateTime.Now;
                    // 获取日期
                    string date = dt.ToLongDateString().ToString();
                    resultContent = "截止" + date + ",机器人历史使用人数达"+count+"人。";
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
            }
            else if (message.Contains(MessageConstant.THIS_WEEK))
            {
                // 七日使用
                // 判定是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    Hashtable hashtable = DBHelperMySQL.getThisWeek();
                    resultContent = "";
                    foreach (Object item in hashtable.Keys)
                    {
                        string dateData =  item.ToString();
                        string count = hashtable[item].ToString();
                        resultContent += dateData + " 使用人数为:" + count + "人;\n";
                    }
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
            }
            else if (message.Contains(MessageConstant.QUN_TOTAL))
            {
                // 群数量
                // 判定是否为管理员
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                if (isAdmin)
                {
                    resultContent = "群数量";
                }
                else
                {
                    resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.QUN_TOTAL);
            }
            else if (message.Contains(MessageConstant.MONEY_DESC))
            {
                // 财富榜
                bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
                // 检索是否为做作家团
                if (DBHelperMySQL.exitsUser(fromQQ) || isAdmin)
                {
                    resultContent = DBHelperMySQL.Top30Money();
                }
                else
                {
                    resultContent = "您不是作家团成员!";
                }
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.MONEY_DESC);
            }
            else
            {
                // 其他内容
                resultContent = MessageConstant.HELP_CONTENT;
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: "");
            }

            if (resultContent == "" || resultContent == null || resultContent.Length == 0) {
                messageModel.SendMessage = "\n无数据";
                messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP);
            }
            // 记录用户操作数据
            DBHelperMySQL.addUserData(fromQQ, content, resultContent);
            return messageModel;
        }

19 View Source File : AssetBundleManager.cs
License : Apache License 2.0
Project Creator : A7ocin

static public void UnloadAllreplacedetBundles()
		{
#if UNITY_EDITOR
			// If we're in Editor simulation mode, we don't have to load the manifest replacedetBundle.
			if (SimulatereplacedetBundleInEditor)
				return;
#endif
			List<string> bundlesToUnload = new List<string>();
			foreach (KeyValuePair<string, LoadedreplacedetBundle> kp in m_LoadedreplacedetBundles)
			{
				if (kp.Key.IndexOf(Utility.GetPlatformName().ToLower() + "index") == -1)//dont try to unload the index...
					bundlesToUnload.Add(kp.Key);
			}
			foreach (string bundleName in bundlesToUnload)
			{
				UnloadreplacedetBundleInternal(bundleName);
				UnloadDependencies(bundleName);//I think its unloading dependencies thats causing an issue with UMA
			}

		}

19 View Source File : MetadataProvider.cs
License : MIT License
Project Creator : afaniuolo

private MetadataTemplate MergeBaseMetadataTemplate(MetadataTemplate metadataTemplate, string baseTemplateMetadataFilePath)
		{
			if (string.IsNullOrEmpty(baseTemplateMetadataFilePath)) return metadataTemplate;

			MetadataTemplate baseTemplateMeta = GereplacedemMetadataByFilePath(baseTemplateMetadataFilePath);

			if (baseTemplateMeta == null) return metadataTemplate;

			// Iterate merging if baseTemplate filename is not null
			if (!string.IsNullOrEmpty(baseTemplateMeta.baseTemplateMetadataFileName))
			{
				var filePath = _metadataFiles.FirstOrDefault(f => f.IndexOf(baseTemplateMeta.baseTemplateMetadataFileName, StringComparison.InvariantCultureIgnoreCase) > -1);
				baseTemplateMeta = MergeBaseMetadataTemplate(baseTemplateMeta, filePath);
			}

			// Merge Fields
			metadataTemplate.fields = MergeFields(baseTemplateMeta.fields, metadataTemplate.fields);

			// Merge Descendant Items
			metadataTemplate.descendanreplacedems =
				MergeDescendanreplacedems(baseTemplateMeta.descendanreplacedems, metadataTemplate.descendanreplacedems);

			// Override dataValueType
			if (string.IsNullOrEmpty(metadataTemplate.dataValueType))
			{
				metadataTemplate.dataValueType = baseTemplateMeta.dataValueType;
			}

			// Override dataValueConverter
			if (string.IsNullOrEmpty(metadataTemplate.dataValueConverter))
			{
				metadataTemplate.dataValueConverter = baseTemplateMeta.dataValueConverter;
			}

			return metadataTemplate;
		}

19 View Source File : TemplateData.cs
License : MIT License
Project Creator : alexismorin

void FetchInputs( MasterNodePortCategory portCategory )
		{
			string beginTag = ( portCategory == MasterNodePortCategory.Fragment ) ? TemplatesManager.TemplateInputsFragBeginTag : TemplatesManager.TemplateInputsVertBeginTag;
			int[] inputBeginIndexes = m_templateBody.AllIndexesOf( beginTag );
			if( inputBeginIndexes != null && inputBeginIndexes.Length > 0 )
			{
				for( int i = 0; i < inputBeginIndexes.Length; i++ )
				{
					int inputEndIdx = m_templateBody.IndexOf( TemplatesManager.TemplateEndSectionTag, inputBeginIndexes[ i ] );
					int defaultValueBeginIdx = inputEndIdx + TemplatesManager.TemplateEndSectionTag.Length;
					int endLineIdx = m_templateBody.IndexOf( TemplatesManager.TemplateFullEndTag, defaultValueBeginIdx );

					string defaultValue = m_templateBody.Substring( defaultValueBeginIdx, endLineIdx - defaultValueBeginIdx );
					string tagId = m_templateBody.Substring( inputBeginIndexes[ i ], endLineIdx + TemplatesManager.TemplateFullEndTag.Length - inputBeginIndexes[ i ] );

					int beginIndex = inputBeginIndexes[ i ] + beginTag.Length;
					int length = inputEndIdx - beginIndex;
					string inputData = m_templateBody.Substring( beginIndex, length );
					string[] inputDataArray = inputData.Split( IOUtils.FIELD_SEPARATOR );
					if( inputDataArray != null && inputDataArray.Length > 0 )
					{
						try
						{
							string portName = inputDataArray[ (int)TemplatePortIds.Name ];
							WirePortDataType dataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), inputDataArray[ (int)TemplatePortIds.DataType ].ToUpper() );

							int portUniqueIDArrIdx = (int)TemplatePortIds.UniqueId;
							int portUniqueId = ( portUniqueIDArrIdx < inputDataArray.Length ) ? Convert.ToInt32( inputDataArray[ portUniqueIDArrIdx ] ) : -1;
							if( portUniqueId < 0 )
								portUniqueId = m_inputDataList.Count;

							int portOrderArrayIdx = (int)TemplatePortIds.OrderId;
							int portOrderId = ( portOrderArrayIdx < inputDataArray.Length ) ? Convert.ToInt32( inputDataArray[ portOrderArrayIdx ] ) : -1;
							if( portOrderId < 0 )
								portOrderId = m_inputDataList.Count;

							AddInput( inputBeginIndexes[ i ], tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId );
						}
						catch( Exception e )
						{
							Debug.LogException( e );
						}
					}
				}
			}
		}

19 View Source File : AopXmlParser.cs
License : Apache License 2.0
Project Creator : alipay

private static string ParseSignSourceData(string body, string rootNode, int indexOfRootNode)
        {

            //  第一个字母+长度+>
            int signDataStartIndex = indexOfRootNode + rootNode.Length + 1;
            int indexOfSign = body.IndexOf("<" + AlipayConstants.SIGN, System.StringComparison.Ordinal);
            int indexOfCert = body.IndexOf("<" + AlipayConstants.ALIPAY_CERT_SN, System.StringComparison.Ordinal);
            if (indexOfSign < 0)
            {
                return null;
            }

            int signDataEndIndex = indexOfSign;
            if (indexOfCert > 0)
            {
                signDataEndIndex = indexOfCert < indexOfSign ? indexOfCert : indexOfSign;
            }

            return body.Substring(signDataStartIndex, signDataEndIndex - signDataStartIndex);
        }

See More Examples