本文整理汇总了C#中IResource类的典型用法代码示例。如果您正苦于以下问题:C# IResource类的具体用法?C# IResource怎么用?C# IResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResource类属于命名空间,在下文中一共展示了IResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProfilingDialog
/// <summary>
/// Initializes a new instance of the ProfilingDialog class
/// </summary>
/// <param name="item"></param>
/// <param name="resourceId"></param>
/// <param name="connection"></param>
public ProfilingDialog(IResource item, string resourceId, IServerConnection connection)
: this()
{
m_connection = connection;
m_item = item;
m_resourceId = resourceId;
}
示例2: Location
/// <summary>
/// Initializes a new instance of the Location class.
/// </summary>
/// <param name="resource"></param>
/// <param name="source"></param>
public Location(IResource resource, object source)
{
//TODO: look into re-enabling this since resource *is* NULL when parsing config classes vs. acquiring IResources
//AssertUtils.ArgumentNotNull(resource, "resource");
this.resource = resource;
this.source = source;
}
示例3: EncodedResource
/// <summary>
/// Create an encoded resource using the specified encoding.
/// </summary>
/// <param name="resource">the resource to read from. Must not be <c>null</c></param>
/// <param name="encoding">the encoding to use. If <c>null</c>, encoding will be autodetected.</param>
/// <param name="autoDetectEncoding">whether to autoDetect encoding from byte-order marks (<see cref="StreamReader(Stream, Encoding, bool)"/>)</param>
public EncodedResource(IResource resource, Encoding encoding, bool autoDetectEncoding)
{
AssertUtils.ArgumentNotNull(resource, "resource");
this.resource = resource;
this.encoding = encoding;
this.autoDetectEncoding = autoDetectEncoding;
}
示例4: Validate
/// <summary>
/// Validats the specified resources for common issues associated with this
/// resource type
/// </summary>
/// <param name="context"></param>
/// <param name="resource"></param>
/// <param name="recurse"></param>
/// <returns></returns>
public virtual ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
{
if (!resource.GetResourceTypeDescriptor().Equals(this.SupportedResourceAndVersion))
return null;
return ValidateBase(context, resource, recurse);
}
示例5: AbstractInterpreter
/// <summary>
/// Initializes a new instance of the <see cref="AbstractInterpreter"/> class
/// from an The <see cref="IResource"/>.
/// </summary>
/// <param name="source">The <see cref="IResource"/>.</param>
public AbstractInterpreter(IResource source)
{
Contract.Require.That(source, Is.Not.Null).When("retrieving argument IResource in AbstractInterpreter constructor");
resource = source;
}
示例6: GetURLInternal
private string GetURLInternal(IResource resource)
{
IResourceLocation location = resource.Location;
string path;
if (location is TypeLocation)
{
TypeLocation tl = location as TypeLocation;
path = String.Format("{2}/{3}{0}/{1}{4}", HttpUtility.UrlPathEncode(tl.ProxyType.Assembly.GetName().Name), HttpUtility.UrlPathEncode(tl.ProxyType.FullName), AppPath, ResourceHttpHandler.AssemblyPath, ResourceHttpHandler.Extension);
}
else if (location is EmbeddedLocation)
{
EmbeddedLocation el = location as EmbeddedLocation;
path = String.Format("{2}/{3}{0}/{1}{4}", HttpUtility.UrlPathEncode(el.Assembly.GetName().Name), HttpUtility.UrlPathEncode(el.ResourceName), AppPath, ResourceHttpHandler.AssemblyPath, ResourceHttpHandler.Extension);
}
else if (location is VirtualPathLocation)
{
VirtualPathLocation vl = location as VirtualPathLocation;
path = HttpUtility.UrlPathEncode(vl.VirtualPath);
if (resource is IProxyResource) path += ResourceHttpHandler.Extension;
}
else if (location is ExternalLocation)
{
ExternalLocation el = location as ExternalLocation;
return el.Uri.ToString();
}
else
throw new Exception("Unknown IResourceLocationType");
return path + "?" + ToHex(resource.Version);
}
示例7: DecorateClass
public override void DecorateClass(IResource resource,
IMethod request,
CodeTypeDeclaration requestClass,
CodeTypeDeclaration resourceClass)
{
requestClass.Members.Add(CreateRequiredConstructor(resourceClass, request, false));
}
示例8: listViewModels_SelectedIndexChanged
private void listViewModels_SelectedIndexChanged(object sender, EventArgs e)
{
if (listViewModels.SelectedItems.Count > 0)
{
selectedItem = (IResource)listViewModels.SelectedItems[0].Tag;
}
}
示例9: Parse
/// <summary>
/// Parses a script from the specified resource.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="resource">The resource wcich to parse as script.</param>
/// <returns>Returns the parsed script.</returns>
/// <exception cref="ParseScriptException">Thrown when an exception occurres while parsing the script.</exception>
public IExpressionScript Parse(IMansionContext context, IResource resource)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (resource == null)
throw new ArgumentNullException("resource");
// open the script
var cacheKey = ResourceCacheKey.Create(resource);
return cachingService.GetOrAdd(
context,
cacheKey,
() =>
{
// get the phrase
string rawPhrase;
using (var resourceStream = resource.OpenForReading())
using (var reader = resourceStream.Reader)
rawPhrase = reader.ReadToEnd();
// let someone else do the heavy lifting
var phrase = ParsePhrase(context, rawPhrase);
// create the cache object
return new CachedPhrase(phrase);
});
}
示例10: LoadMidi
public bool LoadMidi(IResource midiFile)
{
if (playing == true)
return false;
LoadMidiFile(new MidiFile(midiFile));
return true;
}
示例11: SerializeResourceForStudio
/// <summary>
/// Strips for ship.
/// </summary>
/// <param name="resource">The resource.</param>
/// <returns></returns>
public SerializableResource SerializeResourceForStudio(IResource resource)
{
// convert the fliping errors due to json issues in c# ;(
var errors = new List<ErrorInfo>();
var parseErrors = resource.Errors;
if(parseErrors != null)
{
errors.AddRange(parseErrors.Select(error => (error as ErrorInfo)));
}
var datalist = "<DataList></DataList>";
if(resource.DataList != null)
{
var replace = resource.DataList.Replace("\"", GlobalConstants.SerializableResourceQuote);
datalist = replace.Replace("'", GlobalConstants.SerializableResourceSingleQuote).ToString();
}
return new SerializableResource
{
Inputs = resource.Inputs,
Outputs = resource.Outputs,
ResourceCategory = resource.ResourcePath,
ResourceID = resource.ResourceID,
VersionInfo = resource.VersionInfo,
ResourceName = resource.ResourceName,
Permissions = AuthorizationService.GetResourcePermissions(resource.ResourceID),
ResourceType = resource.ResourceType,
IsValid = resource.IsValid,
DataList = datalist,
Errors = errors,
IsNewResource = resource.IsNewResource
};
}
示例12: ThrowsSecurityExceptionIfUserIsNotLoggedOn
public Spec ThrowsSecurityExceptionIfUserIsNotLoggedOn(string input, IResource output)
{
return
new Spec()
.If(UserIsNotLoggedOn)
.Throws<SecurityException>();
}
示例13: LoadBank
public void LoadBank(IResource bankFile)
{
if (!bankFile.ReadAllowed())
throw new Exception("The bank file provided does not have read access.");
bank.Clear();
assets.PatchAssetList.Clear();
assets.SampleAssetList.Clear();
bankName = string.Empty;
comment = string.Empty;
switch (IOHelper.GetExtension(bankFile.GetName()).ToLower())
{
case ".bank":
bankName = IOHelper.GetFileNameWithoutExtension(bankFile.GetName());
LoadMyBank(bankFile.OpenResourceForRead());
break;
case ".sf2":
bankName = "SoundFont";
LoadSf2(bankFile.OpenResourceForRead());
break;
default:
throw new Exception("Invalid bank resource was provided. An extension must be included in the resource name.");
}
assets.PatchAssetList.TrimExcess();
assets.SampleAssetList.TrimExcess();
}
示例14: DecorateClass
public void DecorateClass(IResource resource,
string className,
CodeTypeDeclaration resourceClass,
ResourceClassGenerator generator,
string serviceClassName,
IEnumerable<IResourceDecorator> allDecorators)
{
var gen = new ResourceGenerator(className, objectTypeProvider, commentCreator);
foreach (var method in resource.Methods.Values)
{
logger.Debug("Adding RequestObject Method {0}.{1}", resource.Name, method.Name);
// Add the default request method to the class:
CodeTypeMember convenienceMethod = gen.CreateMethod(resourceClass, resource, method, false);
if (convenienceMethod != null)
{
resourceClass.Members.Add(convenienceMethod);
}
// Add the request method specifiying all parameters (also optional ones) to the class:
if (AddOptionalParameters && method.HasOptionalParameters())
{
convenienceMethod = gen.CreateMethod(resourceClass, resource, method, true);
if (convenienceMethod != null)
{
resourceClass.Members.Add(convenienceMethod);
}
}
}
}
示例15: ConvertRecursively
private static void ConvertRecursively(IResource currentResource, JObject node, JsonSerializer serializer)
{
if (currentResource == null)
{
return;
}
var currentResourceType = currentResource.GetType();
var readableProperties = GetReadablePropertyInfos(currentResourceType);
var nonResourceProperties = readableProperties.Where(IsNeitherResourceOrReservedProperty).ToList();
var resourceProperties = readableProperties.Where(IsResourceProperty).ToList();
node.Add(ReservedPropertyNames.Relations, JObject.FromObject(currentResource.Relations, serializer));
var embeddedResourceObject = new JObject();
node.Add(ReservedPropertyNames.EmbeddedResources, embeddedResourceObject);
foreach (var resourceProperty in resourceProperties)
{
var embeddedResourceNodeValue = new JObject();
ConvertRecursively((IResource)resourceProperty.GetValue(currentResource), embeddedResourceNodeValue, serializer);
embeddedResourceObject.Add(ToCamelCase(resourceProperty.Name), embeddedResourceNodeValue);
}
if (IsCollectionResourceType(currentResourceType))
{
var currentResourceDynamic = (dynamic) currentResource;
var jArray = new JArray();
string name = "";
foreach (IResource resourceItem in currentResourceDynamic.Items)
{
var embeddedResourceNodeValue = new JObject();
ConvertRecursively(resourceItem, embeddedResourceNodeValue, serializer);
jArray.Add(embeddedResourceNodeValue);
name = resourceItem.GetType().Name;
}
// Remove the "Resource" by convention.
if (name.EndsWith("Resource"))
{
name = name.Remove(name.LastIndexOf("Resource", StringComparison.Ordinal));
}
embeddedResourceObject.Add(ToCamelCase(name), jArray);
}
foreach (var nonResourceProperty in nonResourceProperties)
{
var value = nonResourceProperty.GetValue(currentResource);
if (value != null && value.GetType().GetTypeInfo().IsClass && value.GetType() != typeof(string))
{
node.Add(ToCamelCase(nonResourceProperty.Name), JToken.FromObject(value, serializer));
}
else
{
node.Add(ToCamelCase(nonResourceProperty.Name), new JValue(value));
}
}
}