Beispiel #1
0
        void SetSpannedText(string span)
        {
            NSString str   = new NSString(string.Format(span, _text));
            NSError  error = new NSError();

            _view.AttributedText = new NSAttributedString(str.DataUsingEncoding(NSStringEncoding.Unicode)
                                                          , new NSAttributedStringDocumentAttributes()
            {
                DocumentType = NSDocumentType.HTML
            }
                                                          , ref error);

            Console.WriteLine(error);
        }
Beispiel #2
0
        private void SetSpannedText(string span, bool force = true)
        {
            if (_view != null && span != null)
            {
                UITextAlignment alignment = _view.TextAlignment;
                UIEdgeInsets    textInset = _view.TextContainerInset;

                var str   = new NSString(string.Format(span, _text));
                var error = new NSError();

                if (_view != null && (force || _blinkAllowed))
                {
                    _view.AttributedText = new NSAttributedString(str.DataUsingEncoding(NSStringEncoding.Unicode)
                                                                  , new NSAttributedStringDocumentAttributes {
                        DocumentType = NSDocumentType.HTML
                    }
                                                                  , ref error);

                    _view.TextAlignment      = alignment;
                    _view.TextContainerInset = textInset;
                }
            }
        }
Beispiel #3
0
        private void SetSpannedText(string span, bool force = true)
        {
            if (_view != null && span != null)
            {
                UIControlContentHorizontalAlignment alignment = _view.HorizontalAlignment;
                UIEdgeInsets textInset = _view.ContentEdgeInsets;

                var str   = new NSString(string.Format(span, _text));
                var error = new NSError();

                var title = new NSAttributedString(str.DataUsingEncoding(NSStringEncoding.Unicode)
                                                   , new NSAttributedStringDocumentAttributes {
                    DocumentType = NSDocumentType.HTML
                }
                                                   , ref error);

                if (_view != null && (force || _blinkAllowed))
                {
                    _view.SetAttributedTitle(title, UIControlState.Normal);
                    _view.HorizontalAlignment = alignment;
                    _view.ContentEdgeInsets   = textInset;
                }
            }
        }
Beispiel #4
0
        NSData CreateRequestBody()
        {
            _syncWriter = (SyncWriter) new ODataAtomWriter(base.BaseUri);

            _syncWriter.StartFeed(_wrapper.CacheRequest.IsLastBatch, _wrapper.CacheRequest.KnowledgeBlob ?? new byte[0]);

            MemoryStream requestStream = new MemoryStream();

            if (_wrapper.CacheRequest.RequestType == CacheRequestType.UploadChanges)
            {
                foreach (IOfflineEntity entity in _wrapper.CacheRequest.Changes)
                {
                    // Skip tombstones that dont have a ID element.
                    if (entity.ServiceMetadata.IsTombstone && string.IsNullOrEmpty(entity.ServiceMetadata.Id))
                    {
                        continue;
                    }

                    string tempId = null;

                    // Check to see if this is an insert. i.e ServiceMetadata.Id is null or empty
                    if (string.IsNullOrEmpty(entity.ServiceMetadata.Id))
                    {
                        if (_wrapper.TempIdToEntityMapping == null)
                        {
                            _wrapper.TempIdToEntityMapping = new Dictionary <string, IOfflineEntity> ();
                        }

                        tempId = Guid.NewGuid().ToString();

                        _wrapper.TempIdToEntityMapping.Add(tempId, entity);
                    }

                    _syncWriter.AddItem(entity, tempId);
                }
            }

            if (base.SerializationFormat == SerializationFormat.ODataAtom)
            {
                _syncWriter.WriteFeed(XmlWriter.Create(requestStream));
            }
            else
            {
                _syncWriter.WriteFeed(JsonReaderWriterFactory.CreateJsonWriter(requestStream));
            }

            string result = "";

            requestStream.Seek(0, SeekOrigin.Begin);

            using (StreamReader reader = new StreamReader(requestStream)) {
                result = reader.ReadToEnd();
            }

            requestStream.Flush();
            requestStream.Close();

            NSString dataString = new NSString(result);

            return(dataString.DataUsingEncoding(NSStringEncoding.UTF8));
        }
        NSData CreateRequestBody()
        {
            if (ApplicationContext.Current.Settings.BitMobileFormatterDisabled)
                _syncWriter = new ODataAtomWriter(BaseUri);
            else
                _syncWriter = new BMWriter(BaseUri);

            _syncWriter.StartFeed(_wrapper.CacheRequest.IsLastBatch, _wrapper.CacheRequest.KnowledgeBlob ?? new byte[0]);

            var requestStream = new MemoryStream();

            if (_wrapper.CacheRequest.RequestType == CacheRequestType.UploadChanges)
            {
                foreach (IOfflineEntity entity in _wrapper.CacheRequest.Changes)
                {
                    var ientity = (IEntity)entity;
                    // Skip tombstones that dont have a ID element.
                    if (entity.ServiceMetadata.IsTombstone && string.IsNullOrEmpty(entity.ServiceMetadata.Id))
                    {
                        if (ientity != null)
                            LogManager.Logger.SyncUpload(ientity.EntityType, true);
                        continue;
                    }

                    string tempId = null;

                    // Check to see if this is an insert. i.e ServiceMetadata.Id is null or empty
                    if (string.IsNullOrEmpty(entity.ServiceMetadata.Id))
                    {
                        if (_wrapper.TempIdToEntityMapping == null)
                        {
                            _wrapper.TempIdToEntityMapping = new Dictionary<string, IOfflineEntity>();
                        }

                        tempId = Guid.NewGuid().ToString();

                        _wrapper.TempIdToEntityMapping.Add(tempId, entity);
                    }

                    _syncWriter.AddItem(entity, tempId);

                    if (ientity != null)
                        LogManager.Logger.SyncUpload(ientity.EntityType);
                }
            }

            _syncWriter.WriteFeed(SerializationFormat == SerializationFormat.ODataAtom
                ? XmlWriter.Create(requestStream)
                : JsonReaderWriterFactory.CreateJsonWriter(requestStream));

            string result;

            requestStream.Seek(0, SeekOrigin.Begin);

            using (var reader = new StreamReader(requestStream))
            {
                result = reader.ReadToEnd();
            }

            requestStream.Flush();
            requestStream.Close();

            var dataString = new NSString(result);

            return dataString.DataUsingEncoding(NSStringEncoding.UTF8);
        }
Beispiel #6
0
        NSData CreateRequestBody()
        {
            if (ApplicationContext.Current.Settings.BitMobileFormatterDisabled)
            {
                _syncWriter = new ODataAtomWriter(BaseUri);
            }
            else
            {
                _syncWriter = new BMWriter(BaseUri);
            }

            _syncWriter.StartFeed(_wrapper.CacheRequest.IsLastBatch, _wrapper.CacheRequest.KnowledgeBlob ?? new byte[0]);

            var requestStream = new MemoryStream();

            if (_wrapper.CacheRequest.RequestType == CacheRequestType.UploadChanges)
            {
                foreach (IOfflineEntity entity in _wrapper.CacheRequest.Changes)
                {
                    var ientity = (IEntity)entity;
                    // Skip tombstones that dont have a ID element.
                    if (entity.ServiceMetadata.IsTombstone && string.IsNullOrEmpty(entity.ServiceMetadata.Id))
                    {
                        if (ientity != null)
                        {
                            LogManager.Logger.SyncUpload(ientity.EntityType, true);
                        }
                        continue;
                    }

                    string tempId = null;

                    // Check to see if this is an insert. i.e ServiceMetadata.Id is null or empty
                    if (string.IsNullOrEmpty(entity.ServiceMetadata.Id))
                    {
                        if (_wrapper.TempIdToEntityMapping == null)
                        {
                            _wrapper.TempIdToEntityMapping = new Dictionary <string, IOfflineEntity>();
                        }

                        tempId = Guid.NewGuid().ToString();

                        _wrapper.TempIdToEntityMapping.Add(tempId, entity);
                    }

                    _syncWriter.AddItem(entity, tempId);

                    if (ientity != null)
                    {
                        LogManager.Logger.SyncUpload(ientity.EntityType);
                    }
                }
            }

            _syncWriter.WriteFeed(SerializationFormat == SerializationFormat.ODataAtom
                ? XmlWriter.Create(requestStream)
                : JsonReaderWriterFactory.CreateJsonWriter(requestStream));

            string result;

            requestStream.Seek(0, SeekOrigin.Begin);

            using (var reader = new StreamReader(requestStream))
            {
                result = reader.ReadToEnd();
            }

            requestStream.Flush();
            requestStream.Close();

            var dataString = new NSString(result);

            return(dataString.DataUsingEncoding(NSStringEncoding.UTF8));
        }
		NSData CreateRequestBody ()
		{
			_syncWriter = (SyncWriter)new ODataAtomWriter (base.BaseUri);

			_syncWriter.StartFeed (_wrapper.CacheRequest.IsLastBatch, _wrapper.CacheRequest.KnowledgeBlob ?? new byte[0]);

			MemoryStream requestStream = new MemoryStream ();

			if (_wrapper.CacheRequest.RequestType == CacheRequestType.UploadChanges) {
				foreach (IOfflineEntity entity in _wrapper.CacheRequest.Changes) {
					// Skip tombstones that dont have a ID element.
					if (entity.ServiceMetadata.IsTombstone && string.IsNullOrEmpty (entity.ServiceMetadata.Id)) {
						continue;
					}

					string tempId = null;

					// Check to see if this is an insert. i.e ServiceMetadata.Id is null or empty
					if (string.IsNullOrEmpty (entity.ServiceMetadata.Id)) {
						if (_wrapper.TempIdToEntityMapping == null) {
							_wrapper.TempIdToEntityMapping = new Dictionary<string, IOfflineEntity> ();
						}

						tempId = Guid.NewGuid ().ToString ();

						_wrapper.TempIdToEntityMapping.Add (tempId, entity);
					}

					_syncWriter.AddItem (entity, tempId);
				}
			}

			if (base.SerializationFormat == SerializationFormat.ODataAtom) {
				_syncWriter.WriteFeed (XmlWriter.Create (requestStream));
			} else {
				_syncWriter.WriteFeed (JsonReaderWriterFactory.CreateJsonWriter (requestStream));
			}

			string result = "";

			requestStream.Seek (0, SeekOrigin.Begin);

			using (StreamReader reader = new StreamReader (requestStream)) {
				result = reader.ReadToEnd ();
			}

			requestStream.Flush ();
			requestStream.Close ();

			NSString dataString = new NSString (result);

			return dataString.DataUsingEncoding (NSStringEncoding.UTF8);
		}