Beispiel #1
0
        private int?ComputeHash(XmlNode rootNode, bool shouldChangeTrack)
        {
            int?       result = null;
            List <int> list   = new List <int>(50);

            list.Add(ChangeTrackingNode.GetQualifiedName(rootNode).GetHashCode());
            foreach (object obj in rootNode.ChildNodes)
            {
                XmlNode xmlNode       = (XmlNode)obj;
                string  qualifiedName = ChangeTrackingNode.GetQualifiedName(xmlNode);
                if (shouldChangeTrack && this.changeTrackingNodes.ContainsKey(qualifiedName))
                {
                    int num = this.changeTrackingNodes[qualifiedName];
                    this.seenNodes[num] = xmlNode;
                    if (ChangeTrackingFilter.IsContainer(xmlNode))
                    {
                        AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Recursively computing hash for change tracked container {0}", qualifiedName);
                        this.newChangeTrackingInformation[num] = this.ComputeHash(xmlNode, shouldChangeTrack);
                        AirSyncDiagnostics.TraceInfo <string, int?>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Returned hash for change tracked container {0} = {1}", qualifiedName, this.newChangeTrackingInformation[num]);
                    }
                    else
                    {
                        int value = ChangeTrackingNode.GetQualifiedName(xmlNode).GetHashCode() ^ this.GetHashCode(xmlNode);
                        this.newChangeTrackingInformation[num] = new int?(value);
                        AirSyncDiagnostics.TraceInfo <string, int?>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Calculated change tracked node hash {0} {1}", qualifiedName, this.newChangeTrackingInformation[num]);
                    }
                }
                else if (ChangeTrackingFilter.IsContainer(xmlNode))
                {
                    int?arg = this.ComputeHash(xmlNode, false);
                    if (arg != null)
                    {
                        list.Add(arg.Value);
                        AirSyncDiagnostics.TraceInfo <string, string, int?>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Returned container node hash {0}{1} = {2}", xmlNode.NamespaceURI, xmlNode.Name, arg);
                    }
                }
                else
                {
                    int item = ChangeTrackingNode.GetQualifiedName(xmlNode).GetHashCode() ^ this.GetHashCode(xmlNode);
                    list.Add(item);
                    AirSyncDiagnostics.TraceInfo <string, string, int>(ExTraceGlobals.RequestsTracer, this, "ChangeTrackingFilter.ComputeHash() Calculated node hash {0}{1} = {2}", xmlNode.NamespaceURI, xmlNode.Name, item.GetHashCode());
                }
            }
            if (list.Count > 1)
            {
                list.Sort();
                StringBuilder stringBuilder = new StringBuilder(list.Count * 10);
                foreach (int num2 in list)
                {
                    stringBuilder.Append(num2.ToString(CultureInfo.InvariantCulture));
                }
                result = new int?(stringBuilder.ToString().GetHashCode());
            }
            return(result);
        }
Beispiel #2
0
        public override bool HasSchemaPropertyChanged(ISyncItem syncItem, int?[] oldChangeTrackingInformation, XmlDocument xmlResponse, MailboxLogger mailboxLogger)
        {
            bool    flag        = false;
            XmlNode xmlItemRoot = xmlResponse.CreateElement("ApplicationData", "AirSync:");

            try
            {
                this.EntityDataObject.Bind(syncItem.NativeItem);
                base.AirSyncDataObject.Bind(xmlItemRoot);
                base.AirSyncDataObject.CopyFrom(this.EntityDataObject);
            }
            catch (Exception ex)
            {
                if (!SyncCommand.IsItemSyncTolerableException(ex))
                {
                    throw;
                }
                if (mailboxLogger != null)
                {
                    mailboxLogger.SetData(MailboxLogDataName.MailboxSyncCommand_HasSchemaPropertyChanged_Exception, ex);
                }
                AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
                AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "Sync-tolerable Entity conversion Exception was thrown. HasSchemaPropertyChanged() {0}", arg);
                flag = true;
            }
            finally
            {
                this.EntityDataObject.Unbind();
                base.AirSyncDataObject.Unbind();
            }
            if (!flag)
            {
                int?[] array = base.ChangeTrackFilter.UpdateChangeTrackingInformation(xmlItemRoot, oldChangeTrackingInformation);
                AirSyncDiagnostics.TraceDebug <int?[], int?[]>(ExTraceGlobals.RequestsTracer, this, "HasSchemaPropertyChanged oldCCI {0} newCCI {1}", oldChangeTrackingInformation, array);
                flag = !ChangeTrackingFilter.IsEqual(array, oldChangeTrackingInformation);
            }
            return(flag);
        }