• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IAsset类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IAsset的典型用法代码示例。如果您正苦于以下问题:C# IAsset类的具体用法?C# IAsset怎么用?C# IAsset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IAsset类属于命名空间,在下文中一共展示了IAsset类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Handle

        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="asset">
        /// The asset.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <returns>
        /// The <see cref="dynamic"/>.
        /// </returns>
        public IRawAsset Handle(IAsset asset, AssetTarget target)
        {
            var fontAsset = asset as FontAsset;

            if (target == AssetTarget.CompiledFile)
            {
                if (fontAsset.PlatformData == null)
                {
                    throw new InvalidOperationException(
                        "Attempted save of font asset as a compiled file, but the font wasn't compiled.  This usually " +
                        "indicates that the font '" + fontAsset.FontName + "' is not installed on the current system.");
                }

                return new CompiledAsset
                {
                    Loader = typeof(FontAssetLoader).FullName,
                    PlatformData = fontAsset.PlatformData
                };
            }

            return
                new AnonymousObjectBasedRawAsset(
                    new
                    {
                        Loader = typeof(FontAssetLoader).FullName,
                        fontAsset.FontSize,
                        fontAsset.FontName,
                        fontAsset.UseKerning,
                        fontAsset.Spacing,
                        PlatformData = target == AssetTarget.SourceFile ? null : fontAsset.PlatformData
                    });
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:44,代码来源:FontAssetSaver.cs


示例2: PlainScript

 public PlainScript(IAsset asset, Bundle bundle, IAmdConfiguration modules)
     : base(asset, bundle)
 {
     this.modules = modules;
     jsonSerializer = new SimpleJsonSerializer();
     asset.AddAssetTransformer(this);
 }
开发者ID:joshperry,项目名称:cassette,代码行数:7,代码来源:PlainScript.cs


示例3: AddRawFileReferenceForEachImportedFile

 void AddRawFileReferenceForEachImportedFile(IAsset asset, CompileResult compileResult)
 {
     foreach (var importedFilePath in compileResult.ImportedFilePaths)
     {
         asset.AddRawFileReference(importedFilePath);
     }
 }
开发者ID:jlopresti,项目名称:cassette,代码行数:7,代码来源:CompileAsset.cs


示例4: AssetSimulated

        /**
         * Create a simulated asset from a real one.
         * It extract the name of real asset for "fake" one
         * and the first price (at first date) and simulate
         * at all dates from dates_simul.
         * 
         * getPrice(t) with t from dates_simul will then return
         * a simulated price
         * getPrice(t) with t before first date from dates_simul
         * will return real price of asset
         * getPrice(t) with all others date will throw exception
         **/
        public AssetSimulated(IAsset real, LinkedList<DateTime> dates_simul, RandomNormal rand)
        {
            this.real = real;
            prices = new Dictionary<DateTime, double>();
            first_date = dates_simul.First();
            r = 0.04;
                //real.getCurrency().getInterestRate(first_date, TimeSpan.Zero);
            // TODO
            //sigma = real.getVolatility(first_date);
            sigma = 0.2;

            // debug kevin
            double St = 75 + 50*rand.NextDouble();
            DateTime lastDate = first_date;
            //double S0 = real.getPrice(first_date);
            int i = 0;
            foreach (DateTime date in dates_simul)
            {
                double T = (date - lastDate).TotalDays / 365; // time in year
                double WT = Math.Sqrt(T) * rand.NextNormal();
                St = St * Math.Exp((r - sigma * sigma / 2) * T + sigma * WT);
                prices[date] = St;
                lastDate = date;
                i++;
            }
        }
开发者ID:bonkoskk,项目名称:peps,代码行数:38,代码来源:AssetSimulated.cs


示例5: AssetFileCollection

 /// <summary>
 /// Initializes a new instance of the <see cref="AssetFileCollection"/> class.
 /// </summary>
 /// <param name="cloudMediaContext">The cloud media context.</param>
 /// <param name="parentAsset">The parent <see cref="IAsset"/>.</param>
 internal AssetFileCollection(MediaContextBase cloudMediaContext, IAsset parentAsset)
     : this(cloudMediaContext)
 {
     _parentAsset = parentAsset;
     MediaServicesClassFactory factory = this.MediaContext.MediaServicesClassFactory;
     this._assetFileQuery = new Lazy<IQueryable<IAssetFile>>(() => factory.CreateDataServiceContext().CreateQuery<IAssetFile, AssetFileData>(FileSet));
 }
开发者ID:Ginichen,项目名称:azure-sdk-for-media-services,代码行数:12,代码来源:AssetFileCollection.cs


示例6: Transform

 public Func<Stream> Transform(Func<Stream> openSourceStream, IAsset asset)
 {
     return delegate
     {
         var css = ReadCss(openSourceStream);
         var currentDirectory = GetCurrentDirectory(asset);
         var urlMatches = UrlMatchesInReverse(css);
         var builder = new StringBuilder(css);
         foreach (var match in urlMatches)
         {
             var matchedUrlGroup = match.Groups["url"];
             string queryString;
             string fragment;
             var relativeFilename = GetImageFilename(matchedUrlGroup, currentDirectory, out queryString, out fragment);
             if (ReplaceUrlWithCassetteRawFileUrl(builder, matchedUrlGroup, relativeFilename, queryString, fragment))
             {
                 asset.AddRawFileReference(relativeFilename);
             }
             else
             {
                 ReplaceUrlWithAbsoluteUrl(builder, matchedUrlGroup, currentDirectory);
             }
         }
         return builder.ToString().AsStream();
     };
 }
开发者ID:jlopresti,项目名称:cassette,代码行数:26,代码来源:ExpandCssUrlsAssetTransformer.cs


示例7: Transform

        public Func<Stream> Transform(Func<Stream> openSourceStream, IAsset asset)
        {
            return () =>
            {
                var addTemplateCalls = openSourceStream().ReadToEnd();

                var output = string.Format(
                    @"(function(d) {{
            var addTemplate = function(id, content) {{
            var script = d.createElement('script');
            script.type = '{0}';
            script.id = id;
            if (typeof script.textContent !== 'undefined') {{
            script.textContent = content;
            }} else {{
            script.innerText = content;
            }}
            var x = d.getElementsByTagName('script')[0];
            x.parentNode.insertBefore(script, x);
            }};
            {1}
            }}(document));",
                    contentType,
                    addTemplateCalls);

                return new MemoryStream(Encoding.UTF8.GetBytes(output));
            };
        }
