Exemple #1
0
        private static bool IsTypeContentCorrectForTypes(Type a, Type b, TypeContent typeContent)
        {
            switch (typeContent)
            {
            case TypeContent.Target:
                if (a == b)
                {
                    return(true);
                }
                break;

            case TypeContent.Inherited:
                if (a != b)
                {
                    // do not list Inherited members that are not a part of targeted assemblies
                    return(Generator.LoadedAssemblies.Any(e => e == a.Assembly));
                }

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(typeContent), typeContent, null);
            }

            return(false);
        }
 public void SetMsg(string msg, ConsoleView.Color type = ConsoleView.Color.MSG_INFO)
 {
     _typeContent = TypeContent.MESSAGE;
     _typeMsg     = type;
     _msg         = msg;
     Show();
 }
 public Content(TypeContent typeContent, ContentTitle contentTitle, ContentText contentText, ContentSvg contentSvg, ContentPng contentPng)
 {
     TypeContent  = typeContent;
     ContentTitle = contentTitle;
     ContentText  = contentText;
     ContentSvg   = contentSvg;
     ContentPng   = contentPng;
 }
 /// <summary>
 /// Инициализатор плейлиста на основе списка файлов и указанного типа контента
 /// </summary>
 /// <param name="_FileList"></param>
 /// <param name="_typeContent"></param>
 public PlayListByTypeContent(FileList _FileList, TypeContent _typeContent, TypePlaying _typePlaying)
 {
     logger = MainWindow.Logger;
     logger.Info("Запущена инициализация плейлиста");
     FileList    = _FileList;
     typeContent = _typeContent;
     typePlaying = _typePlaying;
     GeneratePlaylist();
 }
        public async Task TypeContent_ConstructorWithRequestOnly_ShouldAddDefaultHeaders()
        {
            var typeContent = new TypeContent <ComplexTypes.ComplexTypeRequest>(ComplexTypes.ComplexTypeRequestInstance);

            Assert.AreEqual("application/json", typeContent.Headers.ContentType.MediaType);
            Assert.AreEqual("utf-8", typeContent.Headers.ContentType.CharSet);

            var content = await typeContent.ReadAsStringAsync();

            Assert.AreEqual(ComplexTypes.ComplexTypeRequestString.ToLower(), content.ToLower());
        }
    public async Task TypeContent_ConstructorWithEncodingOnly_ShouldAddCorrectHeaders()
    {
        var typeContent = new TypeContent <ComplexTypes.ComplexTypeRequest>(ComplexTypes.ComplexTypeRequestInstance, Encoding.UTF32);

        Assert.AreEqual("application/json", typeContent?.Headers?.ContentType?.MediaType);
        Assert.AreEqual("utf-32", typeContent?.Headers?.ContentType?.CharSet);

        var content = await(typeContent?.ReadAsStringAsync() ?? Task.FromResult(string.Empty));

        Assert.AreEqual(ComplexTypes.ComplexTypeRequestString.ToLower(), content.ToLower());
    }
        public async Task TypeContent_ConstructorWithEncodingAndMediaType_ShouldAddCorrectHeaders()
        {
            var typeContent = new TypeContent <ComplexTypes.ComplexTypeRequest>(ComplexTypes.ComplexTypeRequestInstance, Encoding.UTF32, "test/type");

            Assert.AreEqual("test/type", typeContent.Headers.ContentType.MediaType);
            Assert.AreEqual("utf-32", typeContent.Headers.ContentType.CharSet);

            var content = await typeContent.ReadAsStringAsync();

            Assert.AreEqual(ComplexTypes.ComplexTypeRequestString.ToLower(), content.ToLower());
        }
 public void SetFile(string path)
 {
     _typeContent = TypeContent.FILE_INFO;
     if (Directory.Exists(path))
     {
         _file = new DirectoryInfo(path);
     }
     else if (File.Exists(path))
     {
         _file = new FileInfo(path);
     }
     Show();
 }
        /// Next item detection
        /// Return a object ContentNext with the type of element and position in string
        private ContentNext _nextContent(String s)
        {
            // print('str: ' + s);
            int         pos        = s.Length;
            int         nextPos    = 0;
            String      content    = "";
            TypeContent type       = TypeContent.Null;
            int         startIndex = 0;
            int         endIndex   = 0;

            // Title
            startIndex = s.IndexOf(STARTTAGTIT) == -1 ? 0 : s.IndexOf(STARTTAGTIT) + STARTTAGTIT.Length;
            endIndex   = s.IndexOf(ENDTAGTIT, startIndex);
            bool swValidTitle = (startIndex > 0) && (endIndex - startIndex) > 0;

            if (!swValidTitle)
            {
                startIndex = 0;
                endIndex   = 0;
            }
            else
            {
                if (pos > startIndex)
                {
                    pos     = startIndex;
                    nextPos = endIndex + ENDTAGTIT.Length;
                    // Mod of dart
                    content = s.Substring(startIndex, endIndex - startIndex);
                    //content = s.Substring(startIndex, endIndex);
                    // End mod of dart
                    type = TypeContent.TypeTitle;
                }
            }
            // Text
            startIndex = s.IndexOf(STARTTAGTEX) == -1 ? 0 : s.IndexOf(STARTTAGTEX) + STARTTAGTEX.Length;
            endIndex   = s.IndexOf(ENDTAGTEX, startIndex);
            bool swValidText = (startIndex > 0) && (endIndex - startIndex) > 0;

            if (!swValidText)
            {
                startIndex = 0;
                endIndex   = 0;
            }
            else
            {
                if (pos > startIndex)
                {
                    pos     = startIndex;
                    nextPos = endIndex + ENDTAGTEX.Length;
                    // Mod of dart
                    // content = s.Substring(startIndex, endIndex);
                    content = s.Substring(startIndex, endIndex - startIndex);
                    // End mod of dart
                    type = TypeContent.TypeText;
                }
            }
            // Svg
            startIndex = s.IndexOf(STARTTAGSVG) == -1 ? 0 : s.IndexOf(STARTTAGSVG) + STARTTAGSVG.Length;
            endIndex   = s.IndexOf(ENDTAGSVG, startIndex);
            bool swValidSvg = (startIndex > 0) && (endIndex - startIndex) > 0;

            if (!swValidSvg)
            {
                startIndex = 0;
                endIndex   = 0;
            }
            else
            {
                if (pos > startIndex)
                {
                    pos     = startIndex;
                    nextPos = endIndex + ENDTAGSVG.Length;
                    // Mod of dart
                    // content = "assets/svg/astro_py_text/" + s.Substring(startIndex, endIndex);
                    content = "assets/svg/astro_py_text/" + s.Substring(startIndex, endIndex - startIndex);
                    // End mod of dart
                    type = TypeContent.TypeSvg;
                }
            }
            // Svg Zodiac local
            startIndex = s.IndexOf(STARTTAGSVZ) == -1 ? 0 : s.IndexOf(STARTTAGSVZ) + STARTTAGSVZ.Length;
            endIndex   = s.IndexOf(ENDTAGSVZ, startIndex);
            bool swValidSvgz = (startIndex > 0) && (endIndex - startIndex) > 0;

            if (!swValidSvgz)
            {
                startIndex = 0;
                endIndex   = 0;
            }
            else
            {
                if (pos > startIndex)
                {
                    pos     = startIndex;
                    nextPos = endIndex + ENDTAGSVZ.Length;
                    // Mod of dart
                    // content = "assets/svg/zodiac/" + s.Substring(startIndex, endIndex);
                    content = "assets/svg/zodiac/" + s.Substring(startIndex, endIndex - startIndex);
                    // End mod of dart
                    type = TypeContent.TypeSvg;
                }
            }
            // Png
            startIndex = s.IndexOf(STARTTAGPNG) == -1 ? 0 : s.IndexOf(STARTTAGPNG) + STARTTAGPNG.Length;
            endIndex   = s.IndexOf(ENDTAGPNG, startIndex);
            bool swValidPng = (startIndex > 0) && (endIndex - startIndex) > 0;

            if (!swValidPng)
            {
                startIndex = 0;
                endIndex   = 0;
            }
            else
            {
                if (pos > startIndex)
                {
                    pos     = startIndex;
                    nextPos = endIndex + ENDTAGPNG.Length;
                    // Mod of dart
                    // content = "assets/png/astro_py_text/" + s.Substring(startIndex, endIndex);
                    content = "assets/png/astro_py_text/" + s.Substring(startIndex, endIndex - startIndex);
                    // End mod of dart
                    type = TypeContent.TypePng;
                }
            }
            return(new ContentNext(type, nextPos, content));
        }
