本文整理汇总了C#中TextRange.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# TextRange.Intersect方法的具体用法?C# TextRange.Intersect怎么用?C# TextRange.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRange
的用法示例。
在下文中一共展示了TextRange.Intersect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessElementParametersOwner
private void ProcessElementParametersOwner(IElement element)
{
IDeclaredParametersOwner declaredParametersOwner = element as IDeclaredParametersOwner;
// TODO use get reference
if(declaredParametersOwner != null)
{
IParameterDescriptorProvider parameterDescriptorProvider = declaredParametersOwner as IParameterDescriptorProvider;
if (parameterDescriptorProvider == null)
return;
if(!parameterDescriptorProvider.IsAvailable)
return;
ICollection<IParameterDescriptor> infos = parameterDescriptorProvider.GetParameterDescriptors();
ICollection<IDeclaredParameter> declaredParameters = declaredParametersOwner.GetParams();
// Highlight invalid names
foreach (IDeclaredParameter param in declaredParameters)
{
if(ParametersUtil.GetByName(infos, param.Name) == null)
{
highlightings.Add(new HighlightingInfo(param.NameDocumentRange, new InvalidPropertyHighlighting()));
}
}
// Highlight requred attributes
IXmlTag tag = element as IXmlTag;
foreach (IParameterDescriptor descriptor in infos)
{
if(descriptor.IsRequired)
{
if(ParametersUtil.GetByName(declaredParameters, descriptor.Name) != null
// it is conxeption hak, TODO fix parameters conception
|| (tag != null && tag.GetAttribute(descriptor.Name) != null))
continue;
DocumentRange range;
if (tag != null)
range = GetHighlightRange(tag.ToTreeNode().Header);
else
range = element.ToTreeNode().GetDocumentRange();
highlightings.Add(new HighlightingInfo(range, new MissedParameterError(descriptor, element)));
}
}
// highlight invalid values
foreach (IDeclaredParameter param in declaredParameters)
{
IParameterDescriptor descriptor = ParametersUtil.GetByName(infos, param.Name);
if (descriptor == null)
continue;
IParameterStringValueValidator validator = ValidatorsManager.Instance().GetValidator(descriptor);
if (validator == null)
continue;
// TODO introduce interface marker to determine tag pased parameters
PropertyParamImpl propertyParam = param as PropertyParamImpl;
IXmlAttributeValue attributeValue = null;
if (propertyParam != null)
{
attributeValue = propertyParam.Value;
}
else // attribute
{
IXmlAttribute attribute = ((IXmlTag)declaredParametersOwner).GetAttribute(param.Name);
if (attribute != null)
attributeValue = attribute.Value;
}
if (attributeValue == null)
continue;
string unquotedValue = attributeValue.UnquotedValue;
ValidationResult validateResult = validator.Validate(unquotedValue);
if (validateResult == ValidationResult.Ok)
continue;
if(validateResult.Range == TextRange.InvalidRange)
continue;
int valueStart = attributeValue.ToTreeNode().GetDocumentRange().TextRange.StartOffset + 1;
TextRange valueRange = new TextRange(valueStart, valueStart + unquotedValue.Length);
int errorStart = valueRange.StartOffset + validateResult.Range.StartOffset;
TextRange errorRange = new TextRange(errorStart, errorStart + validateResult.Range.Length);
errorRange = valueRange.Intersect(errorRange);
if (errorRange == TextRange.InvalidRange)
continue;
if(errorRange.IsEmpty)
{
if (attributeValue.UnquotedValue.Length == 0)
{
//.........这里部分代码省略.........