public void Mutation() { var name = new ResourceName(s_template, "foo", "bar") { ServiceName = "svc" }; Assert.Equal("//svc/buckets/foo/objects/bar", name.ToString()); name["bucket"] = "baz"; Assert.Equal("//svc/buckets/baz/objects/bar", name.ToString()); }
public ObjectClass(string name) { _uid = Guid.NewGuid(); _name = new ResourceName(this, name); _origin = Point.Zero; _propertyManager = new PropertyManager(_propertyClassManager, this); _propertyManager.CustomProperties.Modified += (s, e) => OnModified(EventArgs.Empty); }
public ObjectClass(string name) { _uid = Guid.NewGuid(); _name = new ResourceName(this, name); _origin = Point.Zero; _properties = new PropertyCollection(_reservedPropertyNames); _predefinedProperties = new ObjectClass.ObjectClassProperties(this); _properties.Modified += (s, e) => OnModified(EventArgs.Empty); }
public void Clone() { var name = new ResourceName(s_template, "foo", "bar") { ServiceName = "svc" }; var clone = name.Clone(); Assert.Equal("//svc/buckets/foo/objects/bar", name.ToString()); clone["bucket"] = "baz"; clone.ServiceName = null; // Original is untouched Assert.Equal("//svc/buckets/foo/objects/bar", name.ToString()); // Modifications affect the clone Assert.Equal("buckets/baz/objects/bar", clone.ToString()); }
void CanConstruct() { ResourceName resourceName; resourceName = new ResourceName("fu", "man", "chu"); Assert.Equal("fu/man/chu", resourceName.ToString()); resourceName = new ResourceName(resourceName, "too"); Assert.Equal("fu/man/chu/too", resourceName.ToString()); Assert.Throws(typeof(ArgumentNullException), () => new ResourceName("fu", null)); Assert.Throws(typeof(ArgumentNullException), () => new ResourceName(resourceName, "fu", null, "chu")); Assert.Throws(typeof(ArgumentNullException), () => new ResourceName((ResourceName)null, "fu", "man", "chu")); }
private Level (Guid uid, string name) { _uid = uid; _name = new ResourceName(this, name); _layers = new OrderedResourceCollection<Layer>(); _layers.ResourceAdded += (s, e) => OnLayerAdded(new ResourceEventArgs<Layer>(e.Resource)); _layers.ResourceRemoved += (s, e) => OnLayerRemoved(new ResourceEventArgs<Layer>(e.Resource)); _layers.ResourceModified += (s, e) => OnModified(EventArgs.Empty); _properties = new PropertyCollection(_reservedPropertyNames); _properties.Modified += (s, e) => OnModified(EventArgs.Empty); _predefinedProperties = new LevelProperties(this); }
void CanCompare() { var resourceNames = new ResourceName[] { new ResourceName("1", "2", "3"), new ResourceName("1", "2", "4"), new ResourceName("1", "3", "3"), new ResourceName("2", "2", "3"), new ResourceName("4", "5", "6"), new ResourceName("1", "2", "3", "4"), new ResourceName("1", "2") }; Assert.True(resourceNames[0].Equals((object)resourceNames[0])); Assert.True(resourceNames[0].Equals(resourceNames[0])); Assert.False(resourceNames[0].Equals(resourceNames[1])); Assert.False(resourceNames[0].Equals(resourceNames[2])); Assert.False(resourceNames[0].Equals(resourceNames[3])); Assert.False(resourceNames[0].Equals(resourceNames[4])); Assert.False(resourceNames[0].Equals(resourceNames[5])); Assert.False(resourceNames[0].Equals(resourceNames[6])); Assert.True(resourceNames[0].CompareTo((object)resourceNames[0]) == 0); Assert.True(resourceNames[0].CompareTo(resourceNames[0]) == 0); Assert.True(resourceNames[0].CompareTo(resourceNames[1]) < 0); Assert.True(resourceNames[0].CompareTo(resourceNames[2]) < 0); Assert.True(resourceNames[0].CompareTo(resourceNames[3]) < 0); Assert.True(resourceNames[0].CompareTo(resourceNames[4]) < 0); Assert.True(resourceNames[0].CompareTo(resourceNames[5]) < 0); Assert.True(resourceNames[6].CompareTo(resourceNames[0]) < 0); Assert.True(resourceNames[1].CompareTo(resourceNames[0]) > 0); Assert.True(resourceNames[2].CompareTo(resourceNames[0]) > 0); Assert.True(resourceNames[3].CompareTo(resourceNames[0]) > 0); Assert.True(resourceNames[4].CompareTo(resourceNames[0]) > 0); Assert.True(resourceNames[5].CompareTo(resourceNames[0]) > 0); Assert.True(resourceNames[0].CompareTo(resourceNames[6]) > 0); Assert.True(resourceNames[0].CompareTo((ResourceName)null) > 0); Assert.True(resourceNames[0].CompareTo(new object()) > 0); Assert.True(resourceNames[0].CompareTo(null) > 0); }
/// <summary> /// Sends a PUT request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Trulioo services namespace. /// </param> /// <param name="resource"> /// An object identifying a resource. /// </param> /// <param name="content"> /// An object identifying the HTTP content. /// </param> /// <returns> /// The response to the PUT request. /// </returns> internal async Task <TReturn> PutAsync <TReturn>(Namespace ns, ResourceName resource, dynamic content = null) { var response = await sendAsync <TReturn>(HttpMethod.Put, ns, resource, content).ConfigureAwait(false); return(response); }
private byte[] GetResourceData(IntPtr hModule, ResourceName name, int lpType) { try { IntPtr lpName = name.GetValue(); return GetResourceData(hModule, lpName, lpType); } finally { name.Free(); } }
/// <summary> /// Sends a GET request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Splunk services namespace. /// </param> /// <param name="resourceName"> /// /// </param> /// <param name="token"> /// /// </param> /// <param name="argumentSets"> /// /// </param> /// <returns> /// The response to the GET request. /// </returns> public virtual async Task<Response> GetAsync(Namespace ns, ResourceName resourceName, CancellationToken token, params IEnumerable<Argument>[] argumentSets) { var response = await this.SendAsync(HttpMethod.Get, ns, resourceName, null, token, argumentSets); return response; }
async Task<Response> SendAsync(HttpMethod method, Namespace ns, ResourceName resource, HttpContent content, CancellationToken cancellationToken, IEnumerable<Argument>[] argumentSets) { Contract.Requires<ArgumentNullException>(ns != null); Contract.Requires<ArgumentNullException>(resource != null); var serviceUri = this.CreateServiceUri(ns, resource, argumentSets); using (var request = new HttpRequestMessage(method, serviceUri) { Content = content }) { if (this.SessionKey != null) { request.Headers.Add("Authorization", string.Concat("Splunk ", this.SessionKey)); } var message = await this.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); var response = await Response.CreateAsync(message); return response; } }
/// <summary> /// Sends a GET request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Trulioo services namespace. /// </param> /// <param name="resource"> /// An object identifying a resource. /// </param> /// <returns> /// The response to the GET request. /// </returns> internal async Task <TReturn> GetAsync <TReturn>(Namespace ns, ResourceName resource) { var response = await sendAsync <TReturn>(HttpMethod.Get, ns, resource).ConfigureAwait(false); return(response); }
/// <summary> /// Sends a GET request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Splunk services namespace. /// </param> /// <param name="resource"> /// An object identifiying a Splunk resource in the context of <paramref name="ns"/>. /// </param> /// <param name="token"> /// /// </param> /// <param name="argumentSets"> /// /// </param> /// <returns> /// The response to the GET request. /// </returns> public virtual async Task<HttpResponseMessage> GetHttpResponseMessageAsync(Namespace ns, ResourceName resource, CancellationToken token, params IEnumerable<Argument>[] argumentSets) { var message = await this.SendAsync(HttpMethod.Get, ns, resource, null, token, argumentSets).ConfigureAwait(false); return message; }
public static Uri ToPutUri(this ResourceSet set, ResourceName name) { return(ToPutUri(set.ToString(), name.ToString())); }
/// <summary> /// 增加资源更新。 /// </summary> /// <param name="resourceName">资源名称。</param> /// <param name="loadType">资源加载方式。</param> /// <param name="length">资源大小。</param> /// <param name="hashCode">资源哈希值。</param> /// <param name="zipLength">压缩后大小。</param> /// <param name="zipHashCode">压缩后哈希值。</param> /// <param name="resourcePath">资源路径。</param> public void AddResourceUpdate(ResourceName resourceName, LoadType loadType, int length, int hashCode, int zipLength, int zipHashCode, string resourcePath) { m_UpdateCandidateInfo.Add(new UpdateInfo(resourceName, loadType, length, hashCode, zipLength, zipHashCode, resourcePath)); }
public override void Reload() { UnderlyingClear(); if (_stream != null) { _stream.Close(); // consequtive calls to .Close() is safe } _stream = new FileStream(FileInfo.FullName, FileMode.Open); if (!_stream.CanSeek) { throw new AnolisException("RES FileStream must support seeking"); } _resources.Clear(); // the RES format is quite simple, it's just a concatenated list of Resource Data instances, all with their header info _stream.Seek(0, SeekOrigin.Begin); BinaryReader rdr = new BinaryReader(_stream, System.Text.Encoding.Unicode); while (rdr.BaseStream.Position < rdr.BaseStream.Length) { /////////////////////////////// // Read the RESOURCEHEADER Int64 start = rdr.BaseStream.Position; ResResourceHeader header = new ResResourceHeader(rdr); if (header.DataSize == 0 && rdr.BaseStream.Position == rdr.BaseStream.Length) { break; } Int64 stop = rdr.BaseStream.Position; Int32 headerSize = (int)(stop - start); ResResource res = new ResResource(); res.DataOffset = rdr.BaseStream.Position; res.DataLength = (int)header.DataSize; // HACK: this might cause problems for resources larger than 2GB res.HeaderOffset = start; res.HeaderLength = header.HeaderSize; // Read past the Resource data _stream.Seek(header.DataSize, SeekOrigin.Current); // don't do anything if it's empty if (!(header.Type is String)) { Int32 headerType = Convert.ToInt32(header.Type, Cult.InvariantCulture); if (headerType == 0) { rdr.Align4(); continue; } } /////////////////////////////// // Create ResourceType, Name, and Lang instance ResourceTypeIdentifier typeId = header.Type is String ? new ResourceTypeIdentifier((String)header.Type) : new ResourceTypeIdentifier(Convert.ToInt32(header.Type, Cult.InvariantCulture)); ResourceType type = UnderlyingFind(t => t.Identifier.Equals(typeId)); if (type == null) { type = new ResourceType(typeId, this); UnderlyingAdd(type); } /////////////////////////////////////////////////////////// ResourceIdentifier nameId = header.Name is String ? new ResourceIdentifier((String)header.Name) : new ResourceIdentifier(Convert.ToInt32(header.Name, Cult.InvariantCulture)); ResourceName name = UnderlyingFind(type, n => n.Identifier.Equals(nameId)); if (name == null) { name = new ResourceName(nameId, type); UnderlyingAdd(type, name); } /////////////////////////////////////////////////////////// // TODO: Maybe do some validation to ensure the same lang hasn't been added twice? ResourceLang lang = new ResourceLang(header.LanguageId, name); UnderlyingAdd(name, lang); /////////////////////////////////////////////////////////// res.Lang = lang; _resources.Add(res); rdr.Align4(); } }
/// <summary> /// Checks resource name validity /// </summary> /// <remarks> /// A resource name is valid if it is not a reserved word, does not contains a /// reserved word and does not start with a reserved word /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceNameDefinition'> /// Resource object with values for resource name and resource type /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <CheckResourceNameResult> CheckResourceNameAsync(this ISubscriptionClient operations, ResourceName resourceNameDefinition = default(ResourceName), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CheckResourceNameWithHttpMessagesAsync(resourceNameDefinition, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Checks resource name validity /// </summary> /// <remarks> /// A resource name is valid if it is not a reserved word, does not contains a /// reserved word and does not start with a reserved word /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceNameDefinition'> /// Resource object with values for resource name and resource type /// </param> public static CheckResourceNameResult CheckResourceName(this ISubscriptionClient operations, ResourceName resourceNameDefinition = default(ResourceName)) { return(operations.CheckResourceNameAsync(resourceNameDefinition).GetAwaiter().GetResult()); }
internal JobCollection(Context context, Namespace @namespace, ResourceName resourceName) : base(context, @namespace, resourceName) { }
private async Task <TReturn> sendAsync <TReturn>(HttpMethod httpMethod, Namespace ns, ResourceName resource, dynamic content = null) { var response = await sendInternalAsync(httpMethod, ns, resource, content).ConfigureAwait(false); var message = typeof(TReturn) == typeof(string) ? await response.Content.ReadAsStringAsync().ConfigureAwait(false) : JsonConvert.DeserializeObject <TReturn>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)); return(message); }
/// <summary> /// Ends the session by associated with the current instance. /// </summary> /// <remarks> /// This method uses the <a href="http://goo.gl/hdNhwA">DELETE /// authentication/httpauth-tokens/{name}</a> endpoint to end the /// the session by removing <see cref="SessionKey"/>. /// </remarks> public async Task LogoffAsync() { Contract.Requires<InvalidOperationException>(this.SessionKey != null); var resourceName = new ResourceName(AuthenticationHttpAuthTokens, this.SessionKey); using (var response = await this.Context.DeleteAsync(Namespace.Default, resourceName)) { await response.EnsureStatusCodeAsync(HttpStatusCode.OK); this.SessionKey = null; } }
private async Task <HttpResponseMessage> sendInternalAsync(HttpMethod httpMethod, Namespace ns, ResourceName resource, dynamic content = null) { var serviceUri = createServiceUri(ns, resource); var stringContent = getStringContent(content); using (var request = new HttpRequestMessage(httpMethod, serviceUri) { Content = stringContent }) { request.Headers.Add("Authorization", $"Basic {_credentials}"); var response = await HttpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead, CancellationToken.None).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { await throwRequestExceptionAsync(response).ConfigureAwait(false); } return(response); } }
async Task<Response> GetResponseAsync(HttpMethod method, Namespace ns, ResourceName resource, HttpContent content, CancellationToken cancellationToken, IEnumerable<Argument>[] argumentSets) { var message = await this.SendAsync(method, ns, resource, content, cancellationToken, argumentSets); var response = await Response.CreateAsync(message).ConfigureAwait(false); // If a Set-Cookie Header is received, parse it and add/update the cookie store if (response.Message.Headers.Contains("Set-Cookie")) { foreach (string setCookieString in response.Message.Headers.GetValues("Set-Cookie")) { this.CookieJar.AddCookie(setCookieString); } } return response; }
public int QueryModified(ulong address, ulong size, ResourceName name, (ulong, ulong)[] modifiedRanges = null)
/// <summary> /// Sends a POST request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Splunk services namespace. /// </param> /// <param name="resource"> /// /// </param> /// <param name="content"> /// /// </param> /// <param name="argumentSets"> /// /// </param> /// <returns> /// The response to the GET request. /// </returns> public virtual async Task<Response> PostAsync(Namespace ns, ResourceName resource, HttpContent content, params IEnumerable<Argument>[] argumentSets) { var token = CancellationToken.None; var response = await this.SendAsync(HttpMethod.Post, ns, resource, content, token, argumentSets); return response; }
public override int GetHashCode() { int hash = 1; if (ResourceName.Length != 0) { hash ^= ResourceName.GetHashCode(); } if (id_ != null) { hash ^= Id.GetHashCode(); } if (name_ != null) { hash ^= Name.GetHashCode(); } if (Status != global::Google.Ads.GoogleAds.V2.Enums.BiddingStrategyStatusEnum.Types.BiddingStrategyStatus.Unspecified) { hash ^= Status.GetHashCode(); } if (Type != global::Google.Ads.GoogleAds.V2.Enums.BiddingStrategyTypeEnum.Types.BiddingStrategyType.Unspecified) { hash ^= Type.GetHashCode(); } if (campaignCount_ != null) { hash ^= CampaignCount.GetHashCode(); } if (nonRemovedCampaignCount_ != null) { hash ^= NonRemovedCampaignCount.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.EnhancedCpc) { hash ^= EnhancedCpc.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.PageOnePromoted) { hash ^= PageOnePromoted.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.TargetCpa) { hash ^= TargetCpa.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.TargetImpressionShare) { hash ^= TargetImpressionShare.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.TargetOutrankShare) { hash ^= TargetOutrankShare.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.TargetRoas) { hash ^= TargetRoas.GetHashCode(); } if (schemeCase_ == SchemeOneofCase.TargetSpend) { hash ^= TargetSpend.GetHashCode(); } hash ^= (int)schemeCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Constructor /// </summary> /// <param name="reader">Raw data. This instance owns this reader.</param> /// <param name="name">Name</param> public ResourceData(ResourceName name, IBinaryReader reader) : base(name) { this.reader = reader; }
/// <summary> /// 增加资源更新。 /// </summary> /// <param name="resourceName">资源名称。</param> /// <param name="fileSystemName">资源所在的文件系统名称。</param> /// <param name="loadType">资源加载方式。</param> /// <param name="length">资源大小。</param> /// <param name="hashCode">资源哈希值。</param> /// <param name="compressedLength">压缩后大小。</param> /// <param name="compressedHashCode">压缩后哈希值。</param> /// <param name="resourcePath">资源路径。</param> public void AddResourceUpdate(ResourceName resourceName, string fileSystemName, LoadType loadType, int length, int hashCode, int compressedLength, int compressedHashCode, string resourcePath) { m_UpdateCandidateInfo.Add(resourceName, new UpdateInfo(resourceName, fileSystemName, loadType, length, hashCode, compressedLength, compressedHashCode, resourcePath)); }
/// <summary> /// Finds a <see cref="ResourceDirectory"/> /// </summary> /// <param name="type">Type</param> /// <param name="name">Name</param> /// <returns>The <see cref="ResourceDirectory"/> or <c>null</c> if none found</returns> public ResourceDirectory Find(ResourceName type, ResourceName name) { var dir = Find(type); if (dir == null) return null; return dir.FindDirectory(name); }
private void OnCheckerResourceNeedUpdate(ResourceName resourceName, LoadType loadType, int length, int hashCode, int zipLength, int zipHashCode) { m_ResourceUpdater.AddResourceUpdate(resourceName, loadType, length, hashCode, zipLength, zipHashCode, Utility.Path.GetCombinePath(m_ReadWritePath, Utility.Path.GetResourceNameWithSuffix(resourceName.FullName)), Utility.Path.GetRemotePath(m_UpdatePrefixUri, Utility.Path.GetResourceNameWithCrc32AndSuffix(resourceName.FullName, hashCode)), 0); }
/// <summary> /// Sends a GET request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Trulioo services namespace. /// </param> /// <param name="resource"> /// An object identifying a resource. /// </param> /// <returns> /// The response to the GET request. /// </returns> internal async Task <TReturn> GetAsync <TReturn>(Namespace ns, ResourceName resource, Func <HttpResponseMessage, TReturn> processResponse = null) { var response = await sendAsync <TReturn>(HttpMethod.Get, ns, resource, processResponse : processResponse).ConfigureAwait(false); return(response); }
/// <summary> /// Constructor /// </summary> /// <param name="depth">Starts from 0. If it's big enough, we'll stop reading more data.</param> /// <param name="name">Name</param> /// <param name="resources">Resources</param> /// <param name="reader">Reader positioned at the start of this resource directory</param> public ResourceDirectoryPE(uint depth, ResourceName name, Win32ResourcesPE resources, IBinaryReader reader) : base(name) { this.resources = resources; this.depth = depth; Initialize(reader); }
/// <summary> /// Sends a DELETE request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Trulioo services namespace. /// </param> /// <param name="resource"> /// An object identifying a resource. /// </param> /// <param name="content"> /// An object identifying the HTTP content. /// </param> /// <returns> /// The response to the DELETE request. /// </returns> internal async Task DeleteAsync(Namespace ns, ResourceName resource, dynamic content = null) { await sendAsync(HttpMethod.Delete, ns, resource, content).ConfigureAwait(false); }
/// <summary> /// /// </summary> /// <param name="namespace"> /// </param> /// <param name="resource"> /// </param> /// <param name="argumentSets"> /// </param> /// <returns></returns> public async Task<Response> GetAsync(Namespace @namespace, ResourceName resource, params IEnumerable<Argument>[] argumentSets) { var token = CancellationToken.None; var response = await this.SendAsync(HttpMethod.Get, @namespace, resource, null, token, argumentSets); return response; }
/// <summary> /// 应用指定资源包的资源。 /// </summary> /// <param name="resourcePackPath">要应用的资源包路径。</param> public void ApplyResources(string resourcePackPath) { if (!m_CheckResourcesComplete) { throw new GameFrameworkException("You must check resources complete first."); } if (m_ApplyingResourcePackStream != null) { throw new GameFrameworkException(Utility.Text.Format("There is already a resource pack '{0}' being applied.", m_ApplyingResourcePackPath)); } if (m_UpdatingResourceGroup != null) { throw new GameFrameworkException(Utility.Text.Format("There is already a resource group '{0}' being updated.", m_UpdatingResourceGroup.Name)); } try { long length = 0L; ResourcePackVersionList versionList = default(ResourcePackVersionList); using (FileStream fileStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read)) { length = fileStream.Length; versionList = m_ResourceManager.m_ResourcePackVersionListSerializer.Deserialize(fileStream); } if (!versionList.IsValid) { throw new GameFrameworkException("Deserialize resource pack version list failure."); } if (versionList.Offset + versionList.Length != length) { throw new GameFrameworkException("Resource pack length is invalid."); } m_ApplyingResourcePackPath = resourcePackPath; m_ApplyingResourcePackStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read); m_ApplyingResourcePackStream.Position = versionList.Offset; m_FailureFlag = false; ResourcePackVersionList.Resource[] resources = versionList.GetResources(); foreach (ResourcePackVersionList.Resource resource in resources) { ResourceName resourceName = new ResourceName(resource.Name, resource.Variant, resource.Extension); UpdateInfo updateInfo = null; if (!m_UpdateCandidateInfo.TryGetValue(resourceName, out updateInfo)) { continue; } if (updateInfo.LoadType == (LoadType)resource.LoadType && updateInfo.Length == resource.Length && updateInfo.HashCode == resource.HashCode) { m_ApplyWaitingInfo.Add(new ApplyInfo(resourceName, updateInfo.FileSystemName, (LoadType)resource.LoadType, resource.Offset, resource.Length, resource.HashCode, resource.CompressedLength, resource.CompressedHashCode, updateInfo.ResourcePath)); } } } catch (Exception exception) { if (m_ApplyingResourcePackStream != null) { m_ApplyingResourcePackStream.Dispose(); m_ApplyingResourcePackStream = null; } throw new GameFrameworkException(Utility.Text.Format("Apply resources '{0}' with exception '{1}'.", resourcePackPath, exception.ToString()), exception); } }
public override int GetHashCode() { int hash = 1; if (ResourceName.Length != 0) { hash ^= ResourceName.GetHashCode(); } if (id_ != null) { hash ^= Id.GetHashCode(); } if (name_ != null) { hash ^= Name.GetHashCode(); } if (amountMicros_ != null) { hash ^= AmountMicros.GetHashCode(); } if (totalAmountMicros_ != null) { hash ^= TotalAmountMicros.GetHashCode(); } if (Status != 0) { hash ^= Status.GetHashCode(); } if (DeliveryMethod != 0) { hash ^= DeliveryMethod.GetHashCode(); } if (explicitlyShared_ != null) { hash ^= ExplicitlyShared.GetHashCode(); } if (referenceCount_ != null) { hash ^= ReferenceCount.GetHashCode(); } if (hasRecommendedBudget_ != null) { hash ^= HasRecommendedBudget.GetHashCode(); } if (recommendedBudgetAmountMicros_ != null) { hash ^= RecommendedBudgetAmountMicros.GetHashCode(); } if (Period != 0) { hash ^= Period.GetHashCode(); } if (recommendedBudgetEstimatedChangeWeeklyClicks_ != null) { hash ^= RecommendedBudgetEstimatedChangeWeeklyClicks.GetHashCode(); } if (recommendedBudgetEstimatedChangeWeeklyCostMicros_ != null) { hash ^= RecommendedBudgetEstimatedChangeWeeklyCostMicros.GetHashCode(); } if (recommendedBudgetEstimatedChangeWeeklyInteractions_ != null) { hash ^= RecommendedBudgetEstimatedChangeWeeklyInteractions.GetHashCode(); } if (recommendedBudgetEstimatedChangeWeeklyViews_ != null) { hash ^= RecommendedBudgetEstimatedChangeWeeklyViews.GetHashCode(); } if (Type != 0) { hash ^= Type.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public EntryInfo(ResourceName name, uint offset) { this.name = name; this.offset = offset; }
public static void DeploymentStatus(WatchEventType type, ResourceName name) { Log.LogDebug((int)EventIds.DeploymentStatus, $"Deployment '{name}', status'{type}'"); }
/// <summary> /// Reads the directory header and initializes <see cref="ResourceDirectory.directories"/> and /// <see cref="ResourceDirectory.data"/>. /// </summary> /// <param name="reader"></param> void Initialize(IBinaryReader reader) { if (depth > MAX_DIR_DEPTH || !reader.CanRead(16)) { InitializeDefault(); return; } characteristics = reader.ReadUInt32(); timeDateStamp = reader.ReadUInt32(); majorVersion = reader.ReadUInt16(); minorVersion = reader.ReadUInt16(); ushort numNamed = reader.ReadUInt16(); ushort numIds = reader.ReadUInt16(); int total = numNamed + numIds; if (!reader.CanRead(total * 8)) { InitializeDefault(); return; } dataInfos = new List<EntryInfo>(); dirInfos = new List<EntryInfo>(); long offset = reader.Position; for (int i = 0; i < total; i++, offset += 8) { reader.Position = offset; uint nameOrId = reader.ReadUInt32(); uint dataOrDirectory = reader.ReadUInt32(); ResourceName name; if ((nameOrId & 0x80000000) != 0) name = new ResourceName(ReadString(reader, nameOrId & 0x7FFFFFFF) ?? string.Empty); else name = new ResourceName((int)nameOrId); if ((dataOrDirectory & 0x80000000) == 0) dataInfos.Add(new EntryInfo(name, dataOrDirectory)); else dirInfos.Add(new EntryInfo(name, dataOrDirectory & 0x7FFFFFFF)); } directories = new LazyList<ResourceDirectory>(dirInfos.Count, null, (ctx, i) => ReadResourceDirectory((int)i)); data = new LazyList<ResourceData>(dataInfos.Count, null, (ctx, i) => ReadResourceData((int)i)); }
public static void DeploymentNameMismatch(string received, ResourceName expected) { Log.LogDebug((int)EventIds.DeploymentNameMismatch, $"Watching for edge deployments for '{expected}', received notification for '{received}'"); }
/// <summary> /// /// </summary> /// <param name="namespace"></param> /// <param name="resource"></param> /// <param name="argumentSets"></param> /// <returns></returns> public async Task<Response> PostAsync(Namespace @namespace, ResourceName resource, params IEnumerable<Argument>[] argumentSets) { var content = this.CreateStringContent(argumentSets); var token = CancellationToken.None; var response = await this.SendAsync(HttpMethod.Post, @namespace, resource, content, token, null); return response; }
private void OnLoadUpdatableVersionListSuccess(string fileUri, byte[] bytes, float duration, object userData) { if (m_UpdatableVersionListReady) { throw new GameFrameworkException("Updatable version list has been parsed."); } MemoryStream memoryStream = null; try { memoryStream = new MemoryStream(bytes, false); UpdatableVersionList versionList = m_ResourceManager.m_UpdatableVersionListSerializer.Deserialize(memoryStream); if (!versionList.IsValid) { throw new GameFrameworkException("Deserialize updatable version list failure."); } UpdatableVersionList.Asset[] assets = versionList.GetAssets(); UpdatableVersionList.Resource[] resources = versionList.GetResources(); UpdatableVersionList.FileSystem[] fileSystems = versionList.GetFileSystems(); UpdatableVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups(); m_ResourceManager.m_ApplicableGameVersion = versionList.ApplicableGameVersion; m_ResourceManager.m_InternalResourceVersion = versionList.InternalResourceVersion; m_ResourceManager.m_AssetInfos = new Dictionary <string, AssetInfo>(assets.Length, StringComparer.Ordinal); m_ResourceManager.m_ResourceInfos = new Dictionary <ResourceName, ResourceInfo>(resources.Length, new ResourceNameComparer()); m_ResourceManager.m_ReadWriteResourceInfos = new SortedDictionary <ResourceName, ReadWriteResourceInfo>(new ResourceNameComparer()); ResourceGroup defaultResourceGroup = m_ResourceManager.GetOrAddResourceGroup(string.Empty); foreach (UpdatableVersionList.FileSystem fileSystem in fileSystems) { int[] resourceIndexes = fileSystem.GetResourceIndexes(); foreach (int resourceIndex in resourceIndexes) { UpdatableVersionList.Resource resource = resources[resourceIndex]; if (resource.Variant != null && resource.Variant != m_CurrentVariant) { continue; } SetCachedFileSystemName(new ResourceName(resource.Name, resource.Variant, resource.Extension), fileSystem.Name); } } foreach (UpdatableVersionList.Resource resource in resources) { if (resource.Variant != null && resource.Variant != m_CurrentVariant) { continue; } ResourceName resourceName = new ResourceName(resource.Name, resource.Variant, resource.Extension); int[] assetIndexes = resource.GetAssetIndexes(); foreach (int assetIndex in assetIndexes) { UpdatableVersionList.Asset asset = assets[assetIndex]; int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes(); int index = 0; string[] dependencyAssetNames = new string[dependencyAssetIndexes.Length]; foreach (int dependencyAssetIndex in dependencyAssetIndexes) { dependencyAssetNames[index++] = assets[dependencyAssetIndex].Name; } m_ResourceManager.m_AssetInfos.Add(asset.Name, new AssetInfo(asset.Name, resourceName, dependencyAssetNames)); } SetVersionInfo(resourceName, (LoadType)resource.LoadType, resource.Length, resource.HashCode, resource.CompressedLength, resource.CompressedHashCode); defaultResourceGroup.AddResource(resourceName, resource.Length, resource.CompressedLength); } foreach (UpdatableVersionList.ResourceGroup resourceGroup in resourceGroups) { ResourceGroup group = m_ResourceManager.GetOrAddResourceGroup(resourceGroup.Name); int[] resourceIndexes = resourceGroup.GetResourceIndexes(); foreach (int resourceIndex in resourceIndexes) { UpdatableVersionList.Resource resource = resources[resourceIndex]; if (resource.Variant != null && resource.Variant != m_CurrentVariant) { continue; } group.AddResource(new ResourceName(resource.Name, resource.Variant, resource.Extension), resource.Length, resource.CompressedLength); } } m_UpdatableVersionListReady = true; RefreshCheckInfoStatus(); } catch (Exception exception) { if (exception is GameFrameworkException) { throw; } throw new GameFrameworkException(Utility.Text.Format("Parse updatable version list exception '{0}'.", exception.ToString()), exception); } finally { if (memoryStream != null) { memoryStream.Dispose(); memoryStream = null; } } }
/// <summary> /// Sends a GET request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Splunk services namespace. /// </param> /// <param name="resource"> /// An object identifiying a Splunk resource in the context of <paramref name="ns"/>. /// </param> /// <param name="argumentSets"> /// /// </param> /// <returns> /// The response to the GET request. /// </returns> public virtual async Task<Response> GetAsync(Namespace ns, ResourceName resource, params IEnumerable<Argument>[] argumentSets) { var token = CancellationToken.None; var response = await this.GetResponseAsync(HttpMethod.Get, ns, resource, null, token, argumentSets).ConfigureAwait(false); return response; }
private void SetCachedFileSystemName(ResourceName resourceName, string fileSystemName) { GetOrAddCheckInfo(resourceName).SetCachedFileSystemName(fileSystemName); }
/// <summary> /// Sends a GET, POST, or DELETE request as an asynchronous operation. /// </summary> /// <param name="method"> /// /// </param> /// <param name="ns"> /// An object identifying a Splunk services namespace. /// </param> /// <param name="resource"> /// /// </param> /// <param name="argumentSets"> /// /// </param> /// <returns> /// The response to the GET, POST, or DELETE request. /// </returns> public virtual async Task<Response> SendAsync(HttpMethod method, Namespace ns, ResourceName resource, params IEnumerable<Argument>[] argumentSets) { Contract.Requires<ArgumentNullException>(method != null); Contract.Requires<ArgumentException>(method == HttpMethod.Delete || method == HttpMethod.Get || method == HttpMethod.Post); var token = CancellationToken.None; HttpContent content = null; if (method == HttpMethod.Post) { content = CreateStringContent(argumentSets); argumentSets = null; } var response = await this.GetResponseAsync(method, ns, resource, content, token, argumentSets).ConfigureAwait(false); return response; }
private void SetVersionInfo(ResourceName resourceName, LoadType loadType, int length, int hashCode, int compressedLength, int compressedHashCode) { GetOrAddCheckInfo(resourceName).SetVersionInfo(loadType, length, hashCode, compressedLength, compressedHashCode); }
async Task<HttpResponseMessage> SendAsync(HttpMethod method, Namespace ns, ResourceName resource, HttpContent content, CancellationToken cancellationToken, IEnumerable<Argument>[] argumentSets) { Contract.Requires<ArgumentNullException>(ns != null); Contract.Requires<ArgumentNullException>(resource != null); var serviceUri = this.CreateServiceUri(ns, resource, argumentSets); using (var request = new HttpRequestMessage(method, serviceUri) { Content = content }) { // If the CookieStore has cookies, include them in the Cookie header // Otherwise if there is a SessionKey, include it in the Authorization header if (!this.CookieJar.IsEmpty()) { request.Headers.Add("Cookie", this.CookieJar.GetCookieHeader()); } else if (this.SessionKey != null) { request.Headers.Add("Authorization", string.Concat("Splunk ", this.SessionKey)); } var message = await this.HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); return message; } }
private void SetReadOnlyInfo(ResourceName resourceName, LoadType loadType, int length, int hashCode) { GetOrAddCheckInfo(resourceName).SetReadOnlyInfo(loadType, length, hashCode); }
/// <summary> /// Sends a POST request as an asynchronous operation. /// </summary> /// <param name="ns"> /// An object identifying a Splunk services namespace. /// </param> /// <param name="resource"> /// /// </param> /// <param name="argumentSets"> /// /// </param> /// <returns> /// The response to the GET request. /// </returns> public virtual async Task<Response> PostAsync(Namespace ns, ResourceName resource, params IEnumerable<Argument>[] argumentSets) { var content = CreateStringContent(argumentSets); return await PostAsync(ns, resource, content, null); }
private IEnumerator Start() { while (true) { yield return((object)null); if (playingBGMID != requestBGMID) { changingBGM = true; playingBGMID = requestBGMID; LoadObject lo_bgm = null; if (playingBGMID != 0) { ResourceManager.enableCache = false; lo_bgm = new LoadObject(this, RESOURCE_CATEGORY.SOUND_BGM, ResourceName.GetBGM(requestBGMID), false); ResourceManager.enableCache = true; } if (audioSourceBGM != null && audioSourceBGM.get_isPlaying()) { bool is_play_fadeout = true; EventDelegate.Callback OnFinishedCallBack = delegate { ((_003CStart_003Ec__Iterator240) /*Error near IL_00f3: stateMachine*/)._003Cis_play_fadeout_003E__1 = false; }; TweenVolume fadeout = TweenVolume.Begin(this.get_gameObject(), fadeOutTime, 0f); EventDelegate.Add(fadeout.onFinished, OnFinishedCallBack); while (is_play_fadeout) { audioSourceBGM.set_volume(fadeout.value); yield return((object)null); } EventDelegate.Remove(fadeout.onFinished, OnFinishedCallBack); } if (lo_bgm != null) { if (lo_bgm.isLoading) { yield return((object)lo_bgm.Wait(this)); } if (!(lo_bgm.loadedObject != null)) { int num3 = playingBGMID = (requestBGMID = 0); } else { if (audioSourceBGM == null) { audioSourceBGM = this.get_gameObject().AddComponent <AudioSource>(); } if (audioSourceBGM != null) { audioSourceBGM.set_priority(0); audioSourceBGM.set_reverbZoneMix(0f); audioSourceBGM.set_spread(360f); audioSourceBGM.set_spatialBlend(0f); audioSourceBGM.set_outputAudioMixerGroup(mixerGroupBGM); audioSourceBGM.set_loop(m_IsNextBGMLoop); audioSourceBGM.set_enabled(true); audioSourceBGM.set_clip(lo_bgm.loadedObject as AudioClip); audioSourceBGM.set_volume(volumeBGM); audioSourceBGM.Play(0uL); } } } if (playingBGMID == 0 && audioSourceBGM != null) { audioSourceBGM.Stop(); } changingBGM = false; } } }
Uri CreateServiceUri(Namespace ns, ResourceName name, params IEnumerable<Argument>[] argumentSets) { var builder = new StringBuilder(this.ToString()); builder.Append("/"); builder.Append(ns.ToUriString()); builder.Append("/"); builder.Append(name.ToUriString()); if (argumentSets != null) { var query = string.Join("&", from args in argumentSets where args != null from arg in args select string.Join("=", Uri.EscapeDataString(arg.Name), Uri.EscapeDataString(arg.Value.ToString()))); if (query.Length > 0) { builder.Append('?'); builder.Append(query); } } var uri = UriConverter.Instance.Convert(builder.ToString()); return uri; }
public static AudioClip GetSEAudioClip(int se_id) { return(GetSEAudioClip(ResourceName.GetSE(se_id))); }
/// <summary> /// Constructor /// </summary> /// <param name="name">Name</param> public ResourceData(ResourceName name) : base(name) { }
public static AudioClip GetStoryVoiceAudioClip(int voice_id) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return(MonoBehaviourSingleton <ResourceManager> .I.cache.GetCachedObject(RESOURCE_CATEGORY.SOUND_VOICE, ResourceName.GetStoryVoicePackageNameFromVoiceID(voice_id), ResourceName.GetStoryVoiceName(voice_id))); }
/// <summary> /// Constructor /// </summary> /// <param name="reader">Raw data. This instance owns this reader.</param> /// <param name="name">Name</param> /// <param name="codePage">Code page</param> /// <param name="reserved">Reserved value</param> public ResourceData(ResourceName name, IBinaryReader reader, uint codePage, uint reserved) : base(name) { this.reader = reader; this.codePage = codePage; this.reserved = reserved; }
/// <summary> /// 增加资源更新。 /// </summary> /// <param name="resourceName">资源名称。</param> /// <param name="loadType">资源加载方式。</param> /// <param name="length">资源大小。</param> /// <param name="hashCode">资源哈希值。</param> /// <param name="zipLength">压缩包大小。</param> /// <param name="zipHashCode">压缩包哈希值。</param> /// <param name="downloadPath">下载后存放路径。</param> /// <param name="downloadUri">下载地址。</param> /// <param name="retryCount">已重试次数。</param> public void AddResourceUpdate(ResourceName resourceName, LoadType loadType, int length, int hashCode, int zipLength, int zipHashCode, string downloadPath, string downloadUri, int retryCount) { m_UpdateWaitingInfo.Add(new UpdateInfo(resourceName, loadType, length, hashCode, zipLength, zipHashCode, downloadPath, downloadUri, retryCount)); }
/// <summary> /// Finds a <see cref="ResourceDirectory"/> /// </summary> /// <param name="type">Type</param> /// <returns>The <see cref="ResourceDirectory"/> or <c>null</c> if none found</returns> public ResourceDirectory Find(ResourceName type) { var dir = Root; if (dir == null) return null; return dir.FindDirectory(type); }
/// <summary> /// 解析资源包资源列表。 /// </summary> /// <param name="fileUri">版本资源列表文件路径。</param> /// <param name="bytes">要解析的数据。</param> /// <param name="errorMessage">错误信息。</param> private void ParsePackageList(string fileUri, byte[] bytes, string errorMessage) { if (bytes == null || bytes.Length <= 0) { throw new GameFrameworkException(Utility.Text.Format("Package list '{0}' is invalid, error message is '{1}'.", fileUri, string.IsNullOrEmpty(errorMessage) ? "<Empty>" : errorMessage)); } MemoryStream memoryStream = null; try { memoryStream = new MemoryStream(bytes, false); using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8)) { memoryStream = null; if (binaryReader.ReadChar() != PackageListHeader[0] || binaryReader.ReadChar() != PackageListHeader[1] || binaryReader.ReadChar() != PackageListHeader[2]) { throw new GameFrameworkException("Package list header is invalid."); } byte listVersion = binaryReader.ReadByte(); if (listVersion == 0) { byte[] encryptBytes = binaryReader.ReadBytes(4); m_ResourceManager.m_ApplicableGameVersion = m_ResourceManager.GetEncryptedString(binaryReader, encryptBytes); m_ResourceManager.m_InternalResourceVersion = binaryReader.ReadInt32(); int assetCount = binaryReader.ReadInt32(); m_ResourceManager.m_AssetInfos = new Dictionary <string, AssetInfo>(assetCount); int resourceCount = binaryReader.ReadInt32(); m_ResourceManager.m_ResourceInfos = new Dictionary <ResourceName, ResourceInfo>(resourceCount, new ResourceNameComparer()); ResourceLength[] resourceLengths = new ResourceLength[resourceCount]; for (int i = 0; i < resourceCount; i++) { string name = m_ResourceManager.GetEncryptedString(binaryReader, encryptBytes); string variant = m_ResourceManager.GetEncryptedString(binaryReader, encryptBytes); ResourceName resourceName = new ResourceName(name, variant); LoadType loadType = (LoadType)binaryReader.ReadByte(); int length = binaryReader.ReadInt32(); int hashCode = binaryReader.ReadInt32(); byte[] hashCodeBytes = Utility.Converter.GetBytes(hashCode); resourceLengths[i] = new ResourceLength(resourceName, length, length); int assetNamesCount = binaryReader.ReadInt32(); for (int j = 0; j < assetNamesCount; j++) { string assetName = m_ResourceManager.GetEncryptedString(binaryReader, hashCodeBytes); int dependencyAssetNamesCount = binaryReader.ReadInt32(); string[] dependencyAssetNames = new string[dependencyAssetNamesCount]; for (int k = 0; k < dependencyAssetNamesCount; k++) { dependencyAssetNames[k] = m_ResourceManager.GetEncryptedString(binaryReader, hashCodeBytes); } if (variant == null || variant == m_CurrentVariant) { m_ResourceManager.m_AssetInfos.Add(assetName, new AssetInfo(assetName, resourceName, dependencyAssetNames)); } } if (variant == null || variant == m_CurrentVariant) { ProcessResourceInfo(resourceName, loadType, length, hashCode); } } ResourceGroup defaultResourceGroup = m_ResourceManager.GetOrAddResourceGroup(string.Empty); for (int i = 0; i < resourceCount; i++) { if (resourceLengths[i].ResourceName.Variant == null || resourceLengths[i].ResourceName.Variant == m_CurrentVariant) { defaultResourceGroup.AddResource(resourceLengths[i].ResourceName, resourceLengths[i].Length, resourceLengths[i].ZipLength); } } int resourceGroupCount = binaryReader.ReadInt32(); for (int i = 0; i < resourceGroupCount; i++) { string resourceGroupName = m_ResourceManager.GetEncryptedString(binaryReader, encryptBytes); ResourceGroup resourceGroup = m_ResourceManager.GetOrAddResourceGroup(resourceGroupName); int resourceGroupResourceCount = binaryReader.ReadInt32(); for (int j = 0; j < resourceGroupResourceCount; j++) { ushort index = binaryReader.ReadUInt16(); if (index >= resourceCount) { throw new GameFrameworkException(Utility.Text.Format("Package index '{0}' is invalid, resource count is '{1}'.", index.ToString(), resourceCount.ToString())); } if (resourceLengths[index].ResourceName.Variant == null || resourceLengths[index].ResourceName.Variant == m_CurrentVariant) { resourceGroup.AddResource(resourceLengths[index].ResourceName, resourceLengths[index].Length, resourceLengths[index].ZipLength); } } } } else { throw new GameFrameworkException("Package list version is invalid."); } } ResourceInitComplete(); } catch (Exception exception) { if (exception is GameFrameworkException) { throw; } throw new GameFrameworkException(Utility.Text.Format("Parse package list exception '{0}'.", exception.Message), exception); } finally { if (memoryStream != null) { memoryStream.Dispose(); memoryStream = null; } } }
/// <summary> /// Finds a <see cref="ResourceData"/> /// </summary> /// <param name="type">Type</param> /// <param name="name">Name</param> /// <param name="langId">Language ID</param> /// <returns>The <see cref="ResourceData"/> or <c>null</c> if none found</returns> public ResourceData Find(ResourceName type, ResourceName name, ResourceName langId) { var dir = Find(type, name); if (dir == null) return null; return dir.FindData(langId); }
/// <summary> /// Finds a <see cref="ResourceData"/> /// </summary> /// <param name="self">this</param> /// <param name="type">Type</param> /// <param name="name">Name</param> /// <param name="langId">Language ID</param> /// <returns>The <see cref="ResourceData"/> or <c>null</c> if none found</returns> public static ResourceData FindWin32ResourceData(this IPEImage self, ResourceName type, ResourceName name, ResourceName langId) { var w32Resources = self.Win32Resources; return(w32Resources == null ? null : w32Resources.Find(type, name, langId)); }