Exemple #10
0
 public void SetTypeContent(TypeContent typeContent = TypeContent.Default)
 {
 }
Exemple #11
0
        internal static void BuildEvents(Type t, StringBuilder str, XmlNodeList nodes, TypeContent typeContent, bool applyStatic)
        {
            var events = t.GetEvents();

            Program.Process($"{events.Length} events in {t.Name}. content:{typeContent}, static:{applyStatic}");

            var buildProperties = new List <DocProperty>();

            foreach (var e in events)
            {
                if (!CanApplyStatic(IsEventStatic(e), applyStatic))
                {
                    continue;
                }
                if (!IsTypeContentCorrectForTypes(e.DeclaringType, t, typeContent))
                {
                    continue;
                }

                //if (IsTypeArrayContainsNotAllowed(e.PropertyType, e.DeclaringType))
                //    continue;
                DocClassHelper.CollectClassEvent(nodes, e, out var name, out var type, out var description);
                buildProperties.Add(new DocProperty
                {
                    Name        = name,
                    Type        = type,
                    Description = description
                });
            }
            DocProperty.BuildTabeleFromProperties(str, DocPropertyTabeleStyle.Event, applyStatic, buildProperties.ToArray());
        }
        public override void openFile()
        {
            string path = this.mySharedData.basicInfo.curFile;

            if (File.Exists(path) == false)
            {
                throw new FileNotFoundException(path + Constants.STR_FILENOTEXISTS_MSG);
            }

            TypeContent type = this.getContentType(path);

            if (type != TypeContent.EDocument)
            {
                path = path.Replace("\\", "\\\\");
            }

            if (type == TypeContent.EPicture)
            {
                if (this.scriptBytes == null)
                {
                    this.scriptBytes = System.Convert.FromBase64String(script);
                }

                string str = System.Text.ASCIIEncoding.UTF8.GetString(this.scriptBytes);
                str = str.Replace("oldPath", path);
                webBrowser.DocumentText = str;
            }
            else if (type == TypeContent.EUnity3D)
            {
                if (this.unityBytes == null)
                {
                    this.unityBytes = System.Convert.FromBase64String(unityScript);
                }

                string str = System.Text.ASCIIEncoding.UTF8.GetString(this.unityBytes);
                str = str.Replace(replaceFile, path);
                webBrowser.DocumentText = str;
            }
            else if (type == TypeContent.EAdobeDirector)
            {
                if (this.dcrBytes == null)
                {
                    this.dcrBytes = System.Convert.FromBase64String(dcrScript);
                }

                string str = System.Text.ASCIIEncoding.UTF8.GetString(this.dcrBytes);
                str = str.Replace(replaceFile, path);
                str = str.Replace(swVersion, this.mySharedData.swPlayerVersion);
                webBrowser.DocumentText = str;
            }
            else if (type == TypeContent.ECortona3D)
            {
                if (this.wrlzBytes == null)
                {
                    this.wrlzBytes = System.Convert.FromBase64String(wrlzScript);
                }

                string str = System.Text.ASCIIEncoding.UTF8.GetString(this.wrlzBytes);
                str = str.Replace(replaceFile, path);
                webBrowser.DocumentText = str;
            }
            else if (type == TypeContent.EDocument)
            {
                this.webBrowser.Navigate("file:////" + path);
            }
            this.ch = true;
        }
