Пример #1
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiImplements = EnsureApiElementType <ApiImplements> (apiElement);
            JniType       = apiImplements.JniType;
        }
Пример #2
0
        public virtual void Init(ApiElement apiElement)
        {
            if (apiElement == null)
            {
                throw new ArgumentNullException(nameof(apiElement));
            }

            this.apiElement = apiElement;

            IsBoundAPI = true;

            Name            = apiElement.Name;
            FullName        = GenerateFullJavaName();
            ManagedName     = apiElement.ManagedName;
            FullManagedName = null;
            JniSignature    = apiElement.JniSignature;

            DocumentPath       = apiElement.DocumentPath;
            DeprecatedMessage  = apiElement.DeprecatedMessage;
            IsDeprecated       = apiElement.IsDeprecated;
            DeprecatedSinceAPI = apiElement.DeprecatedSinceAPI;
            AvailableSinceAPI  = apiElement.AvailableSinceAPI;
            AvailableUntilAPI  = apiElement.AvailableUntilAPI;
            SourceLine         = apiElement.SourceLine;
            SourceColumn       = apiElement.SourceColumn;
        }
Пример #3
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiMethodParameter = EnsureApiElementType <ApiMethodParameter> (apiElement);
            JniType            = apiMethodParameter.JniType;
        }
Пример #4
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiException     = EnsureApiElementType <ApiException> (apiElement);
            Type             = apiException.Type;
            TypeGenericAware = apiException.TypeGenericAware;
        }
Пример #5
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiTypeMember = EnsureApiElementType <ApiTypeMember> (apiElement);
            Final         = apiTypeMember.Final;
            Static        = apiTypeMember.Static;
            Visibility    = apiTypeMember.Visibility;
        }
Пример #6
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiField         = EnsureApiElementType <ApiField> (apiElement);
            Transient        = apiField.Transient;
            Type             = apiField.Type;
            TypeGenericAware = apiField.TypeGenericAware;
            Value            = apiField.Value;
            Volatile         = apiField.Volatile;
        }
Пример #7
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiTypeParameter = EnsureApiElementType <ApiTypeParameter> (apiElement);

            // Unused for now
            //
            // ClassBound = apiTypeParameter.ClassBound;
            // JniClassBound = apiTypeParameter.JniClassBound;
            // InterfaceBounds = apiTypeParameter.InterfaceBounds;
            // JniInterfaceBounds = apiTypeParameter.JniInterfaceBounds;
        }
Пример #8
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiClass = ApiElement as ApiClass;
            if (apiClass == null)
            {
                return;
            }

            Extends             = apiClass.Extends;
            ExtendsGenericAware = apiClass.ExtendsGenericAware;
            Obfuscated          = apiClass.Obfuscated;
        }
        public static bool IsInInternalNamespace(ApiElement e)
        {
            var type = e as TypeDescriptor;

            if (type == null)
            {
                return(false);
            }

            var segments = type.Name.Split('.');

            // Skip the last segment as is the type name.
            return(segments.Take(segments.Length - 1).Any(s => s.Equals("Internal")));
        }
Пример #10
0
        protected TApiElement EnsureApiElementType <TApiElement> (ApiElement apiElement) where TApiElement : ApiElement
        {
            if (apiElement == null)
            {
                throw new ArgumentNullException(nameof(apiElement));
            }

            TApiElement ret = apiElement as TApiElement;

            if (ret == null)
            {
                throw new InvalidOperationException($"Expected API element of type '{typeof (TApiElement).FullName}' but got '{apiElement.GetType ().FullName}' instead");
            }

            return(ret);
        }
Пример #11
0
        void AddLocationComment(ApiElement element, HierarchyElement hierarchyElement)
        {
            if (String.IsNullOrEmpty(element.DocumentPath) || element.SourceLine < 0)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.Append(element.DocumentPath);
            if (element.SourceColumn > 0)
            {
                sb.Append($" [{element.SourceLine}:{element.SourceColumn}]");
            }
            else
            {
                sb.Append($":{element.SourceLine}");
            }
            hierarchyElement.AddComment(sb.ToString());
        }
