Exemple #1
0
        public bool Equals(Variant other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(string.Equals(Owner, other.Owner) &&
                   OwnerType == other.OwnerType &&
                   ResourceId.Equals(other.ResourceId) &&
                   ResourceType == other.ResourceType);
        }
Exemple #2
0
        internal Stream GetZipChunkingResourceStream(ILogger logger)
        {
            if (ResourceId.Equals(Constants.ZipChunkingResourceFiles.ZeroByteOfficeDocumentResourceId))
            {
                return(new MemoryStream(new byte[0]));
            }

            try
            {
                string resourcePath = FilePath + Constants.ZipChunkingResourceFiles.FileStream;
                Stream stream       = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath);
                return(stream);
            }
            catch (IOException ex)
            {
                logger.Log($"{nameof(Resource.GetZipChunkingResourceStream)} IO Exception when trying to get resource content.");
                logger.Log(ex.Message);
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// Returns true if Authorization instances are equal
        /// </summary>
        /// <param name="other">Instance of Authorization to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Authorization other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ResourceId == other.ResourceId ||
                     ResourceId != null &&
                     ResourceId.Equals(other.ResourceId)
                 ) &&
                 (
                     RoleId == other.RoleId ||
                     RoleId != null &&
                     RoleId.Equals(other.RoleId)
                 ) &&
                 (
                     PolicyId == other.PolicyId ||
                     PolicyId != null &&
                     PolicyId.Equals(other.PolicyId)
                 ) &&
                 (
                     ScopeMap == other.ScopeMap ||
                     ScopeMap != null &&
                     ScopeMap.Equals(other.ScopeMap)
                 ));
        }
Exemple #4
0
        public override bool Equals(MediaItem other)
        {
            YoutubeItem otherItem = (YoutubeItem)other;

            return(ResourceId.Equals(otherItem.ResourceId));
        }
Exemple #5
0
 protected bool Equals(ServerExplorerItem other)
 {
     return(ResourceId.Equals(other.ResourceId));
 }
Exemple #6
0
 protected bool Equals(ServerExplorerItem other) => ResourceId.Equals(other.ResourceId);
Exemple #7
0
        internal void GetZipChunkingBlobs(ILogger logger, out string[] blobIds, out IReadOnlyDictionary <string, IBlob> blobs)
        {
            if (ResourceId.Equals(Constants.ZipChunkingResourceFiles.ZeroByteOfficeDocumentResourceId))
            {
                blobIds = new string[0];
                blobs   = new Dictionary <string, IBlob>();
                return;
            }

            try
            {
                List <string> offsets = new List <string>();

                string chunkIdsResourcePath = FilePath + Constants.ZipChunkingResourceFiles.ChunkIds;
                using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(chunkIdsResourcePath))
                    using (StreamReader streamReader = new StreamReader(stream))
                    {
                        while (!streamReader.EndOfStream)
                        {
                            offsets.Add(streamReader.ReadLine());
                        }
                    }

                string[] blobIdsToReturn = new string[offsets.Count];
                Dictionary <string, IBlob> blobsToReturn = new Dictionary <string, IBlob>();
                IBlobAllocator             blobAllocator = new BlobAllocator();
                string fileStreamResourcePath            = FilePath + Constants.ZipChunkingResourceFiles.FileStream;
                using (Stream fs = Assembly.GetExecutingAssembly().GetManifestResourceStream(fileStreamResourcePath))
                {
                    for (int i = 0; i < offsets.Count; i++)
                    {
                        if (!int.TryParse(offsets[i], out int offset_1))
                        {
                            throw new IOException($"In {nameof(Resource.GetZipChunkingBlobs)}, FileName:{FileName}, FilePath:{FilePath}, Offset:{offsets[ i ]} parsing failed");
                        }

                        if (fs.Position != offset_1)
                        {
                            throw new IOException("Filestream position not equal to offset parsed from ChunkIds.txt");
                        }

                        int offset_2 = (int)fs.Length;
                        if (i + 1 < offsets.Count)
                        {
                            if (!int.TryParse(offsets[i + 1], out offset_2))
                            {
                                throw new IOException($"In {nameof(Resource.GetZipChunkingBlobs)}, FileName:{FileName}, FilePath:{FilePath}, Offset:{offsets[ i + 1 ]} parsing failed");
                            }
                        }

                        IBlob blob = blobAllocator.CreateBlob(fs, offset_2 - offset_1);
                        blobIdsToReturn[i] = blob.BlobId;
                        if (!blobsToReturn.ContainsKey(blob.BlobId))
                        {
                            blobsToReturn.Add(blob.BlobId, blob);
                        }
                    }
                }

                blobIds = blobIdsToReturn;
                blobs   = blobsToReturn;
                return;
            }
            catch (IOException ex)
            {
                logger.Log($"{nameof(Resource.GetZipChunkingBlobs)} IO Exception when trying to get resource content.");
                logger.Log(ex.Message);

                blobIds = new string[0];
                blobs   = new Dictionary <string, IBlob>();
                return;
            }
        }