/// <summary> /// Internal method called by ContainerChildrenList whenever a child /// is about to be placed in the collection of children. Allows /// specific content containers to apply additional validation /// rules to their children /// </summary> /// <param name="child"></param> internal virtual void OnValidateChild(IContentObject child) { //Make sure this object has a parent equal to the parent for this collection if (((IContentObject)child).Parent != this) { throw new ArgumentException(); } }
/// <summary> /// Boxes any Object The Implements the IContentObjectInterface into a DE Content Object /// </summary> /// <param name="content">Object That Implements the IContentObject Interface</param> /// <returns>Boxed IContentObject Message in a DE Content Object</returns> /// <exception cref="ArgumentNullException">content is null</exception> /// <seealso cref="ContentObject"/> public static ContentObject Box(IContentObject content) { if (content == (IContentObject)null) { throw new ArgumentNullException("Input Object Can't Be Null"); } ContentObject contentobj = new ContentObject(); contentobj.ContentDescription = content.Description; contentobj.ContentKeyword = FromListofCTValueList(content.Keywords); XMLContentType xcontent = new XMLContentType(); string s = content.ToXmlString(); // imsg.ValidateToSchema(s); XElement xe = XElement.Parse(s); xcontent.EmbeddedXMLContent.Add(xe); contentobj.XMLContent = xcontent; xcontent = null; return(contentobj); }
/// <summary> /// Overrides base validation logic to ensure that only file system objects /// are added to the folder /// </summary> /// <param name="child"></param> internal override void OnValidateChild(IContentObject child) { base.OnValidateChild (child); if (!(child is IFileSystemObject)) { throw new ArgumentException(); } }
public MimePartResponseMessage(HttpRequestMessage requestMessage, IContentObject contentObject) { tempFilePath = Path.GetTempFileName(); RequestMessage = requestMessage; using (var tempFile = File.OpenWrite(tempFilePath)) { contentObject.DecodeTo(tempFile); } Content = new StreamContent(File.OpenRead(tempFilePath)); }
public MimePartFileStreamResult(IContentObject contentObject, string contentType) : base(new MemoryStream(), contentType) { tempFilePath = Path.GetTempFileName(); using (var tempFile = File.OpenWrite(tempFilePath)) { contentObject.DecodeTo(tempFile); } this.FileStream.Dispose(); this.FileStream = File.OpenRead(tempFilePath); }
public void GetContent(string scope, string app, string graph, string id, string format) { try { IContentObject iContentObject = _dtoProvider.GetContent(scope, app, graph, id, format); HttpContext.Current.Response.ContentType = iContentObject.ContentType; HttpContext.Current.Response.BinaryWrite(iContentObject.Content.ToMemoryStream().GetBuffer()); } catch (Exception ex) { ExceptionHander(ex); } }
private MimePart CreateMimePart(string mediaType, string mediaSubtype, string filename) { var contentType = new MimeKit.ContentType(mediaType, mediaSubtype); IContentObject contentObject = A.Fake <IContentObject>(); A.CallTo(() => contentObject.Stream).Returns(new MemoryStream()); return(new MimePart(contentType) { FileName = filename, ContentObject = contentObject }); }
/// <summary> /// Initializes a new instance of the <see cref="MimeKit.MimePart"/> class /// with the specified media type and subtype. /// </summary> /// <remarks> /// Creates a new <see cref="MimePart"/> with the specified media type and subtype. /// </remarks> /// <param name="mediaType">The media type.</param> /// <param name="mediaSubtype">The media subtype.</param> /// <param name="args">An array of initialization parameters: headers and part content.</param> /// <exception cref="System.ArgumentNullException"> /// <para><paramref name="mediaType"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><paramref name="mediaSubtype"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><paramref name="args"/> is <c>null</c>.</para> /// </exception> /// <exception cref="System.ArgumentException"> /// <para><paramref name="args"/> contains more than one <see cref="MimeKit.IContentObject"/> or /// <see cref="System.IO.Stream"/>.</para> /// <para>-or-</para> /// <para><paramref name="args"/> contains one or more arguments of an unknown type.</para> /// </exception> public MimePart(string mediaType, string mediaSubtype, params object[] args) : this(mediaType, mediaSubtype) { if (args == null) { throw new ArgumentNullException(nameof(args)); } IContentObject content = null; foreach (object obj in args) { if (obj == null || TryInit(obj)) { continue; } var co = obj as IContentObject; if (co != null) { if (content != null) { throw new ArgumentException("ContentObject should not be specified more than once."); } content = co; continue; } var stream = obj as Stream; if (stream != null) { if (content != null) { throw new ArgumentException("Stream (used as content) should not be specified more than once."); } // Use default as specified by ContentObject ctor when building a new MimePart. content = new ContentObject(stream); continue; } throw new ArgumentException("Unknown initialization parameter: " + obj.GetType()); } if (content != null) { ContentObject = content; } }
/// <summary> /// Boxes any Object The Implements the IContentObjectInterface into a DE Content Object /// </summary> /// <param name="imsg">Object That Implements the IContentObject Interface</param> /// <returns>Boxed IContentObject Message in a DE Content Object</returns> /// <exception cref="ArgumentNullException">ismg is null</exception> /// <seealso cref="ContentObject"/> public static ContentObject Box(IContentObject imsg) { if (imsg == (IContentObject)null) { throw new ArgumentNullException("Input Object Can't Be Null"); } ContentObject contentobj = new ContentObject(); ValueList ckw = new ValueList(); ckw.ValueListURN = EDXLConstants.ContentKeywordListName; contentobj.ContentDescription = imsg.SetContentKeywords(ckw); contentobj.ContentKeyword.Add(ckw); XMLContentType xcontent = new XMLContentType(); StringBuilder sb = new StringBuilder(); XmlWriterSettings xsettings = new XmlWriterSettings(); xsettings.CloseOutput = true; xsettings.Encoding = Encoding.UTF8; xsettings.Indent = true; xsettings.OmitXmlDeclaration = true; XmlWriter xwriter = XmlWriter.Create(sb, xsettings); imsg.WriteXML(xwriter); xwriter.Flush(); xwriter.Close(); string s = sb.ToString(); sb = null; // imsg.ValidateToSchema(s); XElement xe = XElement.Parse(s); xcontent.EmbeddedXMLContent.Add(xe); contentobj.XMLContent = xcontent; ckw = null; xcontent = null; xwriter = null; return(contentobj); }
private MimePart CreateMimePart(string mediaType, string mediaSubtype, string filename, params Header[] headers) { var contentType = new MimeKit.ContentType(mediaType, mediaSubtype); IContentObject contentObject = A.Fake <IContentObject>(); A.CallTo(() => contentObject.Stream).Returns(new MemoryStream()); MimePart mimePart = new MimePart(contentType) { FileName = filename, ContentObject = contentObject }; foreach (Header header in headers) { mimePart.Headers.Add(header); } return(mimePart); }
/// <summary> /// Given a content object stored on one of the active db4o data stores, determines which /// data store. /// </summary> /// <param name="obj"></param> /// <returns>The data store containing obj, or null if obj is not in any active data store</returns> public IDataStore GetDataStoreForObject(IContentObject obj) { return GetDataStoreForObject(obj, false); }
/// <summary> /// Given a content object stored on one of the active db4o data stores, determines which /// data store. /// </summary> /// <param name="obj"></param> /// <param name="recursive">true if the object's parent should be consulted recursively /// until an object stored in one of the active data stores is found; default is false</param> /// <returns>The data store containing obj, or null if obj is not in any active data store</returns> public IDataStore GetDataStoreForObject(IContentObject obj, bool recursive) { db4oDataStore ds = null; do { //Check all active data stores for one containing obj foreach (db4oDataStore tempDs in _dataStores) { if (tempDs.IsObjectInDataStore(obj)) { ds = ds; break; } } if (ds == null) { //None found; check obj's parent obj = obj.Parent; } } while (ds == null && obj != null); //Walked the entire ancestry line up to the root, and still couldn't find //an active data store containing the object return null; }
public System.Collections.IDictionary CreateDictionary(IContentObject owner) { return _container.collections().newHashMap(5); }
protected IContentObject ToContentObject(DataRow dataRow, DataObject objectDefinition) { IContentObject dataObject = null; if (dataRow != null) { try { dataObject = new GenericContentObject() { ObjectType = objectDefinition.objectName }; } catch (Exception ex) { _logger.Error(string.Format("Error instantiating data object: {0}", ex)); throw ex; } if (dataObject != null && objectDefinition.dataProperties != null) { foreach (DataProperty objectProperty in objectDefinition.dataProperties) { try { if (objectProperty.columnName != null) { if (dataRow.Table.Columns.Contains(objectProperty.columnName)) { object value = dataRow[objectProperty.columnName]; if (value.GetType() == typeof(System.DBNull)) { value = null; } dataObject.SetPropertyValue(objectProperty.propertyName, value); } else { _logger.Warn(String.Format("Value for column [{0}] not found in data row of table [{1}]", objectProperty.columnName, objectDefinition.tableName)); } } } catch (Exception ex) { _logger.Error(string.Format("Error getting data row value: {0}", ex)); throw ex; } } // evaluate has-content expression if (_settings["HasContentExpression"] != null) { string expression = _settings["HasContentExpression"].ToString(); foreach (DataProperty prop in objectDefinition.dataProperties) { if (expression.Contains(prop.propertyName)) { object value = dataObject.GetPropertyValue(prop.propertyName); if (value != null) { string valueStr = value.ToString(); if (prop.dataType == DataType.Char || prop.dataType == DataType.String) { valueStr = "\"" + valueStr + "\""; } expression = expression.Replace(prop.propertyName, valueStr); } } } if ((bool)Utility.Evaluate(expression)) { ((GenericContentObject)dataObject).HasContent = true; } } } } else { dataObject = new GenericContentObject() { ObjectType = objectDefinition.objectName }; foreach (DataProperty objectProperty in objectDefinition.dataProperties) { dataObject.SetPropertyValue(objectProperty.propertyName, null); } } return(dataObject); }
internal void RemoveModel( IContentObject model ) { this.listLoadedModels.ClearSelected(); this.listLoadedModels.Items.Remove( model ); }
public void RemoveModel( IContentObject model ) { this.browserWindow.Invoke( new Action( () => this.browserWindow.RemoveModel( model ) ) ); }
internal void AddModel( IContentObject model ) { this.listLoadedModels.ClearSelected(); this.listLoadedModels.Items.Add( model ); }
internal void AddActor( IContentObject actor ) { this.listActors.ClearSelected(); this.listActors.Items.Add( actor ); }
public int Compare(IContentObject a, IContentObject b) { int result = 0; for (int i = 0; i <= _keys.GetUpperBound(0); i++) { switch (_keys[i]) { case ContentCompareKey.Author: if (a.Authors.Count > 0 & b.Authors.Count > 0) { result = a.Authors[0].Contact.LastName.CompareTo(b.Authors[0].Contact.LastName); } else if (a.Authors.Count == 0) { result = -1; } else if (b.Authors.Count == 0) { result = 1; } else { result = 0; } break; case ContentCompareKey.ExpireDate: result = a.ExpirationDate.CompareTo(b.ExpirationDate); break; case ContentCompareKey.ID: result = a.ID - b.ID; break; case ContentCompareKey.MenuEnabled: if (a.MenuEnabled & !b.MenuEnabled) { result = -1; } else if (!a.MenuEnabled & b.MenuEnabled) { result = 1; } break; case ContentCompareKey.MenuOrder: result = a.MenuOrder - b.MenuOrder; // AHHH! THIS HAS TO BE REVERSED! break; case ContentCompareKey.SortOrder: result = a.SortOrder - b.SortOrder; break; case ContentCompareKey.PublishDate: result = a.PublishDate.CompareTo(b.PublishDate); break; case ContentCompareKey.Title: result = a.Title.CompareTo(b.Title); break; } // cease compare processing if the result is not equal if (result != 0) { return(result); } } return(result); }
public System.Collections.IList CreateList(IContentObject owner) { return _container.collections().newLinkedList(); }
public IDictionary CreateDictionary(IContentObject owner) { return new Hashtable(); }
/// <summary> /// Checks if a given object is contained in this data store /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool IsObjectInDataStore(IContentObject obj) { return _container.isStored(obj); }
internal void RemoveActor( IContentObject actor ) { this.listActors.ClearSelected(); this.listActors.Items.Remove( actor ); }
public IList CreateList(IContentObject owner) { return new ArrayList(); }
public void RemoveActor( IContentObject actor ) { this.browserWindow.Invoke( new Action( () => this.browserWindow.RemoveActor( actor ) ) ); }