Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     Name.ToStream(output);
     NativeName.ToStream(output);
     LangCode.ToStream(output);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        public string GetValue(NativeName name)
        {
            NativeGlobalSymbol symbol;

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

            return(GetValue(symbol));
        }
Exemplo n.º 7
0
            protected override bool ShouldAllowCore(NativeName name)
            {
                NativeConstant constant;

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

                return(base.ShouldAllowCore(name));
            }
Exemplo n.º 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));
            }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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")));
 }
Exemplo n.º 13
0
        private bool IsAnyWrittenState(NativeName name)
        {
            bool?value;

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

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