Exemple #13
0
        public static FileTypeInfo GetContentType(string text)
        {
            string      contentType = string.Empty;
            TypeContent typeContent = TypeContent.video;

            var _typeFile = GetTypeFile(text);

            switch (_typeFile)
            {
            case "jpg":
                contentType = $"image/{_typeFile}";
                typeContent = TypeContent.image;
                break;

            case "jpeg":
                contentType = $"image/{_typeFile}";
                typeContent = TypeContent.image;
                break;

            case "gif":
                contentType = $"image/{_typeFile}";
                typeContent = TypeContent.image;
                break;

            case "png":
                contentType = $"image/{_typeFile}";
                typeContent = TypeContent.image;
                break;

            case "mp4":
                contentType = $"video/{_typeFile}";
                typeContent = TypeContent.video;
                break;

            case "mpeg4":
                contentType = $"video/{_typeFile}";
                typeContent = TypeContent.video;
                break;

            case "mpeg":
                contentType = $"video/{_typeFile}";
                typeContent = TypeContent.video;
                break;

            case "vmk":
                contentType = $"video/{_typeFile}";
                typeContent = TypeContent.video;
                break;

            case "wma":
                contentType = $"video/{_typeFile}";
                typeContent = TypeContent.video;
                break;

            case "zip":
                contentType = $"application/zip";
                typeContent = TypeContent.video;
                break;

            default:
                contentType = $"";
                typeContent = TypeContent.video;
                break;
            }


            return(new FileTypeInfo
            {
                TypeContent = typeContent,
                TypeFileString = contentType
            });
        }
        public async Task <FileInformation> GetPathContentAsync(string key)
        {
            string      path        = string.Empty;
            TypeContent typeContent = TypeContent.none;
            string      file_type   = string.Empty;
            string      file_name   = string.Empty;

            byte[]       _data     = new byte[0];
            FileInfo     _fileInfo = null;
            FileTypeInfo fileType  = null;

            Dictionary <string, string> tokensMemory = _tokenManager.GetTokens();

            path = tokensMemory.GetValueOrDefault(key);
            // path = @"C:\Users\spegov\Downloads\video_ru (1).mp4";
            if (path == null)
            {
                return new FileInformation
                       {
                           Error       = Error.NotFound,
                           FileName    = string.Empty,
                           Path        = path,
                           Type        = string.Empty,
                           FullName    = string.Empty,
                           TypeContent = typeContent
                       }
            }
            ;

            Storege storege = storegeContentManager.Storeges.GetValueOrDefault(key);

            if (storege == null)
            {
                _fileInfo = new FileInfo(path);

                if (!_fileInfo.Exists)
                {
                    return new FileInformation
                           {
                               Error       = Error.NotFound,
                               FileName    = string.Empty,
                               Path        = path,
                               Type        = string.Empty,
                               FullName    = string.Empty,
                               TypeContent = typeContent
                           }
                }
                ;

                _data = await File.ReadAllBytesAsync(_fileInfo.FullName);

                fileType = FileHelper.GetContentType(_fileInfo.Extension);
                storege  = new Storege
                {
                    Key      = key,
                    Data     = _data,
                    Name     = _fileInfo.Name,
                    TypeFile = fileType.TypeFileString
                };

                storegeContentManager.InsertUser(storege);
                return(new FileInformation
                {
                    Error = Error.None,
                    FileName = _fileInfo.Name,
                    Path = path,
                    Data = _data,
                    Type = fileType.TypeFileString,
                    FullName = _fileInfo.Name,
                    TypeContent = fileType.TypeContent
                });
            }
            else
            {
                return(new FileInformation
                {
                    Error = Error.None,
                    FileName = storege.Name,
                    Path = string.Empty,
                    Data = storege.Data,
                    Type = storege.TypeFile,
                    FullName = storege.Name,
                    TypeContent = TypeContent.video
                });
            }
        }
    }
}
Exemple #15
0
        internal static void BuildProperties(Type t, StringBuilder str, XmlNodeList nodes, TypeContent typeContent, bool applyStatic)
        {
            var properties = t.GetProperties();

            Program.Process($"{properties.Length} properties in {t.Name}. content:{typeContent}, static:{applyStatic}");

            var buildProperties = new List <DocProperty>();

            foreach (var p in properties)
            {
                if (!CanApplyStatic(IsPropertyStatic(p), applyStatic))
                {
                    continue;
                }
                if (!IsTypeContentCorrectForTypes(p.DeclaringType, t, typeContent))
                {
                    continue;
                }

                if (IsTypeArrayContainsNotAllowed(p.PropertyType, p.DeclaringType))
                {
                    Program.Process($"property {p.Name} refused to generate: IsTypeArrayContainsNotAllowed::True", true);
                    continue;
                }

                DocClassHelper.CollectClassProperty(nodes, p, out var name, out var type, out var protection, out var description);
                buildProperties.Add(new DocProperty
                {
                    Name        = name,
                    Type        = type,
                    Protection  = protection,
                    Description = description
                });
            }
            DocProperty.BuildTabeleFromProperties(str, DocPropertyTabeleStyle.Property, applyStatic, buildProperties.ToArray());
        }
