Esempio n. 1
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Count != null)
                {
                    hash = hash * 57 + Count.GetHashCode();
                }

                if (ResourceArray != null)
                {
                    hash = hash * 57 + ResourceArray.GetHashCode();
                }

                if (Date != null)
                {
                    hash = hash * 57 + Date.GetHashCode();
                }

                if (XMsItemCount != null)
                {
                    hash = hash * 57 + XMsItemCount.GetHashCode();
                }

                if (XMsContinuation != null)
                {
                    hash = hash * 57 + XMsContinuation.GetHashCode();
                }

                if (XMsRequestCharge != null)
                {
                    hash = hash * 57 + XMsRequestCharge.GetHashCode();
                }

                if (XMsActivityId != null)
                {
                    hash = hash * 57 + XMsActivityId.GetHashCode();
                }

                if (XMsSessionToken != null)
                {
                    hash = hash * 57 + XMsSessionToken.GetHashCode();
                }

                return(hash);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Returns true if QueryResourceResponseBody instances are equal
        /// </summary>
        /// <param name="other">Instance of QueryResourceResponseBody to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(QueryResourceResponseBody other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                     ) &&
                 (
                     Count == other.Count ||
                     Count != null &&
                     Count.Equals(other.Count)
                 ) &&
                 (
                     ResourceArray == other.ResourceArray ||
                     ResourceArray != null &&
                     ResourceArray.Equals(other.ResourceArray)
                 ) &&
                 (
                     Date == other.Date ||
                     Date != null &&
                     Date.Equals(other.Date)
                 ) &&
                 (
                     XMsItemCount == other.XMsItemCount ||
                     XMsItemCount != null &&
                     XMsItemCount.Equals(other.XMsItemCount)
                 ) &&
                 (
                     XMsContinuation == other.XMsContinuation ||
                     XMsContinuation != null &&
                     XMsContinuation.Equals(other.XMsContinuation)
                 ) &&
                 (
                     XMsRequestCharge == other.XMsRequestCharge ||
                     XMsRequestCharge != null &&
                     XMsRequestCharge.Equals(other.XMsRequestCharge)
                 ) &&
                 (
                     XMsActivityId == other.XMsActivityId ||
                     XMsActivityId != null &&
                     XMsActivityId.Equals(other.XMsActivityId)
                 ) &&
                 (
                     XMsSessionToken == other.XMsSessionToken ||
                     XMsSessionToken != null &&
                     XMsSessionToken.Equals(other.XMsSessionToken)
                 ));
        }
Esempio n. 3
0
        public void Deserialize(Stream input)
        {
            this.Version = input.ReadValueU16(false);

            if (this.Version != 2)
            {
                throw new InvalidDataException("not version 2");
            }

            // Effects
            {
                this.Effects = new List <EffectArray>();
                short type = input.ReadValueS16(false);
                while (type != -1)
                {
                    short version = input.ReadValueS16(false);

                    if (type < 0 || type >= EffectTypes.Length || EffectTypes[type] == null)
                    {
                        throw new InvalidOperationException("invalid type " + type.ToString());
                    }

                    if (EffectTypes[type].GetInterface("IEffectFormat") == null)
                    {
                        throw new InvalidOperationException(EffectTypes[type].ToString() + " does not derive IEffectFormat");
                    }

                    EffectArray effects = new EffectArray();
                    effects.Type    = type;
                    effects.Version = version;
                    effects.Entries = new List <IEffectFormat>();

                    int count = input.ReadValueS32(false);
                    for (int i = 0; i < count; i++)
                    {
                        IEffectFormat instance = (IEffectFormat)Activator.CreateInstance(EffectTypes[type]);

                        if (version < instance.MinimumVersion || version > instance.MaximumVersion)
                        {
                            throw new InvalidOperationException("bad version " + version.ToString() + " for type " + instance.ToString());
                        }

                        instance.Deserialize(input, effects.Version);
                        effects.Entries.Add(instance);
                    }

                    this.Effects.Add(effects);

                    type = input.ReadValueS16(false);
                }
            }

            // Resources
            {
                this.Resources = new List <ResourceArray>();
                short type = input.ReadValueS16(false);
                while (type != -1)
                {
                    short version = input.ReadValueS16(false);

                    if (type < 0 || type >= ResourceTypes.Length || ResourceTypes[type] == null)
                    {
                        throw new InvalidOperationException("invalid resource " + type.ToString());
                    }

                    if (ResourceTypes[type].GetInterface("IEffectFormat") == null)
                    {
                        throw new InvalidOperationException(ResourceTypes[type].ToString() + " does not derive IEffectFormat");
                    }

                    ResourceArray resources = new ResourceArray();
                    resources.Type    = type;
                    resources.Version = version;
                    resources.Entries = new List <IEffectFormat>();

                    int count = input.ReadValueS32(false);
                    for (int i = 0; i < count; i++)
                    {
                        IEffectFormat instance = (IEffectFormat)Activator.CreateInstance(ResourceTypes[type]);

                        if (version < instance.MinimumVersion || version > instance.MaximumVersion)
                        {
                            throw new InvalidOperationException("bad version " + version.ToString() + " for resource " + instance.ToString());
                        }

                        instance.Deserialize(input, resources.Version);
                        resources.Entries.Add(instance);
                    }

                    this.Resources.Add(resources);

                    type = input.ReadValueS16(false);
                }
            }

            // Visual effects
            {
                short version = input.ReadValueS16(false);

                this.VisualEffects         = new VisualEffectArray();
                this.VisualEffects.Version = version;
                this.VisualEffects.Entries = new List <IEffectFormat>();

                int count = input.ReadValueS32(false);
                for (int i = 0; i < count; i++)
                {
                    Effects.VisualEffect visualEffect = new Effects.VisualEffect();
                    visualEffect.Deserialize(input, version);
                    this.VisualEffects.Entries.Add(visualEffect);
                }
            }

            // ???
            {
                int unk = input.ReadValueS32(false);
                while (unk != -1)
                {
                    throw new NotImplementedException();
                    //unk = input.ReadS32(false);
                }
            }

            this.EffectNames = new Dictionary <int, string>();

            int id = input.ReadValueS32(false);

            while (id != -1)
            {
                this.EffectNames.Add(id, input.ReadStringASCIIZ());
                id = input.ReadValueS32(false);
            }

            throw new NotImplementedException();
        }