Пример #12
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiMethod                 = EnsureApiElementType <ApiMethod> (apiElement);
            Abstract                  = apiMethod.Abstract;
            ArgsType                  = apiMethod.ArgsType;
            EnumReturn                = apiMethod.EnumReturn;
            EventName                 = apiMethod.EventName;
            GenerateAsyncWrapper      = apiMethod.GenerateAsyncWrapper;
            GenerateDispatchingSetter = apiMethod.GenerateDispatchingSetter;
            ManagedReturn             = apiMethod.ManagedReturn;
            Native       = apiMethod.Native;
            PropertyName = apiMethod.PropertyName;
            Return       = apiMethod.Return;
            JniReturn    = apiMethod.JniReturn;
            Synchronized = apiMethod.Synchronized;
            IsBridge     = apiMethod.IsBridge;
            IsSynthetic  = apiMethod.IsSynthetic;
        }
Пример #13
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiType = EnsureApiElementType <ApiType>(apiElement);
            if (apiElement.ChildElements != null)
            {
                foreach (ApiImplements ai in apiElement.ChildElements.OfType <ApiImplements> ().Where(o => o != null))
                {
                    string name = ai.NameGenericAware?.Trim();
//					if (String.IsNullOrEmpty (name))
                    name = ai.Name;
                    AddImplements(name);
                }
            }

            Abstract   = apiType.Abstract;
            Static     = apiType.Static;
            Visibility = apiType.Visibility;
            Final      = apiType.Final;
        }
Пример #14
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);
            apiEnum = EnsureApiElementType <ApiEnum> (apiElement);

            // Enums are special - their name attribute is set to the full managed name
            int lastDot = apiElement.Name.LastIndexOf('.');

            if (lastDot < 0)
            {
                return;
            }

            if (lastDot == 0)
            {
                throw new InvalidOperationException($"Type name ({apiElement.Name}) must not start with a dot");
            }

            FullName = Name;
            Name     = apiElement.Name.Substring(lastDot + 1);
        }
        /// <summary>
        /// Gets the full qualified response file path.
        /// </summary>
        /// <param name="api">ApiElement instance.</param>
        /// <returns>Returns the full qualified response file path.</returns>
        public string GetApiReponseFullPath(ApiElement api)
        {
            var src = api.Src;

            if (!this.HasValidJsonFileExtension(src))
            {
                src = this.GetDefaultApiResponseFilePath(api);
            }

            string fullpath;

            if (HostingEnvironment.IsHosted)
            {
                fullpath = HostingEnvironment.MapPath(src);
                return(fullpath);
            }

            var assembly  = Assembly.GetExecutingAssembly();
            var directory = Path.GetDirectoryName(assembly.Location);

            fullpath = (directory + src.Replace("~/", "/")).Replace("/", "\\");
            if (File.Exists(fullpath))
            {
                return(fullpath);
            }

            var codebase = String.Join("/", assembly.CodeBase
                                       .Replace("file:///", "")
                                       .Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries)
                                       .TakeWhile(p => !p.ToLower().EndsWith(".dll")));

            fullpath = (codebase + src.Replace("~/", "/")).Replace("/", "\\");
            if (File.Exists(fullpath))
            {
                return(fullpath);
            }

            return(null);
        }
Пример #16
0
 public override void Init(ApiElement apiElement)
 {
     base.Init(apiElement);
     apiNameSpace = EnsureApiElementType <ApiNameSpace> (apiElement);
     JniName      = apiNameSpace.JniName;
 }
 /// <summary>
 /// Gets the default response file path.
 /// </summary>
 /// <param name="api">ApiElement instance.</param>
 /// <returns>Returns the default response file path.</returns>
 public string GetDefaultApiResponseFilePath(ApiElement api)
 {
     return(this.GetDefaultApiResponseFilePath(api.Method, api.Url));
 }
Пример #18
0
        public override void Init(ApiElement apiElement)
        {
            base.Init(apiElement);

            apiTypeParameterGenericConstraint = EnsureApiElementType <ApiTypeParameterGenericConstraint> (apiElement);
        }