Example #1
0
 public uSyncEngine()
 {
     ContentType = new uSyncContentType();
     DataType    = new uSyncDataType();
     Dictionary  = new uSyncDictionary();
     Language    = new uSyncLanguage();
     Macro       = new uSyncMacro();
     MediaType   = new uSyncMediaType();
     Stylesheet  = new uSyncStylesheet();
     Template    = new uSyncTemplate();
     Content     = new uSyncContent();
     Media       = new uSyncMedia();
 }
        public static bool DataTypeChanged(XElement node)
        {
            string fileHash = node.CalculateMD5Hash(true);

            if (string.IsNullOrWhiteSpace(fileHash))
            {
                return(true);
            }

            XAttribute defId = node.Attribute("Definition");

            if (defId == null)
            {
                return(true);
            }

            if (_dataTypeService == null)
            {
                _dataTypeService = ApplicationContext.Current.Services.DataTypeService;
            }

            if (_dataTypes == null)
            {
                // speed test - load all the datatypes once
                // less db ? it's about 1.8s faster with default datatypes
                // more so with more types?
                _dataTypes = new Dictionary <Guid, IDataTypeDefinition>();
                foreach (var dtype in _dataTypeService.GetAllDataTypeDefinitions())
                {
                    _dataTypes.Add(dtype.Key, dtype);
                }
            }

            Guid defGuid = new Guid(defId.Value);

            if (!_dataTypes.ContainsKey(defGuid))
            {
                return(true);
            }

            var item = _dataTypes[defGuid];

            if (item == null)
            {
                return(true);
            }

            var uDt    = new uSyncDataType();
            var dbNode = uDt.Export(item);

            if (dbNode == null)
            {
                return(true);
            }

            string dbHash = dbNode.CalculateMD5Hash(true);

            LogHelper.Debug <ChangeTracker>("Comparing: [{0}] to [{1}]",
                                            () => fileHash, () => dbHash);

            return(!fileHash.Equals(dbHash));
        }