/// <summary> /// Sort based on the following guidance. For the examples assume we are searching for /// "INT" /// /// 1) Starts with before not starts with. "integral" before "aligned int" /// 2) Shorter matches over longer ones /// 3) Alphabetically for everything else /// /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <returns></returns> /// <remarks></remarks> private int SearchSort(NativeName left, NativeName right) { string target = SearchText; string leftName = left.Name; string rightName = right.Name; if (!string.IsNullOrEmpty(target)) { bool leftStart = leftName.StartsWith(target, StringComparison.OrdinalIgnoreCase); bool rightStart = rightName.StartsWith(target, StringComparison.OrdinalIgnoreCase); if (leftStart != rightStart) { if (leftStart) { return(-1); } else { return(1); } } if (leftName.Length != rightName.Length) { return(leftName.Length - rightName.Length); } } return(string.Compare(leftName, rightName, StringComparison.OrdinalIgnoreCase)); }
/// <summary>For template/generic definitions: MyType%1</summary> public void SetParameterCounts(int templateParameterCount, int genericParameterCount) { var count = templateParameterCount + genericParameterCount; NativeName.SetTemplateParameterCount(count); CanonicalName.SetTemplateParameterCount(count); }
public override void ToStream(Stream output) { output.Write(TLUtils.SignatureToBytes(Signature)); Name.ToStream(output); NativeName.ToStream(output); LangCode.ToStream(output); }
/// <summary>For template/generic references: MyType;Str</summary> public void AddTemplateArgument(string?name) { if (!String.IsNullOrEmpty(name)) { NativeName.AddTemplateArgument(name); CanonicalName.AddTemplateArgument(name); } }
protected virtual bool ShouldAllowCore(NativeName name) { if (string.IsNullOrEmpty(SearchText)) { return(true); } string rawName = name.Name; return(rawName.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0); }
public string GetValue(NativeName name) { NativeGlobalSymbol symbol; if (!Storage.TryGetGlobalSymbol(name, out symbol)) { return(string.Empty); } return(GetValue(symbol)); }
protected override bool ShouldAllowCore(NativeName name) { NativeConstant constant; if (!Storage.TryGetGlobalSymbol(name, out constant) || !IsValidConstant(constant)) { return(false); } return(base.ShouldAllowCore(name)); }
protected override bool ShouldAllowCore(NativeName name) { if (!ShowInvalidData && name.Kind == NativeNameKind.Constant) { NativeConstant constant; if (Storage.TryGetGlobalSymbol(name, out constant) && !ConstantsInfo.IsValidConstant(constant)) { return(false); } } return(base.ShouldAllowCore(name)); }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReturnType != null ? ReturnType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NativeName != null ? NativeName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Parameters.GetHashCode(); hashCode = (hashCode * 397) ^ Categories.GetHashCode(); hashCode = (hashCode * 397) ^ GenericTypeParameters.GetHashCode(); hashCode = (hashCode * 397) ^ (Attributes != null ? Attributes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Doc != null ? Doc.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExtensionName != null ? ExtensionName.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Constructor. /// </summary> /// <param name="name"></param> protected EntityMember(string name, NativeName nativeName) { if (name == null) { throw new ArgumentNullException("name"); } if (name.Length == 0) { throw ExceptionHelper.CreateZeroLengthArgumentException("name"); } if (nativeName == null) { throw new ArgumentNullException("nativeName"); } _name = name; _nativeName = nativeName; }
/// <inheritdoc /> public override int GetHashCode() { unchecked { // ReSharper disable NonReadonlyMemberInGetHashCode var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReturnType != null ? ReturnType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NativeName != null ? NativeName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Parameters.GetHashCode(); hashCode = (hashCode * 397) ^ Categories.GetHashCode(); hashCode = (hashCode * 397) ^ GenericTypeParameters.GetHashCode(); hashCode = (hashCode * 397) ^ (Attributes != null ? Attributes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Doc != null ? Doc.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExtensionName != null ? ExtensionName.GetHashCode() : 0); // ReSharper restore NonReadonlyMemberInGetHashCode return(hashCode); } }
private bool IsControllerTypeMatch(Constraint.ControllerType controllerType) { return(controllerType == Constraint.ControllerType.Primary || (controllerType == Constraint.ControllerType.Translational && NativeName.EndsWith("T")) || (controllerType == Constraint.ControllerType.Rotational && NativeName.EndsWith("R"))); }
private bool IsAnyWrittenState(NativeName name) { bool?value; return(_writtenMap.TryGetValue(name, out value) && value != null); }
private bool IsWritten(NativeName name) { bool?value; return(_writtenMap.TryGetValue(name, out value) && value == true); }
/// <summary> /// Constructor. /// </summary> /// <param name="name"></param> protected EntityMember(string name, string nativeName) : this(name, NativeName.GetNativeName(nativeName)) { }
public bool ShouldAllow(NativeName name) { return(ShouldAllowCore(name)); }