开发者ID:jlopresti,项目名称:cassette,代码行数:28,代码来源:WrapJavaScriptHtmlTemplatesTransformer.cs


示例8: PlainScript

 public PlainScript(IAsset asset, Bundle bundle, IModuleInitializer modules,string baseUrl = null)
     : base(asset, bundle, baseUrl)
 {
     this.modules = modules;
     jsonSerializer = new SimpleJsonSerializer();
     asset.AddAssetTransformer(this);
 }
开发者ID:joplaal,项目名称:cassette,代码行数:7,代码来源:PlainScript.cs


示例9: Handle

        /// <summary>
        /// The handle.
        /// </summary>
        /// <param name="asset">
        /// The asset.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <returns>
        /// The <see cref="dynamic"/>.
        /// </returns>
        public IRawAsset Handle(IAsset asset, AssetTarget target)
        {
            var textAsset = asset as LanguageAsset;

            return
                new AnonymousObjectBasedRawAsset(new { Loader = typeof(LanguageAssetLoader).FullName, textAsset.Value });
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:19,代码来源:LanguageAssetSaver.cs


示例10: CreateMediaEncodeJob

        private static async Task<IJob> CreateMediaEncodeJob(CloudMediaContext context, IAsset assetToEncode)
        {
            //string encodingPreset = "H264 Broadband 720p";
            string encodingPreset = "H264 Smooth Streaming 720p";

            IJob job = context.Jobs.Create("Encoding " + assetToEncode.Name + " to " + encodingPreset);

            string[] y =
                context.MediaProcessors.Where(mp => mp.Name.Equals("Azure Media Encoder"))
                    .ToArray()
                    .Select(mp => mp.Version)
                    .ToArray();

            IMediaProcessor latestWameMediaProcessor =
                context.MediaProcessors.Where(mp => mp.Name.Equals("Azure Media Encoder"))
                    .ToArray()
                    .OrderByDescending(
                        mp =>
                            new Version(int.Parse(mp.Version.Split('.', ',')[0]),
                                int.Parse(mp.Version.Split('.', ',')[1])))
                    .First();

            ITask encodeTask = job.Tasks.AddNew("Encoding", latestWameMediaProcessor, encodingPreset, TaskOptions.None);
            encodeTask.InputAssets.Add(assetToEncode);
            encodeTask.OutputAssets.AddNew(assetToEncode.Name + " as " + encodingPreset, AssetCreationOptions.None);

            job.StateChanged += new EventHandler<JobStateChangedEventArgs>((sender, jsc) => Console.WriteLine(
                $"{((IJob) sender).Name}\n  State: {jsc.CurrentState}\n  Time: {DateTime.UtcNow.ToString(@"yyyy_M_d_hhmmss")}\n\n"));
            return await job.SubmitAsync();
        }
开发者ID:se02035,项目名称:WEcanHELP,代码行数:30,代码来源:Functions.cs


示例11: ParseJavaScriptForModuleDefinition

 static ModuleDefinitionParser ParseJavaScriptForModuleDefinition(IAsset asset)
 {
     var tree = ParseJavaScript(asset);
     var moduleDefinitionParser = new ModuleDefinitionParser();
     tree.Accept(moduleDefinitionParser);
     return moduleDefinitionParser;
 }
开发者ID:jlopresti,项目名称:cassette,代码行数:7,代码来源:ModuleInitializer.cs


示例12: Create

 /// <summary>
 /// Returns a new <see cref="ILocator"/> instance.
 /// </summary>
 /// <param name="locators">The <see cref="LocatorBaseCollection"/> instance.</param>
 /// <param name="locatorType">The <see cref="LocatorType"/>.</param>
 /// <param name="asset">The <see cref="IAsset"/> instance for the new <see cref="ILocator"/>.</param>
 /// <param name="permissions">The <see cref="AccessPermissions"/> of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="duration">The duration of the <see cref="IAccessPolicy"/> associated with the new <see cref="ILocator"/>.</param>
 /// <param name="startTime">The start time of the new <see cref="ILocator"/>.</param>
 /// <returns>A a new <see cref="ILocator"/> instance.</returns>
 public static ILocator Create(this LocatorBaseCollection locators, LocatorType locatorType, IAsset asset, AccessPermissions permissions, TimeSpan duration, DateTime? startTime)
 {
     using (Task<ILocator> task = locators.CreateAsync(locatorType, asset, permissions, duration, startTime))
     {
         return task.Result;
     }
 }
开发者ID:huyan2013,项目名称:azure-sdk-for-media-services-extensions,代码行数:17,代码来源:LocatorBaseCollectionExtensions.cs


示例13: EncodeToAdaptiveBitrateMP4s

        public static IAsset EncodeToAdaptiveBitrateMP4s(IAsset asset, AssetCreationOptions options)
        {
            // Prepare a job with a single task to transcode the specified asset
            // into a multi-bitrate asset.

            IJob job = _context.Jobs.CreateWithSingleTask(
                MediaProcessorNames.AzureMediaEncoder,
                MediaEncoderTaskPresetStrings.H264AdaptiveBitrateMP4Set720p,
                asset,
                "Adaptive Bitrate MP4",
                options);

            Console.WriteLine("Submitting transcoding job...");

            // Submit the job and wait until it is completed.
            job.Submit();

            job = job.StartExecutionProgressTask(
                j =>
                {
                    Console.WriteLine("Job state: {0}", j.State);
                    Console.WriteLine("Job progress: {0:0.##}%", j.GetOverallProgress());
                },
                CancellationToken.None).Result;

            Console.WriteLine("Transcoding job finished.");

            IAsset outputAsset = job.OutputMediaAssets[0];

            return outputAsset;
        }
开发者ID:debashish1976,项目名称:dotnetsdk,代码行数:31,代码来源:Program.cs


示例14: CreateSasLocatorAsync

        private static async Task<ILocator> CreateSasLocatorAsync(CloudMediaContext context, IAsset asset)
        {
            var accessPolicy = await context.AccessPolicies.CreateAsync(
                asset.Name, TimeSpan.FromDays(2), AccessPermissions.Write | AccessPermissions.List);

            return await context.Locators.CreateSasLocatorAsync(asset, accessPolicy);
        }
开发者ID:ejadib,项目名称:scriptcs-azuremediaservices,代码行数:7,代码来源:AzureMediaServicesUploader.cs


示例15: NamedModule

        public NamedModule(IAsset asset, Bundle bundle, string modulePath)
            : base(asset, bundle)
        {
            if (modulePath == null) throw new ArgumentNullException("modulePath");

            ModulePath = modulePath;
        }
开发者ID:jlopresti,项目名称:cassette,代码行数:7,代码来源:NamedModule.cs


示例16: ConvertAssetToSmoothStreaming

        public static string ConvertAssetToSmoothStreaming(this CloudMediaContext context, IAsset asset, bool createThumbnail)
        {
            var configuration = MediaServicesHelper.H264SmoothStreamingEncodingPreset;
            var processor = context.MediaProcessors.Where(m => m.Id == MediaServicesHelper.EncoderProcessorId).FirstOrDefault();            

            var job = context.Jobs.Create(asset.Name);

            var task = job.Tasks.AddNew(
                MediaServicesHelper.EncodingTask,
                processor,
                configuration,
                TaskOptions.None);

            task.InputAssets.Add(asset);
            var encodedAsset = task.OutputAssets.AddNew(asset.Name + " - [" + configuration + "]", true, AssetCreationOptions.None);
            encodedAsset.AlternateId = asset.AlternateId + "_0";

            if (createThumbnail)
            {
                var thumbnailTask = job.Tasks.AddNew(
                    MediaServicesHelper.ThumbnailTask,
                    processor,
                    MediaServicesHelper.ThumbnailPreset,
                    TaskOptions.None);

                thumbnailTask.InputAssets.Add(asset);
                var thumbnailAsset = thumbnailTask.OutputAssets.AddNew(asset.Name + " - [thumbnail]", true, AssetCreationOptions.None);
                thumbnailAsset.AlternateId = asset.AlternateId + "_1";
            }
            
            job.Submit();

            return job.Id;
        }
开发者ID:NewforceComputerTechnologies,项目名称:MicrosoftAzureTrainingKit,代码行数:34,代码来源:MediaServicesHelper.cs


示例17: ExportAssetToAzureStorage

        public ExportAssetToAzureStorage(CloudMediaContext contextUploadArg, string MediaServicesStorageAccountKeyArg, IAsset sourceAsset, string StorageSuffix)
        {
            InitializeComponent();
            this.Icon = Bitmaps.Azure_Explorer_ico;
            MediaServicesStorageAccountKey = MediaServicesStorageAccountKeyArg;
            contextUpload = contextUploadArg;

            // list asset files ///////////////////////
            bool bfileinasset = (sourceAsset.AssetFiles.Count() == 0) ? false : true;
            listViewAssetFiles.Items.Clear();
            if (bfileinasset)
            {
                listViewAssetFiles.BeginUpdate();
                foreach (IAssetFile file in sourceAsset.AssetFiles)
                {
                    ListViewItem item = new ListViewItem(file.Name, 0);
                    if (file.IsPrimary) item.ForeColor = Color.Blue;
                    item.SubItems.Add(file.LastModified.ToLocalTime().ToString("G"));
                    item.SubItems.Add(AssetInfo.FormatByteSize(file.ContentFileSize));
                    (listViewAssetFiles.Items.Add(item)).Selected = true;
                    listassetfiles.Add(file);
                }

                listViewAssetFiles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                listViewAssetFiles.EndUpdate();

            }
            myStorageSuffix = StorageSuffix;
        }
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:29,代码来源:ExportAssetToAzureStorage.cs


示例18: LoadAsset

		private IEnumerator LoadAsset(IAsset asset)
		{
			if (!asset.Loaded)
			{
				ResourceRequest request = Resources.LoadAsync(PathPrefix != null ? PathPrefix + "/" + asset.Path : asset.Path);

				Requests[asset] = request;

				yield return request;

				if (request.asset != null)
				{
					asset.Resource = Instantiate(request.asset);

					if (asset.Resource is GameObject)
					{
						((GameObject)(asset.Resource)).transform.SetParent(AssetPool.transform, false);
					}

					asset.Loaded = true;
				}
				else
				{
					Debug.LogError("Failed to load asset! Could not find: " + asset.Path);
				}
			}
		}
开发者ID:Synestry,项目名称:Unity-Framework,代码行数:27,代码来源:AssetLoader.cs


示例19: SendAsset

        void SendAsset(Bundle bundle, IAsset asset)
        {
            response.ContentType = bundle.ContentType;

            var actualETag = "\"" + asset.Hash.ToHexString() + "\"";
            if(request.RawUrl.Contains(asset.Hash.ToHexString())) {
                HttpResponseUtil.CacheLongTime(response, actualETag);
            }
            else {
                HttpResponseUtil.NoCache(response);
            }

            var givenETag = request.Headers["If-None-Match"];
            if (givenETag == actualETag)
            {
                HttpResponseUtil.SendNotModified(response);
            }
            else
            {
                HttpResponseUtil.EncodeStreamAndAppendResponseHeaders(request, response);

                using (var stream = asset.OpenStream())
                {
                    stream.CopyTo(response.OutputStream);
                }
            }
        }
开发者ID:jlopresti,项目名称:cassette,代码行数:27,代码来源:AssetRequestHandler.cs


示例20: Transform

        public Func<Stream> Transform(Func<Stream> openSourceStream, IAsset asset)
        {
            return delegate
            {
                using (var input = new StreamReader(openSourceStream()))
                {
                    var stream = new MemoryStream();
                    var writer = new StreamWriter(stream);

                    var regex = new Regex("__R\\([\"']{1}.*?[\"']{1}\\)", RegexOptions.Compiled);
                    var script = regex.Replace(input.ReadToEnd(), delegate(Match match)
                    {
                        var resource = match.Value
                            .Remove(match.Value.LastIndexOf(")"), 1)
                            .Replace("__R", "$.localize");

                        resource = string.Format("{0}, \"{1}\")", resource, _path);

                        return Path.GetExtension(_path) == ".htm" ? "${" + resource + "}" : resource;
                    });

                    writer.Write(script);
                    writer.Flush();
                    stream.Position = 0;

                    return stream;
                }
            };
        }
开发者ID:rpanday,项目名称:Localization,代码行数:29,代码来源:LocalizationResourceTransformer.cs



注:本文中的IAsset类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IAssetManager类代码示例发布时间:2022-05-24
下一篇:
C# IAssert类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap