예제 #1
0
        public static EListType ContentTypeToListType(EContentType contentType)
        {
            switch (contentType)
            {
            case EContentType.MusicTrack:
                return(EListType.eTrackList);

            case EContentType.MusicAlbum:
                return(EListType.eAlbumList);

            case EContentType.Video:
                return(EListType.eVideoList);

            case EContentType.Artist:
                return(EListType.eArtistList);

            case EContentType.PodcastEpisode:
                return(EListType.ePodcastEpisodeList);

            case EContentType.PodcastSeries:
                return(EListType.ePodcastList);

            case EContentType.App:
                return(EListType.eAppList);

            case EContentType.Playlist:
                return(EListType.ePlaylistList);

            default:
            case EContentType.Unknown:
                return(EListType.eListInvalid);
            }
        }
예제 #2
0
        public static EContentType ExtractContentType(object obj)
        {
            EContentType econtentType = EContentType.Unknown;

            if (obj is MessageRoot messageRoot)
            {
                econtentType = messageRoot.ContentType;
            }
            return(econtentType);
        }
예제 #3
0
        private void OnGUI()
        {
            var select = Selection.activeObject;
            var path   = AssetDatabase.GetAssetPath(select);

            if (File.Exists(path))
            {
                FileInfo fileInfo = new FileInfo(path);
                path = fileInfo.DirectoryName;
            }
            GUILayout.Label("Lua文件名称");
            luaFileName = EditorGUILayout.TextField(luaFileName);
            charSetType = (ECharSetType)EditorGUILayout.EnumPopup("字符集类型", charSetType);
            contentType = (EContentType)EditorGUILayout.EnumPopup("Lua内容格式", contentType);
            isReturn    = true;
            isReturn    = EditorGUILayout.Toggle("是否有返回值", isReturn);
            GUILayout.Label("");
            if (GUILayout.Button("创建脚本"))
            {
                if (luaFileName == null || luaFileName.Equals(""))
                {
                    Debug.LogError("新建Lua脚本文件名称不允许为空");
                }
                else
                {
                    path = string.Format(@"{0}\{1}.lua", path, luaFileName);
                    if (File.Exists(path))
                    {
                        Debug.LogError(string.Format("{0}文件已经存在", luaFileName));
                    }
                    else
                    {
                        string[] content = new string[5];
                        switch (contentType)
                        {
                        case EContentType.类:
                            content[0] = string.Format("{0}=class(\"{1}\");", luaFileName, luaFileName);
                            break;

                        case EContentType.Table表:
                            content[0] = string.Format("{0}={{}};", luaFileName);
                            break;
                        }
                        if (isReturn)
                        {
                            content[4] = string.Format("return {0};", luaFileName);
                        }
                        File.WriteAllLines(path, content, GetEncoding(charSetType));
                        Debug.Log(string.Format("{0}.lua文件创建完成,请刷新下Project面板", luaFileName));
                        this.Close();
                    }
                }
            }
        }
예제 #4
0
 public static object GetObject(EContentType t, byte[] arr)
 {
     switch (t)
     {
         case EContentType.Byte:
             return arr[0];
         case EContentType.Int:
             return BitConverter.ToInt32(arr,0);
         case EContentType.Long:
             return BitConverter.ToInt64(arr,0);
         case EContentType.String:
             return Encoding.UTF8.GetString(arr).TrimEnd('\0');
         default:
             return null;
     }
 }
예제 #5
0
 /// <summary>
 /// 根据数据类型获取byte[]
 /// </summary>
 /// <param name="t"></param>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static byte[] GetBytes(EContentType t, object obj)
 {
     switch (t)
     {
         case EContentType.Byte:
             return new byte[] { Convert.ToByte(obj) };
         case EContentType.Int:
             return BitConverter.GetBytes(Convert.ToInt32(obj));
         case EContentType.Long:
             return BitConverter.GetBytes(Convert.ToInt64(obj));
         case EContentType.String:
             return Encoding.UTF8.GetBytes(Convert.ToString(obj));
         default:
             return null;
     }
 }
예제 #6
0
 private void ChangeContent_Click(object sender, RoutedEventArgs e)
 {
     Source = null;
     if (contentType == EContentType.Books)
     {
         Source        = CollectionViewSource.GetDefaultView(magazines_DataGrid.ItemsSource);
         Source.Filter = MagazineFilter;
         contentType   = EContentType.Magazines;
         SetDataGridView();
     }
     else
     {
         Source        = CollectionViewSource.GetDefaultView(books_DataGrid.ItemsSource);
         Source.Filter = BooksFilter;
         contentType   = EContentType.Books;
         SetDataGridView();
     }
 }