Exemple #16
0
        internal static void BuildFields(Type t, StringBuilder str, XmlNodeList nodes, TypeContent typeContent, bool applyStatic)
        {
            var fields = t.GetFields();

            Program.Process($"{fields.Length} fields in {t.Name}. content:{typeContent}, static:{applyStatic}");

            var buildProperties = new List <DocProperty>();

            foreach (var f in fields)
            {
                if (!CanApplyStatic(f.IsStatic, applyStatic))
                {
                    continue;
                }
                if (!IsTypeContentCorrectForTypes(f.DeclaringType, t, typeContent))
                {
                    continue;
                }

                if (IsTypeArrayContainsNotAllowed(f.FieldType, f.DeclaringType))
                {
                    Program.Process($"field {f.Name} refused to generate: IsTypeArrayContainsNotAllowed::True", true);
                    continue;
                }

                DocClassHelper.CollectClassField(nodes, f, out var name, out var type, out var description);
                buildProperties.Add(new DocProperty
                {
                    Name        = name,
                    Type        = type,
                    Description = description
                });
            }
            DocProperty.BuildTabeleFromProperties(str, DocPropertyTabeleStyle.Field, applyStatic, buildProperties.ToArray());
        }
Exemple #17
0
 public ContentNext(TypeContent type, int nextPos, string content)
 {
     Type    = type;
     NextPos = nextPos;
     Content = content;
 }
Exemple #18
0
        internal static void BuildMethods(Type t, StringBuilder str, XmlNodeList nodes, TypeContent typeContent, bool applyStatic)
        {
            var methods = t.GetMethods();

            Program.Process($"{methods.Length} methods in {t.Name}. content:{typeContent}, static:{applyStatic}");

            var buildProperties = new List <DocProperty>();

            foreach (var m in methods)
            {
                if (!CanApplyStatic(m.IsStatic, applyStatic))
                {
                    continue;
                }
                if (!IsTypeContentCorrectForTypes(m.DeclaringType, t, typeContent))
                {
                    continue;
                }
                if (IsMethodPropertySetOrGet(t, m))
                {
                    continue;
                }

                if (!m.IsPublic || m.IsAbstract || m.IsVirtual || m.IsPrivate)
                {
                    Program.Process($"method {m.Name} refused to generate: can't access::(public:{m.IsPublic} || abstract:{m.IsAbstract} || virtual:{m.IsVirtual} || private:{m.IsPrivate})", true);
                    continue;
                }

                if (!IsDeclaringTypeAllowed(m.DeclaringType))
                {
                    Program.Process($"method {m.Name} refused to generate: IsDeclaringTypeAllowed::false", true);
                    continue;
                }

                if (IsTypeArrayContainsNotAllowed(new List <Type>(m.GetGenericArguments())
                {
                    m.DeclaringType
                }.ToArray()))
                {
                    Program.Process($"method {m.Name} refused to generate: IsTypeArrayContainsNotAllowed::true", true);
                    continue;
                }

                DocClassHelper.CollectClassMethod(nodes, m, out var name, out var type, out var description);
                buildProperties.Add(new DocProperty
                {
                    Name        = name,
                    Type        = type,
                    Description = description
                });
            }

            DocProperty.BuildTabeleFromProperties(str, DocPropertyTabeleStyle.Method, applyStatic, buildProperties.ToArray());
        }