本文整理汇总了C#中IAsset类的典型用法代码示例。如果您正苦于以下问题:C# IAsset类的具体用法?C# IAsset怎么用?C# IAsset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAsset类属于命名空间,在下文中一共展示了IAsset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
});
}
示例2: PlainScript
public PlainScript(IAsset asset, Bundle bundle, IAmdConfiguration modules)
: base(asset, bundle)
{
this.modules = modules;
jsonSerializer = new SimpleJsonSerializer();
asset.AddAssetTransformer(this);
}
示例3: AddRawFileReferenceForEachImportedFile
void AddRawFileReferenceForEachImportedFile(IAsset asset, CompileResult compileResult)
{
foreach (var importedFilePath in compileResult.ImportedFilePaths)
{
asset.AddRawFileReference(importedFilePath);
}
}
示例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++;
}
}
示例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));
}
示例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();
};
}
示例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));
};
}
示例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);
}
示例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 });
}
示例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();
}
示例11: ParseJavaScriptForModuleDefinition
static ModuleDefinitionParser ParseJavaScriptForModuleDefinition(IAsset asset)
{
var tree = ParseJavaScript(asset);
var moduleDefinitionParser = new ModuleDefinitionParser();
tree.Accept(moduleDefinitionParser);
return moduleDefinitionParser;
}
示例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;
}
示例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);
}
示例15: NamedModule
public NamedModule(IAsset asset, Bundle bundle, string modulePath)
: base(asset, bundle)
{
if (modulePath == null) throw new ArgumentNullException("modulePath");
ModulePath = modulePath;
}