예제 #7
0
        public Shelfs_MainWindow()
        {
            InitializeComponent();
            if (Main.Library.GetLoggedUser().Role == ERole.Admin)
            {
                Delete_Button.Visibility    = Visibility.Visible;
                AddEntity_Button.Visibility = Visibility.Visible;
                HireItem_Button.Visibility  = Visibility.Hidden;
            }
            else
            {
                Delete_Button.Visibility    = Visibility.Hidden;
                AddEntity_Button.Visibility = Visibility.Hidden;
                HireItem_Button.Visibility  = Visibility.Visible;
            }

            contentType = EContentType.Books;

            setCellsSize(books_DataGrid);
            setCellsSize(magazines_DataGrid);

            SetComboBox();
            SetListData();
        }
예제 #8
0
 public bool IsDownloading(Guid guidMediaId, EContentType eContentType, out bool fIsDownloadPending, out bool fIsHidden)
 {
     throw new NotImplementedException();
 }
예제 #9
0
 public bool InVisibleCollection(Guid guidMediaId, EContentType eContentType, out int dbMediaId)
 {
     throw new NotImplementedException();
 }
    public void NewRead(BinaryReader br)
    {
      contentType = (EContentType)br.ReadByte();
      const01 = br.ReadByte();
      if (const01 != 1)
      {
        throw new Exception("Hibás konstans érték!");
      }
      blockType = (EBlockType)br.ReadByte();
      blockHeaderSize = br.ReadByte();
      byte[] buffer = br.ReadBytes(blockHeaderSize);
      br.BaseStream.Seek((long)-blockHeaderSize, SeekOrigin.Current);
      blockChecksum8 = Utils.ComputeBlockChecksum(const01, blockType, blockHeaderSize, buffer);
      long num = br.ReadInt64();

      blockHeader = TBlockHeader.GenBlkHeader(br,contentType,blockType);
      blockHeader.Read(br);
      blockChecksum8 = br.ReadByte();
      content = br.ReadBytes((int)blockHeader.contentSize);
      //blockHeader.contentLength 
    }
 public static TBlockHeader Factory(BinaryReader br, EBlockType blockType, EContentType contentType)
 {
   switch (blockType)
   {
     case EBlockType.Code:
       {
         switch (contentType)
         {
           case EContentType.PlainCode:
             return new TCodeBlock();
           case EContentType.SignedCode:
             return new TSignedCodeBlock();
         }
         throw new Exception("Unknown Code Content");
       }
     case EBlockType.Data:
       {
         switch (contentType)
         {
           case EContentType.PlainData:
             return new TDataBlock();
           case EContentType.SignedData:
             return new TSignedDataBlock();
         }
         throw new Exception("Unknown Data Content");
       }
   }
   throw new Exception("Unknown block");
 }
예제 #12
0
        public bool IsDownloadingOrPending(Guid mediaId, EContentType eContentType)
        {
            bool fPending;

            return(this.IsDownloading(mediaId, eContentType, out fPending) || fPending);
        }
예제 #13
0
 public HRESULT GetContentUri(Guid guidMediaId, EContentType eContentType, EContentUriFlags eContentUriFlags, EMediaFormat eMediaFormat, EMediaRights eMediaRights, out string uriOut, out Guid mediaInstanceIdOut)
 {
     throw new NotImplementedException();
 }
예제 #14
0
 public HRESULT GetContentUri(Guid guidMediaId, EContentType eContentType, EContentUriFlags eContentUriFlags, bool fIsHD, bool fIsRental, out string uriOut)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 public bool ReportAConcern(EConcernType concernType, EContentType contentType, Guid mediaId, string message, AsyncCompleteHandler callback)
 {
     throw new NotImplementedException();
 }
예제 #16
0
 public void CancelDownload(Guid guidMediaId, EContentType eContentType)
 {
 }
예제 #17
0
 public DRMInfo GetMediaDRMInfo(Guid mediaId, EContentType eContentType)
 {
     throw new NotImplementedException();
 }
예제 #18
0
        public bool IsDownloading(Guid mediaId, EContentType eContentType, out bool fPending)
        {
            bool fIsHidden = false;

            return(ZuneApplication.Service.IsDownloading(mediaId, eContentType, out fPending, out fIsHidden));
        }
예제 #19
0
 public EMediaStatus GetMediaStatus(Guid guidMediaId, EContentType eContentType)
 {
     throw new NotImplementedException();
 }
예제 #20
0
        /// <summary>
        /// Http请求
        /// </summary>
        /// <param name="url">url地址</param>
        /// <param name="paramData">内容</param>
        /// <param name="headerDic">header参数</param>
        /// <param name="method">请求方式</param>
        /// <param name="contentType">类型</param>
        /// <returns></returns>
        public string Http(string url, string paramData, Dictionary <string, string> headerDic = null, EMethod method = EMethod.Post, EContentType contentType = EContentType.Form)
        {
            string         result    = string.Empty;
            HttpWebRequest wbRequest = null;

            try
            {
                //如果是发送HTTPS请求
                if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
                {
                    ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3;
                    wbRequest = (HttpWebRequest)WebRequest.Create(url);
                    wbRequest.ProtocolVersion = HttpVersion.Version10;
                }
                else
                {
                    wbRequest = (HttpWebRequest)WebRequest.Create(url);
                }
                wbRequest.Method        = method.GetDescription();
                wbRequest.ContentType   = contentType.GetDescription();
                wbRequest.ContentLength = Encoding.UTF8.GetByteCount(paramData);
                if (headerDic != null && headerDic.Count > 0)
                {
                    foreach (var item in headerDic)
                    {
                        wbRequest.Headers.Add(item.Key, item.Value);
                    }
                }
                using (Stream requestStream = wbRequest.GetRequestStream())
                {
                    using (StreamWriter swrite = new StreamWriter(requestStream))
                    {
                        swrite.Write(paramData);
                    }
                }
                HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();
                using (Stream responseStream = wbResponse.GetResponseStream())
                {
                    using (StreamReader sread = new StreamReader(responseStream))
                    {
                        result = sread.ReadToEnd();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
예제 #21
0
 public bool GetUserRating(int iUserId, Guid guidMediaId, EContentType eContentType, ref int piRating)
 {
     throw new NotImplementedException();
 }
    public override void Read(BinaryReader br)
    {
      blockType = (EBlockType)br.ReadByte();
      const01 = br.ReadByte();
      Debug.Assert(const01 == 01, "Const != 01");

      contentType = (EContentType)br.ReadByte();
      blockSize = br.ReadByte();

      // Useful to check for errors
      long currPos = br.BaseStream.Position;
      blockHeader = TBlockHeader.GenBlkHeader(br,contentType,blockType);
      blockHeader.Read(br);
      if (br.BaseStream.Position != currPos + blockSize)
      {
        long missing = (currPos + blockSize - br.BaseStream.Position);
        Debug.Assert(false, "Error Reading Header! ", missing + " bytes left.");
        // Fixes the offset and continue...
        br.BaseStream.Seek(missing, SeekOrigin.Current);
      }

      blockChecksum8 = br.ReadByte();
      content = br.ReadBytes((int)blockHeader.contentSize);
      ROFSTracer.WriteTextBlock( this );
    }
예제 #23
0
 public bool InCompleteCollection(Guid guidMediaId, EContentType eContentType, string strDeviceEndpointId, out int dbMediaId, out bool fHidden)
 {
     throw new NotImplementedException();
 }
    public static TBlockHeader GenBlkHeader(BinaryReader br, EContentType type1, EBlockType type4)
    {
      EContentType type;
      EBlockType type2;
      EBlockType type3;

      type = type1;
      if ((type == EContentType.Code) || (type == EContentType.Data))
      {
        type2 = type4;
        switch (type2)
        {
          case EBlockType.BlockType2E:
            return new TBlockType2E();
          case (EBlockType)0x2f:
            throw new NotImplementedException();
          case EBlockType.BlockType30:
            return new TBlockType30();
        }
        return new TBlockType17();
      }
      type3 = type4;
      switch (type3)
      {
        case EBlockType.BlockType28_CORE_Cert:
          return new TBlockType28_CORE_Cert();
      }
      return new TBlockType27_ROFS_Hash();
    }
예제 #25
0
 public bool InHiddenCollection(Guid guidMediaId, EContentType eContentType)
 {
     throw new NotImplementedException();
 }