示例#1
0
        /// <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));
        }
示例#2
0
        /// <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);
 }
示例#4
0
 /// <summary>For template/generic references: MyType;Str</summary>
 public void AddTemplateArgument(string?name)
 {
     if (!String.IsNullOrEmpty(name))
     {
         NativeName.AddTemplateArgument(name);
         CanonicalName.AddTemplateArgument(name);
     }
 }
示例#5
0
        protected virtual bool ShouldAllowCore(NativeName name)
        {
            if (string.IsNullOrEmpty(SearchText))
            {
                return(true);
            }

            string rawName = name.Name;

            return(rawName.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) >= 0);
        }
示例#6
0
        public string GetValue(NativeName name)
        {
            NativeGlobalSymbol symbol;

            if (!Storage.TryGetGlobalSymbol(name, out symbol))
            {
                return(string.Empty);
            }

            return(GetValue(symbol));
        }
示例#7
0
            protected override bool ShouldAllowCore(NativeName name)
            {
                NativeConstant constant;

                if (!Storage.TryGetGlobalSymbol(name, out constant) ||
                    !IsValidConstant(constant))
                {
                    return(false);
                }

                return(base.ShouldAllowCore(name));
            }
示例#8
0
            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));
            }
示例#9
0
 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);
     }
 }
示例#10
0
        /// <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;
        }
示例#11
0
 /// <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);
     }
 }
示例#12
0
 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")));
 }
示例#13
0
        private bool IsAnyWrittenState(NativeName name)
        {
            bool?value;

            return(_writtenMap.TryGetValue(name, out value) && value != null);
        }
示例#14
0
        private bool IsWritten(NativeName name)
        {
            bool?value;

            return(_writtenMap.TryGetValue(name, out value) && value == true);
        }
示例#15
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="name"></param>
 protected EntityMember(string name, string nativeName) : this(name, NativeName.GetNativeName(nativeName))
 {
 }
示例#16
0
 public bool ShouldAllow(NativeName name)
 {
     return(ShouldAllowCore(name));
 }